Class PlayerModel

java.lang.Object
lol.trq.helios.model.PlayerModel

public final class PlayerModel extends Object
The transforms Minecraft 1.8.9 renders a player with, as plain matrix math: the same chain as RenderPlayer, RendererLivingEntity, ModelPlayer and ModelBiped, so something drawn at an Attachment follows the model exactly.

The chain from model pixels to camera-relative world blocks is T(position) · R_y(180 - bodyYaw) · S(-1, -1, 1) · S(0.9375) · T(0, -1.5078125, 0) · S(1/16), then the part's pivot and rotations. Sneaking adds T(0, 0.2, 0) before the pixel scale, moves the head pivot down one pixel, tilts the body forward 0.5 radians and, for players other than the client's own, lowers the position by 0.125. Riding a living entity limits how far the body turns from the mount, as vanilla does. Sleeping, dying and the elytra are not modelled.

Every method writes into arrays the caller owns and allocates nothing.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final float
    How far armour sits out from the skin, in pixels.
    static final float
    Distance from the body pivot to the back surface, in pixels.
    static final float
    Height of the head, in pixels.
    static final float
    The living renderer's vertical model offset, in model units.
    static final float
    The furthest the body turns from a ridden mount, in degrees.
    static final float
    Model units per pixel.
    static final float
    The player renderer's scale.
    static final float
    Forward tilt of the body when sneaking, in radians.
    static final float
    How far vanilla lowers other sneaking players, in blocks.
    static final float
    Head pivot height when sneaking, in pixels.
    static final float
    How far a sneaking model shifts down, in model units, before scaling.
  • Method Summary

    Modifier and Type
    Method
    Description
    static float[]
    anchor(PlayerPose pose, Attachment attachment, float[] out)
    Writes an attachment's transform: model pixels relative to the anchor, to camera-relative world blocks.
    static float
    Returns the yaw the body is drawn at, after the riding limit.
    static float
    interpolateAngle(float previous, float current, float partialTicks)
    Interpolates between two angles the short way round, as RendererLivingEntity.interpolateRotation.
    static float
    Returns the head yaw relative to the body, as the model receives it.
    static float[]
    root(PlayerPose pose, float[] out)
    Writes the model root: model pixels, before any part's pivot, to camera-relative world blocks.
    static float
    wrap(float degrees)
    Wraps an angle to [-180, 180), as MathHelper.wrapAngleTo180_float.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PIXEL

      public static final float PIXEL
      Model units per pixel.
      See Also:
    • SCALE

      public static final float SCALE
      The player renderer's scale.
      See Also:
    • MODEL_OFFSET

      public static final float MODEL_OFFSET
      The living renderer's vertical model offset, in model units.
      See Also:
    • SNEAK_SHIFT

      public static final float SNEAK_SHIFT
      How far a sneaking model shifts down, in model units, before scaling.
      See Also:
    • SNEAK_DROP

      public static final float SNEAK_DROP
      How far vanilla lowers other sneaking players, in blocks.
      See Also:
    • SNEAK_BODY_PITCH

      public static final float SNEAK_BODY_PITCH
      Forward tilt of the body when sneaking, in radians.
      See Also:
    • SNEAK_HEAD_PIVOT

      public static final float SNEAK_HEAD_PIVOT
      Head pivot height when sneaking, in pixels.
      See Also:
    • HEAD_HEIGHT

      public static final float HEAD_HEIGHT
      Height of the head, in pixels.
      See Also:
    • BACK_DEPTH

      public static final float BACK_DEPTH
      Distance from the body pivot to the back surface, in pixels.
      See Also:
    • ARMOUR_OUTSET

      public static final float ARMOUR_OUTSET
      How far armour sits out from the skin, in pixels.
      See Also:
    • MOUNT_LIMIT

      public static final float MOUNT_LIMIT
      The furthest the body turns from a ridden mount, in degrees.
      See Also:
  • Method Details

    • bodyYaw

      public static float bodyYaw(PlayerPose pose)
      Returns the yaw the body is drawn at, after the riding limit.
      Parameters:
      pose - the pose
      Returns:
      the body yaw in degrees
    • netHeadYaw

      public static float netHeadYaw(PlayerPose pose)
      Returns the head yaw relative to the body, as the model receives it. When riding, vanilla measures it from the mount rather than from the drawn body.
      Parameters:
      pose - the pose
      Returns:
      the relative head yaw in degrees
    • root

      public static float[] root(PlayerPose pose, float[] out)
      Writes the model root: model pixels, before any part's pivot, to camera-relative world blocks.
      Parameters:
      pose - the pose
      out - receives the matrix
      Returns:
      out
    • anchor

      public static float[] anchor(PlayerPose pose, Attachment attachment, float[] out)
      Writes an attachment's transform: model pixels relative to the anchor, to camera-relative world blocks. Draw an attachment in pixels around the origin, with x toward the player's left, y down and z toward the back.
      Parameters:
      pose - the pose
      attachment - the anchor
      out - receives the matrix
      Returns:
      out
    • wrap

      public static float wrap(float degrees)
      Wraps an angle to [-180, 180), as MathHelper.wrapAngleTo180_float.
      Parameters:
      degrees - the angle
      Returns:
      the wrapped angle
    • interpolateAngle

      public static float interpolateAngle(float previous, float current, float partialTicks)
      Interpolates between two angles the short way round, as RendererLivingEntity.interpolateRotation.
      Parameters:
      previous - the angle last tick
      current - the angle this tick
      partialTicks - the frame's partial tick
      Returns:
      the interpolated angle