Class PrefabSpawner

java.lang.Object
com.hypixel.hytale.builtin.adventure.worldevents.condition.spawner.PrefabSpawner
All Implemented Interfaces:
Spawner

public class PrefabSpawner extends Object implements Spawner
  • Field Details

  • Constructor Details

  • Method Details

    • test

      public Spawner.Result test(@Nonnull World world, @Nonnull org.joml.Vector3ic position, @Nonnull Random random)
      Description copied from interface: Spawner
      Tests whether position is a valid placement site and records any state needed by Spawner.onComplete(Vector3ic, WorldEvent).

      This may be called up to several times per tick with different positions, so keep it cheap. If the test involves selecting from a random set (e.g. choosing a prefab), store the selection as a field rather than regenerating it in Spawner.onComplete(Vector3ic, WorldEvent).

      Check terrain validity using the static helpers on this interface. Reject the position (return false) if any required chunk is unloaded, i.e. if Spawner.findSurface(int, int, int, int, int, ChunkStore) returns Spawner.INVALID_HEIGHT.

      Specified by:
      test in interface Spawner
      Parameters:
      world - the world the position is in
      position - the candidate block position, with Y already set to the nearest qualifying surface
      random - a random source for any stochastic validation logic
      Returns:
      true if the position is acceptable
    • onComplete

      public boolean onComplete(@Nonnull org.joml.Vector3ic position, @Nonnull WorldEvent event)
      Description copied from interface: Spawner
      Called once when the owning stage completes, with the position that last returned true from Spawner.test(World, Vector3ic, Random). Write any context values that downstream actions will need into the event context here.
      Specified by:
      onComplete in interface Spawner
      Parameters:
      position - the accepted block position
      event - the running world event whose context should be populated
      Returns:
      false if the spawner cannot produce a valid result, treating the stage as failed