pub struct IndexedData {Show 59 fields
pub version: Version,
pub blocks_array: Arc<Vec<Block>>,
pub blocks_by_id: Arc<HashMap<u32, Block>>,
pub blocks_by_name: Arc<HashMap<String, Block>>,
pub blocks_by_state_id: Arc<HashMap<u32, Block>>,
pub items_array: Arc<Vec<Item>>,
pub items_by_id: Arc<HashMap<u32, Item>>,
pub items_by_name: Arc<HashMap<String, Item>>,
pub biomes_array: Arc<Vec<Biome>>,
pub biomes_by_id: Arc<HashMap<u32, Biome>>,
pub biomes_by_name: Arc<HashMap<String, Biome>>,
pub effects_array: Arc<Vec<Effect>>,
pub effects_by_id: Arc<HashMap<u32, Effect>>,
pub effects_by_name: Arc<HashMap<String, Effect>>,
pub entities_array: Arc<Vec<Entity>>,
pub entities_by_id: Arc<HashMap<u32, Entity>>,
pub entities_by_name: Arc<HashMap<String, Entity>>,
pub mobs_by_id: Arc<HashMap<u32, Entity>>,
pub objects_by_id: Arc<HashMap<u32, Entity>>,
pub sounds_array: Arc<Vec<Sound>>,
pub sounds_by_id: Arc<HashMap<u32, Sound>>,
pub sounds_by_name: Arc<HashMap<String, Sound>>,
pub particles_array: Arc<Vec<Particle>>,
pub particles_by_id: Arc<HashMap<u32, Particle>>,
pub particles_by_name: Arc<HashMap<String, Particle>>,
pub attributes_array: Arc<Vec<Attribute>>,
pub attributes_by_name: Arc<HashMap<String, Attribute>>,
pub attributes_by_resource: Arc<HashMap<String, Attribute>>,
pub instruments_array: Arc<Vec<Instrument>>,
pub instruments_by_id: Arc<HashMap<u32, Instrument>>,
pub instruments_by_name: Arc<HashMap<String, Instrument>>,
pub foods_array: Arc<Vec<Food>>,
pub foods_by_id: Arc<HashMap<u32, Food>>,
pub foods_by_name: Arc<HashMap<String, Food>>,
pub enchantments_array: Arc<Vec<Enchantment>>,
pub enchantments_by_id: Arc<HashMap<u32, Enchantment>>,
pub enchantments_by_name: Arc<HashMap<String, Enchantment>>,
pub map_icons_array: Arc<Vec<MapIcon>>,
pub map_icons_by_id: Arc<HashMap<u32, MapIcon>>,
pub map_icons_by_name: Arc<HashMap<String, MapIcon>>,
pub windows_array: Arc<Vec<Window>>,
pub windows_by_id: Arc<HashMap<String, Window>>,
pub windows_by_name: Arc<HashMap<String, Window>>,
pub block_loot_array: Arc<Vec<BlockLoot>>,
pub block_loot_by_name: Arc<HashMap<String, BlockLoot>>,
pub entity_loot_array: Arc<Vec<EntityLoot>>,
pub entity_loot_by_name: Arc<HashMap<String, EntityLoot>>,
pub block_shapes_by_state_id: Arc<HashMap<u32, Vec<[f64; 6]>>>,
pub block_shapes_by_name: Arc<HashMap<String, Vec<[f64; 6]>>>,
pub block_collision_shapes_raw: Arc<Option<BlockCollisionShapes>>,
pub tints: Arc<Option<Tints>>,
pub language: Arc<HashMap<String, String>>,
pub legacy: Arc<Option<Legacy>>,
pub recipes: Arc<Option<Value>>,
pub materials: Arc<Option<Value>>,
pub commands: Arc<Option<Value>>,
pub protocol: Arc<Option<Value>>,
pub protocol_comments: Arc<Option<Value>>,
pub login_packet: Arc<Option<Value>>,
}
Expand description
Holds all loaded and indexed Minecraft data for a specific version.
Instances of this struct are cached globally by the mc_data
function.
Fields are wrapped in Arc
to allow cheap cloning when retrieving from the cache.
Fields§
§version: Version
The canonical Version
struct this data corresponds to.
blocks_array: Arc<Vec<Block>>
§blocks_by_id: Arc<HashMap<u32, Block>>
§blocks_by_name: Arc<HashMap<String, Block>>
§blocks_by_state_id: Arc<HashMap<u32, Block>>
§items_array: Arc<Vec<Item>>
§items_by_id: Arc<HashMap<u32, Item>>
§items_by_name: Arc<HashMap<String, Item>>
§biomes_array: Arc<Vec<Biome>>
§biomes_by_id: Arc<HashMap<u32, Biome>>
§biomes_by_name: Arc<HashMap<String, Biome>>
§effects_array: Arc<Vec<Effect>>
§effects_by_id: Arc<HashMap<u32, Effect>>
§effects_by_name: Arc<HashMap<String, Effect>>
§entities_array: Arc<Vec<Entity>>
§entities_by_id: Arc<HashMap<u32, Entity>>
§entities_by_name: Arc<HashMap<String, Entity>>
§mobs_by_id: Arc<HashMap<u32, Entity>>
§objects_by_id: Arc<HashMap<u32, Entity>>
§sounds_array: Arc<Vec<Sound>>
§sounds_by_id: Arc<HashMap<u32, Sound>>
§sounds_by_name: Arc<HashMap<String, Sound>>
§particles_array: Arc<Vec<Particle>>
§particles_by_id: Arc<HashMap<u32, Particle>>
§particles_by_name: Arc<HashMap<String, Particle>>
§attributes_array: Arc<Vec<Attribute>>
§attributes_by_name: Arc<HashMap<String, Attribute>>
§attributes_by_resource: Arc<HashMap<String, Attribute>>
§instruments_array: Arc<Vec<Instrument>>
§instruments_by_id: Arc<HashMap<u32, Instrument>>
§instruments_by_name: Arc<HashMap<String, Instrument>>
§foods_array: Arc<Vec<Food>>
§foods_by_id: Arc<HashMap<u32, Food>>
§foods_by_name: Arc<HashMap<String, Food>>
§enchantments_array: Arc<Vec<Enchantment>>
§enchantments_by_id: Arc<HashMap<u32, Enchantment>>
§enchantments_by_name: Arc<HashMap<String, Enchantment>>
§map_icons_array: Arc<Vec<MapIcon>>
§map_icons_by_id: Arc<HashMap<u32, MapIcon>>
§map_icons_by_name: Arc<HashMap<String, MapIcon>>
§windows_array: Arc<Vec<Window>>
§windows_by_id: Arc<HashMap<String, Window>>
§windows_by_name: Arc<HashMap<String, Window>>
§block_loot_array: Arc<Vec<BlockLoot>>
§block_loot_by_name: Arc<HashMap<String, BlockLoot>>
§entity_loot_array: Arc<Vec<EntityLoot>>
§entity_loot_by_name: Arc<HashMap<String, EntityLoot>>
§block_shapes_by_state_id: Arc<HashMap<u32, Vec<[f64; 6]>>>
§block_shapes_by_name: Arc<HashMap<String, Vec<[f64; 6]>>>
§block_collision_shapes_raw: Arc<Option<BlockCollisionShapes>>
Raw data from blockCollisionShapes.json, if available for the version.
tints: Arc<Option<Tints>>
Data from tints.json, if available.
language: Arc<HashMap<String, String>>
Data from language.json (typically en_us), if available.
legacy: Arc<Option<Legacy>>
Data from legacy.json (mapping old IDs to new), if available.
recipes: Arc<Option<Value>>
§materials: Arc<Option<Value>>
§commands: Arc<Option<Value>>
§protocol: Arc<Option<Value>>
§protocol_comments: Arc<Option<Value>>
§login_packet: Arc<Option<Value>>
Implementations§
Source§impl IndexedData
impl IndexedData
Sourcepub fn load(version: Version) -> Result<Self, McDataError>
pub fn load(version: Version) -> Result<Self, McDataError>
Loads all required and optional data files for the given canonical version,
then indexes them into the IndexedData
struct fields.
Sourcepub fn is_newer_or_equal_to(
&self,
other_version_str: &str,
) -> Result<bool, McDataError>
pub fn is_newer_or_equal_to( &self, other_version_str: &str, ) -> Result<bool, McDataError>
Checks if the current data’s version is newer than or equal to another version string.
Resolves the other_version_str
and compares using the Version
struct’s Ord
implementation.
§Errors
Returns McDataError::InvalidVersion
if other_version_str
is invalid.
Returns McDataError::Internal
if attempting to compare versions from different editions.
Sourcepub fn is_older_than(
&self,
other_version_str: &str,
) -> Result<bool, McDataError>
pub fn is_older_than( &self, other_version_str: &str, ) -> Result<bool, McDataError>
Checks if the current data’s version is strictly older than another version string.
Resolves the other_version_str
and compares using the Version
struct’s Ord
implementation.
§Errors
Returns McDataError::InvalidVersion
if other_version_str
is invalid.
Returns McDataError::Internal
if attempting to compare versions from different editions.
Sourcepub fn support_feature(&self, feature_name: &str) -> Result<Value, McDataError>
pub fn support_feature(&self, feature_name: &str) -> Result<Value, McDataError>
Checks support for a named feature based on the current data’s version.
Consults the features.json
data and returns the feature’s value (often boolean,
but can be other JSON types) if supported for this version, or Value::Bool(false)
otherwise.
§Errors
Returns McDataError
if feature data or version information cannot be loaded or resolved.
Trait Implementations§
Source§impl Clone for IndexedData
impl Clone for IndexedData
Source§fn clone(&self) -> IndexedData
fn clone(&self) -> IndexedData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more