Class Velocity

java.lang.Object
com.hypixel.hytale.server.core.modules.physics.component.Velocity
All Implemented Interfaces:
Component<EntityStore>, Cloneable

public class Velocity extends Object implements Component<EntityStore>
An entity component that stores the current velocity of the entity
  • Field Details

  • Constructor Details

    • Velocity

      public Velocity()
      Default Constructor for a Velocity instance

      Used by the entity store to instantiate a velocity component

    • Velocity

      public Velocity(@Nonnull Velocity other)
      Constructor for a Velocity instance that clones from an existing instance
      Parameters:
      other - The existing instance to clone from
    • Velocity

      public Velocity(@Nonnull org.joml.Vector3d initialVelocity)
      Constructor for a Velocity instance that initializes with a set initial velocity
      Parameters:
      initialVelocity - The initial velocity to set
  • Method Details

    • getComponentType

      @Nonnull public static ComponentType<EntityStore, Velocity> getComponentType()
      Returns:
      the component type for Velocity components
    • setZero

      public void setZero()
      Called to set the value of the velocity to zero
    • addVelocity

      public void addVelocity(@Nonnull org.joml.Vector3d velocityDelta)
      Adds the given velocity value to the velocity
      Parameters:
      velocityDelta - The velocity value to add
    • addVelocity

      public void addVelocity(double x, double y, double z)
      Adds the given velocity values to the velocity
      Parameters:
      x - The X velocity value
      y - The Y velocity value
      z - The Z velocity value
    • set

      public void set(@Nonnull org.joml.Vector3d newVelocity)
      Sets the velocity to the given velocity value
      Parameters:
      newVelocity - The new velocity value to set
    • set

      public void set(double x, double y, double z)
      Sets the velocity to the given velocity values
      Parameters:
      x - The X value to set
      y - The Y value to set
      z - The Z value to set
    • setClient

      public void setClient(@Nonnull org.joml.Vector3d newVelocity)
      Sets the client velocity to the given velocity value
      Parameters:
      newVelocity - The velocity value to set
    • setClient

      public void setClient(double x, double y, double z)
      Sets the client velocity to the given velocity values
      Parameters:
      x - The X value to set
      y - The Y value to set
      z - The Z value to set
    • setX

      public void setX(double x)
      Sets the X value of the velocity
      Parameters:
      x - The X value to be set
    • setY

      public void setY(double y)
      Sets the Y value of the velocity
      Parameters:
      y - The Y value to be set
    • setZ

      public void setZ(double z)
      Sets the Z value of the velocity
      Parameters:
      z - The Z value to be set
    • getX

      public double getX()
      Returns:
      the X value of the velocity
    • getY

      public double getY()
      Returns:
      the Y value of the velocity
    • getZ

      public double getZ()
      Returns:
      the Z value of the velocity
    • getSpeed

      public double getSpeed()
      Returns:
      the overall speed of the velocity
    • addInstruction

      public void addInstruction(@Nonnull org.joml.Vector3d velocity, @Nullable VelocityConfig config, @Nonnull ChangeVelocityType type)
      Adds a new instruction to be performed on the velocity of the entity
      Parameters:
      velocity - The velocity value to be applied
      config - The velocity config to be referenced, if any
      type - The type of application to perform with the velocity
    • addInstruction

      public void addInstruction(@Nonnull org.joml.Vector3d velocity, @Nullable VelocityConfig config, @Nonnull ChangeVelocityType type, float preMultiplier)
      Adds a new instruction to be performed on the velocity of the entity
      Parameters:
      velocity - The velocity value to be applied
      config - The velocity config to be referenced, if any
      type - The type of application to perform with the velocity
      preMultiplier - Tracked scaling value for knockback horizontal velocity scaling
    • getInstructions

      @Nonnull public List<Velocity.Instruction> getInstructions()
      Returns:
      the list of pending instructions for this velocity component
    • getVelocity

      @Nonnull public org.joml.Vector3d getVelocity()
      Returns the actual velocity vector. It is recommended to use assignVelocityTo(Vector3d) when possible. Otherwise, use with caution, as modifying this vector modifies the velocity of the entity.

      Note: This is the expected behavior, however currently this does not apply for NPCs and Player entities, and will not until they've been properly ported to the ECS.

      Returns:
      the actual velocity vector, modify with caution
    • getClientVelocity

      @Nonnull public org.joml.Vector3d getClientVelocity()
      Returns:
      the last known client velocity that we have cached
    • assignVelocityTo

      @Nonnull public org.joml.Vector3d assignVelocityTo(@Nonnull org.joml.Vector3d vector)
      Assigns the velocity vector to another vector to prevent unintentional modification of the velocity
      Parameters:
      vector - the Vector3d to assign the velocity to
      Returns:
      the given vector, for chaining
    • clone

      @Nonnull public Component<EntityStore> clone()
      Specified by:
      clone in interface Component<EntityStore>
      Returns:
      a clone instance of the original component instance.