Class TransformComponent

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

public class TransformComponent extends Object implements Component<EntityStore>
An entity component that holds the position and rotation of an entity.
  • Field Details

  • Constructor Details

    • TransformComponent

      public TransformComponent()
      Empty Constructor for a TransformComponent instance.

      Used by the codec to instantiate TransformComponent instances.

    • TransformComponent

      public TransformComponent(@Nonnull org.joml.Vector3dc position, @Nonnull Rotation3fc rotation)
      Default Constructor for a TransformComponent instance.
      Parameters:
      position - The position of the entity.
      rotation - The rotation of the entity.
  • Method Details

    • getComponentType

      public static ComponentType<EntityStore, TransformComponent> getComponentType()
      Returns:
      the component type for the TransformComponent component.
    • getPosition

      @Nonnull public org.joml.Vector3d getPosition()
      Returns:
      the position of the entity.
    • setPosition

      public void setPosition(@Nonnull org.joml.Vector3dc position)
      Called to set the position of the entity.
      Parameters:
      position - The given position to set.
    • teleportPosition

      public void teleportPosition(@Nonnull org.joml.Vector3dc position)
      Set the position. NaN values will be ignored.
      Parameters:
      position - the position to set, with NaN for any component that should not be set.
    • getRotation

      @Nonnull public Rotation3f getRotation()
      Returns:
      the rotation of the entity.
    • setRotation

      public void setRotation(@Nonnull Rotation3f rotation)
      Called to set the rotation of the entity.
      Parameters:
      rotation - The given rotation to set.
    • getTransform

      @Nonnull public Transform getTransform()
      Returns:
      a new Transform with the current position and rotation.
    • teleportRotation

      public void teleportRotation(@Nonnull Rotation3f rotation)
      Set the rotation. NaN values will be ignored.
      Parameters:
      rotation - the rotation to set, with NaN for any component that should not be set.
    • getSentTransform

      @Nonnull public ModelTransform getSentTransform()
      Returns:
      the last sent transform of the entity.
    • getSectionRef

      @Nullable public Ref<ChunkStore> getSectionRef()
      Returns:
      the entity reference of the chunk section that the entity is currently in, or null if not set.
    • setSectionLocation

      public void setSectionLocation(@Nullable Ref<ChunkStore> sectionRef)
      Called to set the chunk section that the entity is currently in.
      Parameters:
      sectionRef - The section entity reference, or null to clear the section membership.
    • seedLastSavedPosition

      public void seedLastSavedPosition()
      Records the current position as the last saved position so pollMovedEnoughToSave() returns false until the entity moves past the threshold. For use by load paths whose persisted per-entity state already matches the current position; without a seed the first poll requests a save, which is how entities that have never had a per-entity row written (e.g. legacy embedded entities) get their initial save.
    • pollMovedEnoughToSave

      public boolean pollMovedEnoughToSave()
      Returns whether the entity has moved far enough since the last call to warrant a save, and if so, updates the recorded "last save position" to the current position. Callers should therefore only invoke this when they intend to act on the result, since it consumes the movement threshold and mutates internal state.
    • clone

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