Skip to main content

ghast_data/v26_1/
mod.rs

1//! Minecraft 26.1 (protocol 775) data: the global block-state palette with properties, collision
2//! voxel shapes and the per-state facts the movement code reads.
3//!
4//! Every movement-relevant value comes from the real 26.1 jar (oracle dump
5//! `tests/golden/26.1/voxel_shapes.jsonl.gz`): collision voxel grids, per-state flags, fluids,
6//! friction / speed / jump factors, the block tags and `instanceof` tests vanilla's movement code
7//! makes. PrismarineJS minecraft-data (`pc/26.1`) supplies the property layout and display data
8//! and is cross-checked against the jar at generation time.
9//!
10//! The hot path is one table read per state: [`BlockState::phys`] returns a packed
11//! [`StatePhys`] (shape index, flags, fluid, per-kind extra bits, [`BlockKind`]).
12
13use crate::common::{SelectionShape, lookup_name};
14use crate::generated::v26_1 as g;
15
16pub use crate::modern::{
17    BlockKind, StatePhys, VoxelClass, VoxelShapeRef, block_flags, state_flags,
18};
19use core::fmt;
20
21pub use g::blocks::Property;
22
23pub mod dig;
24pub mod entities;
25pub mod items;
26
27pub use entities::{
28    EntityTypeData, entities, entity, entity_by_name, entity_type, entity_types,
29    vanilla_entity_size, vanilla_entity_sizes,
30};
31pub use items::{BlockSet, Food, Item, Tool, ToolRule, food};
32
33/// Static per-block data (jar values for everything movement reads).
34#[derive(Clone, Copy, Debug, PartialEq)]
35pub struct BlockData {
36    /// Registry name without namespace.
37    pub name: &'static str,
38    /// English display name (minecraft-data).
39    #[cfg(feature = "display-names")]
40    pub display_name: &'static str,
41    /// Destroy time (minecraft-data; `None` = unbreakable).
42    pub hardness: Option<f32>,
43    /// Explosion resistance (minecraft-data).
44    pub resistance: f32,
45    /// Can be mined (minecraft-data).
46    pub diggable: bool,
47    /// Lets light through (minecraft-data).
48    pub transparent: bool,
49    /// Light emitted (minecraft-data).
50    pub emit_light: u8,
51    /// Light filtered (minecraft-data).
52    pub filter_light: u8,
53    /// `Block.getFriction()` (jar).
54    pub friction: f32,
55    /// `Block.getSpeedFactor()` (jar).
56    pub speed_factor: f32,
57    /// `Block.getJumpFactor()` (jar).
58    pub jump_factor: f32,
59    /// [`block_flags`] bits.
60    pub flags: u32,
61    /// Special movement behaviour.
62    pub kind: BlockKind,
63    /// Model offset function: `(max horizontal, max vertical, xyz)`; bamboo and pointed dripstone
64    /// shift their collision shape by it.
65    pub offset: Option<(f32, f32, bool)>,
66}
67
68/// Registry name of block `id` (no namespace).
69fn block_name(id: u16) -> &'static str {
70    g::blocks::BLOCKS[usize::from(id)].name
71}
72
73/// English display name of block `id`.
74#[cfg(feature = "display-names")]
75fn block_display_name(id: u16) -> &'static str {
76    g::blocks::BLOCKS[usize::from(id)].display_name
77}
78
79/// Static item data (default components).
80#[derive(Clone, Copy, Debug, PartialEq)]
81pub struct ItemData {
82    /// Registry name without namespace.
83    pub name: &'static str,
84    /// English display name (minecraft-data).
85    #[cfg(feature = "display-names")]
86    pub display_name: &'static str,
87    /// Default `minecraft:max_stack_size`.
88    pub max_stack_size: u8,
89    /// Default `minecraft:max_damage` (damageable items).
90    pub max_damage: Option<u16>,
91    /// The block a `BlockItem` places (block id).
92    pub block: Option<u16>,
93    /// Default `minecraft:food`.
94    pub food: Option<Food>,
95    /// Default `minecraft:tool` (index into the tool table).
96    pub tool: Option<u16>,
97}
98
99/// Registry name of item `id` (no namespace).
100fn item_name(id: u16) -> &'static str {
101    g::items::ITEMS[usize::from(id)].name
102}
103
104/// English display name of item `id`.
105#[cfg(feature = "display-names")]
106fn item_display_name(id: u16) -> &'static str {
107    g::items::ITEMS[usize::from(id)].display_name
108}
109
110// The API shared with the other modern versions (`v26_2` compiles the same source).
111include!("../modern_api.rs");
112
113#[cfg(test)]
114mod tests;