Class StructurePlaceAnimator
java.lang.Object
net.rodofire.easierworldcreator.placer.blocks.animator.StructurePlaceAnimator
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 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
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(blockListComparator);
How to use the animator?
- Specify if you want to play block Place Sounds
- Specify how you want your animation to be played.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumenum to decide how to play soundsstatic enumenum to determine how much time the structure will be placed. -
Constructor Summary
ConstructorsConstructorDescriptionStructurePlaceAnimator(net.minecraft.world.StructureWorldAccess world, BlockSorter blockSorter, StructurePlaceAnimator.AnimatorTime animatorTime) init aStructurePlaceAnimatorobject -
Method Summary
Modifier and TypeMethodDescriptionReturns the AnimatorSound object, which manages sounds for the animation.Returns the AnimatorTime object, which manages timing for the animation.Returns the AnimatorType, representing the type of animation.intReturns the number of blocks to place per tick.Returns the random bounds for blocks placed per tick.floatReturns the interval of ticks between sounds during the animation.intgetTicks()Returns the current tick count.net.minecraft.world.StructureWorldAccessgetWorld()Returns the StructureWorldAccess for interacting with the world.<T extends AbstractOrderedBlockListComparator<U>,U>
voidplace(T comparator) Method to handle animated block placement.<T extends AbstractBlockListComparator<U,V, W, X>, U extends DefaultBlockList, V, W extends AbstractOrderedBlockListComparator<X>, X>
voidplaceFromBlockList(T comparator) method to place the structure by sorting the BlockList depending on theanimatorTypevoidplaceFromDividedBlockList(List<Set<DefaultBlockList>> blockList) Deprecated, for removal: This API element is subject to removal in a future version.voidsetAnimatorSound(StructurePlaceAnimator.AnimatorSound animatorSound) Sets the AnimatorSound object, which manages sounds for the animation.voidsetAnimatorTime(StructurePlaceAnimator.AnimatorTime animatorTime) Sets the AnimatorTime object, which manages timing for the animation.voidsetAnimatorType(BlockSorter blockSorter) Sets the AnimatorType, representing the type of animation.voidsetBlocksPerTick(int blocksPerTick) Sets the number of blocks to place per tick.voidSets the bounds forStructurePlaceAnimator.AnimatorTimevoidsetSoundPerTicks(float soundPerTicks) Sets the interval of ticks between sounds during the animation.voidsetTicks(int ticks) Sets the current tick count.voidsetWorld(net.minecraft.world.StructureWorldAccess world) Sets the StructureWorldAccess for interacting with the world.
-
Constructor Details
-
StructurePlaceAnimator
public StructurePlaceAnimator(net.minecraft.world.StructureWorldAccess world, BlockSorter blockSorter, StructurePlaceAnimator.AnimatorTime animatorTime) init aStructurePlaceAnimatorobject- Parameters:
world- the world the animation will take placeblockSorter- the type of the animationanimatorTime- the time of the animation
-
-
Method Details
-
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
Sets the bounds forStructurePlaceAnimator.AnimatorTime- Parameters:
bounds- the pair. See more details onStructurePlaceAnimator.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
Returns the AnimatorTime object, which manages timing for the animation.- Returns:
- the AnimatorTime object.
-
setAnimatorTime
Sets the AnimatorTime object, which manages timing for the animation.- Parameters:
animatorTime- the AnimatorTime object.
-
getAnimatorType
Returns the AnimatorType, representing the type of animation.- Returns:
- the AnimatorType.
-
setAnimatorType
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
Returns the AnimatorSound object, which manages sounds for the animation.- Returns:
- the AnimatorSound object.
-
setAnimatorSound
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<DefaultBlockList>> 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 theanimatorType- Parameters:
blockList- the list of BlockList that will be placed
-
placeFromBlockList
public <T extends AbstractBlockListComparator<U,V, void placeFromBlockListW, X>, U extends DefaultBlockList, V, W extends AbstractOrderedBlockListComparator<X>, X> (T comparator) method to place the structure by sorting the BlockList depending on theanimatorType- Parameters:
comparator- the comparator that will be placed
-
place
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:
comparator- theList<Pair<>>that will be placed.
-