dev.polymodloader.api.entity
This page is generated from the source's Javadoc by ./gradlew apiReference. Do not edit it; fix the source comment and generate it again.
| Type | Kind | Description |
|---|---|---|
DamageInfo | record | What hurt an entity. |
EntityView | interface | An entity in a loaded world. |
Hand | enum | One of a player's or mob's two hands. |
LivingEntityView | interface | An entity with health and status effects: players and mobs. |
MobView | interface | A mob with AI: pathfinding, looking, and an attack target. |
PlayerView | interface | A 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.
| Component | Type | Description |
|---|---|---|
type | ResourceId | damage type, for example minecraft:fall or minecraft:player_attack |
amount | float | damage before armour, in half-hearts |
attacker | Optional<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.
| Parameter | Type | Description |
|---|---|---|
tag | TagKey | — |
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.
| Parameter | Type | Description |
|---|---|---|
x | double | — |
y | double | — |
z | double | — |
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.
| Parameter | Type | Description |
|---|---|---|
dimension | ResourceId | — |
x | double | — |
y | double | — |
z | double | — |
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.
| Parameter | Type | Description |
|---|---|---|
x | double | — |
y | double | — |
z | double | — |
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.
| Parameter | Type | Description |
|---|---|---|
yaw | float | — |
pitch | float | — |
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.
| Parameter | Type | Description |
|---|---|---|
noGravity | boolean | — |
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.
| Parameter | Type | Description |
|---|---|---|
vehicle | EntityView | — |
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.
| Parameter | Type | Description |
|---|---|---|
key | EntityDataKey | — |
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.
| Constant | Description |
|---|---|
MAIN_HAND | The main hand: the selected hotbar slot for players. |
OFF_HAND | The 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.
| Parameter | Type | Description |
|---|---|---|
health | float | — |
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.
| Parameter | Type | Description |
|---|---|---|
amount | float | — |
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/.
| Parameter | Type | Description |
|---|---|---|
damageType | ResourceId | — |
amount | float | — |
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.
| Parameter | Type | Description |
|---|---|---|
effect | ResourceId | — |
ticks | int | duration in ticks (20 per second) |
amplifier | int | 0 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.
| Parameter | Type | Description |
|---|---|---|
effect | ResourceId | — |
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.
| Parameter | Type | Description |
|---|---|---|
type | ResourceId | — |
speed | float | blocks per tick (snowball 1.5) |
inaccuracy | float | random 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.
| Parameter | Type | Description |
|---|---|---|
x | double | — |
y | double | — |
z | double | — |
speed | double | multiplier 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.
| Parameter | Type | Description |
|---|---|---|
x | double | — |
y | double | — |
z | double | — |
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.
| Parameter | Type | Description |
|---|---|---|
target | LivingEntityView | — |
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.
| Parameter | Type | Description |
|---|---|---|
name | String | the 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.
| Parameter | Type | Description |
|---|---|---|
name | String | the 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.
| Parameter | Type | Description |
|---|---|---|
text | String | — |
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.
| Parameter | Type | Description |
|---|---|---|
item | ResourceId | — |
count | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
item | ResourceId | — |
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.
| Parameter | Type | Description |
|---|---|---|
pos | BlockPos | — |
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.
| Parameter | Type | Description |
|---|---|---|
advancement | ResourceId | — |
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.
| Parameter | Type | Description |
|---|---|---|
advancement | ResourceId | — |
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.
| Parameter | Type | Description |
|---|---|---|
advancement | ResourceId | — |
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.
| Parameter | Type | Description |
|---|---|---|
node | PermissionNode | — |
Returns boolean