dev.polymodloader.api.world
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 |
|---|---|---|
BlockPos | record | Integer block coordinates. |
Direction | enum | The six block faces; the first four horizontal ones are NORTH to EAST. |
InteractionResult | enum | Outcome of a block or item interaction, mapped onto the game's interaction results. |
StorageOptions | record | How WorldView.storage(ResourceId, StorageOptions) keeps data. |
StoredData | interface | Mod data saved with one dimension of a world, for state that belongs to no block or entity (counters, quest progress, claimed areas). |
Vector3 | record | A direction or velocity in blocks (per tick for velocities). |
WorldView | interface | Read and write access to one loaded dimension. |
BlockPos
record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public record BlockPos(int x, int y, int z)
Integer block coordinates. Inside a game test the coordinates are relative to the test structure; everywhere else they are absolute world coordinates.
| Component | Type | Description |
|---|---|---|
x | int | east (+) / west (-) |
y | int | up (+) / down (-) |
z | int | south (+) / north (-) |
| Constant or field | Type | Description |
|---|---|---|
ORIGIN | BlockPos | The position (0, 0, 0). |
of(int, int, int)
public static BlockPos of(int x, int y, int z)
Since 0.1.0-alpha.4 or earlier
Creates a position.
| Parameter | Type | Description |
|---|---|---|
x | int | — |
y | int | — |
z | int | — |
Returns BlockPos
offset(int, int, int)
public BlockPos offset(int dx, int dy, int dz)
Since 0.1.0-alpha.4 or earlier
This position moved by the given amounts.
| Parameter | Type | Description |
|---|---|---|
dx | int | — |
dy | int | — |
dz | int | — |
Returns BlockPos
above()
public BlockPos above()
Since 0.1.0-alpha.4 or earlier
The position one block up.
Returns BlockPos
below()
public BlockPos below()
Since 0.1.0-alpha.4 or earlier
The position one block down.
Returns BlockPos
Direction
enum · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public enum Direction
The six block faces; the first four horizontal ones are NORTH to EAST.
| Constant | Description |
|---|---|
DOWN | — |
UP | — |
NORTH | — |
SOUTH | — |
WEST | — |
EAST | — |
isHorizontal()
public boolean isHorizontal()
Since 0.1.0-alpha.4 or earlier
Whether this is one of the four horizontal directions.
Returns boolean
opposite()
public Direction opposite()
Since 0.1.0-alpha.4 or earlier
The direction pointing the other way.
Returns Direction
InteractionResult
enum · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public enum InteractionResult
Outcome of a block or item interaction, mapped onto the game's interaction results.
| Constant | Description |
|---|---|
SUCCESS | The interaction happened; the player's arm swings. |
CONSUME | The interaction happened without an arm swing. |
PASS | Nothing happened; the game continues with its default behaviour. |
FAIL | The interaction was refused; the game does not try anything else. |
StorageOptions
record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public record StorageOptions(int version, Optional<DataMigration> migration, boolean syncToClients)
How WorldView.storage(ResourceId, StorageOptions) keeps data.
| Component | Type | Description |
|---|---|---|
version | int | the current data version; saved data of an older version runs migration |
migration | Optional<DataMigration> | upgrades older data, if any |
syncToClients | boolean | whether every player's client gets a read-only copy, updated on StoredData.markChanged() |
| Constant or field | Type | Description |
|---|---|---|
DEFAULT | StorageOptions | Version 0, no migration, not synchronised. |
withVersion(int, DataMigration)
public StorageOptions withVersion(int value, DataMigration upgrade)
Since 0.1.0-alpha.4 or earlier
These options at version, upgrading older data with migration.
| Parameter | Type | Description |
|---|---|---|
value | int | — |
upgrade | DataMigration | — |
Returns StorageOptions
syncedToClients()
public StorageOptions syncedToClients()
Since 0.1.0-alpha.4 or earlier
These options, synchronised to clients.
Returns StorageOptions
StoredData
interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public interface StoredData
Mod data saved with one dimension of a world, for state that belongs to no block or entity (counters, quest progress, claimed areas). Server side only.
data()
DataTree data()
Since 0.1.0-alpha.4 or earlier
The data; call markChanged() after changing it so it is saved.
Returns DataTree
markChanged()
void markChanged()
Since 0.1.0-alpha.4 or earlier
Marks the data for saving with the next world save.
Vector3
record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public record Vector3(double x, double y, double z)
A direction or velocity in blocks (per tick for velocities).
| Component | Type | Description |
|---|---|---|
x | double | east (+) / west (-) |
y | double | up (+) / down (-) |
z | double | south (+) / north (-) |
| Constant or field | Type | Description |
|---|---|---|
ZERO | Vector3 | No movement. |
length()
public double length()
Since 0.1.0-alpha.4 or earlier
Length of the vector.
Returns double
WorldView
interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public interface WorldView
Read and write access to one loaded dimension.
Thread: only on the thread that handed out the view (the server or client thread). Lifetime: views passed to callbacks are valid only during the callback; do not store them.
dimension()
ResourceId dimension()
Since 0.1.0-alpha.4 or earlier
The dimension, for example minecraft:overworld.
Returns ResourceId
isClientSide()
boolean isClientSide()
Since 0.1.0-alpha.4 or earlier
Whether this is the client's copy of the world, which must not be changed.
Returns boolean
blockAt(BlockPos)
ResourceId blockAt(BlockPos pos)
Since 0.1.0-alpha.4 or earlier
The block at pos, for example minecraft:air. Unloaded positions read as air.
| Parameter | Type | Description |
|---|---|---|
pos | BlockPos | — |
Returns ResourceId
setBlock(BlockPos, ResourceId)
boolean setBlock(BlockPos pos, ResourceId block)
Since 0.1.0-alpha.4 or earlier
Replaces the block at pos with the default state of block and notifies neighbours and clients.
| Parameter | Type | Description |
|---|---|---|
pos | BlockPos | — |
block | ResourceId | — |
Returns boolean — whether the block changed
Throws IllegalArgumentException — when block is not a registered block
Throws IllegalStateException — on the client side
gameTime()
long gameTime()
Since 0.1.0-alpha.4 or earlier
Ticks since the world was created.
Returns long
players()
List<PlayerView> players()
Since 0.1.0-alpha.4 or earlier
Players in this dimension.
Returns List<PlayerView>
stateAt(BlockPos)
BlockStateView stateAt(BlockPos pos)
Since 0.1.0-alpha.4 or earlier
The block and its property values at pos.
| Parameter | Type | Description |
|---|---|---|
pos | BlockPos | — |
Returns BlockStateView
setProperty(BlockPos, BlockProperty<T>, T)
<T> boolean setProperty(BlockPos pos, BlockProperty<T> property, T value)
Since 0.1.0-alpha.4 or earlier
Changes one property of the block at pos, keeping the others.
| Parameter | Type | Description |
|---|---|---|
pos | BlockPos | — |
property | BlockProperty<T> | — |
value | T | — |
Returns boolean — whether the state changed
Throws IllegalArgumentException — when the block has no such property or the value is not allowed
Throws IllegalStateException — on the client side
blockEntityAt(BlockPos)
Optional<BlockEntityView> blockEntityAt(BlockPos pos)
Since 0.1.0-alpha.4 or earlier
The mod block entity at pos, if there is one.
| Parameter | Type | Description |
|---|---|---|
pos | BlockPos | — |
Returns Optional<BlockEntityView>
storage(ResourceId)
StoredData storage(ResourceId id)
Since 0.1.0-alpha.4 or earlier
Data saved with this dimension under id (use your mod ID as namespace), created empty on first use.
| Parameter | Type | Description |
|---|---|---|
id | ResourceId | — |
Returns StoredData
Throws IllegalStateException — on the client side
schedule(int, Runnable)
void schedule(int ticks, Runnable task)
Since 0.1.0-alpha.4 or earlier
Runs task on the server thread after ticks ticks of this dimension (0 = next tick). Pending tasks are dropped when the server stops; they are not saved.
| Parameter | Type | Description |
|---|---|---|
ticks | int | — |
task | Runnable | — |
Throws IllegalStateException — on the client side
storage(ResourceId, StorageOptions)
StoredData storage(ResourceId id, StorageOptions options)
Since 0.1.0-alpha.4 or earlier
World storage with a data version and optional client synchronisation. Saved data records its version; loading older data runs the migration first. The key poly_version is reserved. On the client this returns the synchronised copy (empty until the server sends it), read-only.
| Parameter | Type | Description |
|---|---|---|
id | ResourceId | — |
options | StorageOptions | — |
Returns StoredData
spawnEntity(ResourceId, double, double, double)
EntityView spawnEntity(ResourceId type, double x, double y, double z)
Since 0.1.0-alpha.4 or earlier
Spawns an entity of type (for example minecraft:pig or a mod mob) at the position; server side only.
| Parameter | Type | Description |
|---|---|---|
type | ResourceId | — |
x | double | — |
y | double | — |
z | double | — |
Returns EntityView
Throws IllegalArgumentException — for an unknown or unspawnable type
entitiesNear(double, double, double, double)
List<EntityView> entitiesNear(double x, double y, double z, double radius)
Since 0.1.0-alpha.4 or earlier
Entities whose position is within radius blocks of the point.
| Parameter | Type | Description |
|---|---|---|
x | double | — |
y | double | — |
z | double | — |
radius | double | — |
Returns List<EntityView>
playSound(BlockPos, ResourceId, float, float)
void playSound(BlockPos pos, ResourceId sound, float volume, float pitch)
Since 0.1.0-alpha.4 or earlier
Plays a sound to players near pos (server) or locally (client).
| Parameter | Type | Description |
|---|---|---|
pos | BlockPos | — |
sound | ResourceId | — |
volume | float | — |
pitch | float | — |
Throws IllegalArgumentException — for an unknown sound event
spawnParticles(ResourceId, double, double, double, int, double)
void spawnParticles(ResourceId particle, double x, double y, double z, int count, double spread)
Since 0.1.0-alpha.4 or earlier
Shows a simple particle (one without options, such as minecraft:heart or minecraft:flame) to nearby players; server side only.
| Parameter | Type | Description |
|---|---|---|
particle | ResourceId | — |
x | double | — |
y | double | — |
z | double | — |
count | int | — |
spread | double | random offset in blocks on each axis |
Throws IllegalArgumentException — for an unknown particle or one that needs options
gameRule(GameRuleKey<T>)
<T> T gameRule(GameRuleKey<T> rule)
Since 0.1.0-alpha.4 or earlier
The current value of a game rule in this world; server side only.
| Parameter | Type | Description |
|---|---|---|
rule | GameRuleKey<T> | — |
Returns T
setGameRule(GameRuleKey<T>, T)
<T> void setGameRule(GameRuleKey<T> rule, T value)
Since 0.1.0-alpha.4 or earlier
Changes a game rule for this world; server side only.
| Parameter | Type | Description |
|---|---|---|
rule | GameRuleKey<T> | — |
value | T | — |
setChunkForced(int, int, boolean)
boolean setChunkForced(int chunkX, int chunkZ, boolean forced)
Since 0.1.0-alpha.4 or earlier
Keeps a chunk loaded (and ticking) until released, like /forceload; saved with the world. Chunk coordinates are block coordinates divided by 16 (rounded down).
| Parameter | Type | Description |
|---|---|---|
chunkX | int | — |
chunkZ | int | — |
forced | boolean | — |
Returns boolean — whether the setting changed
Throws IllegalStateException — on the client side
isChunkLoaded(int, int)
boolean isChunkLoaded(int chunkX, int chunkZ)
Since 0.1.0-alpha.4 or earlier
Whether the chunk is loaded.
| Parameter | Type | Description |
|---|---|---|
chunkX | int | — |
chunkZ | int | — |
Returns boolean
biomeAt(BlockPos)
ResourceId biomeAt(BlockPos pos)
Since 0.1.0-alpha.4 or earlier
The biome at pos, for example minecraft:plains.
| Parameter | Type | Description |
|---|---|---|
pos | BlockPos | — |
Returns ResourceId
tags()
TagView tags()
Since 0.1.0-alpha.4 or earlier
The block, item, and entity type tags the game loaded (the server's data, or the client's copy).
Returns TagView
isBlockIn(BlockPos, TagKey)
boolean isBlockIn(BlockPos pos, TagKey tag)
Since 0.1.0-alpha.4 or earlier
Whether the block at pos is in a block tag, for example #minecraft:logs. Unloaded positions read as air.
| Parameter | Type | Description |
|---|---|---|
pos | BlockPos | — |
tag | TagKey | — |
Returns boolean
Throws IllegalArgumentException — when tag is not a block tag
emittedLight(BlockPos)
int emittedLight(BlockPos pos)
Since 0.1.0-alpha.4 or earlier
Light the block at pos emits, 0–15.
| Parameter | Type | Description |
|---|---|---|
pos | BlockPos | — |
Returns int
naturalSpawns(BlockPos, MobCategory)
List<ResourceId> naturalSpawns(BlockPos pos, MobCategory category)
Since 0.1.0-alpha.4 or earlier
Mobs that can spawn by themselves at pos in category, by the biome there; for checking natural spawn settings.
| Parameter | Type | Description |
|---|---|---|
pos | BlockPos | — |
category | MobCategory | — |
Returns List<ResourceId>
otherDimension(ResourceId)
Optional<WorldView> otherDimension(ResourceId dimension)
Since 0.1.0-alpha.4 or earlier
Another loaded dimension of the same server, such as a mod dimension from data; server side only.
| Parameter | Type | Description |
|---|---|---|
dimension | ResourceId | — |
Returns Optional<WorldView>