Class Cutscene

java.lang.Object
net.ixdarklord.coolcatcanvas.api.cutscene.Cutscene

public final class Cutscene extends Object
A cutscene: a camera flown along keyframes while the player watches, with letterbox bars, fades, subtitles and markers in time with it. It is plain data, the same on both sides: built in code, read from assets/<namespace>/cutscene/<path>.json, made in the in-game editor, or sent by the server.
Cutscene intro = Cutscene.builder()
        .keyframe(0, new Vec3(10, 80, 10), 135, 20)
        .keyframe(100, new Vec3(-4, 72, 30), 200, 5).easing(Easing.SINE_IN_OUT).fov(45)
        .keyframe(160, new Vec3(-6, 70, 42), 180, 0)
        .letterbox()
        .fadeIn(15).fadeOut(15)
        .subtitle(20, 70, Component.literal("Long ago..."))
        .marker(100, MyMod.id("thunder"))
        .build();
Times are ticks from the start; fractions are allowed. On the client, Cutscenes registers and plays them; on the server, CutsceneControl plays them for a player.

The camera only shows what the client has loaded: chunks around the player, not around the camera. Keep a path within the player's view distance of where they stand.

  • Field Details

    • CINEMATIC_ASPECT

      public static final float CINEMATIC_ASPECT
      The widescreen cinema ratio the letterbox bars frame by default.
      See Also:
    • CODEC

      public static final com.mojang.serialization.Codec<Cutscene> CODEC
  • Method Details

    • builder

      public static Cutscene.Builder builder()
    • toBuilder

      public Cutscene.Builder toBuilder()
      A builder holding everything this cutscene has, to make a changed copy.
    • keyframes

      public List<CameraKeyframe> keyframes()
      The keyframes, in time order.
    • duration

      public float duration()
      How long it lasts, in ticks.
    • anchor

      public CutsceneAnchor anchor()
    • letterbox

      public float letterbox()
      The aspect ratio (width over height) the letterbox bars frame, or 0 for no bars.
    • fade

      public ValueTrack fade()
      How dark the screen is over time, 0 to 1; empty for no fades.
    • fadeColor

      public int fadeColor()
      The colour faded to, as 0xRRGGBB.
    • focuses

      public List<CameraFocus> focuses()
    • subtitles

      public List<Cutscene.Subtitle> subtitles()
    • markers

      public List<Cutscene.Marker> markers()
      The markers, in time order.
    • blendIn

      public float blendIn()
      Over how many ticks the view glides from the player's own into the first keyframe; 0 cuts.
    • blendOut

      public float blendOut()
      Over how many ticks the view glides back to the player's own at the end; 0 cuts.
    • hideHud

      public boolean hideHud()
    • lockInput

      public boolean lockInput()
      Whether the player can't move, look or act while it plays.
    • skippable

      public boolean skippable()
    • editable

      public boolean editable()
      Whether the in-game editor may open it. A cutscene that isn't editable is left out of the editor's list, so players can't load a copy of it to change or reuse. It plays the same either way.
    • isPortable

      public boolean isPortable()
      Whether it can be written to a file or sent to a client: every easing it uses has a name in Easings. Cutscenes built with lambdas or reversed() curves only play where they were built.
    • barsAt

      public float barsAt(float time)
      How far the letterbox bars are in at a time, 0 to 1. Without a track of its own, a letterboxed cutscene slides its bars in over its first ticks and out over its last.
    • fadeAt

      public float fadeAt(float time)
      How dark the fade is at a time, 0 to 1.
    • poseAt

      public CameraPose poseAt(float time)
      The camera at a time, in the cutscene's own space, taking 70 for a keyframe without a field of view.
    • poseAt

      public CameraPose poseAt(float time, float playerFov)
      The camera at a time, in the cutscene's own space, before any CameraFocus turns it.
      Parameters:
      playerFov - the field of view keyframes without one of their own take