java.lang.Object
net.rodofire.easierworldcreator.blockdata.blocklist.basic.DefaultBlockList
All Implemented Interfaces:
BlockListManager
Direct Known Subclasses:
CompoundBlockList, ForceBlockList

public class DefaultBlockList extends Object implements BlockListManager

Class used to connect BlockPos to a BlockState.


the class is composed of a List<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.StructureBlockInfo

It also allows for better manipulation of how blocks behave and allows to save memory since that there is no double blockStates.

  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultBlockList(List<net.minecraft.util.math.BlockPos> posList, net.minecraft.block.BlockState blockState)
    init a BlockShapeManager
    DefaultBlockList(net.minecraft.util.math.BlockPos pos, net.minecraft.block.BlockState state)
    init a BlockShapeManager
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addBlockPos(List<net.minecraft.util.math.BlockPos> pos)
    allow you to add multiple BlockPos to the existing list
    void
    addBlockPos(net.minecraft.util.math.BlockPos pos)
    allow you to add a BlockPos to the existing list
    net.minecraft.block.BlockState
    used to get the blockState
    net.minecraft.util.math.BlockPos
    method to get the first blockPos of the posList
    net.minecraft.util.math.BlockPos
    method to get the last blockPos of the posList
    net.minecraft.util.math.BlockPos
    getPos(int index)
    method to get a certain pos from an index in the posList
    List<net.minecraft.util.math.BlockPos>
    used to get the list of blockPos related to a layer
    net.minecraft.util.math.BlockPos
    Method to get a random BlockPos in the posList by using a new minecraft Random
    net.minecraft.util.math.BlockPos
    getRandomPos(net.minecraft.util.math.random.Random random)
    Method to get a random BlockPos in the posList based on a provided random
    void
    place(net.minecraft.world.StructureWorldAccess world, int index)
    method to place the Block related to the index
    void
    placeAll(net.minecraft.world.StructureWorldAccess worldAccess)
    Method to place all the blocks in the comparator
    void
    placeAllWithDeletion(net.minecraft.world.StructureWorldAccess worldAccess)
    Method to place all the blocks in the comparator and removing the BlockPos
    void
    placeAllWithVerification(net.minecraft.world.StructureWorldAccess worldAccess)
    Method to place all the blocks in the comparator with the BlockPos getting verified
    void
    placeAllWithVerificationDeletion(net.minecraft.world.StructureWorldAccess worldAccess)
    Method to place all the blocks in the comparator with the BlockPos getting verified and the getting deleted
    void
    placeFirst(net.minecraft.world.StructureWorldAccess world)
    method to place the first Block
    void
    placeFirstWithDeletion(net.minecraft.world.StructureWorldAccess world)
    Method to place the first Block and deleting it.
    boolean
    placeFirstWithVerification(net.minecraft.world.StructureWorldAccess world)
    Method to place the first Block.
    boolean
    placeFirstWithVerificationDeletion(net.minecraft.world.StructureWorldAccess world)
    Method to place the first Block and deleting it.
    void
    placeLast(net.minecraft.world.StructureWorldAccess world)
    Method to place the last Block of the comparator.
    void
    placeLastWithDeletion(net.minecraft.world.StructureWorldAccess world)
    Method to place the last Block of the comparator and removing it then.
    boolean
    placeLastWithVerification(net.minecraft.world.StructureWorldAccess world)
    Method to place the last Block.
    boolean
    placeLastWithVerificationDeletion(net.minecraft.world.StructureWorldAccess world)
    Method to place the last Block of the comparator and removing it then.
    void
    placeWithDeletion(net.minecraft.world.StructureWorldAccess world, int index)
    method to place the block with the deletion of the BlockPos
    boolean
    placeWithVerification(net.minecraft.world.StructureWorldAccess world, int index)
    Method to place the block related to the index.
    boolean
    placeWithVerificationDeletion(net.minecraft.world.StructureWorldAccess world, int index)
    Method to place the block with the deletion of the BlockPos The method also performs verification to know if the block can be placed.
    void
    Clears all elements from posList, posMap, and statesMap.
    net.minecraft.util.math.BlockPos
    Removes and returns the first BlockPos from the posList and posMap.
    net.minecraft.util.math.BlockPos
    Removes and returns the last BlockPos from the posList and posMap.
    net.minecraft.util.math.BlockPos
    removePos(int index)
    Removes the BlockPos at the specified index from the posList and posMap.
    void
    removePos(List<net.minecraft.util.math.BlockPos> pos)
    allow you to remove a list of BlockPos to the existing list
    void
    removePos(net.minecraft.util.math.BlockPos pos)
    allow you to remove a BlockPos to the existing list
    void
    replacePos(net.minecraft.util.math.BlockPos oldPos, net.minecraft.util.math.BlockPos newPos)
    method to replace one blockPos to another one
    void
    setBlockState(net.minecraft.block.BlockState blockState)
    change the blockState of the BlockShapeManager
    void
    setPosList(List<net.minecraft.util.math.BlockPos> posList)
    It uses a list of blockPos to allow multiple BlockPos to have a BlockState
    int
    method to get the number of BlockPos present in the related BlockList
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DefaultBlockList

      public DefaultBlockList(List<net.minecraft.util.math.BlockPos> posList, net.minecraft.block.BlockState blockState)
      init a BlockShapeManager
      Parameters:
      posList - pos of the blockState
      blockState - the blockState related to the pos list
    • DefaultBlockList

      public DefaultBlockList(net.minecraft.util.math.BlockPos pos, net.minecraft.block.BlockState state)
      init a BlockShapeManager
      Parameters:
      pos - pos of the blockState
      state - the blockState related to the pos list
  • Method Details

    • getPosList

      public List<net.minecraft.util.math.BlockPos> getPosList()
      used to get the list of blockPos related to a layer
      Specified by:
      getPosList in interface BlockListManager
      Returns:
      the list of BlockPos
    • setPosList

      public void setPosList(List<net.minecraft.util.math.BlockPos> posList)
      It uses a list of blockPos to allow multiple BlockPos to have a BlockState
      Specified by:
      setPosList in interface BlockListManager
      Parameters:
      posList - a list of BlockPos
    • addBlockPos

      public void addBlockPos(net.minecraft.util.math.BlockPos pos)
      allow you to add a BlockPos to the existing list
      Specified by:
      addBlockPos in interface BlockListManager
      Parameters:
      pos - the pos added
    • addBlockPos

      public void addBlockPos(List<net.minecraft.util.math.BlockPos> pos)
      allow you to add multiple BlockPos to the existing list
      Specified by:
      addBlockPos in interface BlockListManager
      Parameters:
      pos - the pos list added
    • removePos

      public void removePos(net.minecraft.util.math.BlockPos pos)
      allow you to remove a BlockPos to the existing list
      Specified by:
      removePos in interface BlockListManager
      Parameters:
      pos - the pos removed
    • removePos

      public void removePos(List<net.minecraft.util.math.BlockPos> pos)
      allow you to remove a list of BlockPos to the existing list
      Specified by:
      removePos in interface BlockListManager
      Parameters:
      pos - the list pos removed
    • removePos

      public net.minecraft.util.math.BlockPos removePos(int index)
      Removes the BlockPos at the specified index from the posList and posMap.
      Parameters:
      index - the index of the BlockPos to remove.
      Returns:
      the removed BlockPos.
      Throws:
      IndexOutOfBoundsException - if the index is out of range
    • removeFirstPos

      public net.minecraft.util.math.BlockPos removeFirstPos()
      Removes and returns the first BlockPos from the posList and posMap.
      Returns:
      the first BlockPos that was removed.
      Throws:
      IndexOutOfBoundsException - if the list is empty.
    • removeLastPos

      public net.minecraft.util.math.BlockPos removeLastPos()
      Removes and returns the last BlockPos from the posList and posMap.
      Specified by:
      removeLastPos in interface BlockListManager
      Returns:
      the first BlockPos that was removed.
      Throws:
      IndexOutOfBoundsException - if the list is empty.
    • removeAll

      public void removeAll()
      Clears all elements from posList, posMap, and statesMap. After this operation, all structures will be empty.
    • replacePos

      public void replacePos(net.minecraft.util.math.BlockPos oldPos, net.minecraft.util.math.BlockPos newPos)
      method to replace one blockPos to another one
      Specified by:
      replacePos in interface BlockListManager
      Parameters:
      oldPos - the oldPos that will be replaced
      newPos - the newPos that will replace the other blockPos
    • getPos

      public net.minecraft.util.math.BlockPos getPos(int index)
      method to get a certain pos from an index in the posList
      Specified by:
      getPos in interface BlockListManager
      Parameters:
      index - the index of the BlockPos
      Returns:
      the BlockPos of the index
    • getLastPos

      public net.minecraft.util.math.BlockPos getLastPos()
      method to get the last blockPos of the posList
      Specified by:
      getLastPos in interface BlockListManager
      Returns:
      the last blockPos of the posList
    • getFirstPos

      public net.minecraft.util.math.BlockPos getFirstPos()
      method to get the first blockPos of the posList
      Specified by:
      getFirstPos in interface BlockListManager
      Returns:
      the first blockPos of the posList
    • getRandomPos

      public net.minecraft.util.math.BlockPos getRandomPos()
      Method to get a random BlockPos in the posList by using a new minecraft Random
      Specified by:
      getRandomPos in interface BlockListManager
      Returns:
      a random BlockPos
    • getRandomPos

      public net.minecraft.util.math.BlockPos getRandomPos(net.minecraft.util.math.random.Random random)
      Method to get a random BlockPos in the posList based on a provided random
      Specified by:
      getRandomPos in interface BlockListManager
      Parameters:
      random - the random object that will be used to get the index
      Returns:
      a random BlockPos
    • getBlockState

      public net.minecraft.block.BlockState getBlockState()
      used to get the blockState
      Specified by:
      getBlockState in interface BlockListManager
      Returns:
      the blockState of the BlockShapeManager
    • setBlockState

      public void setBlockState(net.minecraft.block.BlockState blockState)
      change the blockState of the BlockShapeManager
      Specified by:
      setBlockState in interface BlockListManager
      Parameters:
      blockState - the blockState related to the BlockPos list
    • size

      public int size()
      method to get the number of BlockPos present in the related BlockList
      Specified by:
      size in interface BlockListManager
      Returns:
      the number of BlockPos
    • placeAll

      public void placeAll(net.minecraft.world.StructureWorldAccess worldAccess)
      Method to place all the blocks in the comparator
      Parameters:
      worldAccess - the world where the blocks will be placed
    • placeAllWithVerification

      public void placeAllWithVerification(net.minecraft.world.StructureWorldAccess worldAccess)
      Method to place all the blocks in the comparator with the BlockPos getting verified
      Parameters:
      worldAccess - the world where the blocks will be placed
    • placeAllWithDeletion

      public void placeAllWithDeletion(net.minecraft.world.StructureWorldAccess worldAccess)
      Method to place all the blocks in the comparator and removing the BlockPos
      Parameters:
      worldAccess - the world where the blocks will be placed
    • placeAllWithVerificationDeletion

      public void placeAllWithVerificationDeletion(net.minecraft.world.StructureWorldAccess worldAccess)
      Method to place all the blocks in the comparator with the BlockPos getting verified and the getting deleted
      Parameters:
      worldAccess - the world where the blocks will be placed
    • place

      public void place(net.minecraft.world.StructureWorldAccess world, int index)
      method to place the Block related to the index
      Parameters:
      world - the world the block will be placed
      index - the index of the BlockPos
    • placeWithDeletion

      public void placeWithDeletion(net.minecraft.world.StructureWorldAccess world, int index)
      method to place the block with the deletion of the BlockPos
      Parameters:
      world - the world the block will be placed
      index - the index of the block
    • placeWithVerification

      public boolean placeWithVerification(net.minecraft.world.StructureWorldAccess world, int index)
      Method to place the block related to the index. The method also performs verification to know if the block can be placed.
      Parameters:
      world - the world the block will be placed
      index - the index of the block
      Returns:
      true if the block was placed, false if not
    • placeWithVerificationDeletion

      public boolean placeWithVerificationDeletion(net.minecraft.world.StructureWorldAccess world, int index)
      Method to place the block with the deletion of the BlockPos The method also performs verification to know if the block can be placed.
      Parameters:
      world - the world the block will be placed
      index - the index of the block
      Returns:
      true if the block was placed, false if not
    • placeFirst

      public void placeFirst(net.minecraft.world.StructureWorldAccess world)
      method to place the first Block
      Parameters:
      world - the world the block will be placed
    • placeFirstWithDeletion

      public void placeFirstWithDeletion(net.minecraft.world.StructureWorldAccess world)
      Method to place the first Block and deleting it. You shouldn't use this method in normal case since that the method is pretty costly O(n). Use instead placeLastWithDeletion() that is faster O(1).
      Parameters:
      world - the world where the block will be placed
    • placeFirstWithVerification

      public boolean placeFirstWithVerification(net.minecraft.world.StructureWorldAccess world)
      Method to place the first Block.

      The method also performs verification to know if the block can be placed.

      Parameters:
      world - the world where the block will be placed
      Returns:
      true if the block was placed, false if not.
    • placeFirstWithVerificationDeletion

      public boolean placeFirstWithVerificationDeletion(net.minecraft.world.StructureWorldAccess world)

      Method to place the first Block and deleting it.

      The method also performs verification to know if the block can be placed.

      You shouldn't use this method in normal case since that the method is pretty costly O(n).

      Use instead placeLastWithDeletion() that is faster O(1).

      Parameters:
      world - the world where the block will be placed
      Returns:
      true if the block was placed, false if not.
    • placeLastWithDeletion

      public void placeLastWithDeletion(net.minecraft.world.StructureWorldAccess world)
      Method to place the last Block of the comparator and removing it then. Consider using this method because it gives you better performance.
      Parameters:
      world - the world the last block will be placed
    • placeLast

      public void placeLast(net.minecraft.world.StructureWorldAccess world)
      Method to place the last Block of the comparator.
      Parameters:
      world - the world the last block will be placed
    • placeLastWithVerification

      public boolean placeLastWithVerification(net.minecraft.world.StructureWorldAccess world)
      Method to place the last Block.
      Parameters:
      world - the world the last block will be placed The method also performs verification to know if the block can be placed.
      Returns:
      true if the block was placed, false if not
    • placeLastWithVerificationDeletion

      public boolean placeLastWithVerificationDeletion(net.minecraft.world.StructureWorldAccess world)
      Method to place the last Block of the comparator and removing it then. The method also performs verification to know if the block can be placed. Consider using this method because it gives you better performance.
      Parameters:
      world - the world the last block will be placed
      Returns:
      true if the block was placed, false if not
    • toString

      public String toString()
      Overrides:
      toString in class Object