Interface EntityBody
public interface EntityBody
Represents an Entity's Body and Server Attributes
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumRepresents EquipmentSlots consisting of your Main Hand and Off-Handstatic enumRepresents the result of an interaction -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCollideExemption(@NotNull Entity en) Adds an entity that this Mob will not collide with.default voidaddCollideExemptions(@NotNull Iterable<Entity> entities) Adds a collection of entities that this Mob will not collide with.default voidaddCollideExemptions(@NotNull Entity... entities) Adds an array of entities that this Mob will not collide with.default voidaddRiptideTicks(int ticks) Adds Riptiding Ticks to the Mob's current Riptiding Ticks.booleanWhether this Mob can breathe underwater.booleanWhether this Mob can be ridden underwater.voidEats an Item.floatFetches the Mob's current animation speed.floatFetch the percentage of how much armor is covering this Mob.floatFetches the Mob's current body rotation (between 0.0F and 360.0F)Fetches a set of all entities that this Mob will not collide with.intFetches the total amount of ticks this mob has been dead for, or 0 if not dead.Fetches the entity's current default drops.intFetches the amount of experience this Mob will drop.@NotNull MobFetches the entity this body belongs to.floatFetches how far this Mob has flown.floatFetches the Mob's current flying speed.floatFetches the forward speed of this entity.floatFetches the Mob's current head rotation (between 0.0F and 360.0F)intFetches the total amount of ticks this mob has been hurt for.intFetches the number of ticks the mob turns red for after being hit, or 0 when not recently hit.Fetches the last position this Entity touchedMaterial.LAVA.@NotNull EntityBody.InteractionHandGets this Mob's Main Hand.intFetches the maximum distance this Mob can fall before taking damage.floatDeprecated.Exposed in Minecraft 1.20.5 via Attribute#STEP_HEIGHTfloatFetches how far this Mob has moved.floatgetPitch()Fetches the Mob's current pitch (between 0.0F and 360.0F)intFetches the Mob's current Riptiding Ticks.floatFetches the sideways speed of this entity.floatFetches the upward speed of this entity.floatFetches how far this Mob has automatically walked.floatgetYaw()Fetches the Mob's current yaw (between 0.0F and 360.0F)booleanWhether this Mob has horizontal collision enabled.booleanWhether this Mob has vertical collision enabled.default EntityBody.InteractionResultinteract(@NotNull Player p, @Nullable EntityBody.InteractionHand hand) Deprecated.Superseded byinteract(Player, InteractionHand, Vector)interact(@NotNull Player p, @Nullable EntityBody.InteractionHand hand, @Nullable Vector location) Makes this Mob interact with a Player.booleanWhether this Mob is affected by Potions.booleanWhether this Mob is blocking.booleanWhether this Mob is Immune to Fire/Lava Damage.booleanWhether the Mob is currently forced to drop its loot.booleanWhether this Entity is immune to explosions.booleanWhether this Mob is currently in a Bubble Column.booleanDeprecated.UseEntityCombatTracker.isInCombat()instead.booleanFetches whether this Entity is currently inside an Unloaded Chunk.booleanisInvisibleTo(@Nullable Player p) Whether this Mob is invisible to this Player.booleanWhether this Mob is immune to being damaged by this DamageCause.booleanWhether this Entity is Left Handed.booleanisMoving()Whether this Mob is currently moving.booleanWhether this Mob can be spawned in Peaceful Mode,booleanisPushableBy(@Nullable Entity entity) Whether this Mob is pushable by this entity.default booleanWhether this Mob is currently riptiding.booleanWhether this Entity is sensitive to water (e.g.booleanWhether this Mob is swinging its arm.booleanWhether this Mob is currently using an Item.voidnaturalKnockback(double force, double xForce, double zForce) Performs a natural knockback on this Entity.static floatnormalizeRotation(float rotation) Utility Method to normalize the rotation value to be within0.0Fand360.0F.voidplayAnimation(@NotNull EntityAnimation anim) Makes this Mob perform an Animation.voidremoveCollideExemption(@NotNull Entity en) Removes an entity that this Mob will not collide with.voidResets the distance this Entity has fallen.voidSends this Entity to the specified Player as a packet.voidsetAnimationSpeed(float speed) Sets the Mob's current animation speed.voidsetBodyRotation(float rotation) Sets the Mob's current body rotation.voidsetDeathTime(int deathTime) Sets the total amount of ticks this mob has been dead for.default voidsetDefaultDrops(@Nullable Iterable<ItemStack> drops) Sets the entity's current default drops.default voidsetDefaultDrops(@Nullable Material... drops) Sets the entity's current default drops.voidsetDefaultDrops(@Nullable ItemStack... drops) Sets the entity's current default drops.voidsetDiscardFriction(boolean discard) Sets whether this Mob should discard friction.voidsetDroppedExperience(int exp) Sets the amount of experience this Mob will drop.voidsetFlyingSpeed(float speed) Sets the Mob's current flying speed.voidsetForcingDrops(boolean drop) Sets if the Mob should be forced to drop its loot.voidsetForwardSpeed(float speed) Sets the forward speed of this entity.voidsetHeadRotation(float rotation) Sets the Mob's current head rotation.voidsetHorizontalCollision(boolean collision) Sets if this Mob has horizontal collision enabled.voidsetHurtDuration(int hurtDuration) Sets the total amount of ticks this mob has been hurt for.voidsetHurtTime(int hurtTime) Sets the number of ticks the mob turns red for after being hit.voidsetLeftHanded(boolean leftHanded) Sets this Entity to be left-handed.voidsetMaxUpStep(float maxUpStep) Deprecated.Exposed in Minecraft 1.20.5 via Attribute#STEP_HEIGHTvoidsetPitch(float rotation) Sets the Mob's current pitch.voidsetRiptideTicks(int ticks) Sets the Mob's Riptiding Ticks.voidsetRotation(float yaw, float pitch) Sets the Entity's Rotation.voidsetSidewaysSpeed(float speed) Sets the sideways speed of this entity.voidsetUpwardSpeed(float speed) Sets the upward speed of this entity.voidsetVerticalCollision(boolean collision) Sets if this Mob has vertical collision enabled.voidsetYaw(float rotation) Sets the Mob's current yaw.booleanWhether this Mob should discard friction.default booleanshouldRenderFrom(double dist) Whether the entity would render.booleanshouldRenderFrom(double x, double y, double z) Whether the entity would render at this location.default booleanshouldRenderFrom(@NotNull Location l) Whether the entity would render at this location.booleanshouldRenderFromSqr(double dist) Whether the entity would render.default voidMakes this Mob stop riptiding.voiduseItem(@Nullable EntityBody.InteractionHand hand) Makes this Mob use the Item in its Hand.
-
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. SeeshouldDiscardFriction()for more information on what this actually does.- Parameters:
discard- true if mob discards friction, else false- See Also:
-
interact
@Deprecated default EntityBody.InteractionResult interact(@NotNull @NotNull Player p, @Nullable @Nullable EntityBody.InteractionHand hand) Deprecated.Superseded byinteract(Player, InteractionHand, Vector)Makes this Mob interact with a Player.- Parameters:
p- Player to interact withhand- Hand to use- Returns:
- Result of interaction
-
interact
EntityBody.InteractionResult interact(@NotNull @NotNull Player p, @Nullable @Nullable EntityBody.InteractionHand hand, @Nullable @Nullable Vector location) Makes this Mob interact with a Player.- Parameters:
p- Player to interact withhand- Hand to uselocation- Location of interaction relative to the entity- 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
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
-
setDefaultDrops
Sets the entity's current default drops.- Parameters:
drops- Array of Default Drops
-
setDefaultDrops
-
setDefaultDrops
Sets the entity's current default drops.- Parameters:
drops- Array of Default Drops
-
isInCombat
Deprecated.UseEntityCombatTracker.isInCombat()instead.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
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 within0.0Fand360.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
-
addCollideExemption
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
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
Sets the amount of experience this Mob will drop.- Parameters:
exp- Experience Dropped- Throws:
IllegalArgumentException- if experience is less than 0
-
playAnimation
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
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
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
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.Exposed in Minecraft 1.20.5 via Attribute#STEP_HEIGHTFetches the maximum block height this entity can walk up without jumping.- Returns:
- Maximum step height
-
setMaxUpStep
Deprecated.Exposed in Minecraft 1.20.5 via Attribute#STEP_HEIGHTSets 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 touchedMaterial.LAVA.- Returns:
- Last Lava Position
-
setRiptideTicks
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
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
-
shouldRenderFrom
boolean shouldRenderFrom(double x, double y, double z) Whether the entity would render at this location.- Parameters:
x- X Coordinatey- Y Coordinatez- Z Coordinate- Returns:
- true if entity would render, else false
-
shouldRenderFrom
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 ZxForce- X Direction ForcezForce- Z Direction Force
-
eat
-
setRotation
void setRotation(float yaw, float pitch) Sets the Entity's Rotation.- Parameters:
yaw- Yaw to setpitch- 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
-