Skip to main content

MemoryWorld

Struct MemoryWorld 

Source
pub struct MemoryWorld<S> { /* private fields */ }
Expand description

A small in-memory world: explicitly loaded chunk columns, everything else unloaded.

Meant for tests, benches and offline planning. Blocks are stored per column in a dense array of raw values (u16), so lookups are a hash of the column plus an index.

Implementations§

Source§

impl<S: Copy> MemoryWorld<S>

Source

pub fn new(decode: fn(u16) -> S) -> Self

An empty world where nothing is loaded. decode turns a stored raw value into a state (for 1.8: BlockState::from_raw_vanilla); raw 0 must decode to air.

Source

pub fn load_chunks(&mut self, cx0: i32, cz0: i32, cx1: i32, cz1: i32)

Marks the inclusive chunk rectangle [cx0, cz0] ..= [cx1, cz1] as loaded (air until blocks are set).

Source

pub fn set_raw(&mut self, x: i32, y: i32, z: i32, raw: u16)

Stores a raw block value. Positions outside 0..256 in Y are ignored. Setting a block in a column that is not loaded stores it but it stays invisible until the column is loaded.

Source

pub fn fill_raw(&mut self, from: [i32; 3], to: [i32; 3], raw: u16)

Fills the inclusive box with a raw value.

Trait Implementations§

Source§

impl<S: Copy> BlockView for MemoryWorld<S>

Source§

type State = S

Block state type of the protocol version (ghast_data::v1_8::BlockState for 1.8).
Source§

fn block(&self, x: i32, y: i32, z: i32) -> S

The block state at a valid position (air when the column is not loaded).
Source§

fn is_chunk_loaded(&self, chunk_x: i32, chunk_z: i32) -> bool

true when the chunk column (chunk_x, chunk_z) has been received from the server.
Source§

fn world_border(&self) -> WorldBorder

The current world border (default: vanilla’s initial border, centre 0, 0, size 6e7).
Source§

impl<S: Clone> Clone for MemoryWorld<S>

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<S: Debug> Debug for MemoryWorld<S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Forget for MemoryWorld<S>

§

impl<S> Freeze for MemoryWorld<S>
where *const u8 is !null: Freeze, PhantomData<((i32, i32), Box<[u16]>)>: Freeze, PhantomData<[i32; 4]>: Freeze,

§

impl<S> Move for MemoryWorld<S>

§

impl<S> RefUnwindSafe for MemoryWorld<S>

§

impl<S> Send for MemoryWorld<S>
where RawTable<((i32, i32), Box<[u16]>)>: Send, RawVecInner: Send,

§

impl<S> Sync for MemoryWorld<S>
where RawTable<((i32, i32), Box<[u16]>)>: Sync, RawVecInner: Sync,

§

impl<S> Unpin for MemoryWorld<S>
where *const u8 is !null: Unpin, Box<[u16]>: Unpin,

§

impl<S> UnsafeUnpin for MemoryWorld<S>

§

impl<S> UnwindSafe for MemoryWorld<S>
where HashMap<(i32, i32), Box<[u16]>>: UnwindSafe, RawVecInner: UnwindSafe,

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> 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> 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.