Package org.geysermc.geyser.entity.type
Class LivingEntity
java.lang.Object
org.geysermc.geyser.entity.type.Entity
org.geysermc.geyser.entity.type.LivingEntity
- All Implemented Interfaces:
org.geysermc.geyser.api.entity.type.GeyserEntity,Tickable
- Direct Known Subclasses:
ArmorStandEntity,AvatarEntity,MobEntity
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected booleanprotected EnumMap<org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot,GeyserItemStack> protected floatprotected floatFields inherited from class org.geysermc.geyser.entity.type.Entity
definition, dirtyMetadata, displayName, entityId, flags, geyserId, headYaw, motion, nametag, onGround, passengers, pitch, position, propertyManager, session, silent, uuid, valid, vehicle, yaw -
Constructor Summary
ConstructorsConstructorDescriptionLivingEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, org.cloudburstmc.math.vector.Vector3f position, org.cloudburstmc.math.vector.Vector3f motion, float yaw, float pitch, float headYaw) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.cloudburstmc.protocol.bedrock.data.AttributeDatacalculateAttribute(org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.Attribute javaAttribute, GeyserAttributeType type) Calculates the complete attribute value to send to Bedrock.protected booleancanUseSlot(org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot slot) protected final InteractionResultcheckInteractWithNameTag(GeyserItemStack itemStack) Checks to see if a nametag interaction would go through.protected org.cloudburstmc.protocol.bedrock.data.AttributeDataEnumMap<org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot,GeyserItemStack> getItemInSlot(org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot slot) org.cloudburstmc.math.vector.Vector3fintprotected booleanprotected booleanhasShield(boolean offhand) protected voidCalled on entity spawn.interact(org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand hand) Simulates interacting with an entity.booleanisAlive()booleanbooleanbooleanfinal booleanisEquippableInSlot(GeyserItemStack item, org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot var2) booleanbooleanA convenience variable for if the entity has reached the maximum frozen ticks and should be shakingprotected booleanIf true, the entity should be shaking on the client's end.voidmoveAbsolute(org.cloudburstmc.math.vector.Vector3f position, 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) @Nullable org.cloudburstmc.math.vector.Vector3isetBedPosition(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata<Optional<org.cloudburstmc.math.vector.Vector3i>, ?> entityMetadata) voidsetBody(GeyserItemStack stack) voidsetBoots(GeyserItemStack stack) booleansetBoundingBoxHeight(float height) voidsetBoundingBoxWidth(float width) voidsetChestplate(GeyserItemStack stack) protected voidsetDimensionsFromPose(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose pose) Set the height and width of the entity's bounding boxvoidsetDirtyHeadYaw(boolean dirtyHeadYaw) voidsetDirtyPitch(boolean dirtyPitch) voidsetDirtyYaw(boolean dirtyYaw) voidsetEquipment(EnumMap<org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot, GeyserItemStack> equipment) 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.voidsetHand(GeyserItemStack stack) voidsetHealth(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.FloatEntityMetadata entityMetadata) voidsetHelmet(GeyserItemStack stack) voidsetLeggings(GeyserItemStack stack) voidsetLerpPosition(org.cloudburstmc.math.vector.Vector3f lerpPosition) voidsetLerpSteps(int lerpSteps) voidsetLivingEntityFlags(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata entityMetadata) voidsetMaxFrozenState(boolean isMaxFrozenState) A convenience variable for if the entity has reached the maximum frozen ticks and should be shakingvoidsetMaxHealth(float maxHealth) voidsetOffhand(GeyserItemStack stack) voidsetParticles(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata<List<org.geysermc.mcprotocollib.protocol.data.game.level.particle.Particle>> entityMetadata) voidsetPosition(org.cloudburstmc.math.vector.Vector3f position) voidsetSaddle(GeyserItemStack stack) protected voidsetScale(float scale) protected voidsetSpinAttack(boolean value) booleanvoidvoidtick()This function gets called every game tick as long as the game tick loop isn't frozen.voidprotected voidupdateAttribute(org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.Attribute javaAttribute, List<org.cloudburstmc.protocol.bedrock.data.AttributeData> newAttributes) Takes the Java attribute and adds it to newAttributes as a Bedrock-formatted attributevoidupdateBedrockAttributes(GeyserSession session, List<org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.Attribute> attributes) Attributes are properties of an entity that are generally more runtime-based instead of permanent properties.voidvoidupdateNametag(@Nullable Team team) voidprotected voidupdateSaddled(boolean saddled) booleanCalled when a SWING_ARM animation packet is receivedMethods inherited from class org.geysermc.geyser.entity.type.Entity
addAdditionalSpawnData, despawnEntity, doesJumpDismount, getBedrockRotation, getBoundingBoxHeight, getBoundingBoxWidth, getDefinition, getDirtyMetadata, getDisplayName, getEntityId, getFlag, getGeyserId, getHeadYaw, getMaxAir, getMotion, getNametag, getPassengers, getPitch, getPosition, getPropertyManager, getSession, getUuid, getVehicle, getYaw, hasLeashesToDrop, interactAt, isOnGround, isSilent, isValid, javaId, moveAbsolute, moveAbsoluteRaw, moveRelativeRaw, playEntityEvent, playEntityEvent, scoreVisibility, setAir, setAirSupply, setClientSideSilent, setDefinition, setDisplayName, setDisplayNameVisible, setEntityId, setFlag, setFlags, setFlagsDirty, setGliding, setGravity, setHeadYaw, setInvisible, setMotion, setNametag, setOnGround, setPassengers, setPitch, setPose, setRiderSeatPosition, setSilent, setSneaking, setSprinting, setUuid, setValid, setVehicle, setYaw, spawnEntity, standardDisplayName, teamIdentifier, teleport, testInteraction, updateBedrockEntityProperties, updateBedrockMetadata, updateHeadLookRotation, updateInteractiveTag, updateMountOffset, updateNametag, updatePassengerOffsets, updatePositionAndRotation, updatePropertiesBatched, updateRotationMethods 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
-
equipment
protected EnumMap<org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot,GeyserItemStack> equipment -
health
protected float health -
maxHealth
protected float maxHealth -
dirtyYaw
protected boolean dirtyYaw -
dirtyHeadYaw
protected boolean dirtyHeadYaw -
dirtyPitch
protected boolean dirtyPitch
-
-
Constructor Details
-
LivingEntity
public LivingEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, org.cloudburstmc.math.vector.Vector3f position, org.cloudburstmc.math.vector.Vector3f motion, float yaw, float pitch, float headYaw)
-
-
Method Details
-
getItemInSlot
public GeyserItemStack getItemInSlot(org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot slot) -
getMainHandItem
-
getOffHandItem
-
isHolding
-
setHelmet
-
setChestplate
-
setLeggings
-
setBoots
-
setBody
-
setSaddle
-
setHand
-
setOffhand
-
updateSaddled
protected void updateSaddled(boolean saddled) -
switchHands
public void switchHands() -
initializeMetadata
protected void initializeMetadata()Description copied from class:EntityCalled on entity spawn. Used to populate the entity metadata and flags with default values.- Overrides:
initializeMetadatain classEntity
-
updateNametag
- Overrides:
updateNametagin classEntity
-
setLivingEntityFlags
public void setLivingEntityFlags(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata entityMetadata) -
setSpinAttack
protected void setSpinAttack(boolean value) -
setHealth
public void setHealth(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.FloatEntityMetadata entityMetadata) -
setParticles
public void setParticles(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata<List<org.geysermc.mcprotocollib.protocol.data.game.level.particle.Particle>> entityMetadata) -
setBedPosition
public @Nullable org.cloudburstmc.math.vector.Vector3i setBedPosition(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata<Optional<org.cloudburstmc.math.vector.Vector3i>, ?> entityMetadata) -
hasShield
protected boolean hasShield(boolean offhand) -
isShaking
protected boolean isShaking()Description copied from class:EntityIf true, the entity should be shaking on the client's end. -
setDimensionsFromPose
protected void setDimensionsFromPose(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose pose) Description copied from class:EntitySet the height and width of the entity's bounding box- Overrides:
setDimensionsFromPosein classEntity
-
setFreezing
public float setFreezing(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata entityMetadata) Description copied from class:EntitySet a float from 0-1 - how strong the "frozen" overlay should be on screen.- Overrides:
setFreezingin classEntity
-
setScale
protected void setScale(float scale) -
createHealthAttribute
protected org.cloudburstmc.protocol.bedrock.data.AttributeData createHealthAttribute()- Returns:
- a Bedrock health attribute constructed from the data sent from the server
-
isAlive
public boolean isAlive() -
interact
public InteractionResult interact(org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand hand) Description copied from class:EntitySimulates 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). -
setPosition
public void setPosition(org.cloudburstmc.math.vector.Vector3f position) - Overrides:
setPositionin classEntity
-
moveRelative
public void moveRelative(double relX, double relY, double relZ, float yaw, float pitch, float headYaw, boolean isOnGround) - Overrides:
moveRelativein classEntity
-
moveAbsolute
public void moveAbsolute(org.cloudburstmc.math.vector.Vector3f position, float yaw, float pitch, float headYaw, boolean isOnGround, boolean teleported) - Overrides:
moveAbsolutein classEntity
-
shouldLerp
public boolean shouldLerp() -
tick
public void tick()Description copied from interface:TickableThis function gets called every game tick as long as the game tick loop isn't frozen. -
setBoundingBoxHeight
public boolean setBoundingBoxHeight(float height) - Overrides:
setBoundingBoxHeightin classEntity
-
setBoundingBoxWidth
public void setBoundingBoxWidth(float width) - Overrides:
setBoundingBoxWidthin classEntity
-
checkInteractWithNameTag
Checks to see if a nametag interaction would go through. -
updateArmor
public void updateArmor() -
updateMainHand
public void updateMainHand() -
updateOffHand
public void updateOffHand() -
useArmSwingAttack
public boolean useArmSwingAttack()Called when a SWING_ARM animation packet is received- Returns:
- true if an ATTACK_START event should be used instead
-
updateBedrockAttributes
public void updateBedrockAttributes(GeyserSession session, List<org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.Attribute> attributes) Attributes are properties of an entity that are generally more runtime-based instead of permanent properties. Movement speed, current attack damage with a weapon, current knockback resistance.- Parameters:
attributes- the Java list of attributes sent from the server
-
updateAttribute
protected void updateAttribute(org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.Attribute javaAttribute, List<org.cloudburstmc.protocol.bedrock.data.AttributeData> newAttributes) Takes the Java attribute and adds it to newAttributes as a Bedrock-formatted attribute -
hasBodyArmor
protected boolean hasBodyArmor() -
isEquippableInSlot
public final boolean isEquippableInSlot(GeyserItemStack item, org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot var2) -
canUseSlot
protected boolean canUseSlot(org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot slot) -
calculateAttribute
protected org.cloudburstmc.protocol.bedrock.data.AttributeData calculateAttribute(org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.Attribute javaAttribute, GeyserAttributeType type) Calculates the complete attribute value to send to Bedrock. Will be overriden if attributes need to be cached. -
getEquipment
public EnumMap<org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot,GeyserItemStack> getEquipment() -
isMaxFrozenState
public boolean isMaxFrozenState()A convenience variable for if the entity has reached the maximum frozen ticks and should be shaking -
getLerpPosition
public org.cloudburstmc.math.vector.Vector3f getLerpPosition() -
getLerpSteps
public int getLerpSteps() -
isDirtyYaw
public boolean isDirtyYaw() -
isDirtyHeadYaw
public boolean isDirtyHeadYaw() -
isDirtyPitch
public boolean isDirtyPitch() -
setEquipment
public void setEquipment(EnumMap<org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot, GeyserItemStack> equipment) -
setMaxHealth
public void setMaxHealth(float maxHealth) -
setMaxFrozenState
public void setMaxFrozenState(boolean isMaxFrozenState) A convenience variable for if the entity has reached the maximum frozen ticks and should be shaking -
setLerpPosition
public void setLerpPosition(org.cloudburstmc.math.vector.Vector3f lerpPosition) -
setLerpSteps
public void setLerpSteps(int lerpSteps) -
setDirtyYaw
public void setDirtyYaw(boolean dirtyYaw) -
setDirtyHeadYaw
public void setDirtyHeadYaw(boolean dirtyHeadYaw) -
setDirtyPitch
public void setDirtyPitch(boolean dirtyPitch)
-