Interface EntityBody


public interface EntityBody
Represents an Entity's Body and Server Attributes
  • Method Details

    • isLeftHanded

      boolean isLeftHanded()
      Whether this Entity is Left Handed.
      Returns:
      true if left-handed, else false
    • setLeftHanded

      void setLeftHanded(boolean leftHanded)
      Sets this Entity to be left-handed.
      Parameters:
      leftHanded - true if left-handed, else false
    • canBreatheUnderwater

      boolean canBreatheUnderwater()
      Whether this Mob can breathe underwater.
      Returns:
      true if mob can breathe underwater, else false
    • shouldDiscardFriction

      boolean shouldDiscardFriction()
      Whether this Mob should discard friction.

      If this is set to true, the entity's movement will not be amplified while naturally traveling.

      Returns:
      true if mob discards friction, else false
    • setDiscardFriction

      void setDiscardFriction(boolean discard)
      Sets whether this Mob should discard friction. See shouldDiscardFriction() for more information on what this actually does.
      Parameters:
      discard - true if mob discards friction, else false
      See Also:
    • interact

      Makes this Mob interact with a Player.
      Parameters:
      p - Player to interact with
      hand - Hand to use
      Returns:
      Result of interaction
    • isSensitiveToWater

      boolean isSensitiveToWater()
      Whether this Entity is sensitive to water (e.g. enderman)
      Returns:
      true if sensitive to water, else false
    • isAffectedByPotions

      boolean isAffectedByPotions()
      Whether this Mob is affected by Potions.
      Returns:
      true if mob is affected, else false
    • isBlocking

      boolean isBlocking()
      Whether this Mob is blocking.
      Returns:
      true if mob is blocking, else false
    • getArmorCoverPercentage

      float getArmorCoverPercentage()
      Fetch the percentage of how much armor is covering this Mob.
      Returns:
      Percentage of Armor Coverage
    • useItem

      Makes this Mob use the Item in its Hand.
      Parameters:
      hand - Hand to use
    • isUsingItem

      boolean isUsingItem()
      Whether this Mob is currently using an Item.
      Returns:
      true if mob is using item, else false
    • isFireImmune

      boolean isFireImmune()
      Whether this Mob is Immune to Fire/Lava Damage.
      Returns:
      true if Mob is immune to fire, else false
    • isSwinging

      boolean isSwinging()
      Whether this Mob is swinging its arm.
      Returns:
      true if mob is swinging its arm, else false
    • canRideUnderwater

      boolean canRideUnderwater()
      Whether this Mob can be ridden underwater.
      Returns:
      true if mob can be ridden underwater, else false
    • isInvisibleTo

      boolean isInvisibleTo(@Nullable @Nullable Player p)
      Whether this Mob is invisible to this Player.
      Parameters:
      p - Player to use
      Returns:
      true if mob is invisible to this player, else false
    • getMainHand

      Gets this Mob's Main Hand.
      Returns:
      Mob's Main Hand
    • getDefaultDrops

      List<ItemStack> getDefaultDrops()
      Fetches the entity's current default drops.
      Returns:
      List of Default Drops
    • setDefaultDrops

      void setDefaultDrops(@Nullable @Nullable ItemStack... drops)
      Sets the entity's current default drops.
      Parameters:
      drops - Array of Default Drops
    • setDefaultDrops

      default void setDefaultDrops(@Nullable @Nullable Iterable<ItemStack> drops)
      Sets the entity's current default drops.
      Parameters:
      drops - Iterable of Default Drops
    • setDefaultDrops

      default void setDefaultDrops(@Nullable @Nullable Material... drops)
      Sets the entity's current default drops.
      Parameters:
      drops - Array of Default Drops
    • isInCombat

      @Deprecated boolean isInCombat()
      Deprecated.
      Whether this Mob is currently in combat.
      Returns:
      true if mob is in combat, else false
    • getFlyingSpeed

      float getFlyingSpeed()
      Fetches the Mob's current flying speed.
      Returns:
      Current Flying Speed (between 0.0F and 1.0F)
    • setFlyingSpeed

      void setFlyingSpeed(float speed) throws IllegalArgumentException
      Sets the Mob's current flying speed.
      Parameters:
      speed - Flying Speed to set
      Throws:
      IllegalArgumentException - if speed is not between 0.0F and 1.0F
    • isForcingDrops

      boolean isForcingDrops()
      Whether the Mob is currently forced to drop its loot.
      Returns:
      true if mob is forced to drop loot, else false
    • setForcingDrops

      void setForcingDrops(boolean drop)
      Sets if the Mob should be forced to drop its loot.
      Parameters:
      drop - true if mob is forced to drop loot, else false
    • isMoving

      boolean isMoving()
      Whether this Mob is currently moving.
      Returns:
      true if mob is moving, else false
    • normalizeRotation

      static float normalizeRotation(float rotation)
      Utility Method to normalize the rotation value to be within 0.0F and 360.0F.
      Parameters:
      rotation - Rotation to normalize
      Returns:
      Normalized Rotation
    • getBodyRotation

      float getBodyRotation()
      Fetches the Mob's current body rotation (between 0.0F and 360.0F)
      Returns:
      Current Body Rotation
    • setBodyRotation

      void setBodyRotation(float rotation)
      Sets the Mob's current body rotation.

      If the rotation is not between 0.0F and 360.0F, it will be wrapped to be between 0.0F and 360.0F (e.g. 480.0F = 120.0F).
      Parameters:
      rotation - Body Rotation to set
    • getHeadRotation

      float getHeadRotation()
      Fetches the Mob's current head rotation (between 0.0F and 360.0F)
      Returns:
      Current Head Rotation
    • setHeadRotation

      void setHeadRotation(float rotation)
      Sets the Mob's current head rotation.

      If the rotation is not between 0.0F and 360.0F, it will be wrapped to be between 0.0F and 360.0F (e.g. 480.0F = 120.0F).
      Parameters:
      rotation - Head Rotation to set
    • getYaw

      float getYaw()
      Fetches the Mob's current yaw (between 0.0F and 360.0F)
      Returns:
      Current Yaw
    • setYaw

      void setYaw(float rotation)
      Sets the Mob's current yaw.

      If the rotation is not between 0.0F and 360.0F, it will be wrapped to be between 0.0F and 360.0F (e.g. 480.0F = 120.0F).
      Parameters:
      rotation - Yaw to set
    • getPitch

      float getPitch()
      Fetches the Mob's current pitch (between 0.0F and 360.0F)
      Returns:
      Current Pitch
    • setPitch

      void setPitch(float rotation)
      Sets the Mob's current pitch.

      If the rotation is not between 0.0F and 360.0F, it will be wrapped to be between 0.0F and 360.0F (e.g. 480.0F = 120.0F).
      Parameters:
      rotation - Pitch to set
    • getCollideExemptions

      Set<? extends Entity> getCollideExemptions()
      Fetches a set of all entities that this Mob will not collide with.
      Returns:
      Entities that this Mob will not collide with
    • addCollideExemption

      void addCollideExemption(@NotNull @NotNull Entity en) throws IllegalArgumentException
      Adds an entity that this Mob will not collide with.
      Parameters:
      en - Entity to add
      Throws:
      IllegalArgumentException - if entity is null
    • addCollideExemptions

      default void addCollideExemptions(@NotNull @NotNull Entity... entities) throws IllegalArgumentException
      Adds an array of entities that this Mob will not collide with.
      Parameters:
      entities - Entities to add
      Throws:
      IllegalArgumentException - if entities or any entity is null
    • addCollideExemptions

      default void addCollideExemptions(@NotNull @NotNull Iterable<Entity> entities) throws IllegalArgumentException
      Adds a collection of entities that this Mob will not collide with.
      Parameters:
      entities - Entities to add
      Throws:
      IllegalArgumentException - if entities or any entity is null
    • removeCollideExemption

      void removeCollideExemption(@NotNull @NotNull Entity en) throws IllegalArgumentException
      Removes an entity that this Mob will not collide with.
      Parameters:
      en - Entity to remove
      Throws:
      IllegalArgumentException - if entity is null
    • getDroppedExperience

      int getDroppedExperience()
      Fetches the amount of experience this Mob will drop.
      Returns:
      Amount of Experience
    • setDroppedExperience

      void setDroppedExperience(int exp) throws IllegalArgumentException
      Sets the amount of experience this Mob will drop.
      Parameters:
      exp - Experience Dropped
      Throws:
      IllegalArgumentException - if experience is less than 0
    • playAnimation

      void playAnimation(@NotNull @NotNull EntityAnimation anim)
      Makes this Mob perform an Animation.
      Parameters:
      anim - Animation to perform
    • getAnimationSpeed

      float getAnimationSpeed()
      Fetches the Mob's current animation speed.
      Returns:
      Current Animation Speed
    • setAnimationSpeed

      void setAnimationSpeed(float speed) throws IllegalArgumentException
      Sets the Mob's current animation speed.
      Parameters:
      speed - Animation Speed to set
      Throws:
      IllegalArgumentException - if speed is less than 0.0F
    • hasVerticalCollision

      boolean hasVerticalCollision()
      Whether this Mob has vertical collision enabled.
      Returns:
      true if mob has vertical collision, else false
    • setVerticalCollision

      void setVerticalCollision(boolean collision)
      Sets if this Mob has vertical collision enabled.
      Parameters:
      collision - true if mob has vertical collision, else false
    • hasHorizontalCollision

      boolean hasHorizontalCollision()
      Whether this Mob has horizontal collision enabled.
      Returns:
      true if mob has horizontal collision, else false
    • setHorizontalCollision

      void setHorizontalCollision(boolean collision)
      Sets if this Mob has horizontal collision enabled.
      Parameters:
      collision - true if mob has horizontal collision, else false
    • getWalkDistance

      float getWalkDistance()
      Fetches how far this Mob has automatically walked.
      Returns:
      Walking Distance
    • getMoveDistance

      float getMoveDistance()
      Fetches how far this Mob has moved.
      Returns:
      Movement Distance
    • getFlyDistance

      float getFlyDistance()
      Fetches how far this Mob has flown.
      Returns:
      Flying Distance
    • isImmuneToExplosions

      boolean isImmuneToExplosions()
      Whether this Entity is immune to explosions.
      Returns:
      true if immune, else false
    • isPeacefulCompatible

      boolean isPeacefulCompatible()
      Whether this Mob can be spawned in Peaceful Mode,
      Returns:
      true if peaceful, else false
    • isInBubbleColumn

      boolean isInBubbleColumn()
      Whether this Mob is currently in a Bubble Column.
      Returns:
      true if in bubble column, else false
    • isInvulnerableTo

      boolean isInvulnerableTo(@Nullable EntityDamageEvent.DamageCause cause)
      Whether this Mob is immune to being damaged by this DamageCause.
      Parameters:
      cause - DamageCause to check
      Returns:
      true if immune, else false
    • getMaxFallDistance

      int getMaxFallDistance()
      Fetches the maximum distance this Mob can fall before taking damage.
      Returns:
      Maximum Fall Distance
    • isPushableBy

      boolean isPushableBy(@Nullable @Nullable Entity entity)
      Whether this Mob is pushable by this entity.
      Parameters:
      entity - Entity to check
      Returns:
      true if entity can push this mob, else false
    • getMaxUpStep

      @Deprecated float getMaxUpStep()
      Deprecated.
      Exposed in Minecraft 1.20.5 via Attribute#STEP_HEIGHT
      Fetches the maximum block height this entity can walk up without jumping.
      Returns:
      Maximum step height
    • setMaxUpStep

      @Deprecated void setMaxUpStep(float maxUpStep)
      Deprecated.
      Exposed in Minecraft 1.20.5 via Attribute#STEP_HEIGHT
      Sets the maximum block height this entity can walk up without jumping.
      Parameters:
      maxUpStep - Maximum step height
    • getLastLavaContact

      Position getLastLavaContact()
      Fetches the last position this Entity touched Material.LAVA.
      Returns:
      Last Lava Position
    • setRiptideTicks

      void setRiptideTicks(int ticks) throws IllegalArgumentException

      Sets the Mob's Riptiding Ticks.

      The mob will begin riptiding if isRiptiding() returns false, and the number is greater than 0.

      Parameters:
      ticks - Riptiding Ticks to set
      Throws:
      IllegalArgumentException - if ticks is negative
    • stopRiptiding

      default void stopRiptiding()
      Makes this Mob stop riptiding.
    • addRiptideTicks

      default void addRiptideTicks(int ticks) throws IllegalArgumentException
      Adds Riptiding Ticks to the Mob's current Riptiding Ticks.
      Parameters:
      ticks - Riptiding Ticks to add
      Throws:
      IllegalArgumentException - if ticks is negative
    • getRiptideTicks

      int getRiptideTicks()
      Fetches the Mob's current Riptiding Ticks.
      Returns:
      Current Riptiding Ticks
    • isRiptiding

      default boolean isRiptiding()
      Whether this Mob is currently riptiding.
      Returns:
      true if riptiding, else false
    • getEntity

      @NotNull @NotNull Mob getEntity()
      Fetches the entity this body belongs to.
      Returns:
      Body Owner
    • shouldRenderFrom

      boolean shouldRenderFrom(double x, double y, double z)
      Whether the entity would render at this location.
      Parameters:
      x - X Coordinate
      y - Y Coordinate
      z - Z Coordinate
      Returns:
      true if entity would render, else false
    • shouldRenderFrom

      default boolean shouldRenderFrom(@NotNull @NotNull Location l)
      Whether the entity would render at this location.
      Parameters:
      l - Location to check
      Returns:
      true if entity would render, else false
    • shouldRenderFrom

      default boolean shouldRenderFrom(double dist)
      Whether the entity would render.
      Parameters:
      dist - Distance from entity
      Returns:
      true if entity would render, else false
    • shouldRenderFromSqr

      boolean shouldRenderFromSqr(double dist)
      Whether the entity would render.
      Parameters:
      dist - Square Distance from entity
      Returns:
      true if entity would render, else false
    • sendTo

      Sends this Entity to the specified Player as a packet.
      Parameters:
      p - Player to send to
      Throws:
      UnsupportedOperationException - if this Entity cannot be sent as a packet
    • resetFallDistance

      void resetFallDistance()
      Resets the distance this Entity has fallen.
    • isInUnloadedChunk

      boolean isInUnloadedChunk()
      Fetches whether this Entity is currently inside an Unloaded Chunk.
      Returns:
      true if in unloaded chunk, else false
    • naturalKnockback

      void naturalKnockback(double force, double xForce, double zForce)
      Performs a natural knockback on this Entity.
      Parameters:
      force - Force of knockback to influence X and Z
      xForce - X Direction Force
      zForce - Z Direction Force
    • eat

      void eat(@NotNull @NotNull ItemStack item)
      Eats an Item.
      Parameters:
      item - Item to eat
    • setRotation

      void setRotation(float yaw, float pitch)
      Sets the Entity's Rotation.
      Parameters:
      yaw - Yaw to set
      pitch - Pitch to set
    • getHurtTime

      int getHurtTime()
      Fetches the number of ticks the mob turns red for after being hit, or 0 when not recently hit.
      Returns:
      Hurt Time
    • setHurtTime

      void setHurtTime(int hurtTime)
      Sets the number of ticks the mob turns red for after being hit.
      Parameters:
      hurtTime - Hurt Time to set
    • getHurtDuration

      int getHurtDuration()
      Fetches the total amount of ticks this mob has been hurt for.
      Returns:
      Hurt Duration
    • setHurtDuration

      void setHurtDuration(int hurtDuration)
      Sets the total amount of ticks this mob has been hurt for.
      Parameters:
      hurtDuration - Hurt Duration to set
    • getDeathTime

      int getDeathTime()
      Fetches the total amount of ticks this mob has been dead for, or 0 if not dead.
      Returns:
      Death Time
    • setDeathTime

      void setDeathTime(int deathTime)
      Sets the total amount of ticks this mob has been dead for.
      Parameters:
      deathTime - Death Time to set
    • getForwardSpeed

      float getForwardSpeed()
      Fetches the forward speed of this entity.
      Returns:
      Forward Speed
    • setForwardSpeed

      void setForwardSpeed(float speed)
      Sets the forward speed of this entity.
      Parameters:
      speed - Forward Speed to set
    • getSidewaysSpeed

      float getSidewaysSpeed()
      Fetches the sideways speed of this entity.
      Returns:
      Sideways Speed
    • setSidewaysSpeed

      void setSidewaysSpeed(float speed)
      Sets the sideways speed of this entity.
      Parameters:
      speed - Sideways Speed to set
    • getUpwardSpeed

      float getUpwardSpeed()
      Fetches the upward speed of this entity.
      Returns:
      Upward Speed
    • setUpwardSpeed

      void setUpwardSpeed(float speed)
      Sets the upward speed of this entity.
      Parameters:
      speed - Upward Speed to set