Class BlockList

java.lang.Object
fr.rodofire.ewc.blockdata.blocklist.BlockList

public class BlockList extends Object

Class used to connect BlockPos to a BlockState.


the class is composed of a LongArrayList that store all the BlockPos related to a BlockState.

This means that all the BlockPos of the object are connected to the BlockState


this is an easier version of the StructureTemplate.Palette

This approach allows for many improvements:
  • BlockStates are not doubled, saving a lot of memory comparing to Pair<BlockState, BlockPos> since that no BlockState are duplicated
  • BlockPos are compressed into a LongArrayList, saving ~30% memory and allowing for ~70% more performance
  • Provides some describing on how should the Block be placed: overrideBlocks and force
  • provide some useful methods to simplify it's usage
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<BlockList>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    BlockList(BlockDataKey blockDataKey, StructurePlacementRuleManager ruleManager, List<Long> longs)
     
    BlockList(net.minecraft.world.level.block.state.BlockState state, long pos)
    init a BlockShapeManager
    BlockList(net.minecraft.world.level.block.state.BlockState state, it.unimi.dsi.fastutil.longs.LongArrayList posList)
    init a BlockShapeManager
    BlockList(net.minecraft.world.level.block.state.BlockState state, List<net.minecraft.core.BlockPos> posList)
    init a BlockShapeManager
    BlockList(net.minecraft.world.level.block.state.BlockState state, net.minecraft.core.BlockPos pos)
    init a BlockShapeManager
    BlockList(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, long pos)
    init a BlockShapeManager
    BlockList(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, it.unimi.dsi.fastutil.longs.LongArrayList posList)
    init a BlockShapeManager
    BlockList(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, List<net.minecraft.core.BlockPos> posList)
    init a BlockShapeManager
    BlockList(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, net.minecraft.core.BlockPos pos)
    init a BlockShapeManager
  • Method Summary

    Modifier and Type
    Method
    Description
    addAllPos(it.unimi.dsi.fastutil.longs.LongArrayList posList)
     
    addAllPos(List<net.minecraft.core.BlockPos> posList)
     
    void
    addCustomProperty(com.google.gson.JsonObject json)
     
    addPos(long pos)
     
    addPos(net.minecraft.core.BlockPos pos)
     
     
    List<net.minecraft.core.BlockPos>
     
    long
     
    net.minecraft.core.BlockPos
     
    long
     
    net.minecraft.core.BlockPos
     
    long
    getLongPos(int index)
     
    net.minecraft.core.BlockPos
    getPos(int index)
     
    it.unimi.dsi.fastutil.longs.LongArrayList
     
    long
     
    long
    getRandomLongPos(net.minecraft.util.RandomSource random)
     
    net.minecraft.core.BlockPos
     
    net.minecraft.core.BlockPos
    getRandomPos(net.minecraft.util.RandomSource random)
     
     
    net.minecraft.world.level.block.state.BlockState
     
    Optional<net.minecraft.nbt.CompoundTag>
     
    void
    init(net.minecraft.world.level.WorldGenLevel world)
     
    boolean
    place(net.minecraft.world.level.WorldGenLevel world, int index)
     
    boolean
    place(net.minecraft.world.level.WorldGenLevel world, int index, int flag)
     
    boolean
    placeAll(net.minecraft.world.level.WorldGenLevel worldAccess)
     
    boolean
    placeAll(net.minecraft.world.level.WorldGenLevel worldAccess, int flag)
     
    boolean
    placeAllNDelete(net.minecraft.world.level.WorldGenLevel worldAccess)
     
    boolean
    placeAllNDelete(net.minecraft.world.level.WorldGenLevel worldAccess, int flag)
     
    boolean
    placeFirst(net.minecraft.world.level.WorldGenLevel world)
     
    boolean
    placeFirst(net.minecraft.world.level.WorldGenLevel world, int flag)
     
    void
    placeJson(net.minecraft.world.level.ChunkPos chunkPos)
     
    void
    placeJson(net.minecraft.world.level.WorldGenLevel world, net.minecraft.world.level.ChunkPos offset, net.minecraft.world.level.ChunkPos chunkPos)
     
    boolean
    placeLast(net.minecraft.world.level.WorldGenLevel world)
     
    boolean
    placeLast(net.minecraft.world.level.WorldGenLevel world, int flag)
     
    boolean
    placeLastNDelete(net.minecraft.world.level.WorldGenLevel world)
     
    boolean
    placeNDelete(net.minecraft.world.level.WorldGenLevel world, int index)
    for the most performance, it is recommended to not use this method where placeLastNDelete() can be applied
    boolean
    placeNDelete(net.minecraft.world.level.WorldGenLevel world, int index, int flag)
    for the most performance, it is recommended to not use this method where placeLastNDelete() can be applied
    removeAll(List<net.minecraft.core.BlockPos> list)
    time complexity of O(n * m), m being the length of the provided List<> avoid using it in performance crucial applications
    net.minecraft.core.BlockPos
     
    net.minecraft.core.BlockPos
     
    net.minecraft.core.BlockPos
    removePos(int index)
     
    removePos(net.minecraft.core.BlockPos pos)
    time complexity of O(n), avoid using this in performance crucial applications
    replacePos(int index, long newPos)
     
    replacePos(int index, net.minecraft.core.BlockPos newPos)
     
    set(int index, net.minecraft.core.BlockPos newPos)
     
    void
     
    setPosList(it.unimi.dsi.fastutil.longs.LongArrayList posList)
     
    setPosList(List<net.minecraft.core.BlockPos> posList)
     
    void
     
    void
    setState(net.minecraft.world.level.block.state.BlockState state)
     
    void
    setTag(net.minecraft.nbt.CompoundTag tag)
     
    int
     
    com.google.gson.JsonObject
    toJson(net.minecraft.world.level.ChunkPos chunkPos)
     
    com.google.gson.JsonObject
    toJson(net.minecraft.world.level.ChunkPos offset, net.minecraft.world.level.ChunkPos chunkPos)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<BlockList> CODEC
  • Constructor Details

    • BlockList

      public BlockList(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, List<net.minecraft.core.BlockPos> posList)
      init a BlockShapeManager
      Parameters:
      state - the state related to the pos list
      posList - pos of the state
    • BlockList

      public BlockList(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, net.minecraft.core.BlockPos pos)
      init a BlockShapeManager
      Parameters:
      state - the blockState related to the pos list
      pos - pos of the blockState
    • BlockList

      public BlockList(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, it.unimi.dsi.fastutil.longs.LongArrayList posList)
      init a BlockShapeManager
      Parameters:
      state - the state related to the pos list
      posList - pos of the state
    • BlockList

      public BlockList(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, long pos)
      init a BlockShapeManager
      Parameters:
      state - the blockState related to the pos list
      pos - pos of the blockState
    • BlockList

      public BlockList(net.minecraft.world.level.block.state.BlockState state, List<net.minecraft.core.BlockPos> posList)
      init a BlockShapeManager
      Parameters:
      state - the state related to the pos list
      posList - pos of the state
    • BlockList

      public BlockList(net.minecraft.world.level.block.state.BlockState state, net.minecraft.core.BlockPos pos)
      init a BlockShapeManager
      Parameters:
      state - the blockState related to the pos list
      pos - pos of the blockState
    • BlockList

      public BlockList(net.minecraft.world.level.block.state.BlockState state, it.unimi.dsi.fastutil.longs.LongArrayList posList)
      init a BlockShapeManager
      Parameters:
      state - the state related to the pos list
      posList - pos of the state
    • BlockList

      public BlockList(net.minecraft.world.level.block.state.BlockState state, long pos)
      init a BlockShapeManager
      Parameters:
      state - the blockState related to the pos list
      pos - pos of the blockState
    • BlockList

      public BlockList()
    • BlockList

      public BlockList(BlockDataKey blockDataKey, StructurePlacementRuleManager ruleManager, List<Long> longs)
  • Method Details

    • size

      public int size()
    • replacePos

      public BlockList replacePos(int index, net.minecraft.core.BlockPos newPos)
    • replacePos

      public BlockList replacePos(int index, long newPos)
    • addAllPos

      public BlockList addAllPos(List<net.minecraft.core.BlockPos> posList)
    • addAllPos

      public BlockList addAllPos(it.unimi.dsi.fastutil.longs.LongArrayList posList)
    • addPos

      public BlockList addPos(net.minecraft.core.BlockPos pos)
    • addPos

      public BlockList addPos(long pos)
    • setPosList

      public BlockList setPosList(List<net.minecraft.core.BlockPos> posList)
    • setPosList

      public BlockList setPosList(it.unimi.dsi.fastutil.longs.LongArrayList posList)
    • set

      public BlockList set(int index, net.minecraft.core.BlockPos newPos)
    • getConvertedPosList

      public List<net.minecraft.core.BlockPos> getConvertedPosList()
    • getPosList

      public it.unimi.dsi.fastutil.longs.LongArrayList getPosList()
    • getPos

      public net.minecraft.core.BlockPos getPos(int index)
    • getFirstPos

      public net.minecraft.core.BlockPos getFirstPos()
    • getLastPos

      public net.minecraft.core.BlockPos getLastPos()
    • getRandomPos

      public net.minecraft.core.BlockPos getRandomPos()
    • getRandomPos

      public net.minecraft.core.BlockPos getRandomPos(net.minecraft.util.RandomSource random)
    • getLongPos

      public long getLongPos(int index)
    • getFirstLongPos

      public long getFirstLongPos()
    • getLastLongPos

      public long getLastLongPos()
    • getRandomLongPos

      public long getRandomLongPos()
    • getRandomLongPos

      public long getRandomLongPos(net.minecraft.util.RandomSource random)
    • removePos

      public net.minecraft.core.BlockPos removePos(int index)
    • removeLastPos

      public net.minecraft.core.BlockPos removeLastPos()
    • removeFirstPos

      public net.minecraft.core.BlockPos removeFirstPos()
    • removePos

      public BlockList removePos(net.minecraft.core.BlockPos pos)
      time complexity of O(n), avoid using this in performance crucial applications
      Returns:
      the removed pos
    • getTag

      public Optional<net.minecraft.nbt.CompoundTag> getTag()
    • setTag

      public void setTag(net.minecraft.nbt.CompoundTag tag)
    • removeAll

      public BlockList removeAll(List<net.minecraft.core.BlockPos> list)
      time complexity of O(n * m), m being the length of the provided List<> avoid using it in performance crucial applications
      Returns:
      the instance of the object
    • getRuler

      public StructurePlacementRuleManager getRuler()
    • setRuler

      public void setRuler(StructurePlacementRuleManager ruler)
    • getState

      public net.minecraft.world.level.block.state.BlockState getState()
    • setState

      public void setState(net.minecraft.world.level.block.state.BlockState state)
    • getBlockData

      public BlockDataKey getBlockData()
    • setBlockData

      public void setBlockData(BlockDataKey data)
    • placeLast

      public boolean placeLast(net.minecraft.world.level.WorldGenLevel world)
    • placeFirst

      public boolean placeFirst(net.minecraft.world.level.WorldGenLevel world)
    • place

      public boolean place(net.minecraft.world.level.WorldGenLevel world, int index)
    • placeAll

      public boolean placeAll(net.minecraft.world.level.WorldGenLevel worldAccess, int flag)
    • placeLast

      public boolean placeLast(net.minecraft.world.level.WorldGenLevel world, int flag)
    • placeFirst

      public boolean placeFirst(net.minecraft.world.level.WorldGenLevel world, int flag)
    • place

      public boolean place(net.minecraft.world.level.WorldGenLevel world, int index, int flag)
    • placeAll

      public boolean placeAll(net.minecraft.world.level.WorldGenLevel worldAccess)
    • placeLastNDelete

      public boolean placeLastNDelete(net.minecraft.world.level.WorldGenLevel world)
    • placeNDelete

      public boolean placeNDelete(net.minecraft.world.level.WorldGenLevel world, int index)
      for the most performance, it is recommended to not use this method where placeLastNDelete() can be applied
    • placeNDelete

      public boolean placeNDelete(net.minecraft.world.level.WorldGenLevel world, int index, int flag)
      for the most performance, it is recommended to not use this method where placeLastNDelete() can be applied
    • placeAllNDelete

      public boolean placeAllNDelete(net.minecraft.world.level.WorldGenLevel worldAccess)
    • placeAllNDelete

      public boolean placeAllNDelete(net.minecraft.world.level.WorldGenLevel worldAccess, int flag)
    • toJson

      public com.google.gson.JsonObject toJson(net.minecraft.world.level.ChunkPos chunkPos)
    • toJson

      public com.google.gson.JsonObject toJson(net.minecraft.world.level.ChunkPos offset, net.minecraft.world.level.ChunkPos chunkPos)
    • addCustomProperty

      public void addCustomProperty(com.google.gson.JsonObject json)
    • placeJson

      public void placeJson(net.minecraft.world.level.ChunkPos chunkPos)
    • placeJson

      public void placeJson(net.minecraft.world.level.WorldGenLevel world, net.minecraft.world.level.ChunkPos offset, net.minecraft.world.level.ChunkPos chunkPos)
    • init

      public void init(net.minecraft.world.level.WorldGenLevel world)