use crate::common::{SelectionShape, lookup_name};
use crate::generated::v26_2 as g;
pub use crate::modern::{
BlockKind, StatePhys, VoxelClass, VoxelShapeRef, block_flags, state_flags,
};
use core::fmt;
pub use g::blocks::Property;
#[allow(clippy::duplicate_mod)]
#[path = "../v26_1/dig.rs"]
pub mod dig;
#[allow(clippy::duplicate_mod)]
#[path = "../v26_1/entities.rs"]
pub mod entities;
#[allow(clippy::duplicate_mod)]
#[path = "../v26_1/items.rs"]
pub mod items;
pub use entities::{
EntityTypeData, entities, entity, entity_by_name, entity_type, entity_types,
vanilla_entity_size, vanilla_entity_sizes,
};
pub use items::{BlockSet, Food, Item, Tool, ToolRule, food};
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct BlockData {
pub hardness: Option<f32>,
pub resistance: f32,
pub diggable: bool,
pub transparent: bool,
pub emit_light: u8,
pub filter_light: u8,
pub friction: f32,
pub speed_factor: f32,
pub jump_factor: f32,
pub flags: u32,
pub kind: BlockKind,
pub offset: Option<(f32, f32, bool)>,
}
fn nth(text: &'static str, ends: &[u32], i: u16) -> &'static str {
let i = usize::from(i);
let end = ends[i] as usize;
let start = if i == 0 { 0 } else { ends[i - 1] as usize };
&text[start..end]
}
fn block_name(id: u16) -> &'static str {
nth(
g::blocks::BLOCK_ID_NAMES_TEXT,
&g::blocks::BLOCK_ID_NAMES_ENDS,
id,
)
}
#[cfg(feature = "display-names")]
fn block_display_name(id: u16) -> &'static str {
nth(
g::blocks::BLOCK_DISPLAY_NAMES_TEXT,
&g::blocks::BLOCK_DISPLAY_NAMES_ENDS,
id,
)
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct ItemData {
pub max_stack_size: u8,
pub max_damage: Option<u16>,
pub block: Option<u16>,
pub food: Option<Food>,
pub tool: Option<u16>,
}
fn item_name(id: u16) -> &'static str {
nth(
g::items::ITEM_ID_NAMES_TEXT,
&g::items::ITEM_ID_NAMES_ENDS,
id,
)
}
#[cfg(feature = "display-names")]
fn item_display_name(id: u16) -> &'static str {
nth(
g::items::ITEM_DISPLAY_NAMES_TEXT,
&g::items::ITEM_DISPLAY_NAMES_ENDS,
id,
)
}
include!("../modern_api.rs");
#[cfg(test)]
mod tests;