dev.polymodloader.api.content.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 |
|---|---|---|
AiGoal | interface | 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. |
EntityBehavior | interface | Code that runs for a mod mob. |
EntityDefinition | record | 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(). |
EntityDefinition.Builder | class | Builds an EntityDefinition. |
EntityDefinition.GoalEntry | record | An extra AI goal. |
EntityDefinition.Movement | enum | How a mob moves and finds paths. |
EntityDefinition.Riding | enum | How players ride a mob. |
EntityHandle | interface | A declared entity type. |
EntityInteraction | record | A player using (right-clicking) a mod mob. |
GoalControl | enum | What an AiGoal controls. |
MobCategory | enum | Spawn group of a mob, which decides despawning and difficulty rules like the game's categories. |
NaturalSpawn | record | Where and how often a mob spawns by itself. |
ProjectileBehavior | interface | Code that runs when a mod projectile hits something; on the server thread. |
ProjectileDefinition | record | A thrown projectile such as a snowball: it flies, falls with gravity, and on its first hit deals damage, calls the behaviour, and disappears. |
ProjectileDefinition.Builder | class | Builds a ProjectileDefinition. |
ProjectileHit | record | What 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.
| Parameter | Type | Description |
|---|---|---|
mob | MobView | — |
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.
| Parameter | Type | Description |
|---|---|---|
mob | MobView | — |
Returns boolean
start(MobView)
default void start(MobView mob)
Since 0.1.0-alpha.4 or earlier
The goal started.
| Parameter | Type | Description |
|---|---|---|
mob | MobView | — |
tick(MobView)
default void tick(MobView mob)
Since 0.1.0-alpha.4 or earlier
Every tick while running.
| Parameter | Type | Description |
|---|---|---|
mob | MobView | — |
stop(MobView)
default void stop(MobView mob)
Since 0.1.0-alpha.4 or earlier
The goal stopped or was interrupted.
| Parameter | Type | Description |
|---|---|---|
mob | MobView | — |
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.
| Parameter | Type | Description |
|---|---|---|
entity | LivingEntityView | — |
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()).
| Parameter | Type | Description |
|---|---|---|
interaction | EntityInteraction | — |
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().
| Component | Type | Description |
|---|---|---|
width | float | hitbox width in blocks |
height | float | hitbox height in blocks |
category | MobCategory | spawn group |
maxHealth | double | health in half-hearts |
movementSpeed | double | base speed (zombie 0.23, villager 0.5) |
attackDamage | double | melee damage; used only with attackPlayers() |
wander | boolean | walk around randomly |
lookAtPlayers | boolean | look at nearby players |
panicWhenHurt | boolean | run away when hurt |
attackPlayers | boolean | chase and hit players |
temptedBy | Optional<ResourceId> | follow players holding this item, if set |
texture | ResourceId | skin texture, for example my_mod:textures/entity/golem.png |
spawnEggTab | Optional<CreativeTab> | when present, declares <id>_spawn_egg in this creative tab |
behavior | EntityBehavior | callbacks |
naturalSpawns | List<NaturalSpawn> | where the mob spawns by itself; empty for never |
goals | List<EntityDefinition.GoalEntry> | extra AI goals, each created per mob |
riding | EntityDefinition.Riding | whether and how players ride the mob |
noGravity | boolean | whether the mob floats |
pushable | boolean | whether other entities push the mob |
model | Optional<EntityModelDefinition> | a box model drawn with texture, or empty for the player-shaped model |
movement | EntityDefinition.Movement | how the mob moves and finds paths |
flyingSpeed | double | speed 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.
| Parameter | Type | Description |
|---|---|---|
texture | ResourceId | — |
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.
| Parameter | Type | Description |
|---|---|---|
width | float | — |
height | float | — |
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.
| Parameter | Type | Description |
|---|---|---|
category | MobCategory | — |
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.
| Parameter | Type | Description |
|---|---|---|
maxHealth | double | — |
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.
| Parameter | Type | Description |
|---|---|---|
movementSpeed | double | — |
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.
| Parameter | Type | Description |
|---|---|---|
damage | double | — |
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.
| Parameter | Type | Description |
|---|---|---|
item | ResourceId | — |
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.
| Parameter | Type | Description |
|---|---|---|
tab | CreativeTab | — |
Returns EntityDefinition.Builder
behavior(EntityBehavior)
public EntityDefinition.Builder behavior(EntityBehavior behavior)
Since 0.1.0-alpha.4 or earlier
Callbacks for ticks and interaction.
| Parameter | Type | Description |
|---|---|---|
behavior | EntityBehavior | — |
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.
| Parameter | Type | Description |
|---|---|---|
biomes | BiomeSelector | — |
weight | int | — |
minGroup | int | — |
maxGroup | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
priority | int | — |
factory | Supplier<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.
| Parameter | Type | Description |
|---|---|---|
priority | int | — |
factory | Supplier<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.
| Parameter | Type | Description |
|---|---|---|
steerable | boolean | — |
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.
| Parameter | Type | Description |
|---|---|---|
model | EntityModelDefinition | — |
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.
| Parameter | Type | Description |
|---|---|---|
flyingSpeed | double | — |
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.
| Component | Type | Description |
|---|---|---|
priority | int | lower runs first; the built-in goals use 0 (float), 1 (panic), 2 (attack), 3 (tempt), 5 (wander), 6–7 (look around) |
factory | Supplier<AiGoal> | creates the goal for each mob |
target | boolean | whether 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.
| Constant | Description |
|---|---|
WALK | Walks and jumps; swims to the surface in water. |
FLY | Flies in any direction and hovers when it stops, like a bee; takes no fall damage. Paths go through the air. |
SWIM | Swims 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.
| Constant | Description |
|---|---|
NONE | Not at all. |
PASSENGER | Players climb on by using the mob with an empty hand and are carried along. |
STEERABLE | Like 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.
| Component | Type | Description |
|---|---|---|
world | WorldView | the world, client or server copy |
entity | LivingEntityView | the mob |
player | PlayerView | the 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.
| Constant | Description |
|---|---|
MOVE | Walking and pathfinding. |
LOOK | Where the head looks. |
JUMP | Jumping. |
TARGET | Choosing 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.
| Constant | Description |
|---|---|
CREATURE | Peaceful animals; persistent. |
MONSTER | Hostile mobs; removed on peaceful difficulty and despawn far from players. |
AMBIENT | Ambient creatures such as bats. |
WATER_CREATURE | Water 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.
| Component | Type | Description |
|---|---|---|
biomes | BiomeSelector | where |
weight | int | chance relative to the biome's other mobs of the category (pig 10, zombie 100) |
minGroup | int | smallest group |
maxGroup | int | largest 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.
| Parameter | Type | Description |
|---|---|---|
hit | ProjectileHit | — |
onHitBlock(ProjectileHit)
default void onHitBlock(ProjectileHit hit)
Since 0.1.0-alpha.4 or earlier
The projectile hit a block.
| Parameter | Type | Description |
|---|---|---|
hit | ProjectileHit | — |
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.
| Component | Type | Description |
|---|---|---|
item | ResourceId | item drawn in flight |
size | float | hitbox width and height in blocks |
gravity | double | downward acceleration per tick (snowball 0.03) |
damage | float | damage to a hit entity, 0 for none |
behavior | ProjectileBehavior | hit 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.
| Parameter | Type | Description |
|---|---|---|
item | ResourceId | — |
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.
| Parameter | Type | Description |
|---|---|---|
size | float | — |
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).
| Parameter | Type | Description |
|---|---|---|
gravity | double | — |
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.
| Parameter | Type | Description |
|---|---|---|
damage | float | — |
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.
| Parameter | Type | Description |
|---|---|---|
behavior | ProjectileBehavior | — |
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.
| Component | Type | Description |
|---|---|---|
world | WorldView | the server world |
projectile | EntityView | the projectile, removed after the callback |
owner | Optional<EntityView> | who launched it, if known |
entity | Optional<EntityView> | the hit entity, for entity hits |
block | Optional<BlockPos> | the hit block, for block hits |