dev.polymodloader.api.content
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 |
|---|---|---|
AdvancementTrigger | interface | A criterion trigger for advancements in data packs: an advancement criterion with "trigger": "<mod id>:<path>" is met when the mod calls trigger. |
ContentHandle | interface | A declared piece of content. |
ContentRegistrar | interface | Declares a mod's blocks and items. |
CreativeTab | enum | The game's creative inventory tabs that mod items can be listed in. |
CreativeTabDefinition | record | A mod's own creative inventory tab, declared with ContentRegistrar.creativeTab. |
CreativeTabDefinition.Builder | class | Builds a CreativeTabDefinition. |
EntityDataKey | record | Mod data attached to entities (players included): a DataTree per entity, saved with it, kept by players when they respawn, and synchronised to clients as the EntityDataOptions say. |
EntityDataOptions | record | How an EntityDataKey is kept and shared. |
SoundHandle | interface | A declared sound event. |
AdvancementTrigger
interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public interface AdvancementTrigger
A criterion trigger for advancements in data packs: an advancement criterion with "trigger": "<mod id>:<path>" is met when the mod calls trigger.
id()
ResourceId id()
Since 0.1.0-alpha.4 or earlier
The trigger ID used in advancement files.
Returns ResourceId
trigger(PlayerView)
void trigger(PlayerView player)
Since 0.1.0-alpha.4 or earlier
Meets every criterion with this trigger for player.
| Parameter | Type | Description |
|---|---|---|
player | PlayerView | — |
Throws IllegalStateException — on the client side
ContentHandle
interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public interface ContentHandle
A declared piece of content. The game creates it later, when its registries are built.
id()
ResourceId id()
Since 0.1.0-alpha.4 or earlier
The content's ID, <mod id>:<path>.
Returns ResourceId
isRegistered()
boolean isRegistered()
Since 0.1.0-alpha.4 or earlier
Whether the game has created and registered the content yet.
Returns boolean
ContentRegistrar
interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public interface ContentRegistrar
Declares a mod's blocks and items. IDs are <mod id>:<path>.
When: only inside common entrypoints. Poly Mod Loader creates the declared content just before the game freezes its registries; content cannot be added afterwards (POLY-CONTENT-002). Models, textures, translations, recipes, loot tables, and tags come from the mod jar's assets/ and data/ folders, which Poly Mod Loader adds as a required resource and data pack.
Both sides: client and server must declare the same content in the same order, because the game synchronises blocks by number.
block(String, BlockDefinition)
BlockHandle block(String path, BlockDefinition definition)
Since 0.1.0-alpha.4 or earlier
Declares a block; unless the definition says otherwise, a block item with the same ID is declared too.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
definition | BlockDefinition | — |
Returns BlockHandle
Throws IllegalArgumentException — for an invalid path or a path this mod already used (POLY-CONTENT-001)
Throws IllegalStateException — after registration closed (POLY-CONTENT-002)
item(String, ItemDefinition)
ItemHandle item(String path, ItemDefinition definition)
Since 0.1.0-alpha.4 or earlier
Declares an item.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
definition | ItemDefinition | — |
Returns ItemHandle
Throws IllegalArgumentException — for an invalid path or a path this mod already used (POLY-CONTENT-001)
Throws IllegalStateException — after registration closed (POLY-CONTENT-002)
entity(String, EntityDefinition)
EntityHandle entity(String path, EntityDefinition definition)
Since 0.1.0-alpha.4 or earlier
Declares a mob type; with spawnEgg also an item <path>_spawn_egg. Mobs are spawned by eggs, commands (/summon), WorldView.spawnEntity, and naturally where the definition says.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
definition | EntityDefinition | — |
Returns EntityHandle
effect(String, EffectDefinition)
EffectHandle effect(String path, EffectDefinition definition)
Since 0.1.0-alpha.4 or earlier
Declares a status effect usable with /effect and LivingEntityView.addEffect.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
definition | EffectDefinition | — |
Returns EffectHandle
booleanRule(String, boolean, GameRuleCategory)
GameRuleKey<Boolean> booleanRule(String path, boolean defaultValue, GameRuleCategory category)
Since 0.1.0-alpha.4 or earlier
Declares a boolean game rule.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
defaultValue | boolean | — |
category | GameRuleCategory | — |
Returns GameRuleKey<Boolean>
integerRule(String, int, int, int, GameRuleCategory)
GameRuleKey<Integer> integerRule(String path, int defaultValue, int min, int max, GameRuleCategory category)
Since 0.1.0-alpha.4 or earlier
Declares an integer game rule limited to [min, max].
| Parameter | Type | Description |
|---|---|---|
path | String | — |
defaultValue | int | — |
min | int | — |
max | int | — |
category | GameRuleCategory | — |
Returns GameRuleKey<Integer>
sound(String)
SoundHandle sound(String path)
Since 0.1.0-alpha.4 or earlier
Declares a sound event.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
Returns SoundHandle
projectile(String, ProjectileDefinition)
EntityHandle projectile(String path, ProjectileDefinition definition)
Since 0.1.0-alpha.4 or earlier
Declares a thrown projectile type.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
definition | ProjectileDefinition | — |
Returns EntityHandle
itemComponent(String, ComponentType<T>)
<T> ItemComponentKey<T> itemComponent(String path, ComponentType<T> type)
Since 0.1.0-alpha.4 or earlier
Declares a data component that item stacks can carry.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
type | ComponentType<T> | — |
Returns ItemComponentKey<T>
Throws IllegalArgumentException — for an invalid or used path (POLY-CONTENT-001)
particle(String, ParticleDefinition)
ContentHandle particle(String path, ParticleDefinition definition)
Since 0.1.0-alpha.4 or earlier
Declares a particle type, spawnable with WorldView.spawnParticles and /particle.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
definition | ParticleDefinition | — |
Returns ContentHandle
entityData(String, boolean)
default EntityDataKey entityData(String path, boolean syncToOwner)
Since 0.1.0-alpha.4 or earlier
Declares data that entities carry; see EntityDataKey.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
syncToOwner | boolean | — |
Returns EntityDataKey
entityData(String, EntityDataOptions)
EntityDataKey entityData(String path, EntityDataOptions options)
Since 0.1.0-alpha.4 or earlier
Declares data that entities carry, with synchronisation and version options.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
options | EntityDataOptions | — |
Returns EntityDataKey
advancementTrigger(String)
AdvancementTrigger advancementTrigger(String path)
Since 0.1.0-alpha.4 or earlier
Declares an advancement criterion trigger <mod id>:<path>.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
Returns AdvancementTrigger
addToTag(TagKey, ResourceId[])
void addToTag(TagKey tag, ResourceId... entries)
Since 0.1.0-alpha.4 or earlier
Adds entries to a tag of any namespace, as a tag file with "replace": false in the mod jar would; Poly Mod Loader writes them to its generated data pack. Several calls and several mods add up. Entries are checked when the registries freeze: an entry that is not registered then is reported (POLY-CONTENT-007) and left out, the rest of the tag still loads.
| Parameter | Type | Description |
|---|---|---|
tag | TagKey | — |
entries | ResourceId[] | block, item, or entity type IDs matching the tag's registry |
Throws IllegalArgumentException — for no entries
Throws IllegalStateException — after registration closed (POLY-CONTENT-002)
creativeTab(String, CreativeTabDefinition)
ContentHandle creativeTab(String path, CreativeTabDefinition definition)
Since 0.1.0-alpha.4 or earlier
Declares a creative inventory tab <mod id>:<path>, titled by the translation of itemGroup.<mod id>.<path>. Entries and icon are checked when the registries freeze: one that is not a registered item then is reported (POLY-CONTENT-008) and left out (a missing icon falls back to the first valid entry).
| Parameter | Type | Description |
|---|---|---|
path | String | — |
definition | CreativeTabDefinition | — |
Returns ContentHandle
Throws IllegalArgumentException — for an invalid or used path (POLY-CONTENT-001)
Throws IllegalStateException — after registration closed (POLY-CONTENT-002)
CreativeTab
enum · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public enum CreativeTab
The game's creative inventory tabs that mod items can be listed in. Items are appended at the end.
| Constant | Description |
|---|---|
BUILDING_BLOCKS | — |
COLORED_BLOCKS | — |
NATURAL_BLOCKS | — |
FUNCTIONAL_BLOCKS | — |
REDSTONE_BLOCKS | — |
TOOLS_AND_UTILITIES | — |
COMBAT | — |
FOOD_AND_DRINKS | — |
INGREDIENTS | — |
SPAWN_EGGS | — |
CreativeTabDefinition
record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public record CreativeTabDefinition(Optional<ResourceId> icon, List<ResourceId> entries)
A mod's own creative inventory tab, declared with ContentRegistrar.creativeTab. Created with builder(); immutable. The tab's title is the translation of itemGroup.<mod id>.<path> from the mod's language files.
The game's creative screen has room for its own tabs only, so Poly Mod Loader puts mod tabs on extra pages (ten per page, in declaration order) and adds page buttons to the screen. Items can still be listed in the game's tabs with CreativeTab.
| Component | Type | Description |
|---|---|---|
icon | Optional<ResourceId> | item shown on the tab; empty for the first entry |
entries | List<ResourceId> | items listed in the tab, in this order: mod items or the game's |
iconOrFirstEntry()
public ResourceId iconOrFirstEntry()
Since 0.1.0-alpha.4 or earlier
The icon: the declared one or the first entry.
Returns ResourceId
builder()
public static CreativeTabDefinition.Builder builder()
Since 0.1.0-alpha.4 or earlier
A builder for a tab without entries yet.
Returns CreativeTabDefinition.Builder
CreativeTabDefinition.Builder
class · Since 0.1.0-alpha.4 or earlier
public static final class Builder
Builds a CreativeTabDefinition.
icon(ResourceId)
public CreativeTabDefinition.Builder icon(ResourceId item)
Since 0.1.0-alpha.4 or earlier
Sets the item shown on the tab.
| Parameter | Type | Description |
|---|---|---|
item | ResourceId | — |
Returns CreativeTabDefinition.Builder
entry(ResourceId)
public CreativeTabDefinition.Builder entry(ResourceId item)
Since 0.1.0-alpha.4 or earlier
Adds an item to the end of the tab.
| Parameter | Type | Description |
|---|---|---|
item | ResourceId | — |
Returns CreativeTabDefinition.Builder
entries(ResourceId[])
public CreativeTabDefinition.Builder entries(ResourceId... items)
Since 0.1.0-alpha.4 or earlier
Adds items to the end of the tab, in order.
| Parameter | Type | Description |
|---|---|---|
items | ResourceId[] | — |
Returns CreativeTabDefinition.Builder
build()
public CreativeTabDefinition build()
Since 0.1.0-alpha.4 or earlier
Builds the definition.
Returns CreativeTabDefinition
Throws IllegalArgumentException — when no entry was added
EntityDataKey
record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public record EntityDataKey(ResourceId id, EntityDataOptions options)
Mod data attached to entities (players included): a DataTree per entity, saved with it, kept by players when they respawn, and synchronised to clients as the EntityDataOptions say. Read it with EntityView.data(EntityDataKey).
| Component | Type | Description |
|---|---|---|
id | ResourceId | key ID |
options | EntityDataOptions | synchronisation and version |
syncToOwner()
public boolean syncToOwner()
Since 0.1.0-alpha.4 or earlier
Whether a player's own client receives the player's data.
Returns boolean
EntityDataOptions
record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public record EntityDataOptions(boolean syncToOwner, boolean syncToTrackers, int version, Optional<DataMigration> migration)
How an EntityDataKey is kept and shared.
| Component | Type | Description |
|---|---|---|
syncToOwner | boolean | a player's own client receives the player's data |
syncToTrackers | boolean | every client that can see the entity receives its data (for drawing or client logic); includes the owner |
version | int | current data version; data saved with an older one runs migration |
migration | Optional<DataMigration> | upgrades older data, if any |
| Constant or field | Type | Description |
|---|---|---|
DEFAULT | EntityDataOptions | Saved only, not synchronised, version 0. |
syncedToOwner()
public EntityDataOptions syncedToOwner()
Since 0.1.0-alpha.4 or earlier
A copy whose data a player's own client receives.
Returns EntityDataOptions
syncedToTrackers()
public EntityDataOptions syncedToTrackers()
Since 0.1.0-alpha.4 or earlier
A copy whose data every client that can see the entity receives.
Returns EntityDataOptions
withVersion(int, DataMigration)
public EntityDataOptions withVersion(int value, DataMigration upgrade)
Since 0.1.0-alpha.4 or earlier
A copy with data version value; upgrade converts data saved with an older version.
| Parameter | Type | Description |
|---|---|---|
value | int | — |
upgrade | DataMigration | — |
Returns EntityDataOptions
SoundHandle
interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public interface SoundHandle extends ContentHandle
A declared sound event. Its files are listed in the mod's assets/<mod id>/sounds.json under the same path, as for the game's sounds.
Supertypes: ContentHandle