Class StructurePlaceAnimator

java.lang.Object
net.rodofire.easierworldcreator.shape.block.placer.animator.StructurePlaceAnimator

public class StructurePlaceAnimator extends Object
Class to put blocks with an animation. The class will place a number of blocks per seconds every tick depending on the parameters given.
The class provide some parameters like:
  • the fact that you can sort the BlockPos thanks to the BlockSorter.
  • the possibility to change the number of blocks per tick
  • the possibility to play block place sound every x ticks
You can use the animator like this:
     StructurePlaceAnimator animator = new StructurePlaceAnimator(world, blockSorter, AnimatorTime.TICKS);
 //the structure will be placed in 50 ticks no matter the size
 animator.setTicks(50);
 animator.place(blockListManager);
     
 

How to use the animator?

  • Specify if you want to play block Place Sounds
  • Specify how you want your animation to be played.
  • Constructor Details

    • StructurePlaceAnimator

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

    • getBounds

      public net.minecraft.util.Pair<Integer,Integer> getBounds()
      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.
    • setBounds

      public void setBounds(net.minecraft.util.Pair<Integer,Integer> bounds)
      Parameters:
      bounds - the pair. See more details on StructurePlaceAnimator.AnimatorTime
    • 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.
    • 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 BlockSorter getAnimatorType()
      Returns the AnimatorType, representing the type of animation.
      Returns:
      the AnimatorType.
    • setAnimatorType

      public void setAnimatorType(BlockSorter blockSorter)
      Sets the AnimatorType, representing the type of animation.
      Parameters:
      blockSorter - 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

      @Deprecated(forRemoval=true) public void placeFromDividedBlockList(List<Set<BlockList>> blockList)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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
    • place

      public void place(BlockListManager manager)
      method to place the structure by sorting the BlockList depending on the animatorType
      Parameters:
      manager - the manager that will be placed
    • place

      public void place(OrderedBlockListManager manager)

      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 OrderedBlockListManager 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:
      manager - the OrderedBlockListManager that will be placed.