Class PlayerSpawnPhantomsEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.EntityEvent
net.neoforged.neoforge.event.entity.living.LivingEvent
net.neoforged.neoforge.event.entity.player.PlayerEvent
net.neoforged.neoforge.event.entity.player.PlayerSpawnPhantomsEvent
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Controls if the spawn attempt for the group of phantoms will occur.Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.player.PlayerEvent
PlayerEvent.BreakSpeed, PlayerEvent.Clone, PlayerEvent.HarvestCheck, PlayerEvent.ItemCraftedEvent, PlayerEvent.ItemSmeltedEvent, PlayerEvent.LoadFromFile, PlayerEvent.NameFormat, PlayerEvent.PlayerChangedDimensionEvent, PlayerEvent.PlayerChangeGameModeEvent, PlayerEvent.PlayerLoggedInEvent, PlayerEvent.PlayerLoggedOutEvent, PlayerEvent.PlayerRespawnEvent, PlayerEvent.SaveToFile, PlayerEvent.StartTracking, PlayerEvent.StopTracking, PlayerEvent.TabListNameFormat
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingVisibilityEvent
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the result of this event, which controls if a spawn attempt will be made.void
setPhantomsToSpawn
(int phantomsToSpawn) Sets the number of phantoms to be spawned.void
Changes the result of this event, which controls if a spawn attempt will be made.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.Methods inherited from class net.neoforged.neoforge.event.entity.player.PlayerEvent
getEntity
-
Field Details
-
phantomsToSpawn
private int phantomsToSpawn -
result
-
-
Constructor Details
-
PlayerSpawnPhantomsEvent
-
-
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
Changes the result of this event, which controls if a spawn attempt will be made.- See Also:
-
getResult
Returns the result of this event, which controls if a spawn attempt will be made.- See Also:
-
shouldSpawnPhantoms
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'sStats.TIME_SINCE_REST
, as these are checked later.- Parameters:
level
- The level that phantoms are being spawned in (the same level as the player)pos
- The block position of the player- Returns:
- true if a spawn attempt should be made
-