Class PositionSetProvider

java.lang.Object
com.hypixel.hytale.server.npc.sensorinfo.InfoProviderBase
com.hypixel.hytale.server.npc.sensorinfo.PositionSetProvider
All Implemented Interfaces:
InfoProvider, IPositionProvider, IPositionSet

public class PositionSetProvider extends InfoProviderBase implements IPositionProvider, IPositionSet
An InfoProvider holding a computed set of positions (each with an optional associated entity), produced by a PositionSetTransform. Implements IPositionProvider as the slot-0 view and IPositionSet for multi-aware consumers like ForEach.
  • Constructor Details

    • PositionSetProvider

      public PositionSetProvider()
    • PositionSetProvider

      public PositionSetProvider(ParameterProvider parameterProvider)
  • Method Details

    • reset

      public void reset()
      Logically empties the set while keeping the backing buffers for reuse.
    • add

      public void add(double x, double y, double z, @Nullable Ref<EntityStore> target)
      Appends a computed position with an optional source entity. Reuses the Vector3d already at this slot when the buffer has grown large enough on a previous tick.
    • add

      public void add(double x, double y, double z, @Nullable Ref<EntityStore> target, @Nonnull Rotation3fc orientation)
      Appends a computed position carrying an orientation.
    • hasPosition

      public boolean hasPosition()
      Description copied from interface: IPositionProvider
      Test if PositionProvider does return a position currently.
      Specified by:
      hasPosition in interface InfoProvider
      Specified by:
      hasPosition in interface IPositionProvider
      Returns:
      if true providePosition and getX/Y/Z will return positional result of sensor
    • providePosition

      public boolean providePosition(@Nonnull org.joml.Vector3d result)
      Description copied from interface: IPositionProvider
      Test and return sensor positional result if available.
      Specified by:
      providePosition in interface IPositionProvider
      Parameters:
      result - Vector3d receiving position information if available
      Returns:
      True if position is available and result was updated, false if no position available
    • getX

      public double getX()
      Description copied from interface: IPositionProvider
      Return x coordinate of available position.
      Specified by:
      getX in interface IPositionProvider
      Returns:
      Coordinate if position available else result is undefined.
    • getY

      public double getY()
      Description copied from interface: IPositionProvider
      Return y coordinate of available position.
      Specified by:
      getY in interface IPositionProvider
      Returns:
      Coordinate if position available else result is undefined.
    • getZ

      public double getZ()
      Description copied from interface: IPositionProvider
      Return z coordinate of available position.
      Specified by:
      getZ in interface IPositionProvider
      Returns:
      Coordinate if position available else result is undefined.
    • getTarget

      @Nullable public Ref<EntityStore> getTarget()
      Description copied from interface: IPositionProvider
      Return 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:
      getTarget in interface IPositionProvider
      Returns:
      entity ref if sensor is matching and result refers to an entity, else null.
    • provideOrientation

      public boolean provideOrientation(@Nonnull Rotation3f out)
      Description copied from interface: IPositionProvider
      Writes the orientation of the current (primary) position into out, when one is available.
      Specified by:
      provideOrientation in interface IPositionProvider
      Returns:
      true if an orientation was written, false otherwise (in which case out is left untouched).
    • clear

      public void clear()
      Description copied from interface: IPositionProvider
      Reset position provider so that hasPosition() will return false.
      Specified by:
      clear in interface IPositionProvider
    • getPositionProvider

      @Nonnull public IPositionProvider getPositionProvider()
      Description copied from interface: InfoProvider
      We provide direct access to the position provider as it's the most frequently used provider and is used in a very large number of actions and motions.
      Specified by:
      getPositionProvider in interface InfoProvider
      Returns:
      the position provider.
    • size

      public int size()
      Specified by:
      size in interface IPositionSet
      Returns:
      the number of elements in the set (0 when empty).
    • getTarget

      @Nullable public Ref<EntityStore> getTarget(int index)
      Specified by:
      getTarget in interface IPositionSet
      Returns:
      the entity associated with element index, or null when the element is a bare position with no entity (e.g. a computed point), when index is 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: IPositionSet
      Writes the position of element index into out.
      Specified by:
      getPosition in interface IPositionSet
      Returns:
      true if a position was written. false if index is out of range.
    • getOrientation

      public boolean getOrientation(int index, @Nonnull Rotation3f out)
      Description copied from interface: IPositionSet
      Writes the orientation of element index into out, when that element carries one.
      Specified by:
      getOrientation in interface IPositionSet
      Returns:
      true if an orientation was written, false otherwise (in which case out is left untouched).
    • applyTransform

      public static void applyTransform(@Nonnull IPositionProvider in, @Nonnull PositionSetTransform transform, @Nonnull PositionSetProvider out, boolean carryTarget, @Nonnull org.joml.Vector3d tmpIn, @Nonnull org.joml.Vector3d tmpOut, @Nonnull Rotation3f tmpRot, @Nonnull Store<EntityStore> store)
      Maps transform over every element of in (a single position or an IPositionSet) into out, dropping elements the transform rejects. A transform changes position only, so each element's orientation (when present) is carried through unchanged, independent of carryTarget.