Block

Struct Block 

Source
pub struct Block {
    pub id: String,
    pub coords: Option<(i32, i32, i32)>,
    pub properties: Option<Vec<(String, String)>>,
    /* private fields */
}
Expand description

A Minecraft block. This struct does not store any data about the location because to get a block one must use x, y, and z coordinates on a Chunk and thus would already have the location data.

Fields§

§id: String

The general name of a block, ie. ‘stone’

§coords: Option<(i32, i32, i32)>

The coordinates of the block, None if not included.

§properties: Option<Vec<(String, String)>>

Any properties that a block might have.

Implementations§

Source§

impl Block

Source

pub fn new( namespace: String, block_id: Option<String>, coords: Option<(i32, i32, i32)>, properties: Option<Vec<(String, String)>>, ) -> Block

Returns a new block with a given namespace and id.

§Arguments
  • namespace - The namespace for the found block, for vanilla this will always be ‘minecraft’. For modded versions of Minecraft this would represent the namespace of the mod.
  • block_id - The id of the block, this is typically the name of the block without spaces.
§Examples
use simple_anvil::block::Block;
let block = Block::new("minecraft".into(), Some("stone".into()));
println!("{}", block.id);
Source

pub fn name(self) -> String

Returns the full name of the block in question, this looks like ‘namespace:block_id’ or ‘minecraft:stone’.

§Examples
use simple_anvil::block::Block;
let block = Block::new("minecraft".into(), Some("stone".into()));
println!("{}", block.name());
Source

pub fn from_name( name: String, coords: Option<(i32, i32, i32)>, properties: Option<Vec<(String, String)>>, ) -> Block

Returns a Block from a name

§Arguments
  • name - The fullname of the block, this includes the namespace and the colon.
  • coords - The coordinates of the block, None if not included.
§Examples
use simple_anvil::block::Block;
let block = Block::from_name("minecraft:stone".into());
println!("{}", block.id);
Source

pub fn from_palette( tag: &Value, coords: Option<(i32, i32, i32)>, properties: Option<Vec<(String, String)>>, ) -> Block

Returns a block from a Chunk palette value

§Arguments
  • tag - The page representing the palette from a Chunk.
  • coords - The coordinates of the block, None if not included.
  • tag - The value for the block from a chunk. This should be a HashMap containing all of the contents of the block.

Trait Implementations§

Source§

impl Debug for Block

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for Block

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Block

Source§

fn eq(&self, other: &Block) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Block

Source§

impl StructuralPartialEq for Block

Auto Trait Implementations§

§

impl Freeze for Block

§

impl RefUnwindSafe for Block

§

impl Send for Block

§

impl Sync for Block

§

impl Unpin for Block

§

impl UnwindSafe for Block

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.