Class CompanionBlockSpawnerSupport

java.lang.Object
com.hypixel.hytale.builtin.companionblockspawner.CompanionBlockSpawnerSupport

public final class CompanionBlockSpawnerSupport extends Object
Creates and removes the spawn marker that owns a companion NPC for a CompanionBlockSpawnerRecipe.

The spawner block never touches the NPC directly: it places a spawn marker (from the recipe's referenced marker config) on a valid tile next to the spawner, and the existing spawn-marker systems handle spawning, respawning on death, despawn, and reload re-linking. Removing the marker despawns the companion. The marker position is found with a ring search using SpawningContext so the companion lands on real ground beside the (possibly multi-block) spawner, never on it.

All methods mutate the entity/chunk stores and must run on the world thread (via world.execute(...)).

  • Method Details

    • createMarker

      public static void createMarker(@Nonnull World world, @Nonnull org.joml.Vector3i spawnerPos, @Nonnull Ref<ChunkStore> spawnerRef, @Nonnull CompanionBlockSpawnerRecipe recipe)
      Creates a spawn marker for the recipe near spawnerPos and stores it on the spawner's CompanionBlockSpawnerBlock. Re-validates eligibility (the spawner may have changed since this was deferred) and is a no-op if a marker already exists.
    • removeMarker

      public static void removeMarker(@Nonnull World world, @Nonnull UUID markerUuid, @Nonnull String cause)
      Removes the spawn marker with the given UUID and despawns any companion NPC(s) it currently tracks (so the companion disappears immediately rather than waiting for its own lost-marker timeout). Any NPC the marker isn't tracking still despawns on its own once the marker is gone. No-ops if the marker entity is not loaded; the marker-side MarkerHeartbeat removes such orphans when their chunk next loads.
      Parameters:
      cause - short human-readable removal cause, logged so every marker lifecycle transition is traceable.