This function can't be called in read-only mode.
This function can throw errors.
minecraftcommon.InvalidArgumentError
This function can't be called in early-execution mode.
OptionalallowUnloadedChunks: booleanThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionalexplosionOptions: ExplosionOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
Optionaloptions: BlockFillOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { BlockPermutation, BlockVolume, world } from "@minecraft/server";
// Command: /fill 0 10 0 20 30 40 underwater_tnt replace air
const overworld = world.getDimension("overworld");
const volume = new BlockVolume({ x: 0, y: 10, z: 0 }, { x: 20, y: 30, z: 40 });
const tnt = BlockPermutation.resolve("minecraft:underwater_tnt");
overworld.fillBlocks(volume, tnt, { blockFilter: { excludeTypes: ["minecraft:air"] } });
import { BlockPermutation, BlockVolume, Dimension, Vector3, world } from "@minecraft/server";
function fillBlockType(dimension: Dimension, from: Vector3, to: Vector3, block: string): void {
const volume = new BlockVolume(from, to);
dimension.fillBlocks(volume, block);
}
// Command: /fill 0 10 0 20 30 40 diamond_block
const overworld = world.getDimension("overworld");
fillBlockType(overworld, { x: 0, y: 10, z: 0 }, { x: 20, y: 30, z: 40 }, "minecraft:diamond_block");
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
Optionaloptions: BlockRaycastOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
Optionaloptions: BlockRaycastOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
Optionaloptions: BlockRaycastOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionalallowUnloadedChunks: booleanThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { BlockPermutation, BlockVolume, system, world } from "@minecraft/server";
// Get every non-air block location at chunk (0, 0)
const overworld = world.getDimension("overworld");
const volume = new BlockVolume(
{ x: 0, y: overworld.heightRange.min, z: 0 },
{ x: 15, y: overworld.heightRange.max, z: 15 }
);
const locations = overworld.getBlocks(volume, { excludeTypes: ["minecraft:air"] }, false);
/**
A simple generator that replace non-air blocks to cobblestone at chunk (0, 0),
yielding after each block placement.
@returns {Generator<void, void, void>} A generator that yields after each block placement.
/
function* blockPlacingGenerator() {
for (const location of locations.getBlockLocationIterator()) {
const block = overworld.getBlock(location);
block.setPermutation(BlockPermutation.resolve("minecraft:cobblestone"));
yield;
}
}
system.runJob(blockPlacingGenerator());
Optionaloptions: EntityQueryOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { EntityQueryOptions, GameMode, world } from "@minecraft/server";
const options: EntityQueryOptions = {
families: ["mob", "animal"],
excludeTypes: ["cow"],
maxDistance: 50,
excludeGameModes: [GameMode.Creative, GameMode.Spectator],
};
const filteredEntities = world.getDimension("overworld").getEntities(options);
console.log(
"Filtered Entities:",
filteredEntities.map((entity) => entity.typeId)
);
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
Optionaloptions: EntityRaycastOptionsThis function can't be called in read-only mode.
This function can throw errors.
minecraftcommon.InvalidArgumentError
minecraftcommon.UnsupportedFunctionalityError
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
Optionaloptions: EntityQueryOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { EntityQueryOptions, world } from "@minecraft/server";
const entityQueryOptions: EntityQueryOptions = {
maxDistance: 100,
scoreOptions: [
{ objective: "kills", minScore: 10 },
{ objective: "deaths", maxScore: 5 },
],
};
const filteredPlayers = world.getDimension("overworld").getPlayers(entityQueryOptions);
console.log(
"Filtered Players in Overworld:",
filteredPlayers.map((player) => player.name)
);
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionalminHeight: numberThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionalshouldThrow: booleanThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionalsoundOptions: WorldSoundOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
Optionalduration: numberThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
Optionaloptions: SpawnEntityOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionalmolangVariables: MolangVariableMapThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
Throws
This property can throw errors.
World Ready
This property can't be read in early-execution mode.
Example: dimensionHeightRange.js