Class BlockListManager
java.lang.Object
fr.rodofire.ewc.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(BlockList blockList) init a comparatorBlockListManager(BlockListManager comparator) init a comparatorBlockListManager(List<BlockList> blockList) init a comparator -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()getBlockList(int index) getOrdered(BlockSorter sorter) net.minecraft.world.level.block.state.BlockStategetState(int index) booleanplaceAll(net.minecraft.world.level.WorldGenLevel worldAccess) booleanplaceAll(net.minecraft.world.level.WorldGenLevel worldAccess, int flag) booleanplaceAllNDelete(net.minecraft.world.level.WorldGenLevel worldAccess) booleanplaceAllNDelete(net.minecraft.world.level.WorldGenLevel worldAccess, int flag) voidplaceJson(net.minecraft.world.level.WorldGenLevel worldAccess, net.minecraft.world.level.ChunkPos chunkPos) voidplaceJson(net.minecraft.world.level.WorldGenLevel worldAccess, net.minecraft.world.level.ChunkPos chunkPos, net.minecraft.world.level.ChunkPos offset, String name) convert the manager into a Json fileput(BlockListManager manager) put(net.minecraft.world.level.block.state.BlockState state, long pos) put(net.minecraft.world.level.block.state.BlockState state, long pos, StructurePlacementRuleManager ruler) put(net.minecraft.world.level.block.state.BlockState state, it.unimi.dsi.fastutil.longs.LongArrayList pos) put(net.minecraft.world.level.block.state.BlockState state, it.unimi.dsi.fastutil.longs.LongArrayList pos, StructurePlacementRuleManager ruler) put(net.minecraft.world.level.block.state.BlockState state, List<net.minecraft.core.BlockPos> posList) put(net.minecraft.world.level.block.state.BlockState state, List<net.minecraft.core.BlockPos> posList, StructurePlacementRuleManager ruler) put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.core.BlockPos pos) put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.core.BlockPos pos, StructurePlacementRuleManager ruler) put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, long pos) put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, long pos, StructurePlacementRuleManager ruler) put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, it.unimi.dsi.fastutil.longs.LongArrayList pos) put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, it.unimi.dsi.fastutil.longs.LongArrayList pos, StructurePlacementRuleManager ruler) Method to put a list of encoded blockPos in the manager.put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, List<net.minecraft.core.BlockPos> posList) put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, List<net.minecraft.core.BlockPos> posList, StructurePlacementRuleManager ruler) put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, net.minecraft.core.BlockPos pos) put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, net.minecraft.core.BlockPos pos, StructurePlacementRuleManager ruler) shortsize()sort(BlockSorter sorter) intcom.google.gson.JsonArraytoJson(net.minecraft.world.level.ChunkPos chunkPos) com.google.gson.JsonArraytoJson(net.minecraft.world.level.ChunkPos chunkPos, net.minecraft.world.level.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, CompoundTag>and theList<BlockList>. In the case where noCompoundTagis 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.world.level.block.state.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.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, it.unimi.dsi.fastutil.longs.LongArrayList pos) -
put
public BlockListManager put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag 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 ofBlockStateandCompoundTagis 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.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, long pos) -
put
public BlockListManager put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, List<net.minecraft.core.BlockPos> posList) -
put
public BlockListManager put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, net.minecraft.core.BlockPos pos) -
put
public BlockListManager put(net.minecraft.world.level.block.state.BlockState state, it.unimi.dsi.fastutil.longs.LongArrayList pos) -
put
-
put
public BlockListManager put(net.minecraft.world.level.block.state.BlockState state, List<net.minecraft.core.BlockPos> posList) -
put
public BlockListManager put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.core.BlockPos pos) -
put
-
put
-
put
public BlockListManager put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, long pos, StructurePlacementRuleManager ruler) -
put
public BlockListManager put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, List<net.minecraft.core.BlockPos> posList, StructurePlacementRuleManager ruler) -
put
public BlockListManager put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, net.minecraft.core.BlockPos pos, StructurePlacementRuleManager ruler) -
put
public BlockListManager put(net.minecraft.world.level.block.state.BlockState state, it.unimi.dsi.fastutil.longs.LongArrayList pos, StructurePlacementRuleManager ruler) -
put
public BlockListManager put(net.minecraft.world.level.block.state.BlockState state, long pos, StructurePlacementRuleManager ruler) -
put
public BlockListManager put(net.minecraft.world.level.block.state.BlockState state, List<net.minecraft.core.BlockPos> posList, StructurePlacementRuleManager ruler) -
put
public BlockListManager put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.core.BlockPos pos, StructurePlacementRuleManager ruler) -
put
-
put
-
getOrdered
-
getOrdered
-
toString
-
sort
-
clear
public void clear() -
placeAll
public boolean placeAll(net.minecraft.world.level.WorldGenLevel worldAccess) -
placeAllNDelete
public boolean placeAllNDelete(net.minecraft.world.level.WorldGenLevel worldAccess) -
placeAll
public boolean placeAll(net.minecraft.world.level.WorldGenLevel worldAccess, int flag) -
placeAllNDelete
public boolean placeAllNDelete(net.minecraft.world.level.WorldGenLevel worldAccess, int flag) -
toJson
public com.google.gson.JsonArray toJson(net.minecraft.world.level.ChunkPos chunkPos) -
toJson
public com.google.gson.JsonArray toJson(net.minecraft.world.level.ChunkPos chunkPos, net.minecraft.world.level.ChunkPos offset) -
placeJson
public void placeJson(net.minecraft.world.level.WorldGenLevel worldAccess, net.minecraft.world.level.ChunkPos chunkPos) -
placeJson
public void placeJson(net.minecraft.world.level.WorldGenLevel worldAccess, net.minecraft.world.level.ChunkPos chunkPos, net.minecraft.world.level.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
-