Class StructurePlaceAnimator

java.lang.Object
net.rodofire.easierworldcreator.shapeutil.StructurePlaceAnimator

public class StructurePlaceAnimator extends Object
class to put blocks with an animation
  • Constructor Details

    • StructurePlaceAnimator

      public StructurePlaceAnimator(net.minecraft.world.StructureWorldAccess world, StructurePlaceAnimator.AnimatorType animatorType, StructurePlaceAnimator.AnimatorTime animatorTime)
      init a StructurePlaceAnimator object
      Parameters:
      world - the world the animation will take place
      animatorType - the type of the animation
      animatorTime - the time of the animation
  • Method Details

    • getRandomBlocksPerTickBound

      public net.minecraft.util.Pair<Integer,Integer> getRandomBlocksPerTickBound()
      Returns the random bounds for blocks placed per tick.
      Returns:
      a Pair representing the minimum and maximum number of blocks to be placed per tick.
    • setRandomBlocksPerTickBound

      public void setRandomBlocksPerTickBound(net.minecraft.util.Pair<Integer,Integer> randomBlocksPerTickBound)
      Sets the random bounds for blocks placed per tick.
      Parameters:
      randomBlocksPerTickBound - a Pair representing the minimum and maximum number of blocks to be placed per tick.
    • getBlocksPerTick

      public int getBlocksPerTick()
      Returns the number of blocks to place per tick.
      Returns:
      the number of blocks placed each tick.
    • setBlocksPerTick

      public void setBlocksPerTick(int blocksPerTick)
      Sets the number of blocks to place per tick.
      Parameters:
      blocksPerTick - the number of blocks placed each tick.
    • getTicks

      public int getTicks()
      Returns the current tick count.
      Returns:
      the number of ticks.
    • setTicks

      public void setTicks(int ticks)
      Sets the current tick count.
      Parameters:
      ticks - the number of ticks.
    • getCenterPoint

      public net.minecraft.util.math.BlockPos getCenterPoint()
      Returns the central point of the structure.
      Returns:
      the center point as a BlockPos object.
    • setCenterPoint

      public void setCenterPoint(net.minecraft.util.math.BlockPos centerPoint)
      Sets the central point of the structure.
      Parameters:
      centerPoint - the center point as a BlockPos object.
    • getAxisDirection

      public net.minecraft.util.math.Vec3d getAxisDirection()
      Returns the axis direction used in the animation.
      Returns:
      the axis direction as a Vec3d object.
    • setAxisDirection

      public void setAxisDirection(net.minecraft.util.math.Vec3d axisDirection)
      Sets the axis direction used in the animation.
      Parameters:
      axisDirection - the axis direction as a Vec3d object.
    • getAnimatorTime

      public StructurePlaceAnimator.AnimatorTime getAnimatorTime()
      Returns the AnimatorTime object, which manages timing for the animation.
      Returns:
      the AnimatorTime object.
    • setAnimatorTime

      public void setAnimatorTime(StructurePlaceAnimator.AnimatorTime animatorTime)
      Sets the AnimatorTime object, which manages timing for the animation.
      Parameters:
      animatorTime - the AnimatorTime object.
    • getAnimatorType

      public StructurePlaceAnimator.AnimatorType getAnimatorType()
      Returns the AnimatorType, representing the type of animation.
      Returns:
      the AnimatorType.
    • setAnimatorType

      public void setAnimatorType(StructurePlaceAnimator.AnimatorType animatorType)
      Sets the AnimatorType, representing the type of animation.
      Parameters:
      animatorType - the AnimatorType.
    • getWorld

      public net.minecraft.world.StructureWorldAccess getWorld()
      Returns the StructureWorldAccess for interacting with the world.
      Returns:
      the StructureWorldAccess object.
    • setWorld

      public void setWorld(net.minecraft.world.StructureWorldAccess world)
      Sets the StructureWorldAccess for interacting with the world.
      Parameters:
      world - the StructureWorldAccess object.
    • getAnimatorSound

      public StructurePlaceAnimator.AnimatorSound getAnimatorSound()
      Returns the AnimatorSound object, which manages sounds for the animation.
      Returns:
      the AnimatorSound object.
    • setAnimatorSound

      public void setAnimatorSound(StructurePlaceAnimator.AnimatorSound animatorSound)
      Sets the AnimatorSound object, which manages sounds for the animation.
      Parameters:
      animatorSound - the AnimatorSound object.
    • getSoundPerTicks

      public float getSoundPerTicks()
      Returns the interval of ticks between sounds during the animation.
      Returns:
      the interval as a float.
    • setSoundPerTicks

      public void setSoundPerTicks(float soundPerTicks)
      Sets the interval of ticks between sounds during the animation.
      Parameters:
      soundPerTicks - the interval as a float.
    • placeFromDividedBlockList

      public void placeFromDividedBlockList(List<Set<BlockList>> blockList)
      method to place the structure by merging and then sorting the BlockList depending on the animatorType
      Parameters:
      blockList - the list of BlockList that will be placed
    • placeFromBlockList

      public void placeFromBlockList(List<BlockList> blockList)
      method to place the structure by sorting the BlockList depending on the animatorType
      Parameters:
      blockList - the list of BlockList that will be placed
    • place

      public void place(List<net.minecraft.util.Pair<net.minecraft.block.BlockState,net.minecraft.util.math.BlockPos>> blocksToPlace)

      Method to handle animated block placement. This has some advantages :

      - Since that the placement take many ticks instead of one, it will improve user experience when placing huge structures

      - It may look better than just a structure spawning

      The method need a List<Pair<BlockState, BlockPos>> that will be used to place the blocks.

      The method calculates the number of ticks it will take to place the structure and will then place a part of the structure depending on how much blocks per ticks should be placed.

      To place them, it registers an event happening at the end of each world tick.

      Parameters:
      blocksToPlace - the List<Pair<>> that will be placed.