类 PlayerSpawnPhantomsEvent


public class PlayerSpawnPhantomsEvent extends PlayerEvent
This event is fired from PhantomSpawner.tick(net.minecraft.server.level.ServerLevel, boolean, boolean) when phantoms would attempt to be spawned, with one event fired per player. It allows controlling if a spawn attempt will be made for the particular player, but cannot guarantee that a Phantom will be spawned.

This event is only fired on the logical server.

  • 字段详细资料

  • 构造器详细资料

    • PlayerSpawnPhantomsEvent

      public PlayerSpawnPhantomsEvent(Player player, int phantomsToSpawn)
  • 方法详细资料

    • getPhantomsToSpawn

      public int getPhantomsToSpawn()
      返回:
      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.
      参数:
      phantomsToSpawn - How many phantoms should spawn, given checks are passed.
    • setResult

      public void setResult(PlayerSpawnPhantomsEvent.Result result)
      Changes the result of this event, which controls if a spawn attempt will be made.
      另请参阅:
    • getResult

      public PlayerSpawnPhantomsEvent.Result getResult()
      Returns the result of this event, which controls if a spawn attempt will be made.
      另请参阅:
    • shouldSpawnPhantoms

      public boolean shouldSpawnPhantoms(ServerLevel level, BlockPos pos)
      Checks if a spawn attempt should be made by checking the current result and evaluating the vanilla conditions if necessary.

      Does not check DifficultyInstance.isHarderThan(float) or the player's Stats.TIME_SINCE_REST, as these are checked later.

      参数:
      level - The level that phantoms are being spawned in (the same level as the player)
      pos - The block position of the player
      返回:
      true if a spawn attempt should be made