Class BlockListManager
java.lang.Object
net.rodofire.easierworldcreator.blockdata.blocklist.BlockListManager
class to manage a list of DefaultBlockList automatically
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected it.unimi.dsi.fastutil.objects.Object2ShortOpenHashMap<BlockDataKey> the List of BlockList that are managedstatic final com.mojang.serialization.Codec<BlockListManager> protected List<BlockDataKey> Map used for better performance: Instead of searching for aBlockSateinside the list, we useindexes. -
Constructor Summary
ConstructorsConstructorDescriptioninit an empty comparatorBlockListManager(List<BlockList> blockList) init a comparatorBlockListManager(BlockList blockList) init a comparatorBlockListManager(BlockListManager comparator) init a comparator -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()getBlockList(int index) getOrdered(BlockSorter sorter) net.minecraft.block.BlockStategetState(int index) booleanplaceAll(net.minecraft.world.StructureWorldAccess worldAccess) booleanplaceAll(net.minecraft.world.StructureWorldAccess worldAccess, int flag) booleanplaceAllNDelete(net.minecraft.world.StructureWorldAccess worldAccess) booleanplaceAllNDelete(net.minecraft.world.StructureWorldAccess worldAccess, int flag) voidplaceJson(net.minecraft.world.StructureWorldAccess worldAccess, net.minecraft.util.math.ChunkPos chunkPos) voidplaceJson(net.minecraft.world.StructureWorldAccess worldAccess, net.minecraft.util.math.ChunkPos chunkPos, net.minecraft.util.math.ChunkPos offset, String name) convert the manager into a Json fileput(net.minecraft.block.BlockState state, long pos) put(net.minecraft.block.BlockState state, long pos, StructurePlacementRuleManager ruler) put(net.minecraft.block.BlockState state, it.unimi.dsi.fastutil.longs.LongArrayList pos) put(net.minecraft.block.BlockState state, it.unimi.dsi.fastutil.longs.LongArrayList pos, StructurePlacementRuleManager ruler) put(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList, StructurePlacementRuleManager ruler) put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, long pos) put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, long pos, StructurePlacementRuleManager ruler) put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, it.unimi.dsi.fastutil.longs.LongArrayList pos) put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, it.unimi.dsi.fastutil.longs.LongArrayList pos, StructurePlacementRuleManager ruler) Method to put a list of encoded blockPos in the manager.put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, List<net.minecraft.util.math.BlockPos> posList) put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, List<net.minecraft.util.math.BlockPos> posList, StructurePlacementRuleManager ruler) put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, net.minecraft.util.math.BlockPos pos) put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, net.minecraft.util.math.BlockPos pos, StructurePlacementRuleManager ruler) put(net.minecraft.block.BlockState state, net.minecraft.util.math.BlockPos pos) put(net.minecraft.block.BlockState state, net.minecraft.util.math.BlockPos pos, StructurePlacementRuleManager ruler) put(BlockListManager manager) shortsize()sort(BlockSorter sorter) intcom.google.gson.JsonArraytoJson(net.minecraft.util.math.ChunkPos chunkPos) com.google.gson.JsonArraytoJson(net.minecraft.util.math.ChunkPos chunkPos, net.minecraft.util.math.ChunkPos offset) toString()intMethod to know the number of all blockPos stored in everyBlockList.
-
Field Details
-
CODEC
-
blockLists
the List of BlockList that are managed -
stateIndexes
Map used for better performance:- Instead of searching for a
BlockSateinside the list, we useindexes. - The map allows us to get the place of the related
BlockStatein theposList. - Instead of having a time complexity of O(n), we get O(1) by using only a small amount of memory in more.
We use a Shorts to make the link between the
Pair<BlockState, NbtCompound>and theList<BlockList>. In the case where noNbtCompoundis present, we put anullvalue to it.Using short as a link allow us to save two bytes of data for each
BlockState. Since that it is highly unprobable that more than 32 000BlockStateare used, shorts are enough. - Instead of searching for a
-
blockDataMap
-
-
Constructor Details
-
BlockListManager
init a comparator- Parameters:
comparator- the comparator that will be fused
-
BlockListManager
init a comparator- Parameters:
blockList- the list of blockList that will be indexed
-
BlockListManager
init a comparator- Parameters:
blockList- a blockList that will be indexed
-
BlockListManager
public BlockListManager()init an empty comparator
-
-
Method Details
-
getBlockList
-
getAllBlockList
-
getFirstBlockList
-
getLastBlockList
-
getState
public net.minecraft.block.BlockState getState(int index) -
size
public short size() -
totalSize
public int totalSize()Method to know the number of all blockPos stored in everyBlockList. This is notabely used inOrderedBlockListManager. To avoid too much rehash, we count the size?. -
stateSize
public int stateSize() -
put
public BlockListManager put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, it.unimi.dsi.fastutil.longs.LongArrayList pos) -
put
public BlockListManager put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, it.unimi.dsi.fastutil.longs.LongArrayList pos, StructurePlacementRuleManager ruler) Method to put a list of encoded blockPos in the manager. In the case where the pair ofBlockStateandNbtCompoundis already present, the method will fuse the encoded posList in the related blockList. In the other case, the method will create a new BlockList linked to the pair.- Returns:
- the modified instance of the manager
-
put
public BlockListManager put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, long pos) -
put
public BlockListManager put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, List<net.minecraft.util.math.BlockPos> posList) -
put
public BlockListManager put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, net.minecraft.util.math.BlockPos pos) -
put
public BlockListManager put(net.minecraft.block.BlockState state, it.unimi.dsi.fastutil.longs.LongArrayList pos) -
put
-
put
public BlockListManager put(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList) -
put
public BlockListManager put(net.minecraft.block.BlockState state, net.minecraft.util.math.BlockPos pos) -
put
-
put
-
put
public BlockListManager put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, long pos, StructurePlacementRuleManager ruler) -
put
public BlockListManager put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, List<net.minecraft.util.math.BlockPos> posList, StructurePlacementRuleManager ruler) -
put
public BlockListManager put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, net.minecraft.util.math.BlockPos pos, StructurePlacementRuleManager ruler) -
put
public BlockListManager put(net.minecraft.block.BlockState state, it.unimi.dsi.fastutil.longs.LongArrayList pos, StructurePlacementRuleManager ruler) -
put
public BlockListManager put(net.minecraft.block.BlockState state, long pos, StructurePlacementRuleManager ruler) -
put
public BlockListManager put(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList, StructurePlacementRuleManager ruler) -
put
public BlockListManager put(net.minecraft.block.BlockState state, net.minecraft.util.math.BlockPos pos, StructurePlacementRuleManager ruler) -
put
-
put
-
getOrdered
-
getOrdered
-
toString
-
sort
-
clear
public void clear() -
placeAll
public boolean placeAll(net.minecraft.world.StructureWorldAccess worldAccess) -
placeAllNDelete
public boolean placeAllNDelete(net.minecraft.world.StructureWorldAccess worldAccess) -
placeAll
public boolean placeAll(net.minecraft.world.StructureWorldAccess worldAccess, int flag) -
placeAllNDelete
public boolean placeAllNDelete(net.minecraft.world.StructureWorldAccess worldAccess, int flag) -
toJson
public com.google.gson.JsonArray toJson(net.minecraft.util.math.ChunkPos chunkPos) -
toJson
public com.google.gson.JsonArray toJson(net.minecraft.util.math.ChunkPos chunkPos, net.minecraft.util.math.ChunkPos offset) -
placeJson
public void placeJson(net.minecraft.world.StructureWorldAccess worldAccess, net.minecraft.util.math.ChunkPos chunkPos) -
placeJson
public void placeJson(net.minecraft.world.StructureWorldAccess worldAccess, net.minecraft.util.math.ChunkPos chunkPos, net.minecraft.util.math.ChunkPos offset, String name) convert the manager into a Json file- Parameters:
chunkPos- the chunkpos of the manager. Positions will be written relative to this blockPosoffset- the offset to move the blockPos
-