dev.polymodloader.api.content.entity.model
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 |
|---|---|---|
EntityModelDefinition | record | A box model for a mod mob, in the game's model space: units are pixels (1/16 block), y grows downwards, and a root part with pivot y 24 stands on the ground. |
EntityModelDefinition.Builder | class | Builds an EntityModelDefinition. |
KeyframeAnimation | record | A keyframe animation of a mob's box model, like Blockbench's animations: per part and channel, values at points in time, blended in between. |
KeyframeAnimation.Builder | class | Builds a KeyframeAnimation. |
KeyframeAnimation.Channel | record | The keyframes of one part and target, in time order. |
KeyframeAnimation.Interpolation | enum | How values are blended between two keyframes. |
KeyframeAnimation.Keyframe | record | A value at a point in time. |
KeyframeAnimation.Target | enum | What a channel changes. |
KeyframeAnimation.Trigger | enum | When an animation plays. |
ModelBox | record | A textured cuboid of a model part, in model pixels (1/16 block) relative to the part's pivot. |
ModelPartDefinition | record | A named part of an entity model: boxes around a pivot, an optional parent part, a rest rotation in degrees, and an animation. |
ModelPartDefinition.Builder | class | Builds a ModelPartDefinition. |
PartAnimation | enum | How a model part moves on its own while the mob is drawn. |
EntityModelDefinition
record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public record EntityModelDefinition(int textureWidth, int textureHeight, List<ModelPartDefinition> parts, Map<String,KeyframeAnimation> animations)
A box model for a mod mob, in the game's model space: units are pixels (1/16 block), y grows downwards, and a root part with pivot y 24 stands on the ground. This is the layout that Blockbench's "Modded Entity" projects use. The texture is the mob's texture with textureWidth × textureHeight pixels.
| Component | Type | Description |
|---|---|---|
textureWidth | int | texture width in pixels |
textureHeight | int | texture height in pixels |
parts | List<ModelPartDefinition> | the parts; parents come before their children |
animations | Map<String,KeyframeAnimation> | keyframe animations by name ([a-z0-9_]+), in declaration order |
| Constant or field | Type | Description |
|---|---|---|
MAX_ON_DEMAND_ANIMATIONS | int | At most this many KeyframeAnimation.Trigger.ON_DEMAND animations per model. |
onDemandAnimations()
public List<String> onDemandAnimations()
Since 0.1.0-alpha.4 or earlier
Names of the KeyframeAnimation.Trigger.ON_DEMAND animations, in declaration order.
Returns List<String>
builder(int, int)
public static EntityModelDefinition.Builder builder(int textureWidth, int textureHeight)
Since 0.1.0-alpha.4 or earlier
A builder for a model using a textureWidth × textureHeight texture.
| Parameter | Type | Description |
|---|---|---|
textureWidth | int | — |
textureHeight | int | — |
Returns EntityModelDefinition.Builder
EntityModelDefinition.Builder
class · Since 0.1.0-alpha.4 or earlier
public static final class Builder
Builds an EntityModelDefinition.
part(String, Consumer<ModelPartDefinition.Builder>)
public EntityModelDefinition.Builder part(String name, Consumer<ModelPartDefinition.Builder> part)
Since 0.1.0-alpha.4 or earlier
Adds a part configured by part.
| Parameter | Type | Description |
|---|---|---|
name | String | — |
part | Consumer<ModelPartDefinition.Builder> | — |
Returns EntityModelDefinition.Builder
animation(String, KeyframeAnimation)
public EntityModelDefinition.Builder animation(String name, KeyframeAnimation animation)
Since 0.1.0-alpha.4 or earlier
Adds a keyframe animation called name; KeyframeAnimation.Trigger.ON_DEMAND ones are started by name with MobView.playAnimation.
| Parameter | Type | Description |
|---|---|---|
name | String | — |
animation | KeyframeAnimation | — |
Returns EntityModelDefinition.Builder
build()
public EntityModelDefinition build()
Since 0.1.0-alpha.4 or earlier
Creates the model; invalid parts throw IllegalArgumentException.
Returns EntityModelDefinition
KeyframeAnimation
record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public record KeyframeAnimation(float lengthSeconds, boolean looping, KeyframeAnimation.Trigger trigger, List<KeyframeAnimation.Channel> channels)
A keyframe animation of a mob's box model, like Blockbench's animations: per part and channel, values at points in time, blended in between. The values are added to the part's rest pose.
| Component | Type | Description |
|---|---|---|
lengthSeconds | float | length in seconds |
looping | boolean | whether it starts over at the end; otherwise an Trigger.ON_DEMAND animation ends there and the others hold their last keyframe |
trigger | KeyframeAnimation.Trigger | when it plays |
channels | List<KeyframeAnimation.Channel> | the animated values; at most one channel per part and target |
builder(float)
public static KeyframeAnimation.Builder builder(float lengthSeconds)
Since 0.1.0-alpha.4 or earlier
A builder for an animation lengthSeconds long that plays when the server starts it.
| Parameter | Type | Description |
|---|---|---|
lengthSeconds | float | — |
Returns KeyframeAnimation.Builder
KeyframeAnimation.Builder
class · Since 0.1.0-alpha.4 or earlier
public static final class Builder
Builds a KeyframeAnimation.
looping()
public KeyframeAnimation.Builder looping()
Since 0.1.0-alpha.4 or earlier
Starts over at the end.
Returns KeyframeAnimation.Builder
trigger(KeyframeAnimation.Trigger)
public KeyframeAnimation.Builder trigger(KeyframeAnimation.Trigger trigger)
Since 0.1.0-alpha.4 or earlier
When the animation plays; Trigger.ON_DEMAND by default.
| Parameter | Type | Description |
|---|---|---|
trigger | KeyframeAnimation.Trigger | — |
Returns KeyframeAnimation.Builder
smooth()
public KeyframeAnimation.Builder smooth()
Since 0.1.0-alpha.4 or earlier
Blends the keyframes added after this call along smooth curves instead of straight lines.
Returns KeyframeAnimation.Builder
rotation(String, float, float, float, float)
public KeyframeAnimation.Builder rotation(String part, float time, float x, float y, float z)
Since 0.1.0-alpha.4 or earlier
Rotates part by x, y, z degrees at time seconds.
| Parameter | Type | Description |
|---|---|---|
part | String | — |
time | float | — |
x | float | — |
y | float | — |
z | float | — |
Returns KeyframeAnimation.Builder
position(String, float, float, float, float)
public KeyframeAnimation.Builder position(String part, float time, float x, float y, float z)
Since 0.1.0-alpha.4 or earlier
Moves part by x, y, z model pixels (y up) at time seconds.
| Parameter | Type | Description |
|---|---|---|
part | String | — |
time | float | — |
x | float | — |
y | float | — |
z | float | — |
Returns KeyframeAnimation.Builder
scale(String, float, float, float, float)
public KeyframeAnimation.Builder scale(String part, float time, float x, float y, float z)
Since 0.1.0-alpha.4 or earlier
Scales part by x, y, z (1 keeps the size) at time seconds.
| Parameter | Type | Description |
|---|---|---|
part | String | — |
time | float | — |
x | float | — |
y | float | — |
z | float | — |
Returns KeyframeAnimation.Builder
keyframe(String, KeyframeAnimation.Target, float, float, float, float, KeyframeAnimation.Interpolation)
public KeyframeAnimation.Builder keyframe(String part, KeyframeAnimation.Target target, float time, float x, float y, float z, KeyframeAnimation.Interpolation interpolation)
Since 0.1.0-alpha.4 or earlier
Adds a keyframe with every detail given.
| Parameter | Type | Description |
|---|---|---|
part | String | — |
target | KeyframeAnimation.Target | — |
time | float | — |
x | float | — |
y | float | — |
z | float | — |
interpolation | KeyframeAnimation.Interpolation | — |
Returns KeyframeAnimation.Builder
build()
public KeyframeAnimation build()
Since 0.1.0-alpha.4 or earlier
Creates the animation; invalid values throw IllegalArgumentException.
Returns KeyframeAnimation
KeyframeAnimation.Channel
record · Since 0.1.0-alpha.4 or earlier
public static record Channel(String part, KeyframeAnimation.Target target, List<KeyframeAnimation.Keyframe> keyframes)
The keyframes of one part and target, in time order.
| Component | Type | Description |
|---|---|---|
part | String | model part name |
target | KeyframeAnimation.Target | what the keyframes change |
keyframes | List<KeyframeAnimation.Keyframe> | the keyframes, sorted by time |
KeyframeAnimation.Interpolation
enum · Since 0.1.0-alpha.4 or earlier
public static enum Interpolation
How values are blended between two keyframes.
| Constant | Description |
|---|---|
LINEAR | In a straight line. |
SMOOTH | Along a smooth curve through the neighbouring keyframes (Catmull-Rom). |
KeyframeAnimation.Keyframe
record · Since 0.1.0-alpha.4 or earlier
public static record Keyframe(float time, float x, float y, float z, KeyframeAnimation.Interpolation interpolation)
A value at a point in time.
| Component | Type | Description |
|---|---|---|
time | float | seconds from the start, 0..lengthSeconds |
x | float | value for x |
y | float | value for y |
z | float | value for z |
interpolation | KeyframeAnimation.Interpolation | how the value is reached from the previous keyframe |
KeyframeAnimation.Target
enum · Since 0.1.0-alpha.4 or earlier
public static enum Target
What a channel changes.
| Constant | Description |
|---|---|
ROTATION | Rotation in degrees around x, y and z. |
POSITION | Offset in model pixels; y grows upwards, as in Blockbench. |
SCALE | Size factor per axis; 1 keeps the size. |
KeyframeAnimation.Trigger
enum · Since 0.1.0-alpha.4 or earlier
public static enum Trigger
When an animation plays.
| Constant | Description |
|---|---|
ALWAYS | All the time, from when the mob appears; usually looping (idle breathing, a spinning part). |
WHILE_MOVING | While the mob moves, faster the faster it moves; usually looping (walk cycle, wing beats). |
ON_DEMAND | When the server starts it with MobView.playAnimation; every client that sees the mob plays it from the start (attack, wave). |
ModelBox
record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public record ModelBox(int u, int v, float x, float y, float z, float width, float height, float depth, boolean mirror)
A textured cuboid of a model part, in model pixels (1/16 block) relative to the part's pivot.
| Component | Type | Description |
|---|---|---|
u | int | texture x of the box's net (the game's cube unwrap layout) |
v | int | texture y of the box's net |
x | float | lowest corner x |
y | float | lowest corner y (y grows downwards in models) |
z | float | lowest corner z |
width | float | size along x |
height | float | size along y |
depth | float | size along z |
mirror | boolean | mirrors the texture horizontally |
ModelPartDefinition
record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public record ModelPartDefinition(String name, Optional<String> parent, float pivotX, float pivotY, float pivotZ, float rotationX, float rotationY, float rotationZ, List<ModelBox> boxes, PartAnimation animation)
A named part of an entity model: boxes around a pivot, an optional parent part, a rest rotation in degrees, and an animation.
| Component | Type | Description |
|---|---|---|
name | String | part name, unique in the model |
parent | Optional<String> | parent part, or empty for the root |
pivotX | float | pivot x relative to the parent's pivot (model pixels) |
pivotY | float | pivot y (24 is the ground for root parts, y grows downwards) |
pivotZ | float | pivot z |
rotationX | float | rest rotation around x, degrees |
rotationY | float | rest rotation around y, degrees |
rotationZ | float | rest rotation around z, degrees |
boxes | List<ModelBox> | the part's cuboids |
animation | PartAnimation | how it moves |
ModelPartDefinition.Builder
class · Since 0.1.0-alpha.4 or earlier
public static final class Builder
Builds a ModelPartDefinition.
parent(String)
public ModelPartDefinition.Builder parent(String parent)
Since 0.1.0-alpha.4 or earlier
Attaches the part to parent; its pivot becomes relative to the parent's.
| Parameter | Type | Description |
|---|---|---|
parent | String | — |
Returns ModelPartDefinition.Builder
pivot(float, float, float)
public ModelPartDefinition.Builder pivot(float x, float y, float z)
Since 0.1.0-alpha.4 or earlier
The point the part turns around, relative to the parent's pivot (model pixels, y down).
| Parameter | Type | Description |
|---|---|---|
x | float | — |
y | float | — |
z | float | — |
Returns ModelPartDefinition.Builder
rotation(float, float, float)
public ModelPartDefinition.Builder rotation(float x, float y, float z)
Since 0.1.0-alpha.4 or earlier
Rest rotation in degrees.
| Parameter | Type | Description |
|---|---|---|
x | float | — |
y | float | — |
z | float | — |
Returns ModelPartDefinition.Builder
box(int, int, float, float, float, float, float, float)
public ModelPartDefinition.Builder box(int u, int v, float x, float y, float z, float width, float height, float depth)
Since 0.1.0-alpha.4 or earlier
Adds a box whose texture net starts at u, v.
| Parameter | Type | Description |
|---|---|---|
u | int | — |
v | int | — |
x | float | — |
y | float | — |
z | float | — |
width | float | — |
height | float | — |
depth | float | — |
Returns ModelPartDefinition.Builder
mirroredBox(int, int, float, float, float, float, float, float)
public ModelPartDefinition.Builder mirroredBox(int u, int v, float x, float y, float z, float width, float height, float depth)
Since 0.1.0-alpha.4 or earlier
Adds a box with a mirrored texture.
| Parameter | Type | Description |
|---|---|---|
u | int | — |
v | int | — |
x | float | — |
y | float | — |
z | float | — |
width | float | — |
height | float | — |
depth | float | — |
Returns ModelPartDefinition.Builder
animation(PartAnimation)
public ModelPartDefinition.Builder animation(PartAnimation animation)
Since 0.1.0-alpha.4 or earlier
How the part moves on its own; PartAnimation.NONE by default.
| Parameter | Type | Description |
|---|---|---|
animation | PartAnimation | — |
Returns ModelPartDefinition.Builder
PartAnimation
enum · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public enum PartAnimation
How a model part moves on its own while the mob is drawn.
| Constant | Description |
|---|---|
NONE | Keeps its pose. |
HEAD | Turns with the mob's head (look direction). |
WALK_SWING | Swings forward and back while walking (a leg or arm). |
WALK_SWING_OPPOSITE | Swings opposite to WALK_SWING. |
BOB | Moves gently up and down all the time. |
SPIN | Spins around its vertical axis all the time. |