Struct IndexedData

Source
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

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> IndexedData

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IndexedData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T