use super::*;
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
pub(super) const ACTIVATED_1_8: &[u8] = &[
23, 25, 26, 54, 58, 61, 62, 64, 69, 71, 77, 84, 92, 93, 94, 96, 107, 116, 117, 118, 120, 130,
138, 143, 145, 146, 149, 150, 151, 154, 158, 167, 178, 183, 184, 185, 186, 187, 193, 194, 195,
196, 197,
];
#[cfg(feature = "v1_12_2")]
const USABLE_1_12: &[u16] = &[373, 335, 261, 442];
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
const SWORDS_LEGACY: &[u16] = &[267, 268, 272, 276, 283];
#[cfg(feature = "v1_8")]
const USABLE_1_8: &[u16] = &[373, 335, 261, 267, 268, 272, 276, 283];
pub(crate) fn food_points(data: DataSet, id: u16) -> Option<u8> {
let _ = id;
match data {
#[cfg(feature = "v1_8")]
DataSet::V1_8 => ghast_data::v1_8::item_use::food_points(id),
#[cfg(feature = "v1_12_2")]
DataSet::V1_12 => ghast_data::v1_12::food(id).map(|f| f.food_points),
#[cfg(feature = "v1_16_5")]
DataSet::V1_16_5 => ghast_data::v1_16_5::food(id).map(|f| f.food_points),
#[allow(unreachable_patterns)]
_ => None,
}
}
pub(crate) fn held_item_facts(data: DataSet, id: u16, count: u8, efficiency: u8) -> HeldItem {
match data {
#[cfg(feature = "v1_8")]
DataSet::V1_8 => HeldItem {
modern_item: None,
swing_on_use: false,
equips: false,
equip_swings: false,
creative_keeps_blocks: SWORDS_LEGACY.contains(&id),
use_succeeds: false,
id,
count,
efficiency,
places_block: id < 256,
usable: ghast_data::v1_8::item_use::is_food(id) || USABLE_1_8.contains(&id),
food: ghast_data::v1_8::item_use::is_food(id),
always_edible: ghast_data::v1_8::item_use::always_edible(id),
tool_speed: Some(ghast_data::v1_8::tool_multiplier),
},
#[cfg(feature = "v1_12_2")]
DataSet::V1_12 => HeldItem {
modern_item: None,
swing_on_use: false,
equips: false,
equip_swings: false,
creative_keeps_blocks: SWORDS_LEGACY.contains(&id),
use_succeeds: matches!(id, 332 | 344 | 346 | 384 | 438 | 441),
id,
count,
efficiency,
places_block: id < 256,
usable: ghast_data::v1_12::item_use::is_food(id) || USABLE_1_12.contains(&id),
food: ghast_data::v1_12::item_use::is_food(id),
always_edible: ghast_data::v1_12::item_use::always_edible(id),
tool_speed: Some(ghast_data::v1_12::tool_multiplier),
},
#[cfg(feature = "v1_16_5")]
DataSet::V1_16_5 => HeldItem {
modern_item: None,
swing_on_use: ghast_data::v1_16_5::Item::from_id(id).is_some_and(|i| {
matches!(
i.info().name,
"snowball"
| "egg"
| "ender_pearl"
| "experience_bottle"
| "splash_potion"
| "lingering_potion"
| "fishing_rod"
| "map"
)
}),
equips: false,
equip_swings: false,
creative_keeps_blocks: ghast_data::v1_16_5::Item::from_id(id)
.is_some_and(|i| i.info().name.ends_with("_sword") || i.info().name == "trident"),
use_succeeds: false,
id,
count,
efficiency,
places_block: ghast_data::v1_16_5::Item::from_id(id)
.is_some_and(|i| ghast_data::v1_16_5::Block::from_name(i.info().name).is_some()),
usable: ghast_data::v1_16_5::item_use::is_food(id)
|| ghast_data::v1_16_5::Item::from_id(id).is_some_and(|i| {
matches!(
i.info().name,
"potion"
| "milk_bucket"
| "honey_bottle"
| "bow"
| "crossbow"
| "shield"
| "trident"
)
}),
food: ghast_data::v1_16_5::item_use::is_food(id),
always_edible: ghast_data::v1_16_5::item_use::always_edible(id),
tool_speed: Some(ghast_data::v1_16_5::tool_multiplier),
},
#[cfg(feature = "v26_1")]
DataSet::V26_1 => v26_1::held_item_facts(id, count, efficiency),
#[cfg(feature = "v26_2")]
DataSet::V26_2 => v26_2::held_item_facts(id, count, efficiency),
#[cfg(feature = "v26_3")]
DataSet::V26_3 => v26_3::held_item_facts(id, count, efficiency),
#[allow(unreachable_patterns)]
_ => HeldItem {
modern_item: None,
swing_on_use: false,
equips: false,
equip_swings: false,
creative_keeps_blocks: false,
use_succeeds: false,
id,
count,
efficiency,
places_block: false,
usable: false,
food: false,
always_edible: false,
tool_speed: None,
},
}
}