Class SessionSpawnEntityEvent
java.lang.Object
org.geysermc.geyser.api.event.connection.ConnectionEvent
org.geysermc.geyser.api.event.bedrock.SessionSpawnEntityEvent
- All Implemented Interfaces:
org.geysermc.event.Cancellable,org.geysermc.event.Event
- Direct Known Subclasses:
ServerAttachParrotsEvent,ServerSpawnEntityEvent
public abstract class SessionSpawnEntityEvent
extends ConnectionEvent
implements org.geysermc.event.Cancellable
Base event for entity spawning visible to a specific Bedrock connection.
Specific subtypes are
ServerSpawnEntityEvent (non-player entities) and
ServerAttachParrotsEvent (shoulder parrots).
The event is cancellable; cancelling it suppresses spawning the entity on the Bedrock client.
Setting the definition to
null has the same effect.
- Since:
- 2.11.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract @Nullable GeyserEntityDefinitionReturns the Bedrock entity definition that will be sent to the Bedrock client.abstract voiddefinition(@Nullable GeyserEntityDefinition definition) Overrides the Bedrock entity definition when spawning this entity on the Bedrock client.abstract voidpreSpawnConsumer(Consumer<GeyserEntity> consumer) Registers a callback that is invoked with theGeyserEntityinstance just before the entity is spawned.Methods inherited from class org.geysermc.geyser.api.event.connection.ConnectionEvent
connectionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.geysermc.event.Cancellable
isCancelled, setCancelled
-
Constructor Details
-
SessionSpawnEntityEvent
-
-
Method Details
-
definition
Returns the Bedrock entity definition that will be sent to the Bedrock client.- Returns:
- the entity definition, or
nullif none is currently set - Since:
- 2.11.0
-
definition
Overrides the Bedrock entity definition when spawning this entity on the Bedrock client.The supplied definition must have been previously registered in the
GeyserDefineEntitiesEvent; passing an unregistered definition will throwIllegalStateException. Passingnullcancels the spawn for this connection.- Parameters:
definition- the replacement entity definition, ornullto suppress the spawn- Throws:
IllegalStateException- if the provided definition has not been registered- Since:
- 2.11.0
-
preSpawnConsumer
Registers a callback that is invoked with theGeyserEntityinstance just before the entity is spawned. This means thatEntityData.byJavaId(int),EntityData.byUuid(java.util.UUID), and related lookups will not find the entity from within the consumer.Use this callback to apply initial overrides such as entity data values (scale, width, height, hitboxes) or entity properties before the spawn packet is sent to the client. If multiple consumers are registered, they run in the order they were added.
The consumer is not called if the event is cancelled.
- Parameters:
consumer- the callback receiving the freshly created entity- Since:
- 2.11.0
-