Class BlockListManager

java.lang.Object
net.rodofire.easierworldcreator.blockdata.blocklist.BlockListManager

public class BlockListManager extends Object
class to manage a list of DefaultBlockList automatically
  • Field Details

    • blockLists

      protected List<BlockList> blockLists
      the List of BlockList that are managed
    • stateIndexes

      protected List<BlockDataKey> stateIndexes
      Map used for better performance:
      • Instead of searching for a BlockSate inside the list, we use indexes.
      • The map allows us to get the place of the related BlockState in the posList.
      • 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 the List<BlockList>. In the case where no NbtCompound is present, we put a null value 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 000 BlockState are used, shorts are enough.

    • blockDataMap

      protected it.unimi.dsi.fastutil.objects.Object2ShortOpenHashMap<BlockDataKey> blockDataMap
  • Constructor Details

    • BlockListManager

      public BlockListManager(BlockListManager comparator)
      init a comparator
      Parameters:
      comparator - the comparator that will be fused
    • BlockListManager

      public BlockListManager(List<BlockList> blockList)
      init a comparator
      Parameters:
      blockList - the list of blockList that will be indexed
    • BlockListManager

      public BlockListManager(BlockList blockList)
      init a comparator
      Parameters:
      blockList - a blockList that will be indexed
    • BlockListManager

      public BlockListManager()
      init an empty comparator
  • Method Details

    • getBlockList

      public BlockList getBlockList(int index)
    • getAllBlockList

      public List<BlockList> getAllBlockList()
    • getFirstBlockList

      public BlockList getFirstBlockList()
    • getLastBlockList

      public BlockList 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 every BlockList. This is notabely used in OrderedBlockListManager. 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)
      Method to put a list of encoded blockPos in the manager. In the case where the pair of BlockState and NbtCompound is 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

      public BlockListManager put(net.minecraft.block.BlockState state, long pos)
    • 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

      public BlockListManager put(BlockList[] blockLists)
    • put

      public BlockListManager put(List<BlockList> blockLists)
    • put

      public BlockListManager put(BlockList blockList)
    • put

      public BlockListManager put(BlockListManager manager)
    • getOrdered

      public OrderedBlockListManager getOrdered()
    • getOrdered

      public OrderedBlockListManager getOrdered(BlockSorter sorter)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • sort

      public BlockListManager sort(BlockSorter sorter)
    • 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 blockPos
      offset - the offset to move the blockPos