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

public class LivingEntity extends Entity implements Tickable
  • Field Details

    • equipment

      protected EnumMap<org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot,GeyserItemStack> equipment
    • health

      protected float health
    • maxHealth

      protected float maxHealth
    • attributeScale

      protected float attributeScale
      The scale sent through the Java attributes packet
    • dirtyYaw

      protected boolean dirtyYaw
    • dirtyHeadYaw

      protected boolean dirtyHeadYaw
    • dirtyPitch

      protected boolean dirtyPitch
  • Constructor Details

  • Method Details

    • getItemInSlot

      public GeyserItemStack getItemInSlot(org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot slot)
    • getMainHandItem

      public GeyserItemStack getMainHandItem()
    • getOffHandItem

      public GeyserItemStack getOffHandItem()
    • isHolding

      public boolean isHolding(Item item)
    • setHelmet

      public void setHelmet(GeyserItemStack stack)
    • setChestplate

      public void setChestplate(GeyserItemStack stack)
    • setLeggings

      public void setLeggings(GeyserItemStack stack)
    • setBoots

      public void setBoots(GeyserItemStack stack)
    • setBody

      public void setBody(GeyserItemStack stack)
    • setSaddle

      public void setSaddle(GeyserItemStack stack)
    • setHand

      public void setHand(GeyserItemStack stack)
    • setOffhand

      public void setOffhand(GeyserItemStack stack)
    • updateSaddled

      protected void updateSaddled(boolean saddled)
    • switchHands

      public void switchHands()
    • initializeMetadata

      protected void initializeMetadata()
      Description copied from class: Entity
      Called on entity spawn. Used to populate the entity metadata and flags with default values.
      Overrides:
      initializeMetadata in class Entity
    • updateNametag

      public void updateNametag(@Nullable Team team)
      Overrides:
      updateNametag in class Entity
    • 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: Entity
      If true, the entity should be shaking on the client's end.
      Overrides:
      isShaking in class Entity
      Returns:
      whether EntityFlag.SHAKING should be set to true.
    • setDimensionsFromPose

      protected void setDimensionsFromPose(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose pose)
      Description copied from class: Entity
      Set the height and width of the entity's bounding box
      Overrides:
      setDimensionsFromPose in class Entity
    • setFreezing

      public float setFreezing(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata entityMetadata)
      Description copied from class: Entity
      Set a float from 0-1 - how strong the "frozen" overlay should be on screen.
      Overrides:
      setFreezing in class Entity
    • setAttributeScale

      protected void setAttributeScale(float scale)
    • applyScale

      protected void applyScale()
      Overrides:
      applyScale in class Entity
    • 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()
      Overrides:
      isAlive in class Entity
    • interact

      public InteractionResult interact(org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand hand)
      Description copied from class: Entity
      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).
      Overrides:
      interact in class Entity
    • moveRelative

      public void moveRelative(double relX, double relY, double relZ, float yaw, float pitch, float headYaw, boolean isOnGround)
      Overrides:
      moveRelative in class Entity
    • moveAbsolute

      public void moveAbsolute(org.cloudburstmc.math.vector.Vector3f position, float yaw, float pitch, float headYaw, boolean isOnGround, boolean teleported)
      Overrides:
      moveAbsolute in class Entity
    • shouldLerp

      public boolean shouldLerp()
    • tick

      public void tick()
      Description copied from interface: Tickable
      This function gets called every game tick as long as the game tick loop isn't frozen.
      Specified by:
      tick in interface Tickable
    • setBoundingBoxHeight

      public boolean setBoundingBoxHeight(float height)
      Overrides:
      setBoundingBoxHeight in class Entity
    • setBoundingBoxWidth

      public void setBoundingBoxWidth(float width)
      Overrides:
      setBoundingBoxWidth in class Entity
    • checkInteractWithNameTag

      protected final InteractionResult checkInteractWithNameTag(GeyserItemStack itemStack)
      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 slot)
    • 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)