Skip to main content

NbtNumeric

Trait NbtNumeric 

Source
pub trait NbtNumeric {
    // Required methods
    fn codec_bool(&self) -> Option<bool>;
    fn codec_i8(&self) -> Option<i8>;
    fn codec_i32(&self) -> Option<i32>;
    fn codec_i64(&self) -> Option<i64>;
    fn codec_f32(&self) -> Option<f32>;
    fn codec_f64(&self) -> Option<f64>;
    fn int_value(&self) -> Option<i32>;

    // Provided methods
    fn short_value(&self) -> Option<i16> { ... }
    fn byte_value(&self) -> Option<i8> { ... }
}
Expand description

Decodes numeric NBT tags with vanilla’s numeric conversions.

codec_* mirror DynamicOps number codecs, which truncate floating values. *_value mirror NumericTag, used by ValueInput.get*Or, which floors them. Floating-point reads agree, so codec_f32/codec_f64 also serve getFloatOr/getDoubleOr.

Required Methods§

Source

fn codec_bool(&self) -> Option<bool>

Decodes Codec.BOOL from any numeric NBT tag.

Source

fn codec_i8(&self) -> Option<i8>

Decodes Codec.BYTE from any numeric NBT tag.

Source

fn codec_i32(&self) -> Option<i32>

Decodes Codec.INT from any numeric NBT tag.

Source

fn codec_i64(&self) -> Option<i64>

Decodes Codec.LONG from any numeric NBT tag.

Source

fn codec_f32(&self) -> Option<f32>

Decodes Codec.FLOAT from any numeric NBT tag.

Source

fn codec_f64(&self) -> Option<f64>

Decodes Codec.DOUBLE from any numeric NBT tag.

Source

fn int_value(&self) -> Option<i32>

Converts to an integer, flooring floating values.

Provided Methods§

Source

fn short_value(&self) -> Option<i16>

Returns the low 16 bits of int_value.

Source

fn byte_value(&self) -> Option<i8>

Returns the low 8 bits of int_value.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl NbtNumeric for NbtTag

Source§

impl NbtNumeric for NbtTag<'_, '_>

Implementors§