Skip to main content
Version: Minecraft 26.2

dev.polymodloader.api.content.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
AiGoalinterfaceOne behaviour of a mod mob, run by the game's goal scheduler on the server thread: every tick the scheduler starts the best-priority goals that canStart and whose controls are free, ticks running goals, and stops those that no longer shouldContinue.
EntityBehaviorinterfaceCode that runs for a mod mob.
EntityDefinitionrecordA mod mob: a pathfinding creature with the game's standard AI goals, drawn with the humanoid (player-shaped) model and a 64×64 skin-layout texture, or with its own box model().
EntityDefinition.BuilderclassBuilds an EntityDefinition.
EntityDefinition.GoalEntryrecordAn extra AI goal.
EntityDefinition.MovementenumHow a mob moves and finds paths.
EntityDefinition.RidingenumHow players ride a mob.
EntityHandleinterfaceA declared entity type.
EntityInteractionrecordA player using (right-clicking) a mod mob.
GoalControlenumWhat an AiGoal controls.
MobCategoryenumSpawn group of a mob, which decides despawning and difficulty rules like the game's categories.
NaturalSpawnrecordWhere and how often a mob spawns by itself.
ProjectileBehaviorinterfaceCode that runs when a mod projectile hits something; on the server thread.
ProjectileDefinitionrecordA thrown projectile such as a snowball: it flies, falls with gravity, and on its first hit deals damage, calls the behaviour, and disappears.
ProjectileDefinition.BuilderclassBuilds a ProjectileDefinition.
ProjectileHitrecordWhat a projectile hit.

AiGoal​

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

public interface AiGoal

One behaviour of a mod mob, run by the game's goal scheduler on the server thread: every tick the scheduler starts the best-priority goals that canStart and whose controls are free, ticks running goals, and stops those that no longer shouldContinue. Each mob gets its own goal object from the factory given to EntityDefinition.Builder.goal, so goals may keep state in fields.

controls()​

default Set<GoalControl> controls()

Since 0.1.0-alpha.4 or earlier

The controls this goal needs while it runs; default GoalControl.MOVE.

Returns Set<GoalControl>

canStart(MobView)​

boolean canStart(MobView mob)

Since 0.1.0-alpha.4 or earlier

Whether the goal should start now. Called often; keep it cheap.

ParameterTypeDescription
mobMobView—

Returns boolean

shouldContinue(MobView)​

default boolean shouldContinue(MobView mob)

Since 0.1.0-alpha.4 or earlier

Whether a running goal keeps running; default canStart.

ParameterTypeDescription
mobMobView—

Returns boolean

start(MobView)​

default void start(MobView mob)

Since 0.1.0-alpha.4 or earlier

The goal started.

ParameterTypeDescription
mobMobView—

tick(MobView)​

default void tick(MobView mob)

Since 0.1.0-alpha.4 or earlier

Every tick while running.

ParameterTypeDescription
mobMobView—

stop(MobView)​

default void stop(MobView mob)

Since 0.1.0-alpha.4 or earlier

The goal stopped or was interrupted.

ParameterTypeDescription
mobMobView—

EntityBehavior​

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

public interface EntityBehavior

Code that runs for a mod mob. Defaults keep the game's behaviour.

onServerTick(LivingEntityView)​

default void onServerTick(LivingEntityView entity)

Since 0.1.0-alpha.4 or earlier

Every server tick while the mob is alive. Keep it cheap.

ParameterTypeDescription
entityLivingEntityView—

onInteract(EntityInteraction)​

default InteractionResult onInteract(EntityInteraction interaction)

Since 0.1.0-alpha.4 or earlier

A player used the mob (both sides; check world().isClientSide()).

ParameterTypeDescription
interactionEntityInteraction—

Returns InteractionResult

EntityDefinition​

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

public record EntityDefinition(float width, float height, MobCategory category, double maxHealth, double movementSpeed, double attackDamage, boolean wander, boolean lookAtPlayers, boolean panicWhenHurt, boolean attackPlayers, Optional<ResourceId> temptedBy, ResourceId texture, Optional<CreativeTab> spawnEggTab, EntityBehavior behavior, List<NaturalSpawn> naturalSpawns, List<EntityDefinition.GoalEntry> goals, EntityDefinition.Riding riding, boolean noGravity, boolean pushable, Optional<EntityModelDefinition> model, EntityDefinition.Movement movement, double flyingSpeed)

A mod mob: a pathfinding creature with the game's standard AI goals, drawn with the humanoid (player-shaped) model and a 64×64 skin-layout texture, or with its own box model().

ComponentTypeDescription
widthfloathitbox width in blocks
heightfloathitbox height in blocks
categoryMobCategoryspawn group
maxHealthdoublehealth in half-hearts
movementSpeeddoublebase speed (zombie 0.23, villager 0.5)
attackDamagedoublemelee damage; used only with attackPlayers()
wanderbooleanwalk around randomly
lookAtPlayersbooleanlook at nearby players
panicWhenHurtbooleanrun away when hurt
attackPlayersbooleanchase and hit players
temptedByOptional<ResourceId>follow players holding this item, if set
textureResourceIdskin texture, for example my_mod:textures/entity/golem.png
spawnEggTabOptional<CreativeTab>when present, declares <id>_spawn_egg in this creative tab
behaviorEntityBehaviorcallbacks
naturalSpawnsList<NaturalSpawn>where the mob spawns by itself; empty for never
goalsList<EntityDefinition.GoalEntry>extra AI goals, each created per mob
ridingEntityDefinition.Ridingwhether and how players ride the mob
noGravitybooleanwhether the mob floats
pushablebooleanwhether other entities push the mob
modelOptional<EntityModelDefinition>a box model drawn with texture, or empty for the player-shaped model
movementEntityDefinition.Movementhow the mob moves and finds paths
flyingSpeeddoublespeed in the air for Movement.FLY (parrot 0.4); ignored otherwise

builder(ResourceId)​

public static EntityDefinition.Builder builder(ResourceId texture)

Since 0.1.0-alpha.4 or earlier

A builder for a 0.6×1.95 creature (player-sized) with the given skin texture.

ParameterTypeDescription
textureResourceId—

Returns EntityDefinition.Builder

EntityDefinition.Builder​

class · Since 0.1.0-alpha.4 or earlier

public static final class Builder

Builds an EntityDefinition.

size(float, float)​

public EntityDefinition.Builder size(float width, float height)

Since 0.1.0-alpha.4 or earlier

Hitbox width and height in blocks.

ParameterTypeDescription
widthfloat—
heightfloat—

Returns EntityDefinition.Builder

category(MobCategory)​

public EntityDefinition.Builder category(MobCategory category)

Since 0.1.0-alpha.4 or earlier

Spawn group; MobCategory.CREATURE by default.

ParameterTypeDescription
categoryMobCategory—

Returns EntityDefinition.Builder

maxHealth(double)​

public EntityDefinition.Builder maxHealth(double maxHealth)

Since 0.1.0-alpha.4 or earlier

Health in half-hearts; 20 by default.

ParameterTypeDescription
maxHealthdouble—

Returns EntityDefinition.Builder

movementSpeed(double)​

public EntityDefinition.Builder movementSpeed(double movementSpeed)

Since 0.1.0-alpha.4 or earlier

Base speed (zombie 0.23, villager 0.5); 0.25 by default.

ParameterTypeDescription
movementSpeeddouble—

Returns EntityDefinition.Builder

noWandering()​

public EntityDefinition.Builder noWandering()

Since 0.1.0-alpha.4 or earlier

The mob stands still.

Returns EntityDefinition.Builder

panicWhenHurt()​

public EntityDefinition.Builder panicWhenHurt()

Since 0.1.0-alpha.4 or earlier

The mob runs away for a while after being hurt.

Returns EntityDefinition.Builder

attackPlayers(double)​

public EntityDefinition.Builder attackPlayers(double damage)

Since 0.1.0-alpha.4 or earlier

The mob chases and hits players for damage.

ParameterTypeDescription
damagedouble—

Returns EntityDefinition.Builder

temptedBy(ResourceId)​

public EntityDefinition.Builder temptedBy(ResourceId item)

Since 0.1.0-alpha.4 or earlier

The mob follows players holding item.

ParameterTypeDescription
itemResourceId—

Returns EntityDefinition.Builder

spawnEgg(CreativeTab)​

public EntityDefinition.Builder spawnEgg(CreativeTab tab)

Since 0.1.0-alpha.4 or earlier

Declares a spawn egg item <id>_spawn_egg listed in tab.

ParameterTypeDescription
tabCreativeTab—

Returns EntityDefinition.Builder

behavior(EntityBehavior)​

public EntityDefinition.Builder behavior(EntityBehavior behavior)

Since 0.1.0-alpha.4 or earlier

Callbacks for ticks and interaction.

ParameterTypeDescription
behaviorEntityBehavior—

Returns EntityDefinition.Builder

spawnsNaturally(BiomeSelector, int, int, int)​

public EntityDefinition.Builder spawnsNaturally(BiomeSelector biomes, int weight, int minGroup, int maxGroup)

Since 0.1.0-alpha.4 or earlier

The mob spawns by itself in biomes, in groups of minGroup..maxGroup.

ParameterTypeDescription
biomesBiomeSelector—
weightint—
minGroupint—
maxGroupint—

Returns EntityDefinition.Builder

goal(int, Supplier<AiGoal>)​

public EntityDefinition.Builder goal(int priority, Supplier<AiGoal> factory)

Since 0.1.0-alpha.4 or earlier

Adds an AI goal created for each mob by factory.

ParameterTypeDescription
priorityint—
factorySupplier<AiGoal>—

Returns EntityDefinition.Builder

targetGoal(int, Supplier<AiGoal>)​

public EntityDefinition.Builder targetGoal(int priority, Supplier<AiGoal> factory)

Since 0.1.0-alpha.4 or earlier

Adds a target goal (chooses whom to attack) created for each mob by factory.

ParameterTypeDescription
priorityint—
factorySupplier<AiGoal>—

Returns EntityDefinition.Builder

rideable(boolean)​

public EntityDefinition.Builder rideable(boolean steerable)

Since 0.1.0-alpha.4 or earlier

Players can ride the mob; with steerable they also steer it.

ParameterTypeDescription
steerableboolean—

Returns EntityDefinition.Builder

noGravity()​

public EntityDefinition.Builder noGravity()

Since 0.1.0-alpha.4 or earlier

The mob is not pulled down by gravity.

Returns EntityDefinition.Builder

notPushable()​

public EntityDefinition.Builder notPushable()

Since 0.1.0-alpha.4 or earlier

Other entities do not push the mob.

Returns EntityDefinition.Builder

model(EntityModelDefinition)​

public EntityDefinition.Builder model(EntityModelDefinition model)

Since 0.1.0-alpha.4 or earlier

Draws the mob with a box model instead of the player-shaped one.

ParameterTypeDescription
modelEntityModelDefinition—

Returns EntityDefinition.Builder

flying(double)​

public EntityDefinition.Builder flying(double flyingSpeed)

Since 0.1.0-alpha.4 or earlier

The mob flies and hovers (Movement.FLY) at flyingSpeed (parrot 0.4) in the air; movementSpeed still applies on the ground.

ParameterTypeDescription
flyingSpeeddouble—

Returns EntityDefinition.Builder

swimming()​

public EntityDefinition.Builder swimming()

Since 0.1.0-alpha.4 or earlier

The mob swims under water (Movement.SWIM) at movementSpeed.

Returns EntityDefinition.Builder

build()​

public EntityDefinition build()

Since 0.1.0-alpha.4 or earlier

Creates the definition; invalid values throw IllegalArgumentException.

Returns EntityDefinition

EntityDefinition.GoalEntry​

record · Since 0.1.0-alpha.4 or earlier

public static record GoalEntry(int priority, Supplier<AiGoal> factory, boolean target)

An extra AI goal.

ComponentTypeDescription
priorityintlower runs first; the built-in goals use 0 (float), 1 (panic), 2 (attack), 3 (tempt), 5 (wander), 6–7 (look around)
factorySupplier<AiGoal>creates the goal for each mob
targetbooleanwhether it is a target goal (chooses whom to attack) rather than a behaviour goal

EntityDefinition.Movement​

enum · Since 0.1.0-alpha.4 or earlier

public static enum Movement

How a mob moves and finds paths.

ConstantDescription
WALKWalks and jumps; swims to the surface in water.
FLYFlies in any direction and hovers when it stops, like a bee; takes no fall damage. Paths go through the air.
SWIMSwims in any direction under water, like a dolphin, and breathes there; paths stay in water. Out of water it only crawls slowly. Use MobCategory.WATER_CREATURE to spawn it in water.

EntityDefinition.Riding​

enum · Since 0.1.0-alpha.4 or earlier

public static enum Riding

How players ride a mob.

ConstantDescription
NONENot at all.
PASSENGERPlayers climb on by using the mob with an empty hand and are carried along.
STEERABLELike PASSENGER, and the rider steers with the movement keys, like a horse.

EntityHandle​

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

public interface EntityHandle extends ContentHandle

A declared entity type.

Supertypes: ContentHandle

EntityInteraction​

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

public record EntityInteraction(WorldView world, LivingEntityView entity, PlayerView player)

A player using (right-clicking) a mod mob.

ComponentTypeDescription
worldWorldViewthe world, client or server copy
entityLivingEntityViewthe mob
playerPlayerViewthe player

GoalControl​

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

public enum GoalControl

What an AiGoal controls. Two running goals never share a control; a goal with a better (lower) priority takes it from a worse one.

ConstantDescription
MOVEWalking and pathfinding.
LOOKWhere the head looks.
JUMPJumping.
TARGETChoosing an attack target (target goals).

MobCategory​

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

public enum MobCategory

Spawn group of a mob, which decides despawning and difficulty rules like the game's categories.

ConstantDescription
CREATUREPeaceful animals; persistent.
MONSTERHostile mobs; removed on peaceful difficulty and despawn far from players.
AMBIENTAmbient creatures such as bats.
WATER_CREATUREWater animals.

NaturalSpawn​

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

public record NaturalSpawn(BiomeSelector biomes, int weight, int minGroup, int maxGroup)

Where and how often a mob spawns by itself. Creatures spawn on #minecraft:animals_spawnable_on blocks in daylight, monsters in the dark, water creatures in water, like the game's mobs of the same category.

ComponentTypeDescription
biomesBiomeSelectorwhere
weightintchance relative to the biome's other mobs of the category (pig 10, zombie 100)
minGroupintsmallest group
maxGroupintlargest group

ProjectileBehavior​

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

public interface ProjectileBehavior

Code that runs when a mod projectile hits something; on the server thread.

onHitEntity(ProjectileHit)​

default void onHitEntity(ProjectileHit hit)

Since 0.1.0-alpha.4 or earlier

The projectile hit an entity, after its damage was dealt.

ParameterTypeDescription
hitProjectileHit—

onHitBlock(ProjectileHit)​

default void onHitBlock(ProjectileHit hit)

Since 0.1.0-alpha.4 or earlier

The projectile hit a block.

ParameterTypeDescription
hitProjectileHit—

ProjectileDefinition​

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

public record ProjectileDefinition(ResourceId item, float size, double gravity, float damage, ProjectileBehavior behavior)

A thrown projectile such as a snowball: it flies, falls with gravity, and on its first hit deals damage, calls the behaviour, and disappears. Clients draw it as the item. Launch it with LivingEntityView.launchProjectile.

ComponentTypeDescription
itemResourceIditem drawn in flight
sizefloathitbox width and height in blocks
gravitydoubledownward acceleration per tick (snowball 0.03)
damagefloatdamage to a hit entity, 0 for none
behaviorProjectileBehaviorhit callbacks

builder(ResourceId)​

public static ProjectileDefinition.Builder builder(ResourceId item)

Since 0.1.0-alpha.4 or earlier

A builder for a 0.25-block projectile drawn as item, with snowball gravity and no damage.

ParameterTypeDescription
itemResourceId—

Returns ProjectileDefinition.Builder

ProjectileDefinition.Builder​

class · Since 0.1.0-alpha.4 or earlier

public static final class Builder

Builds a ProjectileDefinition.

size(float)​

public ProjectileDefinition.Builder size(float size)

Since 0.1.0-alpha.4 or earlier

Hitbox width and height in blocks.

ParameterTypeDescription
sizefloat—

Returns ProjectileDefinition.Builder

gravity(double)​

public ProjectileDefinition.Builder gravity(double gravity)

Since 0.1.0-alpha.4 or earlier

Downward acceleration per tick (snowball 0.03).

ParameterTypeDescription
gravitydouble—

Returns ProjectileDefinition.Builder

damage(float)​

public ProjectileDefinition.Builder damage(float damage)

Since 0.1.0-alpha.4 or earlier

Damage to a hit entity, 0 for none.

ParameterTypeDescription
damagefloat—

Returns ProjectileDefinition.Builder

behavior(ProjectileBehavior)​

public ProjectileDefinition.Builder behavior(ProjectileBehavior behavior)

Since 0.1.0-alpha.4 or earlier

Callbacks for hitting blocks and entities.

ParameterTypeDescription
behaviorProjectileBehavior—

Returns ProjectileDefinition.Builder

build()​

public ProjectileDefinition build()

Since 0.1.0-alpha.4 or earlier

Creates the definition; invalid values throw IllegalArgumentException.

Returns ProjectileDefinition

ProjectileHit​

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

public record ProjectileHit(WorldView world, EntityView projectile, Optional<EntityView> owner, Optional<EntityView> entity, Optional<BlockPos> block)

What a projectile hit.

ComponentTypeDescription
worldWorldViewthe server world
projectileEntityViewthe projectile, removed after the callback
ownerOptional<EntityView>who launched it, if known
entityOptional<EntityView>the hit entity, for entity hits
blockOptional<BlockPos>the hit block, for block hits
Buy me a coffee