Package io.github.bakedlibs.dough.blocks
Class ChunkPosition
java.lang.Object
io.github.bakedlibs.dough.blocks.ChunkPosition
This is a memory efficient version of a
Chunk.
It can be used to optimize Map usage or other storage means.- Author:
- TheBusyBiscuit, Walshy
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionChunkPosition(Chunk chunk) ChunkPosition(World world, int x, int z) ChunkPosition(World world, long position) -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic longgetAsLong(int x, int z) This compacts the two provided integers into oneLong.getChunk()Gets theChunkwhere this block is located.longGets the long position of this block.getWorld()Gets theWorldthis block is in.intgetX()Gets the x for thisChunk.intgetZ()Gets the y for thisChunk.inthashCode()booleanisLoaded()This checks whether thisChunkis loaded.toString()
-
Constructor Details
-
ChunkPosition
-
ChunkPosition
-
ChunkPosition
-
ChunkPosition
-
-
Method Details
-
getWorld
Gets theWorldthis block is in. If thisWorldhas been unloaded it will throw anIllegalStateException. This should be getting handled properly by yourself!
Note: This is held as a weak reference!- Returns:
- The
Worldfor this block.
-
isLoaded
public boolean isLoaded()This checks whether thisChunkis loaded. If theWorldis not loaded, this method will return false.- Returns:
- Whether this
Chunkis loaded
-
getPosition
public long getPosition()Gets the long position of this block. This is constructed of the x and z.
This is encoded as follows:(x << 32) | (z & 0xFFFFFFFFL)- Returns:
- The position of this block.
-
getX
public int getX()Gets the x for thisChunk.- Returns:
- This chunks x coordinate.
-
getZ
public int getZ()Gets the y for thisChunk.- Returns:
- This chunks z coordinate.
-
getChunk
Gets theChunkwhere this block is located.- Returns:
- This blocks
Chunk.
-
getAsLong
public static long getAsLong(int x, int z) This compacts the two provided integers into oneLong. This allows us to save a lot memory-wise.- Parameters:
x- The x componentz- The z component- Returns:
- The compacted
Long
-
equals
-
hashCode
public int hashCode() -
toString
-