Contents
Class SnapshotBuffer
java.lang.Object
com.hypixel.hytale.server.core.modules.entity.component.SnapshotBuffer
- All Implemented Interfaces:
Component<EntityStore>, Cloneable
Stores a short history of an entity's hit detection state.
History is stored as flat double/float arrays, packed
three components per tick slot, since this is written for every ticking
entity every tick and only read back occasionally. EntitySnapshot
instances are only materialized on read.
-
Field Summary
Fields inherited from interface Component
EMPTY_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()static ComponentType<EntityStore, SnapshotBuffer> intintgetSnapshot(int tickIndex) Returns the snapshot of the entity's hit-detection information as it was at the given tick index.getSnapshotClamped(int tickIndex) Returns the snapshot of the entity's hit-detection information as it was at the given tick index.booleanvoidresize(int newLength) Clears and resizes the snapshot buffer to the given size.voidstoreSnapshot(int tickIndex, org.joml.Vector3d position, Rotation3f bodyRotation) Stores the given information in a snapshot for the giventickIndex.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Component
cloneSerializable
-
Constructor Details
-
SnapshotBuffer
public SnapshotBuffer()
-
-
Method Details
-
getComponentType
-
getSnapshotClamped
Returns the snapshot of the entity's hit-detection information as it was at the given tick index.If the tick index is older than the oldest stored snapshot that snapshot will be returned instead.
- Parameters:
tickIndex- The tick index to find the snapshot of.- Returns:
- The nearest snapshot to the given tick index.
- Throws:
IllegalStateException- If the snapshot buffer hasn't be initialized with at least one snapshotIllegalArgumentException- If thetickIndexrequested is newer than any stored snapshot.
-
getSnapshot
Returns the snapshot of the entity's hit-detection information as it was at the given tick index.- Parameters:
tickIndex- The tick index to find the snapshot of.- Returns:
- The snapshot at the given tick index or null.
- Throws:
IllegalArgumentException- If thetickIndexrequested is newer than any stored snapshot.
-
storeSnapshot
public void storeSnapshot(int tickIndex, @Nonnull org.joml.Vector3d position, @Nonnull Rotation3f bodyRotation) Stores the given information in a snapshot for the giventickIndex.If the
tickIndexisn't the next expected tick then this buffer will be cleared first to prevent gaps.- Parameters:
tickIndex- The tick index to store this snapshot forposition- The position of the entity to store in the snapshotbodyRotation- The body rotation to store in the snapshot
-
resize
public void resize(int newLength) Clears and resizes the snapshot buffer to the given size.Does nothing if the snapshot buffer is already the correct size.
- Parameters:
newLength- The new size of the buffer.- Throws:
IllegalArgumentException- If the new size is<= 0
-
isInitialized
public boolean isInitialized() -
getCurrentTickIndex
public int getCurrentTickIndex() -
getOldestTickIndex
public int getOldestTickIndex() -
clone
- Specified by:
clonein interfaceComponent<EntityStore>- Returns:
- a clone instance of the original component instance.
-