Package org.geysermc.geyser.entity.type
Class Entity
java.lang.Object
org.geysermc.geyser.entity.type.Entity
- All Implemented Interfaces:
org.geysermc.geyser.api.entity.type.GeyserEntity
- Direct Known Subclasses:
AbstractArrowEntity,AreaEffectCloudEntity,BoatEntity,DisplayBaseEntity,EnderCrystalEntity,EnderDragonPartEntity,EnderEyeEntity,EvokerFangsEntity,ExpOrbEntity,FallingBlockEntity,FireworkEntity,HangingEntity,InteractionEntity,LeashKnotEntity,LightningEntity,LivingEntity,MinecartEntity,ThrowableEntity,TNTEntity
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BedrockEntityDefinitionprotected @Nullable Stringprotected booleanprotected final GeyserDirtyMetadataA container to store temporary metadata before it's sent to Bedrock.protected intThe entity flags for the Bedrock entity.protected final longprotected floatprotected EntityTypeDefinition<?>A container storing all current metadata for an entity.protected org.cloudburstmc.math.vector.Vector3fprotected StringDo not call this setter directly! This will bypass the scoreboard and setting the metadataprotected floatprotected booleanSaves if the entity should be on the ground.protected floatprotected final @Nullable GeyserEntityPropertyManagerprotected floatprotected final GeyserSessionprotected booleanprotected UUIDprotected booleanIndicates if the entity has been initialized and spawnedprotected Entityprotected floatx = Yaw, y = Pitch, z = HeadYaw Java: Y = Yaw, X = Pitch -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAdditionalSpawnData(org.cloudburstmc.protocol.bedrock.packet.AddEntityPacket addEntityPacket) To be overridden in other entity classes, if additional things need to be done to the spawn entity packet.protected voidbedrockDefinition(BedrockEntityDefinition bedrockDefinition) org.cloudburstmc.math.vector.Vector3f@NonNull org.geysermc.geyser.api.entity.definition.GeyserEntityDefinitionvoidDespawns the entitybooleanIf true, the entity can be dismounted by pressing jump.org.cloudburstmc.math.vector.Vector3fx = Pitch, y = Yaw, z = HeadYawfloatfloatA container to store temporary metadata before it's sent to Bedrock.@Nullable StringgetDisplayName(boolean includeStandardName) intfinal booleangetFlag(org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag flag) floatprotected shortA container storing all current metadata for an entity.org.cloudburstmc.math.vector.Vector3fDo not call this setter directly! This will bypass the scoreboard and setting the metadatafloatfloatgetPitch()org.cloudburstmc.math.vector.Vector3fThe entity position as it is known to the Java server@Nullable GeyserEntityPropertyManagerfloatgetScale()floatgetYaw()x = Yaw, y = Pitch, z = HeadYaw Java: Y = Yaw, X = PitchlonggeyserId()booleanprotected voidCalled on entity spawn.interact(org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand hand) Simulates interacting with an entity.interactAt(org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand hand) Simulates interacting with this entity at a specific click point.booleanisAlive()booleanbooleanSaves if the entity should be on the ground.protected booleanIf true, the entity should be shaking on the client's end.booleanisSilent()booleanisValid()Indicates if the entity has been initialized and spawnedintjavaId()voidmoveAbsolute(org.cloudburstmc.math.vector.Vector3f javaPosition, float yaw, float pitch, boolean isOnGround, boolean teleported) voidmoveAbsolute(org.cloudburstmc.math.vector.Vector3f javaPosition, float yaw, float pitch, float headYaw, boolean isOnGround, boolean teleported) voidmoveAbsoluteRaw(org.cloudburstmc.math.vector.Vector3f javaPosition, float yaw, float pitch, float headYaw, boolean isOnGround, boolean teleported) voidmoveRelative(double relX, double relY, double relZ, float yaw, float pitch, float headYaw, boolean isOnGround) voidmoveRelativeRaw(double relX, double relY, double relZ, float yaw, float pitch, float headYaw, boolean isOnGround) voidoffset(float offset, boolean teleport) final voidplayEntityEvent(org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType type) Send an entity event of the specified type to the Bedrock player from this entity.final voidplayEntityEvent(org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType type, int data) Send an entity event of the specified type with the specified data to the Bedrock player from this entity.@NonNull org.cloudburstmc.math.vector.Vector3fposition()protected voidscoreVisibility(boolean show) final voidsetAir(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata entityMetadata) Set an int from 0 - this entity's maximum air - (air / maxAir) represents the percentage of bubbles leftprotected voidsetAirSupply(int amount) booleansetBoundingBoxHeight(float height) voidsetBoundingBoxWidth(float width) protected voidvoidsetCustomBoundingBoxHeight(float height) voidsetCustomBoundingBoxWidth(float width) voidsetCustomName(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata<Optional<net.kyori.adventure.text.Component>, ?> entityMetadata) voidsetCustomNameVisible(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata) protected voidsetDimensionsFromPose(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose pose) Set the height and width of the entity's bounding boxvoidsetEntityId(int entityId) final voidsetFlag(org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag flag, boolean value) Updates a flag value and determines if the flags would need synced with the Bedrock client.voidsetFlags(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata entityMetadata) protected voidsetFlagsDirty(boolean flagsDirty) Indicates if flags have been updated and need to be sent to the client.floatsetFreezing(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata entityMetadata) Set a float from 0-1 - how strong the "frozen" overlay should be on screen.protected voidsetGliding(boolean value) Set a boolean - whether the entity is glidingvoidsetGravity(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata) voidsetHeadYaw(float headYaw) protected voidsetInvisible(boolean value) Set a boolean - whether the entity is invisible or visiblevoidsetJavaTypeDefinition(EntityTypeDefinition<?> javaTypeDefinition) voidsetMotion(org.cloudburstmc.math.vector.Vector3f motion) protected voidsetNameEntityData(String nametag) protected voidsetNametag(@Nullable String nametag, boolean applyTeamStyling) voidsetNametagAlwaysShow(boolean value) voidsetOffset(float offset) voidsetOnGround(boolean onGround) Saves if the entity should be on the ground.voidsetPassengers(List<Entity> passengers) voidsetPitch(float pitch) voidsetPose(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose pose) Usually used for bounding box and not animation.voidsetPosition(org.cloudburstmc.math.vector.Vector3f position) The entity position as it is known to the Java servervoidsetRiderSeatPosition(org.cloudburstmc.math.vector.Vector3f position) voidsetScale(float scale) final voidsetSilent(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata) protected voidsetSneaking(boolean value) protected voidsetSprinting(boolean value) voidsetValid(boolean valid) Indicates if the entity has been initialized and spawnedvoidsetVehicle(Entity vehicle) voidsetYaw(float yaw) x = Yaw, y = Pitch, z = HeadYaw Java: Y = Yaw, X = Pitchvoidprotected Stringvoidteleport(org.cloudburstmc.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround) Teleports an entity to a new location.protected InteractiveTagtestInteraction(org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand hand) Test interacting with the given hand to see if we should send a tag to the Bedrock client.<T> voidupdate(@NonNull org.geysermc.geyser.api.entity.data.GeyserEntityDataType<T> dataType, @Nullable T value) voidSends the Bedrock entity properties to the clientvoidSends the Bedrock metadata to the clientvoidupdateHeadLookRotation(float headYaw) Updates an entity's head position.final voidUpdate the suggestion that the client currently has on their screen for this entity (for example, "Feed" or "Ride")protected voidUpdate this entity's mount offsetvoidupdateNametag(@Nullable Team team) protected voidupdateNametag(@Nullable Team team, boolean visible) protected voidUpdate the mount offsets of each passenger on this vehiclevoidupdatePositionAndRotation(double moveX, double moveY, double moveZ, float yaw, float pitch, boolean isOnGround) Updates an entity's position and rotation.voidupdatePropertiesBatched(Consumer<org.geysermc.geyser.api.entity.property.BatchPropertyUpdater> consumer, boolean immediate) voidupdateRotation(float yaw, float pitch, boolean isOnGround) Updates an entity's rotation.uuid()<T> Tvalue(@NonNull org.geysermc.geyser.api.entity.data.GeyserEntityDataType<T> dataType) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.geysermc.geyser.api.entity.type.GeyserEntity
updatePropertiesBatched, updateProperty
-
Field Details
-
session
-
bedrockDefinition
-
javaTypeDefinition
-
entityId
protected int entityId -
geyserId
protected final long geyserId -
uuid
-
nametag
Do not call this setter directly! This will bypass the scoreboard and setting the metadata -
customNameVisible
protected boolean customNameVisible -
motion
protected org.cloudburstmc.math.vector.Vector3f motion -
yaw
protected float yawx = Yaw, y = Pitch, z = HeadYaw Java: Y = Yaw, X = Pitch -
pitch
protected float pitch -
headYaw
protected float headYaw -
onGround
protected boolean onGroundSaves if the entity should be on the ground. Otherwise entities like parrots are flapping when rotating -
valid
protected boolean validIndicates if the entity has been initialized and spawned -
customName
-
silent
protected boolean silent -
passengers
-
vehicle
-
dirtyMetadata
A container to store temporary metadata before it's sent to Bedrock. -
metadata
protected final Map<org.cloudburstmc.protocol.bedrock.data.entity.EntityDataType<?>,Object> metadataA container storing all current metadata for an entity. -
flags
The entity flags for the Bedrock entity. These must always be saved - if flags are updated and the other values aren't present, the Bedrock client will think they are set to false. -
offset
protected float offset -
scale
protected float scale -
propertyManager
-
-
Constructor Details
-
Entity
-
-
Method Details
-
initializeMetadata
protected void initializeMetadata()Called on entity spawn. Used to populate the entity metadata and flags with default values. -
setClientSideSilent
protected void setClientSideSilent() -
spawnEntity
public void spawnEntity() -
addAdditionalSpawnData
public void addAdditionalSpawnData(org.cloudburstmc.protocol.bedrock.packet.AddEntityPacket addEntityPacket) To be overridden in other entity classes, if additional things need to be done to the spawn entity packet. -
despawnEntity
public void despawnEntity()Despawns the entity -
moveRelative
public void moveRelative(double relX, double relY, double relZ, float yaw, float pitch, float headYaw, boolean isOnGround) -
moveRelativeRaw
public void moveRelativeRaw(double relX, double relY, double relZ, float yaw, float pitch, float headYaw, boolean isOnGround) -
moveAbsolute
public void moveAbsolute(org.cloudburstmc.math.vector.Vector3f javaPosition, float yaw, float pitch, boolean isOnGround, boolean teleported) -
moveAbsolute
public void moveAbsolute(org.cloudburstmc.math.vector.Vector3f javaPosition, float yaw, float pitch, float headYaw, boolean isOnGround, boolean teleported) -
moveAbsoluteRaw
public void moveAbsoluteRaw(org.cloudburstmc.math.vector.Vector3f javaPosition, float yaw, float pitch, float headYaw, boolean isOnGround, boolean teleported) -
teleport
public void teleport(org.cloudburstmc.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround) Teleports an entity to a new location. Used in JavaTeleportEntityTranslator.- Parameters:
position- The new position of the entity.yaw- The new yaw of the entity.pitch- The new pitch of the entity.isOnGround- Whether the entity is currently on the ground.
-
updateHeadLookRotation
public void updateHeadLookRotation(float headYaw) Updates an entity's head position. Used in JavaRotateHeadTranslator.- Parameters:
headYaw- The new head rotation of the entity.
-
updatePositionAndRotation
public void updatePositionAndRotation(double moveX, double moveY, double moveZ, float yaw, float pitch, boolean isOnGround) Updates an entity's position and rotation. Used in JavaMoveEntityPosRotTranslator.- Parameters:
moveX- The new X offset of the current position.moveY- The new Y offset of the current position.moveZ- The new Z offset of the current position.yaw- The new yaw of the entity.pitch- The new pitch of the entity.isOnGround- Whether the entity is currently on the ground.
-
updateRotation
public void updateRotation(float yaw, float pitch, boolean isOnGround) Updates an entity's rotation. Used in JavaMoveEntityRotTranslator.- Parameters:
yaw- The new yaw of the entity.pitch- The new pitch of the entity.isOnGround- Whether the entity is currently on the ground.
-
getFlag
public final boolean getFlag(org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag flag) -
setFlag
public final void setFlag(org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag flag, boolean value) Updates a flag value and determines if the flags would need synced with the Bedrock client. -
updateBedrockMetadata
public void updateBedrockMetadata()Sends the Bedrock metadata to the client -
updateBedrockEntityProperties
public void updateBedrockEntityProperties()Sends the Bedrock entity properties to the client -
setFlags
public void setFlags(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata entityMetadata) -
setInvisible
protected void setInvisible(boolean value) Set a boolean - whether the entity is invisible or visible- Parameters:
value- true if the entity is invisible
-
setGliding
protected void setGliding(boolean value) Set a boolean - whether the entity is gliding -
setSprinting
protected void setSprinting(boolean value) -
setSneaking
protected void setSneaking(boolean value) -
setAir
public final void setAir(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata entityMetadata) Set an int from 0 - this entity's maximum air - (air / maxAir) represents the percentage of bubbles left -
setAirSupply
protected void setAirSupply(int amount) -
getMaxAir
protected short getMaxAir() -
teamIdentifier
-
setCustomName
public void setCustomName(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata<Optional<net.kyori.adventure.text.Component>, ?> entityMetadata) -
standardDisplayName
-
setNametag
-
setNameEntityData
-
updateNametag
-
updateNametag
-
scoreVisibility
protected void scoreVisibility(boolean show) -
getDisplayName
-
setCustomNameVisible
public void setCustomNameVisible(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata) -
setNametagAlwaysShow
public void setNametagAlwaysShow(boolean value) -
setSilent
public final void setSilent(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata) -
setGravity
public void setGravity(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata) -
setPose
public void setPose(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose pose) Usually used for bounding box and not animation. -
setDimensionsFromPose
protected void setDimensionsFromPose(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose pose) Set the height and width of the entity's bounding box -
setBoundingBoxHeight
public boolean setBoundingBoxHeight(float height) -
setBoundingBoxWidth
public void setBoundingBoxWidth(float width) -
getBoundingBoxHeight
public float getBoundingBoxHeight() -
getBoundingBoxWidth
public float getBoundingBoxWidth() -
setCustomBoundingBoxWidth
public void setCustomBoundingBoxWidth(float width) -
setCustomBoundingBoxHeight
public void setCustomBoundingBoxHeight(float height) -
setScale
public void setScale(float scale) -
applyScale
protected void applyScale() -
setFreezing
public float setFreezing(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata entityMetadata) Set a float from 0-1 - how strong the "frozen" overlay should be on screen. -
setRiderSeatPosition
public void setRiderSeatPosition(org.cloudburstmc.math.vector.Vector3f position) -
isShaking
protected boolean isShaking()If true, the entity should be shaking on the client's end.- Returns:
- whether
EntityFlag.SHAKINGshould be set to true.
-
doesJumpDismount
public boolean doesJumpDismount()If true, the entity can be dismounted by pressing jump.- Returns:
- whether the entity can be dismounted when pressing jump.
-
getBedrockRotation
public org.cloudburstmc.math.vector.Vector3f getBedrockRotation()x = Pitch, y = Yaw, z = HeadYaw- Returns:
- the bedrock rotation
-
updatePassengerOffsets
protected void updatePassengerOffsets()Update the mount offsets of each passenger on this vehicle -
updateMountOffset
protected void updateMountOffset()Update this entity's mount offset -
javaId
public int javaId()- Specified by:
javaIdin interfaceorg.geysermc.geyser.api.entity.type.GeyserEntity
-
isAlive
public boolean isAlive() -
bedrockPosition
public org.cloudburstmc.math.vector.Vector3f bedrockPosition() -
updateInteractiveTag
public final void updateInteractiveTag()Update the suggestion that the client currently has on their screen for this entity (for example, "Feed" or "Ride") -
testInteraction
protected InteractiveTag testInteraction(org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand hand) Test interacting with the given hand to see if we should send a tag to the Bedrock client. Should usually mirrorinteract(Hand)without any side effects. -
interact
public InteractionResult interact(org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand hand) Simulates interacting with an entity. The code here should mirror Java Edition code to the best of its ability, to ensure packet parity as well as functionality parity (such as sound effect responses). -
hasLeashesToDrop
public boolean hasLeashesToDrop() -
interactAt
public InteractionResult interactAt(org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand hand) Simulates interacting with this entity at a specific click point. As of Java Edition 1.18.1, this is only used for armor stands. -
playEntityEvent
public final void playEntityEvent(org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType type) Send an entity event of the specified type to the Bedrock player from this entity. -
playEntityEvent
public final void playEntityEvent(org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType type, int data) Send an entity event of the specified type with the specified data to the Bedrock player from this entity. -
updatePropertiesBatched
public void updatePropertiesBatched(Consumer<org.geysermc.geyser.api.entity.property.BatchPropertyUpdater> consumer, boolean immediate) - Specified by:
updatePropertiesBatchedin interfaceorg.geysermc.geyser.api.entity.type.GeyserEntity
-
offset
public void offset(float offset, boolean teleport) -
definition
public @NonNull org.geysermc.geyser.api.entity.definition.GeyserEntityDefinition definition()- Specified by:
definitionin interfaceorg.geysermc.geyser.api.entity.type.GeyserEntity
-
position
public @NonNull org.cloudburstmc.math.vector.Vector3f position()- Specified by:
positionin interfaceorg.geysermc.geyser.api.entity.type.GeyserEntity
-
update
public <T> void update(@NonNull org.geysermc.geyser.api.entity.data.GeyserEntityDataType<T> dataType, @Nullable T value) - Specified by:
updatein interfaceorg.geysermc.geyser.api.entity.type.GeyserEntity
-
value
public <T> T value(@NonNull org.geysermc.geyser.api.entity.data.GeyserEntityDataType<T> dataType) - Specified by:
valuein interfaceorg.geysermc.geyser.api.entity.type.GeyserEntity
-
getSession
-
bedrockDefinition
-
getJavaTypeDefinition
-
getEntityId
public int getEntityId() -
geyserId
public long geyserId()- Specified by:
geyserIdin interfaceorg.geysermc.geyser.api.entity.type.GeyserEntity
-
uuid
- Specified by:
uuidin interfaceorg.geysermc.geyser.api.entity.type.GeyserEntity
-
getNametag
Do not call this setter directly! This will bypass the scoreboard and setting the metadata -
isCustomNameVisible
public boolean isCustomNameVisible() -
getPosition
public org.cloudburstmc.math.vector.Vector3f getPosition()The entity position as it is known to the Java server -
getMotion
public org.cloudburstmc.math.vector.Vector3f getMotion() -
getYaw
public float getYaw()x = Yaw, y = Pitch, z = HeadYaw Java: Y = Yaw, X = Pitch -
getPitch
public float getPitch() -
getHeadYaw
public float getHeadYaw() -
isOnGround
public boolean isOnGround()Saves if the entity should be on the ground. Otherwise entities like parrots are flapping when rotating -
isValid
public boolean isValid()Indicates if the entity has been initialized and spawned -
isSilent
public boolean isSilent() -
getCustomBoundingBoxHeight
-
getCustomBoundingBoxWidth
-
getPassengers
-
getVehicle
-
getDirtyMetadata
A container to store temporary metadata before it's sent to Bedrock. -
getMetadata
A container storing all current metadata for an entity. -
getOffset
public float getOffset() -
getScale
public float getScale() -
getPropertyManager
-
bedrockDefinition
- Returns:
this.
-
setJavaTypeDefinition
-
setEntityId
public void setEntityId(int entityId) -
uuid
- Returns:
this.
-
setMotion
public void setMotion(org.cloudburstmc.math.vector.Vector3f motion) -
setYaw
public void setYaw(float yaw) x = Yaw, y = Pitch, z = HeadYaw Java: Y = Yaw, X = Pitch -
setPitch
public void setPitch(float pitch) -
setHeadYaw
public void setHeadYaw(float headYaw) -
setOnGround
public void setOnGround(boolean onGround) Saves if the entity should be on the ground. Otherwise entities like parrots are flapping when rotating -
setValid
public void setValid(boolean valid) Indicates if the entity has been initialized and spawned -
setPassengers
-
setVehicle
-
setOffset
public void setOffset(float offset) -
setPosition
public void setPosition(org.cloudburstmc.math.vector.Vector3f position) The entity position as it is known to the Java server -
setFlagsDirty
protected void setFlagsDirty(boolean flagsDirty) Indicates if flags have been updated and need to be sent to the client.
-