Package net.minecraftforge.event.entity
Class SpawnPlacementRegisterEvent
java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.entity.SpawnPlacementRegisterEvent
- All Implemented Interfaces:
IModBusEvent
public class SpawnPlacementRegisterEvent
extends net.minecraftforge.eventbus.api.Event
implements IModBusEvent
This event allows each
EntityType
to have a SpawnPlacements.SpawnPredicate
registered or modified.
Spawn Predicates are checked whenever an Entity
of the given EntityType
spawns in the world naturally.
If registering your own entity's spawn placements, you should use register(EntityType, SpawnPlacements.Type, Heightmap.Types, SpawnPlacements.SpawnPredicate, Operation)
So that you ensure that your entity has a heightmap type and placement type registered.
If modifying vanilla or another mod's spawn placements, you can use three operations:
REPLACE: checked first, the last mod to replace the predicate wipes out all other predicates. Listen with a low EventPriority
if you need to do this.
OR: checked second, only one of these predicates must pass along with the original predicate
AND: checked third, these predicates must all pass along with the original predicate
This event is not cancellable and does not have a result.
Fired on the Mod bus IModBusEvent
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static enum
Nested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Event
net.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Map
<EntityType<?>, SpawnPlacementRegisterEvent.MergedSpawnPredicate<?>> -
Constructor Summary
ConstructorDescriptionSpawnPlacementRegisterEvent
(Map<EntityType<?>, SpawnPlacementRegisterEvent.MergedSpawnPredicate<?>> map) -
Method Summary
Modifier and TypeMethodDescription<T extends Entity>
voidregister
(EntityType<T> entityType, SpawnPlacements.SpawnPredicate<T> predicate) Register an optional spawn placementpredicate
for a givenentityType
<T extends Entity>
voidregister
(EntityType<T> entityType, SpawnPlacements.SpawnPredicate<T> predicate, SpawnPlacementRegisterEvent.Operation operation) Register apredicate
for a givenentityType
with a givenoperation
for handling<T extends Entity>
voidregister
(EntityType<T> entityType, SpawnPlacementType placementType, Heightmap.Types heightmap, SpawnPlacements.SpawnPredicate<T> predicate, SpawnPlacementRegisterEvent.Operation operation) Register apredicate
for a givenentityType
andoperation
With the option of changing theplacementType
andheightmap
.Methods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult
-
Field Details
-
map
-
-
Constructor Details
-
SpawnPlacementRegisterEvent
@Internal public SpawnPlacementRegisterEvent(Map<EntityType<?>, SpawnPlacementRegisterEvent.MergedSpawnPredicate<?>> map)
-
-
Method Details
-
register
public <T extends Entity> void register(EntityType<T> entityType, SpawnPlacements.SpawnPredicate<T> predicate) Register an optional spawn placementpredicate
for a givenentityType
-
register
public <T extends Entity> void register(EntityType<T> entityType, SpawnPlacements.SpawnPredicate<T> predicate, SpawnPlacementRegisterEvent.Operation operation) Register apredicate
for a givenentityType
with a givenoperation
for handling -
register
public <T extends Entity> void register(EntityType<T> entityType, @Nullable SpawnPlacementType placementType, @Nullable Heightmap.Types heightmap, SpawnPlacements.SpawnPredicate<T> predicate, SpawnPlacementRegisterEvent.Operation operation) Register apredicate
for a givenentityType
andoperation
With the option of changing theplacementType
andheightmap
. These are only applied ifSpawnPlacementRegisterEvent.Operation.REPLACE
is used. Usenull
for the placement or heightmap to leave them as is (which should be done in almost every case)
-