- Description
- Field Summary
- Constructor Summary
- Method Summary
- Field Details
- Constructor Details
- Method Details
- get()
- setBlockAnimationSpeed(World, int, int, int, float)
- setBlockAnimationSpeed(World, int, int, int, float, float)
- setBlockAnimationPhase(World, int, int, int, float)
- clearBlockAnimationSpeed(World, int, int, int)
- getBlockAnimationSpeedOverride(World, int, int, int)
- getBlockAnimationSectionComponentType()
- getDirtySectionsResourceType()
- canBlockAnimate(World, int, int, int)
- onBlockReplaced(ComponentAccessor, Ref, int, int, int)
Class BlockAnimationModule
- All Implemented Interfaces:
CommandOwner
-
Field Summary
FieldsFields inherited from class PluginBase
METRICS_REGISTRY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanBlockAnimate(World world, int x, int y, int z) Tests whether a block can show a model animation.booleanclearBlockAnimationSpeed(World world, int x, int y, int z) Clears the model animation speed for a loaded block.static BlockAnimationModuleget()getBlockAnimationSpeedOverride(World world, int x, int y, int z) Gets the model animation speed override for a loaded block.static voidonBlockReplaced(ComponentAccessor<ChunkStore> accessor, Ref<ChunkStore> sectionRef, int index, int oldBlockId, int newBlockId) Drops the override of a cell whose block was replaced.booleansetBlockAnimationPhase(World world, int x, int y, int z, float phase) Sets the animation phase for a loaded block with a speed override.booleansetBlockAnimationSpeed(World world, int x, int y, int z, float speed) Sets the model animation speed for a loaded block.booleansetBlockAnimationSpeed(World world, int x, int y, int z, float speed, float phase) Sets the model animation speed and phase for a loaded block.Methods inherited from class JavaPlugin
getClassLoader, getFile, getTypeMethods inherited from class PluginBase
getAssetRegistry, getBasePermission, getChunkStoreRegistry, getClientFeatureRegistry, getCodecRegistry, getCodecRegistry, getCodecRegistry, getCommandRegistry, getDataDirectory, getEntityRegistry, getEntityStoreRegistry, getEventRegistry, getIdentifier, getLogger, getManifest, getName, getState, getTaskRegistry, isDisabled, isEnabled, preLoad
-
Field Details
-
MAX_SPEED
public static final float MAX_SPEED- See Also:
-
MANIFEST
-
-
Constructor Details
-
BlockAnimationModule
-
-
Method Details
-
get
-
setBlockAnimationSpeed
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:
trueif 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:
trueif the override and phase are valid and accepted.
-
setBlockAnimationPhase
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:
trueif an override exists and the phase is accepted.
-
clearBlockAnimationSpeed
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:
trueif 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
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:
trueif 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.
-