Repository navigation
Playback API
kltyton edited this page Dec 1, 2026
·
1 revision
Language: English | 中文
PlayerAnimationLibraryMoreRotation provides a reusable server-to-client playback layer so downstream mods never need to duplicate custom payloads, dimension broadcasters, fade modifiers, or mirror transforms.
import com.kltyton.playeranimationlibrarymorerotation.PalMoreAnimations;
import com.kltyton.playeranimationlibrarymorerotation.PalMoreFirstPersonOptions;
import com.kltyton.playeranimationlibrarymorerotation.PalMorePlayOptions;
import net.minecraft.resources.Identifier; // ResourceLocation on 1.20.1 / 1.21.1
import net.minecraft.server.level.ServerPlayer;
Identifier animation = Identifier.fromNamespaceAndPath("example", "slash");
// Basic play / stop (broadcasts to all same-dimension supporting clients)
PalMoreAnimations.play(serverPlayer, animation);
PalMoreAnimations.stop(serverPlayer);
// Convenience overload: fadeInTicks=2, fadeOutTicks=4, mirrored=true
PalMoreAnimations.play(serverPlayer, animation, 2.0F, 4.0F, true);
// Smooth fade-out stop
PalMoreAnimations.stop(serverPlayer, 4.0F);
// Full options builder
PalMorePlayOptions options = PalMorePlayOptions.builder()
.fadeInTicks(2.0F)
.fadeOutTicks(4.0F)
.mirrored(true)
.firstPersonOptions(PalMoreFirstPersonOptions.SHOW_ARMS_AND_ITEMS)
.quaternionBlend(true) // true = SLERP (default), false = linear Euler blend
.build();
PalMoreAnimations.play(serverPlayer, animation, options);Call only from physical client code:
import com.kltyton.playeranimationlibrarymorerotation.client.PalMoreClientAnimations;
PalMoreClientAnimations.playLocal(avatar, animation);
PalMoreClientAnimations.playLocal(avatar, animation, options);
PalMoreClientAnimations.stopLocal(avatar, 4.0F);
boolean mirrored = PalMoreClientAnimations.isMirrored(avatar);On 1.20.1 and 1.21.1, the entity parameter is AbstractClientPlayer (on 26.x, Avatar).
Attach controller-local handlers for PAL's timeline, sound_effects, and particle_effects keyframes:
import com.kltyton.playeranimationlibrarymorerotation.PalMoreAnimationController;
import com.kltyton.playeranimationlibrarymorerotation.client.PalMoreClientAnimations;
public static final Identifier ATTACK_CONTROLLER =
Identifier.fromNamespaceAndPath("example", "attack_controller");
public static final PalMoreAnimationController ATTACK_PLAYBACK =
PalMoreAnimationController.create(ATTACK_CONTROLLER)
.setCustomInstructionKeyframeHandler(s -> {
if ("runAttack;".equals(s.instructions().replaceAll("\\s+", ""))) {
// Client-side visual effect
}
})
.setParticleKeyframeHandler(s -> {
String effect = s.effect();
String locator = s.locator();
String script = s.script();
})
.setSoundKeyframeHandler(s -> {
String sound = s.sound();
});
// Register once on client startup:
PalMoreClientAnimations.registerController(ATTACK_PLAYBACK);
// Trigger from server with the same controller ID:
PalMoreAnimations.play(serverPlayer, animation, ATTACK_CONTROLLER, options);Only the controller ID is sent over the network; handler lambdas are resolved locally on each client.
Clientbound payload ID: playeranimationlibrarymorerotation:player_animation
| Field | Wire Type | Description |
|---|---|---|
avatarEntityId |
VarInt |
Target player entity ID within the viewer's current dimension |
animationId |
Identifier / ResourceLocation
|
Animation key under assets/<ns>/player_animations/
|
stop |
Boolean |
true to stop playback, false to play |
controllerId |
Identifier / ResourceLocation
|
Named controller ID (empty/default if omitted) |
fadeInTicks |
Float |
Smooth fade-in / interruption blend duration in ticks |
fadeOutTicks |
Float |
Smooth fade-out duration in ticks |
mirrored |
Boolean |
Left/right hand & limb mirror toggle |
firstPersonMask |
Byte |
Synced PalMoreFirstPersonOptions bitmask |
quaternionBlend |
Boolean |
true for quaternion SLERP blending, false for Euler interpolation |
Downstream mods do not need to register this payload or its client receiver.