Skip to main content

Block

Struct Block 

Source
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

Source

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");
Source

pub const fn raw(self) -> u32

The raw state.

assert_eq!(ghast_ext::Block::new(GameVersion::V1_8_9, 17).raw(), 17);
Source

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");
Source

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 wheat
Source

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());
Source

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 ore
Source

pub fn is_log(self) -> bool

A log / stem / hyphae block (tree trunks).

assert!(ghast_ext::Block::new(GameVersion::V1_8_9, 17 << 4).is_log());
Source

pub fn is_liquid(self) -> bool

Water or lava.

assert!(ghast_ext::Block::new(GameVersion::V1_8_9, 9 << 4).is_liquid());

Trait Implementations§

Source§

impl Clone for Block

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Block

Source§

impl Debug for Block

Source§

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

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

impl Eq for Block

Source§

impl Hash for Block

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Block

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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, 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V