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: StringThe 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
impl Block
Sourcepub fn new(
namespace: String,
block_id: Option<String>,
coords: Option<(i32, i32, i32)>,
properties: Option<Vec<(String, String)>>,
) -> Block
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);Sourcepub fn name(self) -> String
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());Sourcepub fn from_name(
name: String,
coords: Option<(i32, i32, i32)>,
properties: Option<Vec<(String, String)>>,
) -> Block
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);Sourcepub fn from_palette(
tag: &Value,
coords: Option<(i32, i32, i32)>,
properties: Option<Vec<(String, String)>>,
) -> Block
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§
impl Eq for Block
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more