Interface IAnimatedBlockContainer

All Known Implementing Classes:
AnimatedBlockContainer, AnimatedPreviewBlockContainer

public interface IAnimatedBlockContainer
Represents a manager for animated blocks.

It is responsible for the creation and cleanup of animated blocks.

The most common example will be a manager that replaces existing blocks with animated blocks and places them in the new location after the animation ends.

  • Method Details

    • createAnimatedBlocks

      boolean createAnimatedBlocks(StructureSnapshot snapshot, IAnimationComponent animationComponent)
      Attempts to create and spawn the animated blocks for the given input.
      Parameters:
      snapshot - The snapshot of the structure to create the animated blocks for.
      animationComponent - The animation component to use for retrieving additional information for the animated blocks.
      Returns:
      The result of the attempted creation of the animated blocks.
    • getAnimatedBlocks

      List<IAnimatedBlock> getAnimatedBlocks()
      Returns:
      All the animated blocks that are part of the animation. In case an error occurred during the creation, this will contain all the animated blocks that have been created up to the point that the problem occurred.
    • getAnimationRegion

      @Nullable @Nullable AnimationRegion getAnimationRegion()
      Getter for the animation region.
      Returns:
      The animation region.
    • spawnAnimatedBlocks

      void spawnAnimatedBlocks() throws Exception
      Tries to replace the original blocks with the animated blocks in the world.

      This method also handles the removal of the original blocks.

      Throws:
      Exception - If something went wrong and the process had to be aborted.
    • removeOriginalBlocks

      void removeOriginalBlocks() throws Exception
      Removes the original blocks from the world.

      This method does not have to be called when spawning the animated blocks using spawnAnimatedBlocks().

      Throws:
      Exception - If something went wrong while removing the original blocks.
    • restoreBlocksOnFailure

      void restoreBlocksOnFailure()
      Restores all spawned animated blocks to their original positions.

      Should be used in case something failed.

    • handleAnimationCompletion

      void handleAnimationCompletion()
      Handles the blocks when the animation is completed.

      For the most common use-case, this means that the animated blocks will be killed and the blocks they represented will be placed in their final positions.