dev.polymodloader.api.resource
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 |
|---|---|---|
BinaryReloadListener | functional interface | Like ResourceReloadListener, for files of any kind: their bytes as stored in the pack. |
ResourceId | record | A namespaced identifier such as minecraft:stone or my_mod:copper_bricks. |
ResourceRegistrar | interface | Lets mods read their own kinds of JSON files from data packs and resource packs, like the game reads recipes or models. |
ResourceReloadListener | functional interface | Receives 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.
| Parameter | Type | Description |
|---|---|---|
files | Map<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.
| Component | Type | Description |
|---|---|---|
namespace | String | mod ID or minecraft |
path | String | name 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.
| Parameter | Type | Description |
|---|---|---|
namespace | String | — |
path | String | — |
Returns ResourceId
minecraft(String)
public static ResourceId minecraft(String path)
Since 0.1.0-alpha.4 or earlier
An identifier in the minecraft namespace.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
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.
| Parameter | Type | Description |
|---|---|---|
text | String | — |
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.
| Parameter | Type | Description |
|---|---|---|
directory | String | for example my_mod/spells; a-z 0-9 _ / . - |
listener | ResourceReloadListener | — |
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.
| Parameter | Type | Description |
|---|---|---|
directory | String | — |
listener | ResourceReloadListener | — |
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.
| Parameter | Type | Description |
|---|---|---|
directory | String | — |
suffix | String | — |
listener | BinaryReloadListener | — |
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.
| Parameter | Type | Description |
|---|---|---|
directory | String | — |
suffix | String | — |
listener | BinaryReloadListener | — |
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.
| Parameter | Type | Description |
|---|---|---|
files | Map<ResourceId,String> | — |