Skip to main content
Version: Minecraft 26.2

dev.polymodloader.api.entity

Generated

This page is generated from the source's Javadoc by ./gradlew apiReference. Do not edit it; fix the source comment and generate it again.

TypeKindDescription
DamageInforecordWhat hurt an entity.
EntityViewinterfaceAn entity in a loaded world.
HandenumOne of a player's or mob's two hands.
LivingEntityViewinterfaceAn entity with health and status effects: players and mobs.
MobViewinterfaceA mob with AI: pathfinding, looking, and an attack target.
PlayerViewinterfaceA player.

DamageInfo​

record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public record DamageInfo(ResourceId type, float amount, Optional<EntityView> attacker)

What hurt an entity.

ComponentTypeDescription
typeResourceIddamage type, for example minecraft:fall or minecraft:player_attack
amountfloatdamage before armour, in half-hearts
attackerOptional<EntityView>the entity responsible, if any

EntityView​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface EntityView

An entity in a loaded world. Same thread and lifetime rules as WorldView.

uuid()​

UUID uuid()

Since 0.1.0-alpha.4 or earlier

Unique, persistent entity ID.

Returns UUID

type()​

ResourceId type()

Since 0.1.0-alpha.4 or earlier

Entity type, for example minecraft:pig.

Returns ResourceId

isIn(TagKey)​

boolean isIn(TagKey tag)

Since 0.1.0-alpha.4 or earlier

Whether the entity's type is in an entity type tag, for example #minecraft:skeletons.

ParameterTypeDescription
tagTagKey—

Returns boolean

Throws IllegalArgumentException — when tag is not an entity type tag

name()​

String name()

Since 0.1.0-alpha.4 or earlier

Display name as plain text.

Returns String

x()​

double x()

Since 0.1.0-alpha.4 or earlier

X coordinate.

Returns double

y()​

double y()

Since 0.1.0-alpha.4 or earlier

Y coordinate (feet).

Returns double

z()​

double z()

Since 0.1.0-alpha.4 or earlier

Z coordinate.

Returns double

blockPos()​

BlockPos blockPos()

Since 0.1.0-alpha.4 or earlier

The block the entity stands in.

Returns BlockPos

world()​

WorldView world()

Since 0.1.0-alpha.4 or earlier

The world the entity is in.

Returns WorldView

isAlive()​

boolean isAlive()

Since 0.1.0-alpha.4 or earlier

Whether the entity is alive and in a world.

Returns boolean

remove()​

void remove()

Since 0.1.0-alpha.4 or earlier

Removes the entity without dropping loot; server side only.

teleport(double, double, double)​

void teleport(double x, double y, double z)

Since 0.1.0-alpha.4 or earlier

Moves the entity within its dimension; server side only.

ParameterTypeDescription
xdouble—
ydouble—
zdouble—

changeDimension(ResourceId, double, double, double)​

EntityView changeDimension(ResourceId dimension, double x, double y, double z)

Since 0.1.0-alpha.4 or earlier

Moves the entity to another dimension, for example minecraft:the_nether or a mod dimension from data; server side only.

ParameterTypeDescription
dimensionResourceId—
xdouble—
ydouble—
zdouble—

Returns EntityView — the view of the entity in the new dimension (it may be a new object)

Throws IllegalArgumentException — for an unknown or unloaded dimension

velocity()​

Vector3 velocity()

Since 0.1.0-alpha.4 or earlier

Velocity in blocks per tick.

Returns Vector3

setVelocity(double, double, double)​

void setVelocity(double x, double y, double z)

Since 0.1.0-alpha.4 or earlier

Sets the velocity; for players it reaches their client. Server side only.

ParameterTypeDescription
xdouble—
ydouble—
zdouble—

isOnGround()​

boolean isOnGround()

Since 0.1.0-alpha.4 or earlier

Whether the entity stands on a block.

Returns boolean

yaw()​

float yaw()

Since 0.1.0-alpha.4 or earlier

Horizontal facing in degrees (0 south, 90 west, 180 north, 270 east).

Returns float

pitch()​

float pitch()

Since 0.1.0-alpha.4 or earlier

Vertical facing in degrees (-90 up, 90 down).

Returns float

setRotation(float, float)​

void setRotation(float yaw, float pitch)

Since 0.1.0-alpha.4 or earlier

Turns the entity. Server side only.

ParameterTypeDescription
yawfloat—
pitchfloat—

hasNoGravity()​

boolean hasNoGravity()

Since 0.1.0-alpha.4 or earlier

Whether gravity is off for this entity.

Returns boolean

setNoGravity(boolean)​

void setNoGravity(boolean noGravity)

Since 0.1.0-alpha.4 or earlier

Turns gravity off or on. Server side only.

ParameterTypeDescription
noGravityboolean—

vehicle()​

Optional<EntityView> vehicle()

Since 0.1.0-alpha.4 or earlier

What the entity rides, if anything.

Returns Optional<EntityView>

passengers()​

List<EntityView> passengers()

Since 0.1.0-alpha.4 or earlier

Who rides the entity.

Returns List<EntityView>

startRiding(EntityView)​

boolean startRiding(EntityView vehicle)

Since 0.1.0-alpha.4 or earlier

Mounts vehicle. Mod mobs accept riders only when their definition is rideable.

ParameterTypeDescription
vehicleEntityView—

Returns boolean — whether the entity now rides it

stopRiding()​

void stopRiding()

Since 0.1.0-alpha.4 or earlier

Dismounts, if riding.

data(EntityDataKey)​

StoredData data(EntityDataKey key)

Since 0.1.0-alpha.4 or earlier

The entity's data for key; call markChanged() after changing it. On the client this is the synchronised copy (the local player's, or any visible entity's for keys synchronised to trackers), read-only, empty until the server sends it.

ParameterTypeDescription
keyEntityDataKey—

Returns StoredData

Throws IllegalArgumentException — for an undeclared key

Hand​

enum · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public enum Hand

One of a player's or mob's two hands.

ConstantDescription
MAIN_HANDThe main hand: the selected hotbar slot for players.
OFF_HANDThe off hand (shield slot).

LivingEntityView​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface LivingEntityView extends EntityView

An entity with health and status effects: players and mobs. Same rules as EntityView.

Supertypes: EntityView

health()​

float health()

Since 0.1.0-alpha.4 or earlier

Current health in half-hearts.

Returns float

maxHealth()​

float maxHealth()

Since 0.1.0-alpha.4 or earlier

Maximum health.

Returns float

setHealth(float)​

void setHealth(float health)

Since 0.1.0-alpha.4 or earlier

Sets health, clamped to [0, maxHealth]; server side only.

ParameterTypeDescription
healthfloat—

hurt(float)​

boolean hurt(float amount)

Since 0.1.0-alpha.4 or earlier

Deals generic damage on the server, as if from /damage. Armour and EntityEvents.ALLOW_DAMAGE apply.

ParameterTypeDescription
amountfloat—

Returns boolean — whether the entity was hurt

Throws IllegalStateException — on the client side

hurt(ResourceId, float)​

boolean hurt(ResourceId damageType, float amount)

Since 0.1.0-alpha.4 or earlier

Deals damage of a data-defined damage type, such as minecraft:magic or one from the mod's data/<mod id>/damage_type/.

ParameterTypeDescription
damageTypeResourceId—
amountfloat—

Returns boolean

Throws IllegalArgumentException — for an unknown damage type

Throws IllegalStateException — on the client side

addEffect(ResourceId, int, int)​

void addEffect(ResourceId effect, int ticks, int amplifier)

Since 0.1.0-alpha.4 or earlier

Adds a status effect, such as minecraft:speed or a mod effect.

ParameterTypeDescription
effectResourceId—
ticksintduration in ticks (20 per second)
amplifierint0 for level I

Throws IllegalArgumentException — for an unknown effect

Throws IllegalStateException — on the client side

hasEffect(ResourceId)​

boolean hasEffect(ResourceId effect)

Since 0.1.0-alpha.4 or earlier

Whether the entity has the effect.

ParameterTypeDescription
effectResourceId—

Returns boolean

launchProjectile(ResourceId, float, float)​

EntityView launchProjectile(ResourceId type, float speed, float inaccuracy)

Since 0.1.0-alpha.4 or earlier

Launches a projectile, such as a mod projectile or minecraft:snowball, from the eyes in the look direction.

ParameterTypeDescription
typeResourceId—
speedfloatblocks per tick (snowball 1.5)
inaccuracyfloatrandom spread (players 1.0, 0 for none)

Returns EntityView — the launched projectile

Throws IllegalArgumentException — when type is not a projectile

Throws IllegalStateException — on the client side

MobView​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface MobView extends LivingEntityView

A mob with AI: pathfinding, looking, and an attack target. Server side for changes.

Supertypes: LivingEntityView

navigateTo(double, double, double, double)​

boolean navigateTo(double x, double y, double z, double speed)

Since 0.1.0-alpha.4 or earlier

Starts walking to a position along a path.

ParameterTypeDescription
xdouble—
ydouble—
zdouble—
speeddoublemultiplier of the mob's speed (1.0 normal)

Returns boolean — whether a path was found

isNavigating()​

boolean isNavigating()

Since 0.1.0-alpha.4 or earlier

Whether the mob is following a path.

Returns boolean

stopNavigating()​

void stopNavigating()

Since 0.1.0-alpha.4 or earlier

Stops following the path.

lookAt(double, double, double)​

void lookAt(double x, double y, double z)

Since 0.1.0-alpha.4 or earlier

Turns the head towards a position this tick.

ParameterTypeDescription
xdouble—
ydouble—
zdouble—

target()​

Optional<LivingEntityView> target()

Since 0.1.0-alpha.4 or earlier

The attack target, if any.

Returns Optional<LivingEntityView>

setTarget(LivingEntityView)​

void setTarget(LivingEntityView target)

Since 0.1.0-alpha.4 or earlier

Sets the attack target, or clears it with null.

ParameterTypeDescription
targetLivingEntityView—

playAnimation(String)​

void playAnimation(String name)

Since 0.1.0-alpha.4 or earlier

Plays one of the mob's ON_DEMAND model animations from the start on every client that sees the mob. Server only.

ParameterTypeDescription
nameStringthe animation's name in the mob's EntityModelDefinition

Throws IllegalArgumentException — if the mob is not a mod mob with a model that has such an animation

stopAnimation(String)​

void stopAnimation(String name)

Since 0.1.0-alpha.4 or earlier

Stops an ON_DEMAND animation on every client; a non-looping one also stops by itself at its end. Server only.

ParameterTypeDescription
nameStringthe animation's name

Throws IllegalArgumentException — if the mob has no such animation

PlayerView​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface PlayerView extends LivingEntityView

A player. Same thread and lifetime rules as WorldView.

Supertypes: LivingEntityView

sendMessage(String)​

void sendMessage(String text)

Since 0.1.0-alpha.4 or earlier

Shows text in the player's chat. On the client this is only shown locally.

ParameterTypeDescription
textString—

give(ResourceId, int)​

void give(ResourceId item, int count)

Since 0.1.0-alpha.4 or earlier

Gives the player count of item; what does not fit is dropped at their feet.

ParameterTypeDescription
itemResourceId—
countint—

Throws IllegalArgumentException — when item is not a registered item or count < 1

Throws IllegalStateException — on the client side

countItem(ResourceId)​

int countItem(ResourceId item)

Since 0.1.0-alpha.4 or earlier

How many of item the player carries in their inventory.

ParameterTypeDescription
itemResourceId—

Returns int

mainHandItem()​

ResourceId mainHandItem()

Since 0.1.0-alpha.4 or earlier

The item in the main hand, minecraft:air when empty.

Returns ResourceId

mainHandStack()​

ItemStackRef mainHandStack()

Since 0.1.0-alpha.4 or earlier

The live stack in the main hand.

Returns ItemStackRef

inventory()​

InventoryView inventory()

Since 0.1.0-alpha.4 or earlier

The player's inventory: 36 main slots (hotbar 0–8), then armour and off hand.

Returns InventoryView

openMenu(BlockPos)​

boolean openMenu(BlockPos pos)

Since 0.1.0-alpha.4 or earlier

Opens the menu of the block entity at pos (a chest-style or laid-out mod menu, or a game container such as a furnace) for this player.

ParameterTypeDescription
posBlockPos—

Returns boolean — whether the block has a menu

Throws IllegalStateException — on the client side

hasAdvancement(ResourceId)​

boolean hasAdvancement(ResourceId advancement)

Since 0.1.0-alpha.4 or earlier

Whether the player has completed an advancement, such as minecraft:story/mine_stone.

ParameterTypeDescription
advancementResourceId—

Returns boolean

Throws IllegalArgumentException — for an unknown advancement

Throws IllegalStateException — on the client side

grantAdvancement(ResourceId)​

boolean grantAdvancement(ResourceId advancement)

Since 0.1.0-alpha.4 or earlier

Completes every criterion of an advancement, with its rewards and announcement.

ParameterTypeDescription
advancementResourceId—

Returns boolean — whether anything changed

revokeAdvancement(ResourceId)​

boolean revokeAdvancement(ResourceId advancement)

Since 0.1.0-alpha.4 or earlier

Clears every criterion of an advancement.

ParameterTypeDescription
advancementResourceId—

Returns boolean — whether anything changed

hasPermission(PermissionNode)​

boolean hasPermission(PermissionNode node)

Since 0.1.0-alpha.4 or earlier

Whether the player has the permission: the first deciding provider, else the node's default operator level. Server side only.

ParameterTypeDescription
nodePermissionNode—

Returns boolean

Buy me a coffee