Class SpawnMarkerEntity

java.lang.Object
com.hypixel.hytale.server.spawning.spawnmarkers.SpawnMarkerEntity
All Implemented Interfaces:
Component<EntityStore>, Cloneable

public class SpawnMarkerEntity extends Object implements Component<EntityStore>
A component that represents a spawn marker entity in the world.
  • Field Details

  • Constructor Details

    • SpawnMarkerEntity

      public SpawnMarkerEntity()
      Default Constructor for a SpawnMarkerEntity instance.
  • Method Details

    • getComponentType

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

      public SpawnMarker getCachedMarker()
      Returns:
      the cached spawn marker asset.
    • setCachedMarker

      public void setCachedMarker(@Nonnull SpawnMarker marker)
      Called to set the cached spawn marker asset.
      Parameters:
      marker - The spawn marker asset to cache.
    • getSpawnCount

      public int getSpawnCount()
      Returns:
      the current spawn count.
    • setSpawnCount

      public void setSpawnCount(int spawnCount)
      Called to set the current spawn count.
      Parameters:
      spawnCount - The spawn count to set.
    • setRespawnCounter

      public void setRespawnCounter(double respawnCounter)
      Called to get the current respawn counter.
      Parameters:
      respawnCounter - The respawn counter to set.
    • setSpawnAfter

      public void setSpawnAfter(@Nullable Instant spawnAfter)
      Called to set the instant after which the NPC can be respawned.
      Parameters:
      spawnAfter - The instant to set.
    • getSpawnAfter

      @Nullable public Instant getSpawnAfter()
      Returns:
      the instant after which the NPC can be respawned.
    • setGameTimeRespawn

      public void setGameTimeRespawn(@Nullable Duration gameTimeRespawn)
      Called to set the game time duration until respawn.
      Parameters:
      gameTimeRespawn - The game time duration to set.
    • pollGameTimeRespawn

      @Nullable public Duration pollGameTimeRespawn()
      Returns:
      the game time duration until respawn, null if not set. This also clears the stored value.
    • tickRespawnTimer

      public boolean tickRespawnTimer(float dt)
      Called to tick the respawn timer.
      Parameters:
      dt - The delta time to tick.
      Returns:
      true if the respawn timer has reached zero, false otherwise.
    • getSuppressedBy

      @Nullable public Set<UUID> getSuppressedBy()
      Returns:
      the set of UUIDs of entities that are currently suppressing this spawn marker.
    • setStoredFlock

      public void setStoredFlock(@Nonnull StoredFlock storedFlock)
      Called to set the stored flock information for this spawn marker.
      Parameters:
      storedFlock - The stored flock information to set.
    • getStoredFlock

      @Nullable public StoredFlock getStoredFlock()
      Returns:
      the stored flock information for this spawn marker.
    • getTimeToDeactivation

      public double getTimeToDeactivation()
      Returns:
      the time, in seconds, until this spawn marker is deactivated.
    • setTimeToDeactivation

      public void setTimeToDeactivation(double timeToDeactivation)
      Called to set the time, in seconds, until this spawn marker is deactivated.
      Parameters:
      timeToDeactivation - The time to deactivation to set.
    • tickTimeToDeactivation

      public boolean tickTimeToDeactivation(float dt)
      Called to tick the time to deactivation.
      Parameters:
      dt - The delta time to tick.
      Returns:
      true if the time to deactivation has reached zero, false otherwise.
    • tickSpawnLostTimeout

      public boolean tickSpawnLostTimeout(float dt)
      Called to tick the spawn lost timeout counter.
      Parameters:
      dt - The delta time to tick.
      Returns:
      true if the spawn lost timeout has reached zero, false otherwise.
    • getSpawnPosition

      @Nonnull public org.joml.Vector3d getSpawnPosition()
      Returns:
      the last known spawn position of the NPCs spawned by this marker.
    • getNpcReferences

      public InvalidatablePersistentRef[] getNpcReferences()
      Returns:
      the array of references to the NPCs spawned by this marker.
    • setNpcReferences

      public void setNpcReferences(@Nullable InvalidatablePersistentRef[] npcReferences)
      Called to set the array of references to the NPCs spawned by this marker.
      Parameters:
      npcReferences - The array of NPC references to set.
    • completeSpawnedNpcRemoval

      public void completeSpawnedNpcRemoval(@Nonnull Instant gameTime)
    • getTempStorageList

      @Nullable public List<it.unimi.dsi.fastutil.Pair<Ref<EntityStore>, NPCEntity>> getTempStorageList()
      Returns:
      the temporary storage list for flock members during despawn/spawn operations.
    • setTempStorageList

      public void setTempStorageList(@Nonnull List<it.unimi.dsi.fastutil.Pair<Ref<EntityStore>, NPCEntity>> tempStorageList)
      Called to set the temporary storage list for flock members during despawn/spawn operations.
      Parameters:
      tempStorageList - The temporary storage list to set.
    • isDespawnStarted

      public boolean isDespawnStarted()
      Returns:
      true if the despawn process has started for this spawn marker, false otherwise.
    • setDespawnStarted

      public void setDespawnStarted(boolean despawnStarted)
      Called to set whether the despawn process has started for this spawn marker.
      Parameters:
      despawnStarted - The despawn started flag to set.
    • refreshTimeout

      public void refreshTimeout()
      Called to refresh the spawn lost timeout counter.
    • spawnNPC

      public boolean spawnNPC(@Nonnull Ref<EntityStore> ref, @Nonnull SpawnMarker marker, @Nullable List<Ref<EntityStore>> outSpawnedList, @Nonnull Store<EntityStore> store)
      Called to spawn an NPC at this spawn marker.
      Parameters:
      ref - The entity reference of the spawn marker entity.
      marker - The associated SpawnMarker asset.
      outSpawnedList - An optional list to collect spawned entity references.
      store - The Store<EntityStore> for component access.
      Returns:
      true if the NPC was successfully spawned or a noop spawn was performed, false if the spawn failed.
    • validate

      public void validate(@Nonnull Ref<EntityStore> ref, @Nonnull Store<EntityStore> store, @Nonnull TransformComponent transform, @Nonnull SpawnMarkerValidation validation)
      Validates the spawn marker's current position and stores the result.
      Parameters:
      ref - The spawn marker entity reference.
      store - The store that contains the spawn marker.
      transform - The current spawn marker transform.
      validation - The component that receives the validation result.
    • setSpawnMarker

      public void setSpawnMarker(@Nonnull SpawnMarker marker)
      Called to set the spawn marker for this entity.
      Parameters:
      marker - The spawn marker to set.
    • decrementAndGetSpawnCount

      public int decrementAndGetSpawnCount()
      Called to decrement the spawn count and get the new value.
      Returns:
      the new spawn count after decrementing.
    • getSpawnMarkerId

      public String getSpawnMarkerId()
      Returns:
      the ID of the associated spawn marker asset.
    • isManualTrigger

      public boolean isManualTrigger()
      Returns:
      true if this spawn marker is manually triggered, false otherwise.
    • trigger

      public boolean trigger(@Nonnull Ref<EntityStore> markerRef, @Nullable List<Ref<EntityStore>> outSpawnedList, @Nonnull Store<EntityStore> store)
      Manually trigger this spawn marker (only valid for spawn markers that have been explicitly set as manually triggered.) Allows passing an optional list to collect spawned references.

      Returns true if the NPC was successfully spawned (or if a noop spawn was performed as this is still part of the config) Returns false if the spawn fails for any reason that cannot be affected by the marker. This includes:

      • No room to spawn the NPC
      • Role of spawned NPC being invalid
      • Player being within the exclusion radius
      • Being offset too far from the ground
      • An NPC has already been spawned and is still alive
      Returns:
      true if the trigger was run successfully, false if not
    • isSuppressedBy

      public boolean isSuppressedBy(@Nonnull SpawnSuppression suppression)
      Whether the given suppression applies to this marker.

      A suppressor that lists no SuppressedGroups blanket-suppresses every marker in range (legacy behaviour). A suppressor that does list groups only suppresses markers whose payload - the NPC role(s) this marker would spawn - belongs to one of those groups, mirroring how SuppressedGroups already gates ambient world-spawns. This lets a marker that spawns an out-of-group NPC (e.g. a player-built companion spawner) keep working inside a camp that only suppresses hostiles/neutrals.

    • suppress

      public void suppress(@Nonnull UUID suppressor)
      Called to suppress this spawn marker.
      Parameters:
      suppressor - The UUID of the entity suppressing this spawn marker.
    • releaseSuppression

      public void releaseSuppression(@Nonnull UUID suppressor)
      Called to release suppression of this spawn marker.
      Parameters:
      suppressor - The UUID of the entity releasing suppression of this spawn marker.
    • clearAllSuppressions

      public void clearAllSuppressions()
      Called to clear all suppressions of this spawn marker.
    • clone

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

    • cloneSerializable

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

    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object
    • getModel

      public static Model getModel(@Nonnull SpawnMarker marker)
      Called to fetch the model for a given spawn marker.
      Parameters:
      marker - The spawn marker to fetch the model for.
      Returns:
      the model for the given spawn marker.