pub struct Block { /* private fields */ }Expand description
A block state of the session’s version, named with ghast-data.
use ghast_client::GameVersion;
use ghast_ext::Block;
let ore = Block::new(GameVersion::V1_8_9, 56 << 4); // 1.8 diamond ore
assert_eq!(ore.name(), "diamond_ore");
assert!(ore.is_ore());
assert!(Block::new(GameVersion::V1_8_9, 0).is_air());Implementations§
Source§impl Block
impl Block
Sourcepub const fn new(version: GameVersion, raw: u32) -> Self
pub const fn new(version: GameVersion, raw: u32) -> Self
The block for a raw state of version (1.8 id << 4 | meta, 1.16 the global
palette id), as ghast_client::WorldView::raw_block returns it.
let b = ghast_ext::Block::new(GameVersion::V1_8_9, 1 << 4);
assert_eq!(b.name(), "stone");Sourcepub const fn raw(self) -> u32
pub const fn raw(self) -> u32
The raw state.
assert_eq!(ghast_ext::Block::new(GameVersion::V1_8_9, 17).raw(), 17);Sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
The registry name without namespace ("stone", "oak_log"; 1.8: "log"), or ""
for an id this version does not know.
assert_eq!(ghast_ext::Block::new(GameVersion::V1_8_9, 17 << 4).name(), "log");Sourcepub fn meta(self) -> u8
pub fn meta(self) -> u8
The 1.8 / 1.12 metadata (raw & 15); 0 on 1.16 (use ghast-data’s properties there).
assert_eq!(ghast_ext::Block::new(GameVersion::V1_8_9, 59 << 4 | 7).meta(), 7); // ripe wheatSourcepub fn is_air(self) -> bool
pub fn is_air(self) -> bool
Air (also cave / void air on 1.16).
assert!(ghast_ext::Block::new(GameVersion::V1_16_5, 0).is_air());Sourcepub fn is_ore(self) -> bool
pub fn is_ore(self) -> bool
An ore (*_ore, nether quartz / gold ore, ancient debris; not the lit redstone ore
variant’s name difference on 1.8: lit_redstone_ore counts too).
assert!(ghast_ext::Block::new(GameVersion::V1_8_9, 15 << 4).is_ore()); // iron oreTrait Implementations§
impl Copy for Block
impl Eq for Block
impl StructuralPartialEq for Block
Auto Trait Implementations§
impl Forget for Block
impl Freeze for Block
impl Move for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnsafeUnpin 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