Skip to main content
Version: Minecraft 26.2

dev.polymodloader.api.content

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
AdvancementTriggerinterfaceA criterion trigger for advancements in data packs: an advancement criterion with "trigger": "<mod id>:<path>" is met when the mod calls trigger.
ContentHandleinterfaceA declared piece of content.
ContentRegistrarinterfaceDeclares a mod's blocks and items.
CreativeTabenumThe game's creative inventory tabs that mod items can be listed in.
CreativeTabDefinitionrecordA mod's own creative inventory tab, declared with ContentRegistrar.creativeTab.
CreativeTabDefinition.BuilderclassBuilds a CreativeTabDefinition.
EntityDataKeyrecordMod 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.
EntityDataOptionsrecordHow an EntityDataKey is kept and shared.
SoundHandleinterfaceA 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.

ParameterTypeDescription
playerPlayerView—

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.

ParameterTypeDescription
pathString—
definitionBlockDefinition—

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.

ParameterTypeDescription
pathString—
definitionItemDefinition—

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.

ParameterTypeDescription
pathString—
definitionEntityDefinition—

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.

ParameterTypeDescription
pathString—
definitionEffectDefinition—

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.

ParameterTypeDescription
pathString—
defaultValueboolean—
categoryGameRuleCategory—

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].

ParameterTypeDescription
pathString—
defaultValueint—
minint—
maxint—
categoryGameRuleCategory—

Returns GameRuleKey<Integer>

sound(String)​

SoundHandle sound(String path)

Since 0.1.0-alpha.4 or earlier

Declares a sound event.

ParameterTypeDescription
pathString—

Returns SoundHandle

projectile(String, ProjectileDefinition)​

EntityHandle projectile(String path, ProjectileDefinition definition)

Since 0.1.0-alpha.4 or earlier

Declares a thrown projectile type.

ParameterTypeDescription
pathString—
definitionProjectileDefinition—

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.

ParameterTypeDescription
pathString—
typeComponentType<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.

ParameterTypeDescription
pathString—
definitionParticleDefinition—

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.

ParameterTypeDescription
pathString—
syncToOwnerboolean—

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.

ParameterTypeDescription
pathString—
optionsEntityDataOptions—

Returns EntityDataKey

advancementTrigger(String)​

AdvancementTrigger advancementTrigger(String path)

Since 0.1.0-alpha.4 or earlier

Declares an advancement criterion trigger <mod id>:<path>.

ParameterTypeDescription
pathString—

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.

ParameterTypeDescription
tagTagKey—
entriesResourceId[]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).

ParameterTypeDescription
pathString—
definitionCreativeTabDefinition—

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.

ConstantDescription
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.

ComponentTypeDescription
iconOptional<ResourceId>item shown on the tab; empty for the first entry
entriesList<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.

ParameterTypeDescription
itemResourceId—

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.

ParameterTypeDescription
itemResourceId—

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.

ParameterTypeDescription
itemsResourceId[]—

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).

ComponentTypeDescription
idResourceIdkey ID
optionsEntityDataOptionssynchronisation 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.

ComponentTypeDescription
syncToOwnerbooleana player's own client receives the player's data
syncToTrackersbooleanevery client that can see the entity receives its data (for drawing or client logic); includes the owner
versionintcurrent data version; data saved with an older one runs migration
migrationOptional<DataMigration>upgrades older data, if any
Constant or fieldTypeDescription
DEFAULTEntityDataOptionsSaved 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.

ParameterTypeDescription
valueint—
upgradeDataMigration—

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

Buy me a coffee