Class PlayerSpawnPhantomsEvent

java.lang.Object
net.minecraftforge.eventbus.api.Event

public class PlayerSpawnPhantomsEvent extends PlayerEvent
This event is fired from PhantomSpawner.tick(net.minecraft.server.level.ServerLevel, boolean, boolean), once per player, when phantoms would attempt to be spawned.
This event is not fired for spectating players.

This event is fired before any per-player checks (but after Player.isSpectator()), but after all global checks.
The behavior of PhantomSpawner is determined by the result of this event.
See setResult(net.minecraftforge.eventbus.api.Event.Result) for documentation.

This event is fired on the MinecraftForge.EVENT_BUS.

See Also:
  • Field Details

    • phantomsToSpawn

      private int phantomsToSpawn
  • Constructor Details

    • PlayerSpawnPhantomsEvent

      public PlayerSpawnPhantomsEvent(Player player, int phantomsToSpawn)
  • Method Details

    • getPhantomsToSpawn

      public int getPhantomsToSpawn()
      Returns:
      How many phantoms will be spawned, if spawning is successful. The default value is randomly generated.
    • setPhantomsToSpawn

      public void setPhantomsToSpawn(int phantomsToSpawn)
      Sets the number of phantoms to be spawned.
      Parameters:
      phantomsToSpawn - How many phantoms should spawn, given checks are passed.
    • setResult

      public void setResult(@NotNull @NotNull net.minecraftforge.eventbus.api.Event.Result result)
      The result of this event controls if phantoms will be spawned.
      • If the result is Event.Result.ALLOW, phantoms will always be spawned;
      • If the result is Event.Result.DENY, phantoms will never be spawned;
      • If the result is Event.Result.DEFAULT, vanilla checks will be run to determine if the spawn may occur.
      Overrides:
      setResult in class net.minecraftforge.eventbus.api.Event