java.lang.Object
net.paulem.arcana.regions.container.ChunkBlockContainer<S,K>
- Type Parameters:
S- The type of the tracked entities being managed, which extendsTracked.K- The type of the key associated with the tracked entities, which extendsWorldKey.
- All Implemented Interfaces:
SubContainerHolderAccessor<S,K>
public class ChunkBlockContainer<S extends Tracked<K>,K extends WorldKey>
extends Object
implements SubContainerHolderAccessor<S,K>
Represents a container for managing and organizing data within a specific chunk of the world.
This container divides the chunk into sections based on the vertical axis, allowing for more
granular management of data associated with tracked entities.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all holders from every section in this chunk container.Collection<Holder<S, K>> getHolder(int x, int y, int z) Retrieves the tracked object at the given coordinates, using the vertical section that y falls into.getOrCreateSection(int sectionY) Retrieves the vertical section at the given index, creating it first if it doesn't exist yet.getSection(int sectionY) Retrieves the vertical section at the given index, without creating it.static <S extends Tracked<K>,K extends WorldKey>
ChunkBlockContainer<S, K> of(WorldBlockContainer<S, K> parent, ChunkKey chunkKey) Creates a new, emptyChunkBlockContainerfor the given parent world container and chunk.voidremoveHolder(int x, int y, int z) Removes the tracked object at the given coordinates, using the vertical section that y falls into.voidremoveSection(ChunkSectionBlockContainer<S, K> section) Removes the given section from this chunk container and notifies the parent world container to remove this chunk if it no longer has any sections left.voidStores a tracked object at the given coordinates, using the vertical section that y falls into.
-
Method Details
-
of
public static <S extends Tracked<K>,K extends WorldKey> ChunkBlockContainer<S,K> of(WorldBlockContainer<S, K> parent, ChunkKey chunkKey) Creates a new, emptyChunkBlockContainerfor the given parent world container and chunk.- Type Parameters:
S- the type of the tracked entities being managedK- the type of the key associated with the tracked entities- Parameters:
parent- the world container this chunk container belongs tochunkKey- the key identifying the chunk this container manages- Returns:
- a new
ChunkBlockContainerinstance
-
getSection
Retrieves the vertical section at the given index, without creating it.- Parameters:
sectionY- the section index- Returns:
- the section at the given index, or
nullif it hasn't been created yet
-
getOrCreateSection
Retrieves the vertical section at the given index, creating it first if it doesn't exist yet.- Parameters:
sectionY- the section index- Returns:
- the section at the given index, never
null
-
removeSection
Removes the given section from this chunk container and notifies the parent world container to remove this chunk if it no longer has any sections left.- Parameters:
section- the section to remove
-
clear
public void clear()Clears all holders from every section in this chunk container. -
getHolder
Retrieves the tracked object at the given coordinates, using the vertical section that y falls into.- Specified by:
getHolderin interfaceSubContainerHolderAccessor<S extends Tracked<K>,K extends WorldKey> - Parameters:
x- the x coordinatey- the y coordinatez- the z coordinate- Returns:
- the tracked object at the given coordinates, or
nullif y is outside this chunk's height range or no object is stored there
-
setHolder
Stores a tracked object at the given coordinates, using the vertical section that y falls into. Does nothing if y is outside this chunk's height range. -
removeHolder
public void removeHolder(int x, int y, int z) Removes the tracked object at the given coordinates, using the vertical section that y falls into. Does nothing if y is outside this chunk's height range.- Specified by:
removeHolderin interfaceSubContainerHolderAccessor<S extends Tracked<K>,K extends WorldKey> - Parameters:
x- the x coordinatey- the y coordinatez- the z coordinate
-
getAllHolders
- Specified by:
getAllHoldersin interfaceSubContainerHolderAccessor<S extends Tracked<K>,K extends WorldKey> - Returns:
- a collection of all holders stored across every section of this chunk
-