Contents
Class TransformComponent
java.lang.Object
com.hypixel.hytale.server.core.modules.entity.component.TransformComponent
- All Implemented Interfaces:
Component<EntityStore>, Cloneable
An entity component that holds the position and rotation of an entity.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BuilderCodec<TransformComponent> The codec used to parseTransformComponentinstances.Fields inherited from interface Component
EMPTY_ARRAY -
Constructor Summary
ConstructorsConstructorDescriptionEmpty Constructor for aTransformComponentinstance.TransformComponent(org.joml.Vector3dc position, Rotation3fc rotation) Default Constructor for aTransformComponentinstance. -
Method Summary
Modifier and TypeMethodDescriptionclone()static ComponentType<EntityStore, TransformComponent> org.joml.Vector3dbooleanReturns 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.voidRecords the current position as the last saved position sopollMovedEnoughToSave()returnsfalseuntil the entity moves past the threshold.voidsetPosition(org.joml.Vector3dc position) Called to set the position of the entity.voidsetRotation(Rotation3f rotation) Called to set the rotation of the entity.voidsetSectionLocation(Ref<ChunkStore> sectionRef) Called to set the chunk section that the entity is currently in.voidteleportPosition(org.joml.Vector3dc position) Set the position.voidteleportRotation(Rotation3f rotation) Set the rotation.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Component
cloneSerializable
-
Field Details
-
CODEC
The codec used to parseTransformComponentinstances.
-
-
Constructor Details
-
TransformComponent
public TransformComponent()Empty Constructor for aTransformComponentinstance.Used by the codec to instantiate
TransformComponentinstances. -
TransformComponent
Default Constructor for aTransformComponentinstance.- Parameters:
position- The position of the entity.rotation- The rotation of the entity.
-
-
Method Details
-
getComponentType
- Returns:
- the component type for the
TransformComponentcomponent.
-
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
- Returns:
- the rotation of the entity.
-
setRotation
Called to set the rotation of the entity.- Parameters:
rotation- The given rotation to set.
-
getTransform
-
teleportRotation
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
- Returns:
- the last sent transform of the entity.
-
getSectionRef
- Returns:
- the entity reference of the chunk section that the entity is currently in, or
nullif not set.
-
setSectionLocation
Called to set the chunk section that the entity is currently in.- Parameters:
sectionRef- The section entity reference, ornullto clear the section membership.
-
seedLastSavedPosition
public void seedLastSavedPosition()Records the current position as the last saved position sopollMovedEnoughToSave()returnsfalseuntil 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
- Specified by:
clonein interfaceComponent<EntityStore>- Returns:
- a clone instance of the original component instance.
-