Package dev.polv.taleapi.event.entity
Interface EntitySpawnCallback
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Called when a non-player entity spawns in the world.
This event fires for mobs, NPCs, and other entities, but NOT for players.
For player spawning/joining, use PlayerJoinCallback instead.
This event is cancellable. If cancelled, the entity will not spawn.
Example Usage
EntitySpawnCallback.EVENT.register((entity, location) -> {
System.out.println("Entity spawned at " + location);
return EventResult.PASS;
});
// Prevent hostile mobs from spawning in a safe zone
EntitySpawnCallback.EVENT.register(EventPriority.HIGH, (entity, location) -> {
if (isHostile(entity) && isInSafeZone(location)) {
return EventResult.CANCEL;
}
return EventResult.PASS;
});
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiononEntitySpawn(TaleEntity entity, Location location) Called when an entity is about to spawn in the world.
-
Field Details
-
EVENT
The event instance. Use this to register listeners and fire the event.
-
-
Method Details
-
onEntitySpawn
Called when an entity is about to spawn in the world.- Parameters:
entity- the entity that is spawninglocation- the location where the entity will spawn- Returns:
- the event result -
EventResult.CANCELto prevent the spawn
-