Class TriggerVolumeManager

java.lang.Object
com.hypixel.hytale.builtin.triggervolumes.manager.TriggerVolumeManager
All Implemented Interfaces:
Resource<EntityStore>, Cloneable

public class TriggerVolumeManager extends Object implements Resource<EntityStore>
  • Field Details

    • ENVIRONMENT_ACTOR_UUID

      @Nonnull public static final UUID ENVIRONMENT_ACTOR_UUID
      The actor UUID used for environment-sourced events that have no instigating entity, so the cooldown machinery (keyed by actor UUID) still functions. All such events share this bucket.
    • CODEC

      @Nonnull public static final BuilderCodec<TriggerVolumeManager> CODEC
  • Constructor Details

    • TriggerVolumeManager

      public TriggerVolumeManager()
  • Method Details

    • register

      public void register(@Nonnull String id, @Nonnull VolumeEntry entry)
    • unregister

      public void unregister(@Nonnull String id)
    • updateTrackingState

      public void updateTrackingState(@Nonnull VolumeEntry entry)
      Adds the volume to the active set while it tracks entities, removes it otherwise.
    • getActiveVolumes

      @Nonnull public Set<VolumeEntry> getActiveVolumes()
    • hasEntityTargetVolumes

      public boolean hasEntityTargetVolumes()
      Whether any enabled volume targets a non-player entity type, gating the per-tick scan of the non-player spatial structure. Players are always scanned. Recomputed lazily after any change that could affect it, so the common no-NPC-volume case skips the entity scan entirely.
    • renameVolume

      @Nullable public VolumeEntry renameVolume(@Nonnull String oldId, @Nonnull String newId)
    • removeWorldGenVolumesInChunk

      public void removeWorldGenVolumesInChunk(long chunkIndex)
      Drops every worldgen-tagged entry whose anchor position lies in the given chunk, plus any group it leaves empty. Called from the chunk-store side when a worldgen chunk is freshly added (regen via viewport / /chunk regenerate / /worldgen reload) so the new generation can re-register its volumes without piling up onto the previous run's entries.
    • removeAllVolumes

      public int removeAllVolumes()
      Drops every volume and group in the world - tool-placed and worldgen alike. Called when worldgen reload --clear wipes the world so nothing stale lingers; loaded chunks re-register their worldgen volumes as they regenerate.
    • getVolume

      @Nullable public VolumeEntry getVolume(@Nonnull String id)
    • getVolumes

      @Nonnull public Collection<VolumeEntry> getVolumes()
    • hasVolumes

      public boolean hasVolumes()
      Cheap check (no view allocation) for whether any volume exists, for gating hot event paths.
    • getVolumesMap

      @Nonnull public Map<String, VolumeEntry> getVolumesMap()
    • hasVolume

      public boolean hasVolume(@Nonnull String id)
    • markSpatialDirty

      public void markSpatialDirty()
      Signals that derived state may be stale after an in-place edit that does not flow through the VolumeEntry mutators (e.g. a target-type set edited via getTargetTypes()). Position/shape/enabled changes notify the index directly, so this only refreshes the entity-target gate.
    • hasActiveRule

      public boolean hasActiveRule(@Nonnull org.joml.Vector3d worldPos, @Nonnull Class<? extends TriggerRule> ruleClass)
      Returns whether any enabled volume with active rules contains worldPos and carries a rule of the given class, either directly or inherited from its group. Used by rule enforcement systems at cancellable event hooks.
    • getActiveRules

      @Nonnull public <T extends TriggerRule> List<T> getActiveRules(@Nonnull org.joml.Vector3d worldPos, @Nonnull Class<T> ruleClass)
      Collects all rule instances of the given class active at worldPos, including group-inherited rules. Lets enforcement systems for configurable rule types read their rule's fields.
    • getActiveRulesWithVolume

      @Nonnull public <T extends TriggerRule> List<TriggerVolumeManager.ActiveRule<T>> getActiveRulesWithVolume(@Nonnull org.joml.Vector3d worldPos, @Nonnull Class<T> ruleClass)
      Like getActiveRules(Vector3d, Class), but pairs each rule with the volume it came from (the in-range member volume for group-inherited rules). Enforcement systems use this when they need to act on the owning volume, e.g. to send a signal back to it.
    • getSpatialIndex

      @Nonnull public VolumeSpatialIndex getSpatialIndex()
    • getDelayedEffectScheduler

      @Nonnull public DelayedEffectScheduler getDelayedEffectScheduler()
    • getNowNanos

      public long getNowNanos()
      The world alive time every volume timer is measured against: delays, intervals, cooldowns and animation gates. This is TimeResource as nanoseconds, so it stops while the world is paused and follows the world time dilation modifier. Volume expiry reads the same resource.

      The value is stamped once per tick, so every timer compared within a tick sees the same instant.

    • stampClock

      public long stampClock(@Nonnull Instant now)
      Stamps the clock for this tick and returns the value. Called by TriggerVolumeTickingSystem before anything reads the clock.
    • setWorld

      public void setWorld(@Nullable World world)
    • getWorld

      @Nullable public World getWorld()
    • registerGroup

      public void registerGroup(@Nonnull String id, @Nonnull GroupEntry entry)
    • makeUniqueVolumeName

      @Nonnull public String makeUniqueVolumeName(@Nullable String desired, @Nullable String excludeId)
      Resolves a unique display name for a volume from the user-supplied desired value: a blank value yields a fresh default name, and a value already used by another volume is disambiguated with the smallest numeric suffix (e.g. Door, Door (2), Door (3)). excludeId is the volume being renamed, so keeping its own name is a no-op.
    • makeUniqueGroupName

      @Nonnull public String makeUniqueGroupName(@Nullable String desired, @Nullable String excludeId)
      Group counterpart of makeUniqueVolumeName(String, String); disambiguates among group display names.
    • unregisterGroup

      public void unregisterGroup(@Nonnull String id)
    • getGroup

      @Nullable public GroupEntry getGroup(@Nonnull String id)
    • hasGroup

      public boolean hasGroup(@Nonnull String id)
    • clearPrefabGroupLinkRemap

      public void clearPrefabGroupLinkRemap()
    • ensureGroupForPrefabLink

      @Nonnull public String ensureGroupForPrefabLink(@Nonnull String groupLinkId, @Nonnull VolumeEntry memberVolume, @Nonnull String worldName)
      Returns a new world group id for this prefab link id, creating GroupEntry on first use.
    • upsertGroupForPrefabLink

      @Nonnull public String upsertGroupForPrefabLink(@Nonnull String groupLinkId, @Nonnull TriggerVolumeGroup groupComponent, @Nonnull String worldName, @Nonnull org.joml.Vector3d origin, float yawRadians)
    • ensureWorldGenGroup

      @Nullable public String ensureWorldGenGroup(int prefabInstanceId, @Nonnull String linkId, @Nonnull VolumeEntry memberVolume, @Nonnull String worldName)
      Returns a deterministic world group id for a world-gen-placed volume keyed by (prefabInstanceId, linkId). Created on first call; subsequent calls (e.g. from the same prefab spanning multiple chunks) find and reuse it. Unlike ensureGroupForPrefabLink(String, VolumeEntry, String) this keeps no remap state on the manager: the id is recoverable from its inputs, and groups is the only source of truth.
      Returns:
      the resolved group id, or null if linkId sanitizes to empty (caller should skip group assignment).
    • upsertWorldGenGroup

      @Nullable public String upsertWorldGenGroup(int prefabInstanceId, @Nonnull String linkId, @Nonnull TriggerVolumeGroup groupComponent, @Nonnull String worldName, @Nonnull org.joml.Vector3d origin, float yawRadians)
    • generateUniqueVolumeId

      @Nonnull public String generateUniqueVolumeId()
      Generates a unique volume id using the tv_ prefix; loops until hasVolume(String) returns false. Shared by all paths that programmatically register volumes (BuilderTools paste, world-generation prefab placement).
    • getGroupsMap

      @Nonnull public Map<String, GroupEntry> getGroupsMap()
    • getGroupMembers

      @Nonnull public List<VolumeEntry> getGroupMembers(@Nonnull String groupId)
    • getVolumesByTag

      @Nonnull public List<VolumeEntry> getVolumesByTag(int tagIndex)
    • getGroupsByTag

      @Nonnull public List<GroupEntry> getGroupsByTag(int tagIndex)
    • setTag

      public boolean setTag(@Nonnull String volumeId, @Nonnull String key, @Nullable String value, @Nullable Ref<EntityStore> actorRef, @Nonnull UUID actorUuid)
    • removeTag

      public boolean removeTag(@Nonnull String volumeId, @Nonnull String key, @Nullable Ref<EntityStore> actorRef, @Nonnull UUID actorUuid)
    • removeTag

      public boolean removeTag(@Nonnull String volumeId, @Nonnull String key, @Nullable String value, @Nullable Ref<EntityStore> actorRef, @Nonnull UUID actorUuid)
    • enqueueBlockEvent

      public void enqueueBlockEvent(@Nonnull TriggerEventType eventType, @Nonnull Ref<EntityStore> actorRef, @Nonnull UUID actorUuid, @Nonnull org.joml.Vector3d blockPosition, @Nonnull String blockId)
    • enqueueBlockEvent

      public void enqueueBlockEvent(@Nonnull TriggerEventType eventType, @Nonnull Ref<EntityStore> actorRef, @Nonnull UUID actorUuid, @Nonnull org.joml.Vector3d blockPosition, @Nonnull String blockId, @Nullable InteractionType interactionType)
    • enqueueEntityUseEvent

      public void enqueueEntityUseEvent(@Nonnull Ref<EntityStore> actorRef, @Nonnull UUID actorUuid, @Nonnull org.joml.Vector3d position, @Nullable String blockId, @Nullable InteractionType interactionType)
      Enqueues a TriggerEventType.BLOCK_USED event for an entity interaction (pressing use on an entity rather than a block), dispatched positionally to volumes containing the entity. blockId carries the entity's type id when one is cheaply available (e.g. an item entity's item id) and is null otherwise, so a block-type condition simply does not match for untyped entity uses.
    • enqueueEnvironmentBlockEvent

      public void enqueueEnvironmentBlockEvent(@Nonnull TriggerEventType eventType, @Nonnull org.joml.Vector3d blockPosition, @Nonnull String blockId)
      Enqueues a block event with no instigating entity (e.g. fire burning a block or an unattributed explosion). The cooldown bucket is keyed by ENVIRONMENT_ACTOR_UUID, so all environment breaks share one cooldown per volume, and effects that require a player actor no-op for these events.
    • enqueuePositionalEvent

      public void enqueuePositionalEvent(@Nonnull TriggerEventType eventType, @Nonnull Ref<EntityStore> actorRef, @Nonnull UUID actorUuid, @Nonnull org.joml.Vector3d position)
      Enqueues a positional event at an arbitrary world position (used by death events). The event is dispatched to every enabled volume whose shape contains the position, mirroring the block-event path but without a block id.
    • enqueueVolumeCreateEvent

      public void enqueueVolumeCreateEvent(@Nonnull VolumeEntry entry, @Nullable Ref<EntityStore> actorRef, @Nonnull UUID actorUuid)
      Enqueues a TriggerEventType.VOLUME_CREATE event scoped to the just-created volume. The actor is the entity that triggered creation when one exists (e.g. the player or shooter behind a spawn interaction); pass ENVIRONMENT_ACTOR_UUID with a null ref for unattributed creations such as world generation, in which case effects needing an actor no-op.
    • enqueueVolumeEvent

      public void enqueueVolumeEvent(@Nonnull TriggerEventType eventType, @Nonnull Ref<EntityStore> actorRef, @Nonnull UUID actorUuid, @Nonnull String volumeId, @Nullable String tagKey, @Nullable String tagValue)
    • enqueueVolumeEvent

      public void enqueueVolumeEvent(@Nonnull TriggerEventType eventType, @Nullable Ref<EntityStore> actorRef, @Nonnull UUID actorUuid, @Nonnull String volumeId, @Nonnull List<SignalTag> signalTags)
    • enqueueVolumeEvent

      public void enqueueVolumeEvent(@Nonnull TriggerEventType eventType, @Nullable Ref<EntityStore> actorRef, @Nonnull UUID actorUuid, @Nonnull String volumeId, @Nonnull List<SignalTag> signalTags, @Nullable org.joml.Vector3d blockPosition, @Nullable String blockId)
    • pollPendingEvent

      @Nullable public TriggerVolumeManager.PendingTriggerEvent pollPendingEvent()
    • hasPendingEvents

      public boolean hasPendingEvents()
    • isViewing

      public boolean isViewing(@Nonnull UUID playerUuid)
    • isViewing

      public boolean isViewing(@Nonnull UUID playerUuid, @Nonnull TriggerVolumeManager.ViewSource source)
    • peekViewerSources

      @Nullable public EnumSet<TriggerVolumeManager.ViewSource> peekViewerSources(@Nonnull UUID playerUuid)
    • addViewer

      public void addViewer(@Nonnull UUID playerUuid, @Nonnull TriggerVolumeManager.ViewSource source)
    • removeViewer

      public void removeViewer(@Nonnull UUID playerUuid, @Nonnull TriggerVolumeManager.ViewSource source)
    • setPlayerSelection

      public void setPlayerSelection(@Nonnull UUID playerUuid, @Nullable String volumeId)
    • getPlayerSelection

      @Nullable public String getPlayerSelection(@Nonnull UUID playerUuid)
    • setSelectionObserver

      public void setSelectionObserver(@Nonnull UUID playerUuid, @Nonnull TriggerVolumeManager.SelectionObserver observer)
    • clearSelectionObserver

      public void clearSelectionObserver(@Nonnull UUID playerUuid, @Nonnull TriggerVolumeManager.SelectionObserver observer)
    • setVolumeUpdateObserver

      public void setVolumeUpdateObserver(@Nonnull UUID playerUuid, @Nonnull TriggerVolumeManager.VolumeUpdateObserver observer)
    • clearVolumeUpdateObserver

      public void clearVolumeUpdateObserver(@Nonnull UUID playerUuid, @Nonnull TriggerVolumeManager.VolumeUpdateObserver observer)
    • notifyViewers

      public void notifyViewers()
    • getViewerCount

      public int getViewerCount()
    • getViewerUuids

      @Nonnull public Set<UUID> getViewerUuids()
    • clearViewers

      public void clearViewers()
    • notifyViewersAdd

      public void notifyViewersAdd(@Nonnull VolumeEntry vol)
    • notifyViewersRemove

      public void notifyViewersRemove(@Nonnull String volumeId)
    • notifyViewersLegacyVolumeSkipped

      public void notifyViewersLegacyVolumeSkipped()
    • sendVolumeDisplay

      public void sendVolumeDisplay(@Nonnull PlayerRef playerRef)
    • buildDisplayEntry

      @Nonnull public TriggerVolumeDisplayEntry buildDisplayEntry(@Nonnull VolumeEntry vol)
      Converts server-side volume geometry into the compact client debug-display packet shape. Box and cylinder entries use their center point for display, while unknown shapes fall back to a sphere based on the shape's display bounding radius.
    • markClientRuleVolumesDirty

      public void markClientRuleVolumesDirty()
      Marks the predicted rule-volume snapshot stale so it is re-broadcast on the next flush. Also marks the NoTick suppression snapshot stale, since the same volume/rule/group mutations that change predicted rule volumes can change which volumes suppress block ticking.
    • flushTickSuppressionIfDirty

      public void flushTickSuppressionIfDirty(@Nonnull TickSuppressionRegistry registry)
      Rebuilds the NoTick suppression snapshot into the world's registry once if it changed.
    • flushClientRuleVolumesIfDirty

      public void flushClientRuleVolumesIfDirty()
      Broadcasts a fresh snapshot to all players once if it changed; called once per world tick.
    • broadcastClientRuleVolumes

      public void broadcastClientRuleVolumes()
    • sendClientRuleVolumes

      public void sendClientRuleVolumes(@Nonnull PlayerRef playerRef)
    • clone

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