Skip to main content
Version: Minecraft 26.2

dev.polymodloader.api.world

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
BlockPosrecordInteger block coordinates.
DirectionenumThe six block faces; the first four horizontal ones are NORTH to EAST.
InteractionResultenumOutcome of a block or item interaction, mapped onto the game's interaction results.
StorageOptionsrecordHow WorldView.storage(ResourceId, StorageOptions) keeps data.
StoredDatainterfaceMod data saved with one dimension of a world, for state that belongs to no block or entity (counters, quest progress, claimed areas).
Vector3recordA direction or velocity in blocks (per tick for velocities).
WorldViewinterfaceRead 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.

ComponentTypeDescription
xinteast (+) / west (-)
yintup (+) / down (-)
zintsouth (+) / north (-)
Constant or fieldTypeDescription
ORIGINBlockPosThe 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.

ParameterTypeDescription
xint—
yint—
zint—

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.

ParameterTypeDescription
dxint—
dyint—
dzint—

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.

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

ConstantDescription
SUCCESSThe interaction happened; the player's arm swings.
CONSUMEThe interaction happened without an arm swing.
PASSNothing happened; the game continues with its default behaviour.
FAILThe 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.

ComponentTypeDescription
versionintthe current data version; saved data of an older version runs migration
migrationOptional<DataMigration>upgrades older data, if any
syncToClientsbooleanwhether every player's client gets a read-only copy, updated on StoredData.markChanged()
Constant or fieldTypeDescription
DEFAULTStorageOptionsVersion 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.

ParameterTypeDescription
valueint—
upgradeDataMigration—

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

ComponentTypeDescription
xdoubleeast (+) / west (-)
ydoubleup (+) / down (-)
zdoublesouth (+) / north (-)
Constant or fieldTypeDescription
ZEROVector3No 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.

ParameterTypeDescription
posBlockPos—

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.

ParameterTypeDescription
posBlockPos—
blockResourceId—

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.

ParameterTypeDescription
posBlockPos—

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.

ParameterTypeDescription
posBlockPos—
propertyBlockProperty<T>—
valueT—

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.

ParameterTypeDescription
posBlockPos—

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.

ParameterTypeDescription
idResourceId—

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.

ParameterTypeDescription
ticksint—
taskRunnable—

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.

ParameterTypeDescription
idResourceId—
optionsStorageOptions—

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.

ParameterTypeDescription
typeResourceId—
xdouble—
ydouble—
zdouble—

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.

ParameterTypeDescription
xdouble—
ydouble—
zdouble—
radiusdouble—

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

ParameterTypeDescription
posBlockPos—
soundResourceId—
volumefloat—
pitchfloat—

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.

ParameterTypeDescription
particleResourceId—
xdouble—
ydouble—
zdouble—
countint—
spreaddoublerandom 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.

ParameterTypeDescription
ruleGameRuleKey<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.

ParameterTypeDescription
ruleGameRuleKey<T>—
valueT—

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

ParameterTypeDescription
chunkXint—
chunkZint—
forcedboolean—

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.

ParameterTypeDescription
chunkXint—
chunkZint—

Returns boolean

biomeAt(BlockPos)​

ResourceId biomeAt(BlockPos pos)

Since 0.1.0-alpha.4 or earlier

The biome at pos, for example minecraft:plains.

ParameterTypeDescription
posBlockPos—

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.

ParameterTypeDescription
posBlockPos—
tagTagKey—

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.

ParameterTypeDescription
posBlockPos—

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.

ParameterTypeDescription
posBlockPos—
categoryMobCategory—

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.

ParameterTypeDescription
dimensionResourceId—

Returns Optional<WorldView>

Buy me a coffee