Skip to main content
Version: Minecraft 26.2

dev.polymodloader.api.resource

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
BinaryReloadListenerfunctional interfaceLike ResourceReloadListener, for files of any kind: their bytes as stored in the pack.
ResourceIdrecordA namespaced identifier such as minecraft:stone or my_mod:copper_bricks.
ResourceRegistrarinterfaceLets mods read their own kinds of JSON files from data packs and resource packs, like the game reads recipes or models.
ResourceReloadListenerfunctional interfaceReceives a mod's own data or asset files each time the game (re)loads its packs.

BinaryReloadListener​

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

public interface BinaryReloadListener

Like ResourceReloadListener, for files of any kind: their bytes as stored in the pack.

onReload(Map<ResourceId,byte[]>)​

void onReload(Map<ResourceId,byte[]> files)

Since 0.1.0-alpha.4 or earlier

Files by ID (<namespace>:<path without the suffix>); the arrays are the listener's own.

ParameterTypeDescription
filesMap<ResourceId,byte[]>—

ResourceId​

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

public record ResourceId(String namespace, String path) implements Comparable<ResourceId>

A namespaced identifier such as minecraft:stone or my_mod:copper_bricks. Names use Minecraft's rules: the namespace may contain a-z 0-9 _ - ., the path additionally /. Invalid names are rejected when the identifier is created, not when the game uses it.

ComponentTypeDescription
namespaceStringmod ID or minecraft
pathStringname inside the namespace

of(String, String)​

public static ResourceId of(String namespace, String path)

Since 0.1.0-alpha.4 or earlier

Creates namespace:path.

ParameterTypeDescription
namespaceString—
pathString—

Returns ResourceId

minecraft(String)​

public static ResourceId minecraft(String path)

Since 0.1.0-alpha.4 or earlier

An identifier in the minecraft namespace.

ParameterTypeDescription
pathString—

Returns ResourceId

parse(String)​

public static ResourceId parse(String text)

Since 0.1.0-alpha.4 or earlier

Parses namespace:path; text without a colon is in the minecraft namespace, as in the game's commands and data files.

ParameterTypeDescription
textString—

Returns ResourceId

ResourceRegistrar​

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

public interface ResourceRegistrar

Lets mods read their own kinds of JSON files from data packs and resource packs, like the game reads recipes or models. Register in entrypoints.

onDataReload(String, ResourceReloadListener)​

void onDataReload(String directory, ResourceReloadListener listener)

Since 0.1.0-alpha.4 or earlier

Reads data/<namespace>/<directory>/**.json from all enabled data packs (including mod jars) when the server starts and on /reload; the listener runs on the server thread after the game's own data has loaded.

ParameterTypeDescription
directoryStringfor example my_mod/spells; a-z 0-9 _ / . -
listenerResourceReloadListener—

Throws IllegalArgumentException — for an invalid directory (POLY-RESOURCE-001)

Throws IllegalStateException — after registration closed (POLY-RESOURCE-002)

onAssetReload(String, ResourceReloadListener)​

void onAssetReload(String directory, ResourceReloadListener listener)

Since 0.1.0-alpha.4 or earlier

Reads assets/<namespace>/<directory>/**.json from the enabled resource packs when the client starts and on F3+T; the listener runs on the client thread. Client only; on a dedicated server it is never called.

ParameterTypeDescription
directoryString—
listenerResourceReloadListener—

onDataFiles(String, String, BinaryReloadListener)​

void onDataFiles(String directory, String suffix, BinaryReloadListener listener)

Since 0.1.0-alpha.4 or earlier

Like onDataReload, for files ending in suffix (for example .png or .txt), handed over as bytes.

ParameterTypeDescription
directoryString—
suffixString—
listenerBinaryReloadListener—

onAssetFiles(String, String, BinaryReloadListener)​

void onAssetFiles(String directory, String suffix, BinaryReloadListener listener)

Since 0.1.0-alpha.4 or earlier

Like onAssetReload, for files ending in suffix, as bytes.

ParameterTypeDescription
directoryString—
suffixString—
listenerBinaryReloadListener—

ResourceReloadListener​

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

public interface ResourceReloadListener

Receives a mod's own data or asset files each time the game (re)loads its packs.

onReload(Map<ResourceId,String>)​

void onReload(Map<ResourceId,String> files)

Since 0.1.0-alpha.4 or earlier

The JSON files found, by ID: data/<namespace>/<directory>/<path>.json becomes <namespace>:<path>; contents are UTF-8 text. Higher-priority packs replace lower ones.

ParameterTypeDescription
filesMap<ResourceId,String>—
Buy me a coffee