AzureLib

Adding Effect Keyframes

How to add Effect Keyframes to animations

In your Animation tab of Blockbench, select the animation you wish to add the keyframe to.

AnimationSelection

Now go to the timeline of the animation and click Animate Effects

AnimationEffects

This will open the effects tray, allowing you set the time you want a Particle, Sound, or Custom Instructions keyframe to be triggered at during the animation. All that needs set here is the Effect field for Particles and Sounds to set that keyframes name to be you will register in code for the sound, particle, or instruction.

SettingKeyframe

How to register Effect Keyframes

In your registerControllers method found in your class that extends the various AzAnimators provided (Entity, BlockEntity, and Item are default options)

Sound Keyframes

Example:

@Override
public void registerControllers(AzAnimationControllerContainer<Entity> animationControllerContainer) {
animationControllerContainer.add(
AzAnimationController.builder(this, "base_controller")
.setKeyframeCallbacks(
AzKeyframeCallbacks.<Entity>builder()
.setSoundKeyframeHandler(
event -> {
if (event.getKeyframeData().getSound().equals("walk")) {
event.getAnimatable()
.level()
.playLocalSound(
event.getAnimatable().getX(),
event.getAnimatable().getY(),
event.getAnimatable().getZ(),
SoundEvents.METAL_STEP,
SoundSource.HOSTILE,
1.0F, // volume
1.0F, // pitch
true // Should have distance delay
);
}
}
)
.build()
)
.build()
);
}

Particle Keyframes

Example:

@Override
public void registerControllers(AzAnimationControllerContainer<Entity> animationControllerContainer) {
animationControllerContainer.add(
AzAnimationController.builder(this, "base_controller")
.setKeyframeCallbacks(
AzKeyframeCallbacks.<Entity>builder()
.setParticleKeyframeHandler(
event -> {
if (event.getKeyframeData().getEffect().equals("walk")) {
event.getAnimatable()
.level()
.addParticle(
ParticleTypes.BUBBLE,
false, // boolean if particle should always render or not
event.getAnimatable().getX(),
event.getAnimatable().getY(),
event.getAnimatable().getZ(),
0, // x axis speed
0, // y axis speed
0 // z axis speed
);
}
}
)
.build()
)
.build()
);
}

Custom Instruction Keyframes

Example:

@Override
public void registerControllers(AzAnimationControllerContainer<Entity> animationControllerContainer) {
animationControllerContainer.add(
AzAnimationController.builder(this, "base_controller")
.setKeyframeCallbacks(
AzKeyframeCallbacks.<Entity>builder()
.setCustomInstructionKeyframeHandler(
event -> {
if (event.getKeyframeData().getInstructions().equals("walk")) {
// Do your custom instructions here
}
}
)
.build()
)
.build()
);
}