Class BlockAnimationModule

java.lang.Object
com.hypixel.hytale.server.core.plugin.PluginBase
com.hypixel.hytale.server.core.plugin.JavaPlugin
com.hypixel.hytale.server.core.modules.blockanimation.BlockAnimationModule
All Implemented Interfaces:
CommandOwner

public class BlockAnimationModule extends JavaPlugin
Provides runtime model animation controls for blocks.
  • Field Details

  • Constructor Details

    • BlockAnimationModule

      public BlockAnimationModule(@Nonnull JavaPluginInit init)
  • Method Details

    • get

      @Nonnull public static BlockAnimationModule get()
    • setBlockAnimationSpeed

      public boolean setBlockAnimationSpeed(@Nonnull World world, int x, int y, int z, float speed)
      Sets the model animation speed for a loaded block.

      The speed range is [0, 100). A speed of 0 pauses the animation.

      Call this method on the world thread. The method returns false if the section is not loaded.

      The first call for a section must occur outside store write processing.

      Parameters:
      world - The world that contains the block.
      x - The block X coordinate.
      y - The block Y coordinate.
      z - The block Z coordinate.
      speed - The animation speed multiplier.
      Returns:
      true if the override is valid and accepted.
    • setBlockAnimationSpeed

      public boolean setBlockAnimationSpeed(@Nonnull World world, int x, int y, int z, float speed, float phase)
      Sets the model animation speed and phase for a loaded block.

      The speed range is [0, 100). A speed of 0 pauses the animation.

      The phase uses animation frames. Block animations use 60 frames per second.

      Phase delivery is best effort. Reapply the phase when strict alignment is required.

      Call this method on the world thread. The method returns false if the section is not loaded.

      The first call for a section must occur outside store write processing.

      Parameters:
      world - The world that contains the block.
      x - The block X coordinate.
      y - The block Y coordinate.
      z - The block Z coordinate.
      speed - The animation speed multiplier.
      phase - The animation phase in frames.
      Returns:
      true if the override and phase are valid and accepted.
    • setBlockAnimationPhase

      public boolean setBlockAnimationPhase(@Nonnull World world, int x, int y, int z, float phase)
      Sets the animation phase for a loaded block with a speed override.

      The phase uses animation frames. Block animations use 60 frames per second.

      Phase delivery is best effort. Reapply the phase when strict alignment is required.

      Call this method on the world thread. The method returns false if the section is not loaded.

      Parameters:
      world - The world that contains the block.
      x - The block X coordinate.
      y - The block Y coordinate.
      z - The block Z coordinate.
      phase - The animation phase in frames.
      Returns:
      true if an override exists and the phase is accepted.
    • clearBlockAnimationSpeed

      public boolean clearBlockAnimationSpeed(@Nonnull World world, int x, int y, int z)
      Clears the model animation speed for a loaded block.

      The asset animation speed applies after a successful clear.

      Call this method on the world thread. The method returns false if the section is not loaded.

      Parameters:
      world - The world that contains the block.
      x - The block X coordinate.
      y - The block Y coordinate.
      z - The block Z coordinate.
      Returns:
      true if an override existed and was removed.
    • getBlockAnimationSpeedOverride

      @Nonnull public OptionalDouble getBlockAnimationSpeedOverride(@Nonnull World world, int x, int y, int z)
      Gets the model animation speed override for a loaded block.

      An empty result means that the asset animation speed applies.

      Call this method on the world thread. An unloaded section returns an empty result.

      Parameters:
      world - The world that contains the block.
      x - The block X coordinate.
      y - The block Y coordinate.
      z - The block Z coordinate.
      Returns:
      The speed override, or an empty result when no override exists.
    • getBlockAnimationSectionComponentType

      @Nonnull public ComponentType<ChunkStore, BlockAnimationSection> getBlockAnimationSectionComponentType()
    • getDirtySectionsResourceType

      @Nonnull public ResourceType<ChunkStore, BlockAnimationDirtySections> getDirtySectionsResourceType()
    • canBlockAnimate

      public boolean canBlockAnimate(@Nonnull World world, int x, int y, int z)
      Tests whether a block can show a model animation. A block shows an animation when the block itself defines one, or when any other state of that block defines one.

      Call this method on the world thread.

      Parameters:
      world - The world that contains the block.
      x - The block X coordinate.
      y - The block Y coordinate.
      z - The block Z coordinate.
      Returns:
      true if the block or one of its states defines a model animation.
    • onBlockReplaced

      public static void onBlockReplaced(@Nonnull ComponentAccessor<ChunkStore> accessor, @Nonnull Ref<ChunkStore> sectionRef, int index, int oldBlockId, int newBlockId)
      Drops the override of a cell whose block was replaced.

      A block that changes to another of its own states keeps its override, so a workstation that cycles between an idle state and a working state keeps the speed that a mod gave it.

      Parameters:
      accessor - The chunk store accessor that holds the section.
      sectionRef - The section that contains the cell.
      index - The cell index inside the section.
      oldBlockId - The block that occupied the cell.
      newBlockId - The block that occupies the cell now.