Contents
Class EntityPositionProvider
java.lang.Object
com.hypixel.hytale.server.npc.sensorinfo.InfoProviderBase
com.hypixel.hytale.server.npc.sensorinfo.PositionProvider
com.hypixel.hytale.server.npc.sensorinfo.EntityPositionProvider
- All Implemented Interfaces:
InfoProvider, IPositionProvider, IPositionSet
Helper class to implement PositionProvider interface for an entity target.
When the entity target becomes invalid hasPosition() will return false.
Also implements IPositionSet: in single-target mode it reports a size of 1 (the primary getTarget()),
and in multi-target mode a sensor accumulates every match via addTarget(Ref, ComponentAccessor) with the primary at index 0.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTarget(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor) Appends a matched target for multi-target mode, resolving and storing its current position so the provider can serve it fromgetPosition(int, Vector3d).voidclear()Reset position provider and clear target reference (including the multi-target list).voidClears the accumulated multi-target list.booleangetOrientation(int index, Rotation3f out) Writes the orientation of elementindexintoout, when that element carries one.booleangetPosition(int index, org.joml.Vector3d out) Writes the position of elementindexintoout.Return target entity if sensor provides it currently.getTarget(int index) booleanTest if PositionProvider does return a position currently.voidpromotePrimary(Ref<EntityStore> ref) Ensuresrefis the first element (index 0) of the multi-target list by moving it from wherever it currently sits, or inserting it if absent.voidsetIncludeDead(boolean includeDead) Sets whether dead targets (those with aDeathComponent) should be retained instead of being treated as invalid.setTarget(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor) Set entity and position to be returned from PositionProvider.intsize()Methods inherited from class PositionProvider
clearOrientation, getPositionProvider, getX, getY, getZ, provideOrientation, providePosition, setOrientation, setTarget, setTarget, setTargetMethods inherited from class InfoProviderBase
getExtraInfo, getParameterProvider, getPassedExtraInfo, passExtraInfo
-
Constructor Details
-
EntityPositionProvider
public EntityPositionProvider() -
EntityPositionProvider
-
-
Method Details
-
setIncludeDead
public void setIncludeDead(boolean includeDead) Sets whether dead targets (those with aDeathComponent) should be retained instead of being treated as invalid. -
clear
public void clear()Reset position provider and clear target reference (including the multi-target list).- Specified by:
clearin interfaceIPositionProvider- Overrides:
clearin classPositionProvider
-
setTarget
public Ref<EntityStore> setTarget(@Nullable Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Set entity and position to be returned from PositionProvider.- Overrides:
setTargetin classPositionProvider- Parameters:
ref- Reference to the targetcomponentAccessor- The component accessor- Returns:
- null if target is null, removed, or dead (unless includeDead is set), else target
-
addTarget
public void addTarget(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Appends a matched target for multi-target mode, resolving and storing its current position so the provider can serve it fromgetPosition(int, Vector3d). The primary (the prioritiser pick) should be added first so it occupies index 0. Invalid or dead targets (perincludeDead) are skipped. -
clearTargets
public void clearTargets()Clears the accumulated multi-target list. Sensors call this at the start of each match pass before re-populating. Unlikeclear()it leaves the primary single-target state untouched. -
promotePrimary
Ensuresrefis the first element (index 0) of the multi-target list by moving it from wherever it currently sits, or inserting it if absent. No-op when the list is empty (single-target mode). -
getTarget
Description copied from interface:IPositionProviderReturn target entity if sensor provides it currently.A sensor might return a valid position but return a null value here if this position does not correlate to an entity.
- Specified by:
getTargetin interfaceIPositionProvider- Overrides:
getTargetin classPositionProvider- Returns:
- entity ref if sensor is matching and result refers to an entity, else null.
-
hasPosition
public boolean hasPosition()Description copied from interface:IPositionProviderTest if PositionProvider does return a position currently.- Specified by:
hasPositionin interfaceInfoProvider- Specified by:
hasPositionin interfaceIPositionProvider- Overrides:
hasPositionin classPositionProvider- Returns:
- if true providePosition and getX/Y/Z will return positional result of sensor
-
size
public int size()- Specified by:
sizein interfaceIPositionSet- Returns:
- the number of elements in the set (0 when empty).
-
getTarget
- Specified by:
getTargetin interfaceIPositionSet- Returns:
- the entity associated with element
index, or null when the element is a bare position with no entity (e.g. a computed point), whenindexis out of range, or when the entity is no longer valid.
-
getPosition
public boolean getPosition(int index, @Nonnull org.joml.Vector3d out) Description copied from interface:IPositionSetWrites the position of elementindexintoout.- Specified by:
getPositionin interfaceIPositionSet- Returns:
- true if a position was written. false if
indexis out of range.
-
getOrientation
Description copied from interface:IPositionSetWrites the orientation of elementindexintoout, when that element carries one.- Specified by:
getOrientationin interfaceIPositionSet- Returns:
- true if an orientation was written, false otherwise (in which case
outis left untouched).
-