Skip to main content

ChunkStorage

Enum ChunkStorage 

Source
pub enum ChunkStorage {
    Disk(RegionManager),
    RamOnly(RamOnlyStorage),
}
Expand description

Chunk storage backend.

This enum provides persistence for chunks, either to disk (region files) or in-memory (for testing/minigames). TODO: make it possible to give plugins the option to load a custom backend

Variants§

§

Disk(RegionManager)

Disk-based storage using region files.

§

RamOnly(RamOnlyStorage)

In-memory storage for testing and minigames.

Implementations§

Source§

impl ChunkStorage

Source

fn invalid_chunk_data(message: impl Into<String>) -> Error

Source

fn validate_packed_palette( palette: &[u16], bits_per_entry: u8, data: &[u64], entry_count: usize, global_palette_len: usize, name: &str, ) -> Result<()>

Source

fn validate_persistent_chunk( persistent: &PersistentChunk<'_>, min_y: i32, height: i32, ) -> Result<()>

Source

pub(super) fn section_to_persistent( section: &SectionHolder, builder: &mut ChunkBuilder<'_>, ) -> PersistentSection

Converts a runtime section to persistent format.

§Panics

If the section holds a value missing from its palette, rather than saving a different block or biome in its place.

Source

pub(super) fn biomes_to_persistent( biomes: &PalettedContainer<u16, 4>, builder: &mut ChunkBuilder<'_>, ) -> PersistentBiomeData

Converts runtime biome data to persistent format.

§Panics

If the container is still in worldgen Building mode or holds a value missing from its palette.

Source

pub(crate) fn try_persistent_to_chunk( persistent: &PersistentChunk<'_>, pos: ChunkPos, status: ChunkStatus, min_y: i32, height: i32, level: Weak<World>, ) -> Result<LoadedChunk>

Converts a persistent chunk to runtime format. The returned chunk is not dirty (freshly loaded from disk).

§Arguments
  • persistent - The persistent chunk data
  • pos - The chunk position
  • status - The chunk status
  • min_y - The minimum Y coordinate of the world
  • height - The total height of the world
  • level - Weak reference to the world for Full chunk runtime access
Source

pub(super) fn heightmaps_to_persistent( heightmaps: &ChunkHeightmaps, status: ChunkStatus, ) -> Vec<PersistentHeightmap>

Converts chunk heightmaps to persistent format for saving.

Source

pub(super) fn persistent_to_heightmaps( persistent: &[PersistentHeightmap], status: ChunkStatus, min_y: i32, height: i32, ) -> ChunkHeightmaps

Reconstructs chunk heightmaps from persistent data.

Source

pub(super) fn pois_to_persistent( chunk: FullChunkRef<'_>, chunk_pos: ChunkPos, ) -> Vec<PersistentPoi>

Collects POI occupancy data from the world’s POI storage for this chunk.

Source

pub(super) fn persistent_to_section( persistent: &PersistentSection, chunk: &PersistentChunk<'_>, ) -> Result<ChunkSection>

Converts a persistent section to runtime format.

Source

pub(super) fn persistent_to_biomes( persistent: &PersistentBiomeData, chunk: &PersistentChunk<'_>, ) -> Result<PalettedContainer<u16, 4>>

Converts persistent biome data to runtime format.

Source

pub(super) fn resolve_block_state( chunk: &PersistentChunk<'_>, index: u16, ) -> Result<BlockStateId>

Resolves a chunk palette index to a runtime BlockStateId.

Source

pub(super) fn resolve_biome( chunk: &PersistentChunk<'_>, index: u16, ) -> Result<u16>

Resolves a chunk palette index to a runtime biome ID.

Source§

impl ChunkStorage

Source

pub(super) fn entities_to_persistent( entities: &[SharedEntity], ) -> Vec<PersistentEntity>

Source

pub(crate) fn entity_tree_to_persistent( entity: &SharedEntity, ) -> Option<PersistentEntity>

Source

pub(crate) fn entity_to_dimension_transition_persistent( entity: &SharedEntity, ) -> Option<PersistentEntity>

Source

pub(super) fn custom_name_to_persistent( custom_name: Option<&TextComponent>, ) -> Vec<u8> ⓘ

Source

pub(super) fn custom_name_from_persistent( bytes: &[u8], uuid: Uuid, ) -> Option<TextComponent>

Source

pub(super) fn compound_to_persistent(compound: &NbtCompound) -> Vec<u8> ⓘ

Source

pub(super) fn compound_from_persistent(bytes: &[u8], uuid: Uuid) -> NbtCompound

Source

pub(super) fn save_data_from_persistent( persistent: &PersistentEntity, uuid: Uuid, ) -> EntityBaseSaveData

Source

pub(super) fn entity_to_persistent( entity: &SharedEntity, visited: &mut FxHashSet<i32>, mode: EntityPersistenceMode, ) -> Option<PersistentEntity>

Source

pub(super) fn entity_should_save(entity: &dyn Entity) -> bool

Source

pub(super) fn entity_should_persist( entity: &dyn Entity, mode: EntityPersistenceMode, ) -> bool

Source

pub(super) fn persistent_block_entity_pos( persistent: &PersistentBlockEntity, chunk_pos: ChunkPos, ) -> BlockPos

Converts a runtime section to persistent format.

Source

pub(super) fn persistent_to_block_entity( persistent: &PersistentBlockEntity, chunk_pos: ChunkPos, chunk: FullChunkRef<'_>, ) -> Option<SharedBlockEntity>

Converts a persistent block entity to runtime format.

Source

pub(super) fn persistent_to_block_entity_at( persistent: &PersistentBlockEntity, pos: BlockPos, level: Weak<World>, state: BlockStateId, ) -> Option<SharedBlockEntity>

Source

pub(crate) fn persistent_to_entity_tree_at_level( persistent: &PersistentEntity, chunk_pos: ChunkPos, level: &Weak<World>, ) -> Vec<SharedEntity> ⓘ

Converts a persistent entity tree to runtime format.

Source

pub(super) fn load_persistent_passenger_tree( persistent: &PersistentEntity, chunk_pos: ChunkPos, level: &Weak<World>, vehicle: &SharedEntity, entities: &mut Vec<SharedEntity>, )

Source

pub(super) fn persistent_to_entity_at_level( persistent: &PersistentEntity, chunk_pos: ChunkPos, level: &Weak<World>, ) -> Option<SharedEntity>

Converts one persistent entity to runtime format without loading passengers.

Source§

impl ChunkStorage

Source

pub(super) fn light_to_persistent(light: &ChunkLightData) -> PersistentLightData

Converts chunk-owned light data to persistent format.

Source

pub(super) fn light_layer_to_persistent( layer: &ChunkLightLayerStorage, ) -> Vec<PersistentLightSection>

Source

pub(super) fn persistent_to_light( persistent: &PersistentLightData, min_y: i32, height: i32, status: ChunkStatus, ) -> ChunkLightData

Source

pub(super) fn apply_persistent_light_layer( layer: &mut ChunkLightLayerStorage, persistent: &[PersistentLightSection], layer_name: &str, )

Source

pub(super) fn persistent_to_light_section( persistent: &PersistentLightSection, layer_name: &str, ) -> Option<LightSection>

Source

pub(super) fn persistent_light_bytes_to_data( data: &[u8], section_index: u32, layer_name: &str, ) -> Option<LightSectionData>

Source§

impl ChunkStorage

Source

pub(super) fn jigsaw_piece_data_to_persistent( data: &JigsawPieceData, ) -> PersistentJigsawPieceData

Source

pub(super) fn persistent_to_jigsaw_piece_data( data: &PersistentJigsawPieceData, ) -> JigsawPieceData

Source

pub(super) fn procedural_piece_data_to_persistent( data: &ProceduralPieceData, ) -> PersistentProceduralPieceData

Source

pub(super) fn persistent_to_procedural_piece_data( data: &PersistentProceduralPieceData, ) -> ProceduralPieceData

Source

pub(super) fn ocean_monument_data_to_persistent( data: &OceanMonumentPieceData, ) -> PersistentOceanMonumentPieceData

Source

pub(super) fn persistent_to_ocean_monument_data( data: &PersistentOceanMonumentPieceData, ) -> OceanMonumentPieceData

Source

const fn ocean_monument_child_to_persistent( child: &OceanMonumentChildPiece, ) -> PersistentOceanMonumentChildPiece

Source

const fn persistent_to_ocean_monument_child( child: &PersistentOceanMonumentChildPiece, ) -> OceanMonumentChildPiece

Source

const fn ocean_monument_child_kind_to_persistent( kind: &OceanMonumentChildPieceKind, ) -> PersistentOceanMonumentChildPieceKind

Source

const fn persistent_to_ocean_monument_child_kind( kind: &PersistentOceanMonumentChildPieceKind, ) -> OceanMonumentChildPieceKind

Source

const fn ocean_monument_room_to_persistent( room: OceanMonumentRoomData, ) -> PersistentOceanMonumentRoomData

Source

const fn persistent_to_ocean_monument_room( room: &PersistentOceanMonumentRoomData, ) -> OceanMonumentRoomData

Source

const fn fortress_piece_data_to_persistent( data: FortressPieceData, ) -> PersistentNetherFortressPieceData

Source

const fn persistent_to_fortress_piece_data( data: &PersistentNetherFortressPieceData, ) -> FortressPieceData

Source

const fn stronghold_door_to_persistent( door: StrongholdSmallDoorType, ) -> PersistentStrongholdSmallDoorType

Source

const fn persistent_to_stronghold_door( door: &PersistentStrongholdSmallDoorType, ) -> StrongholdSmallDoorType

Source

const fn stronghold_piece_data_to_persistent( data: StrongholdPieceData, ) -> PersistentStrongholdPieceData

Source

const fn persistent_to_stronghold_piece_data( data: &PersistentStrongholdPieceData, ) -> StrongholdPieceData

Source

pub(super) fn mineshaft_kind_to_persistent( kind: &MineshaftPieceKind, ) -> PersistentMineshaftPieceKind

Source

pub(super) fn persistent_to_mineshaft_kind( kind: &PersistentMineshaftPieceKind, ) -> MineshaftPieceKind

Source

pub(super) fn structure_piece_payload_to_persistent( payload: &StructurePiecePayload, ) -> PersistentStructurePiecePayload

Source

pub(super) fn persistent_to_structure_piece_payload( payload: &PersistentStructurePiecePayload, ) -> StructurePiecePayload

Source

pub(super) fn pool_element_to_persistent( element: &PoolElement, ) -> PersistentPoolElement

Source

pub(super) fn persistent_to_pool_element( element: &PersistentPoolElement, ) -> PoolElement

Source

pub(super) fn processors_to_persistent( processors: &ProcessorList, ) -> PersistentProcessorList

Source

pub(super) fn persistent_to_processors( processors: &PersistentProcessorList, ) -> ProcessorList

Source

pub(super) fn template_processors_to_persistent( processors: &TemplateProcessorList, ) -> PersistentTemplateProcessorList

Source

pub(super) fn persistent_to_template_processors( processors: &PersistentTemplateProcessorList, ) -> TemplateProcessorList

Source

pub(super) fn structure_starts_to_persistent( starts: &StructureStartMap, ) -> Vec<PersistentStructureStart>

Converts structure starts to persistent format for saving.

Source

pub(super) fn structure_references_to_persistent( refs: &StructureReferenceMap, ) -> Vec<PersistentStructureReference>

Converts structure references to persistent format for saving.

Source

pub(super) fn persistent_to_structure_starts( persistent: &[PersistentStructureStart], ) -> StructureStartMap

Reconstructs structure starts from persistent data.

Source

pub(super) fn persistent_to_structure_references( persistent: &[PersistentStructureReference], ) -> StructureReferenceMap

Reconstructs structure references from persistent data.

Source§

impl ChunkStorage

Source

pub(super) fn block_ticks_to_persistent( ticks: Vec<SavedTick<BlockRef>>, chunk_pos: ChunkPos, ) -> Vec<PersistentTick>

Converts block ticks to persistent format for saving.

Source

pub(super) fn fluid_ticks_to_persistent( ticks: Vec<SavedTick<FluidRef>>, chunk_pos: ChunkPos, ) -> Vec<PersistentTick>

Converts fluid ticks to persistent format for saving.

Source

pub(super) fn persistent_to_block_saved_ticks( persistent: &[PersistentTick], chunk_pos: ChunkPos, ) -> Vec<SavedTick<BlockRef>>

Reconstructs saved block ticks from persistent data.

Source

pub(super) fn persistent_to_fluid_saved_ticks( persistent: &[PersistentTick], chunk_pos: ChunkPos, ) -> Vec<SavedTick<FluidRef>>

Reconstructs saved fluid ticks from persistent data.

Source§

impl ChunkStorage

Source

pub async fn load_chunk( &self, pos: ChunkPos, min_y: i32, height: i32, level: Weak<World>, thread_pool: &ThreadPool, ) -> Result<Option<LoadedChunk>>

Loads a chunk from storage.

Returns Ok(None) if the chunk doesn’t exist in storage. For RamOnly with create_empty_on_miss=true, this always returns an empty chunk (never None).

Source

pub async fn save_chunk_data( &self, prepared: PreparedChunkSave, thread_pool: &ThreadPool, ) -> Result<bool>

Saves prepared chunk data to storage.

Returns Ok(true) if the chunk was saved, Ok(false) if it was a no-op.

Source

pub async fn chunk_exists(&self, pos: ChunkPos) -> Result<bool>

Checks if a chunk exists in storage.

Source

pub async fn acquire_chunk(&self, pos: ChunkPos) -> Result<bool>

Acquires a chunk for loading, preparing any necessary resources.

For disk storage, this opens/creates the region file and returns whether the chunk exists. For RAM storage, this just checks existence.

Source

pub async fn release_chunk(&self, pos: ChunkPos) -> Result<()>

Releases a loaded chunk, allowing the storage to clean up resources.

Source

pub async fn flush_all(&self) -> Result<()>

Flushes all dirty data to storage.

Source

pub async fn close_all(&self) -> Result<()>

Closes all storage handles and flushes pending data.

Source

pub(crate) fn prepare_chunk_save( chunk: &Chunk, status: ChunkStatus, runtime_entities: &[SharedEntity], force: bool, ) -> Option<PreparedChunkSave>

Prepares chunk data and its authoritative persisted status for saving. Call during the holder’s snapshot-preparation phase; end it before save_chunk_data.

Returns None if nothing needs saving or promotion invalidated status; retry later.

§Panics

Panics if status is Full but the chunk has no Full runtime state.

Source

fn entity_position_is_finite(entity: &dyn Entity) -> bool

Source

fn warn_skipping_non_finite_entity(entity: &dyn Entity)

Source

fn assert_unique_save_uuid( seen_uuids: &mut FxHashSet<Uuid>, uuid: Uuid, entity_id: i32, chunk_pos: ChunkPos, )

Source

fn to_persistent( sections: &Sections, block_entities: &[SharedBlockEntity], pending_block_entities: &[BlockPos], entities: &[SharedEntity], block_ticks: Vec<PersistentTick>, fluid_ticks: Vec<PersistentTick>, heightmaps: Vec<PersistentHeightmap>, light: PersistentLightData, postprocessing: Vec<Vec<u16>>, structure_starts: Vec<PersistentStructureStart>, structure_references: Vec<PersistentStructureReference>, pois: Vec<PersistentPoi>, chunk_pos: ChunkPos, ) -> PersistentChunk<'static>

Converts chunk data to persistent format.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoShared for T

Source§

fn into_shared(self) -> Arc<Mutex<RawMutex, Self>> ⓘ

Wraps this value in an Arc<SyncMutex<>>
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more