Interface PathLike

All Known Implementing Classes:
BezierCurve, CalculatedPoint, CatmullRomSpline, ConstantPoint, LineSegment, LookAtPoint, Path, PathTransition

public interface PathLike
A PathLike is the base interface responsible for camera positioning and rotating in a cutscene. They are also commonly referred to as "segment serializers".
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    An object that constructs path segments from JSON and network.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Adds all the point providers that this segment contains to the given stream builder.
    getEnd(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 cutsceneStart)
    Returns a PointProvider representing the end position for this segment.
    net.minecraft.world.phys.Vec3
    getPoint(double t, net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 cutsceneStart)
    Returns the position at the given moment.
    Returns the serializer that is associated with this segment type.
    getStart(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 cutsceneStart)
    Returns a PointProvider representing the starting position for this segment.
    getUtilityPoints(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 cutsceneStart, int initLevel)
    Returns a list of lines representing the utility points used for constructing this segment's path.
    int
    Returns the weight of this segment.
    void
    toNetwork(net.minecraft.network.FriendlyByteBuf buf)
    Writes this segment's parameters to the provided FriendlyByteBuf.
  • Method Details

    • getPoint

      net.minecraft.world.phys.Vec3 getPoint(double t, net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 cutsceneStart)
      Returns the position at the given moment. Depending on the context, it may be treated differently:
      • If the segment is representing the camera position, the resulting position will be treated as an offset from the cutscene starting position, which will then be rotated around the starting point by three axes, depending on the parameters the cutscene was started with.
      • If the segment is representing camera rotation, this method's output will be treated as an offset from the starting camera rotation of the cutscene.
      Parameters:
      t - the progress of the current segment, in range [0, 1]. 0 corresponds to the starting position and 1 is the end position.
      level - the level where the cutscene is run
      cutsceneStart - the starting position of the cutscene
      Returns:
      a point corresponding to the given progress value of the segment.
    • getStart

      PointProvider getStart(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 cutsceneStart)
      Returns a PointProvider representing the starting position for this segment. Ideally, this should match the output of getPoint(0, level, cutsceneStart). Used in paths and path transitions.
      Parameters:
      level - the level where the cutscene is run
      cutsceneStart - the starting position of the cutscene
      Returns:
      the PointProvider representing the starting position for this segment
    • getEnd

      PointProvider getEnd(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 cutsceneStart)
      Returns a PointProvider representing the end position for this segment. Ideally, this should match the output of getPoint(1, level, cutsceneStart). Used in paths and path transitions.
      Parameters:
      level - the level where the cutscene is run
      cutsceneStart - the starting position of the cutscene
      Returns:
      the PointProvider representing the end position for this segment
    • getWeight

      int getWeight()
      Returns the weight of this segment. Used for timing in paths. The higher the value, the more time is dedicated to this segment and the slower it runs, and vice versa.
      Returns:
      this segment's weight
    • toNetwork

      void toNetwork(net.minecraft.network.FriendlyByteBuf buf)
      Writes this segment's parameters to the provided FriendlyByteBuf. This data should be enough to fully reconstruct this segment on the client.
      See Also:
    • getSerializer

      PathLike.SegmentSerializer<?> getSerializer()
      Returns the serializer that is associated with this segment type. Preferably, this should return the same object every time it's called.
      Returns:
      a serializer for this segment's type
    • getUtilityPoints

      default Collection<PathPreviewRenderer.Line> getUtilityPoints(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 cutsceneStart, int initLevel)
      Returns a list of lines representing the utility points used for constructing this segment's path. Used for rendering a cutscene's preview.
      Parameters:
      level - the level where the preview is rendered
      cutsceneStart - the starting position of the cutscene preview
      initLevel - the depth level for this segment. For every segment nested inside another segment, this value increases by 1. This argument should be passed to created lines without changing it.
      Returns:
      a collection of lines representing this segment's utility points.
      See Also:
    • getAllPoints

      default void getAllPoints(Stream.Builder<PointProvider> builder)
      Adds all the point providers that this segment contains to the given stream builder.
      Parameters:
      builder - the stream builder to add all the points to