Repository navigation
Playback API
All public server/common API types live in com.kltyton.interactiveanimation.api (with GeckoLib helpers in com.kltyton.interactiveanimation.compat.geckolib).
Entry point for registering packaged scene files and starting server-authoritative scenes.
InteractiveScenes.register(Class<?> resourceOwner, String animationFile);
SceneHandle InteractiveScenes.play(SceneSubject subject, SceneId scene, Object... participants);
SceneHandle InteractiveScenes.play(SceneSubject subject, SceneId scene, Bindings bindings, PlaybackOptions options);-
animationFilemust be a valid resource path ending in.json, e.g."mymod:animations/duel.animation.json". - The client reads the same resource path automatically during resource reload.
Identifies one scene inside an animation file:
var id = new SceneId("mymod:animations/duel.animation.json", "animation.duel.clash");A SceneSubject supplies the spatial origin (Frame(position, yaw)), validity predicate, optional backing Entity, and optional primary animation controller callbacks (play / stop / transitionTicks).
SceneSubject.entity(Entity entity)
SceneSubject.block(BlockEntity block, float yaw)
SceneSubject.item(ItemStack stack, Entity holder)Attach an existing animation controller via playback(...):
SceneSubject subject = SceneSubject.entity(boss)
.playback(transitionTicks, () -> startNativeAnim(), () -> stopNativeAnim());For custom moving origins (such as scripted vehicle trajectories), construct new SceneSubject(level, frameSupplier, validSupplier, entity, transitionTicks, nativePlayback, play, stop) directly.
// Entity (GeckoLib 4 & 5)
GeckoSubjects.entity(geoEntity, "controllerName", "triggerName", serverTransitionTicks);
// Entity with controller reference (GeckoLib 5)
GeckoSubjects.entity(geoEntity, controller, "triggerName");
// BlockEntity & ItemStack
GeckoSubjects.block(geoBlockEntity, yaw, "controllerName", "triggerName", transitionTicks);
GeckoSubjects.item(stack, holder, instanceId, "controllerName", "triggerName", transitionTicks);Maps runtime objects (Entity, ItemStack, or BlockState) to participant roles and optional bone remapping tables.
Bindings.defaults() // Use default preview assets only
Bindings.ordered(entityA, entityB) // Bind in JSON participants array order
Bindings.named(Map.of("rider", player)) // Bind explicitly by role nameRemap authored bone names in the JSON to target model bone names without editing the animation asset:
var bindings = Bindings.named(Map.of("hero", player))
.mapBones("hero", Map.of("torso", "body"));Direction: authored bone name → actual model bone name.
Immutable configuration record starting from PlaybackOptions.DEFAULT:
| Option / Builder | Default | Description |
|---|---|---|
alignment(snap, checkPath, tolerance, handler) |
snap=true, checkPath=false, tolerance=0.0625
|
Controls initial alignment, optional approach path sweep, tolerance (blocks), and Consumer<AlignmentResult> callback. |
controls(lockDriven, subjectAi, attack, interaction) |
lockDriven=true, others false
|
Locks movement/AI of driven participants, optionally pauses subject AI, attacks, or interactions. |
camera(CameraMode) |
CameraMode.AUTO |
AUTO, VANILLA, FOLLOW, or LOCKED. |
carrier(Entity) |
null |
Optional carrier entity whose motion the scene follows. |
markers(Consumer<Marker>) |
no-op | Receives Marker(playback, instruction, seconds) callbacks from the primary animation's timeline. |
sounds(Consumer<SoundKeyframe>) |
Auto-play (!nativePlayback or participant role) |
Custom handler for SoundKeyframe(playback, role, effect, locator, seconds, position) (pass ignored -> {} to mute auto-play). |
particles(Consumer<ParticleKeyframe>) |
Auto-play (!nativePlayback or participant role) |
Custom handler for ParticleKeyframe(playback, role, effect, locator, script, seconds, position). |
Utility helpers to reuse AnimCue's built-in registry lookup and playback inside custom .sounds(...) or .particles(...) callbacks:
SceneEffects.playSound(level, soundKeyframe);
SceneEffects.playSound(level, sourceEntity, position, "minecraft:block.anvil.land", 1.0F, 1.0F);
SceneEffects.spawnParticle(level, particleKeyframe);
SceneEffects.spawnParticle(level, position, "minecraft:crit");
SceneEffects.spawnParticle(level, position, "mymod:custom_kbr_fx", "v.size=0.75;");
SceneEffects.spawnParticle(level, sourceEntity, position, "mymod:custom_kbr_fx", "v.size=0.75;");Unknown/invalid IDs and parameterized particles (not implementing ParticleOptions) safely return false without throwing; when keyframe.playback() is null, playSound(level, keyframe) skips entity binding lookup and plays at keyframe.position() using SoundSource.NEUTRAL.
When Kltyton Bedrock Runtime (kltyton_bedrock_runtime, Lite or full) is installed alongside AnimCue, SceneEffects.spawnParticle (and the default particle keyframe path on participant tracks and non-native nativePlayback = false primary tracks) automatically falls back to KBR's particle_definitions/*.json billboard and 3D model particles when the particle ID is not a registered vanilla/mod ParticleType, passing the optional script MoLang initialization expression cleanly. On clients with SimpleBedrockModel 2.6.0+ installed (when neither vanilla ParticleType nor KBR handles the particle), SceneEffects.spawnParticle also falls back to SBM's client-local ParticleDefinitionLoader / WorldEmitterManager. Without KBR/SBM installed, vanilla particles still work identically and unknown/parameterized IDs safely return false.
For downstream renderers using SimpleBedrockModel (v1 / v2) on deferred draw queues, SbmScenes.available() and SbmScenes.apply(ClientActor, Object) provide a classloading-safe one-line compose/restore helper.
record AlignmentResult(String role, Status status, Vec3 initial, Vec3 target, Vec3 reached)Status values: ALIGNED, MISALIGNED, BLOCKED, CANCELLED. Helper methods: aligned(), initialOffset(), remainingOffset().
Returned by InteractiveScenes.play(...) and ClientScenes.playLocal(...):
-
State state()—APPROACHING,PLAYING,FINISHED, orCANCELLED. -
Map<String, AlignmentResult> alignmentResults()— Alignment outcome per participant role. -
Object binding(String role)— Bound live instance for a role. -
void cancel()— Stops the scene immediately and releases all control leases. -
void useWorldCoordinates(String role)— Detaches a participant from subject-relative coordinates into world space (useful for throws/releases triggered from atimelinemarker). -
void follow(String role, Entity carrier)— Switches a participant to follow a specific carrier entity. -
SceneId sceneId()— Returns the currently active scene ID (updated seamlessly after runtime branches). -
void setWarpTarget(String anchorId, MotionWarp.Target target)— Updates a Motion Warping target pose dynamically at runtime. -
void setAnchorProvider(String anchorId, TargetAnchor.Provider provider)— Supplies a custom runtime anchor resolver. -
void branchTo(SceneId target, SceneBranch.Transition transition)— Switches seamlessly to another scene on the same session UUID without releasing control leases, crossfading overblendSeconds. -
void detachRole(String role)— Releases a single non-critical role while letting remaining participants continue.
| Builder Method | Description |
|---|---|
recovery(SceneRecovery.Policy[, Consumer<SceneRecovery.Event>]) |
Configures recovery for death, disconnect, chunk unload, external teleport, dimension change, and client stale-session timeout (including safe non-suffocating position restore and optional role detachment). |
blend(SceneBlend.Config) |
Overrides blend-in / blend-out durations, curves, and TAIL_FADE vs POST_RELEASE mode. |
anchor(String id, TargetAnchor.Provider) / warpTarget(String id, MotionWarp.Target)
|
Binds runtime target anchors for Motion Warping and IK. |
warp(String role, MotionWarp.Window) / ik(String role, IkConstraint.Spec)
|
Adds programmatic Motion Warping windows or IK constraints for a role. |
branchCondition(String key, Predicate<SceneBranch.Context>) / onBranch(...) / branchSubject(...)
|
Registers declarative branch predicates, branch listeners, and native primary controller switchers. |
latencyCompensation(double scale) |
Tunes multiplayer RTT latency compensation scale (default 1.0, range [0.0, 1.5]). |
layer(SceneLayer.Config) |
Configures bone-level ownership (BoneMask) and concurrent multi-scene composition (OVERRIDE, MASKED_BLEND, ADDITIVE) synced over the network (0.4.1+). |
worldMotion(WorldMotionCorrector.Policy) |
Enables VoxelShape consecutive stair/slab step-up, ceiling clearance clamping, lava hazard avoidance, water buoyancy, cliff-drop protection, and bystander push-out (0.4.1+). |
clockMode(TickRateClock.Mode) |
Selects GAME_TICK, TICK_RATE_AWARE (/tick rate, /tick freeze, /tick step), or LOW_TPS_COMPENSATED playback timing (0.4.1+). |
planner(ScenePlanner.Plan) |
Enables mid-scene obstacle/hazard path detouring and automatic candidate scene replanning (0.4.1+). |
-
Atomic Transactions & Authoritative Events:
InteractiveScenes.tryPlay(...)returns aSceneTransaction.Receiptwith zero leaked leases on rollback;SceneEvents.subscribe(...)observes ordered server lifecycle and idempotent keyframe events (AuthoritativeEventLedger). -
Pose Rewind & Dynamic Participants:
SceneHandle.sampleRewoundPose(role, rewindSeconds)queries finite-horizon server history;SceneHandle.addParticipant(role, binding)binds/reattaches participants mid-scene. -
Composite Scenes & Hot Reload:
InteractiveScenes.playComposite(...)runsSceneComposition.sequence(...),parallel(...), ornested(...)graphs;InteractiveScenes.reload(owner, file)migrates compatible running scenes live. -
Lock-Free Render Snapshots, Diagnostics & Capabilities:
ClientScenes.snapshot(entityId)reads composed immutableRenderPoseSnapshots;InteractiveScenes.diagnostics()reports runtime metrics;SceneCapabilities&ExternalPoseBridgeRegistryprovide zero-reflection cross-library SPIs.
Reference-counted control leases attached to live entities (ai, movement, attacks, interaction). Multiple overlapping scenes combine cleanly and restore original state only when the last lease closes.
Mods with custom entity AI/controllers can integrate via AnimationControls.register:
AnimationControls.register(MyModEntities.CUSTOM_BOSS.get(), (entity, controls) -> {
var boss = (CustomBossEntity) entity;
if (controls.ai()) boss.setScriptPaused(true);
return () -> {
if (controls.ai()) boss.setScriptPaused(false);
};
});-
Dynamic Scene Matching (
SceneMatcher/InteractiveScenes.playMatched): Automatically filters and scores candidate scenes (or registered JSONmatchblocks viaSceneMatcher.fromRegisteredAssets(...)) using relative sector, distance, target proportions, and 3D terrain features. -
Priority Preemption, Smart Relocation & 3D Terrain (
PlaybackOptions): Configure.priority(ScenePriority.Config.preemptLower(ScenePriority.FINISHER))for safe conflict preemption,.smartRelocate(SpatialPlacementSolver.Options.DEFAULT)for automatic wall-avoiding yaw/offset placement, and.groundSnap(true)for VoxelShape step-up and ground snapping. -
Zero-Latency Client Prediction & Rollback: Start locally with
ClientScenes.predictLocal(...)and pass the resultingpredictionIdtoPlaybackOptions.prediction(predictionId)for seamless server promotion, or callInteractiveScenes.rejectPrediction(player, predictionId)to trigger smooth rollback. -
State Machine, Dynamic Roles & Virtual Props (
SceneHandle): SupportsreplaceRole,spawnProp,transferProp,releaseProp,pushInterruptState, andcurrentStateName; clients report QTE inputs viaClientScenes.reportInput(key, action). -
Universal Sockets & Zero-Reflection Ecosystem SPIs: Register entity/item/block 6DoF sockets in
SocketRegistry, combat adapters inCombatBridgeRegistry, and moving coordinate frames inWorldFrameRegistry(with built-in mod-guarded soft bridges for Epic Fight, Better Combat, TaCZ, Valkyrien Skies 2, Create, and Superb Warfare).