The name of the structure. A valid identifier must include a namespace and must be unique.
The size of the structure. For example, to create a single block structure the size should be {x:1, y:1, z:1}.
Optional
saveMode: StructureSaveModeHow the Structure should be saved upon creation. Defaults to StructureSaveMode.Memory.
Returns the newly created Structure.
Creates an empty Structure in memory. Use Structure.setBlockPermutation to populate the structure with blocks and save changes with Structure.saveAs.
This function can't be called in read-only mode.
Throws if the identifier is invalid. A valid identifier must include a namespace and must be unique.
import { BlockPermutation, StructureSaveMode, world } from "@minecraft/server";
import { MinecraftBlockTypes } from "@minecraft/vanilla-data";
const structure = world.structureManager.createEmpty(
"mystructure:random",
{ x: 10, y: 10, z: 10 },
StructureSaveMode.World
);
const concretes = [
MinecraftBlockTypes.RedConcrete,
MinecraftBlockTypes.YellowConcrete,
MinecraftBlockTypes.BlueConcrete,
];
for (let x = 0; x < 10; x++) {
for (let y = 0; y < 10; y++) {
for (let z = 0; z < 10; z++) {
const permutation = BlockPermutation.resolve(
concretes[Math.floor(Math.random() * concretes.length)]
);
structure.setBlockPermutation({ x, y, z }, permutation);
}
}
}
// Run this command: /structure load mystructure:empty ~ ~ ~
The name of the structure. A valid identifier must include a namespace and must be unique.
The dimension where the blocks should be read from.
Optional
options: StructureCreateOptionsAdditional options for creating a structure from the world.
Returns the newly created Structure.
Creates a new Structure from blocks in the world. This is functionally equivalent to the /structure save command.
This function can't be called in read-only mode.
Throws if the identifier is invalid. A valid identifier must include a namespace and must be unique. Throws if the structure bounds exceed the maximum size. Throws if the structure bounds contains blocks outside the world bounds.
import { StructureSaveMode, world } from "@minecraft/server";
import { Vector3Builder, Vector3Utils } from "@minecraft/math";
const player = world.getAllPlayers()[0];
const from = player.location;
const to = Vector3Utils.add(from, new Vector3Builder(15, 15, 15));
world.structureManager.createFromWorld(
"mystructure:test",
player.dimension,
from,
to,
{ saveMode: StructureSaveMode.World }
);
The structure's identifier or a Structure object.
The dimension where the Structure should be placed.
The location within the dimension where the Structure should be placed.
Optional
options: StructurePlaceOptionsAdditional options for Structure placement.
Places a structure in the world. Structures placed in unloaded chunks will be queued for loading.
This function can't be called in read-only mode.
Throws if the integrity value is outside of the range [0,1] Throws if the integrity seed is invalid. Throws if the placement location contains blocks that are outside the world bounds.
minecraftcommon.ArgumentOutOfBoundsError
import {
world,
StructureAnimationMode,
StructureSaveMode,
BlockPermutation,
} from "@minecraft/server";
import { MinecraftBlockTypes } from "@minecraft/vanilla-data";
function getRandomStructure() {
// Return existing mystructure:random structure
if (
world.structureManager
.getWorldStructureIds()
.includes("mystructure:random")
) {
return world.structureManager.get("mystructure:random");
}
// Create a new mystructure:random structure otherwise
const structure = world.structureManager.createEmpty(
"mystructure:random",
{ x: 10, y: 10, z: 10 },
StructureSaveMode.World
);
const concretes = [
MinecraftBlockTypes.RedConcrete,
MinecraftBlockTypes.YellowConcrete,
MinecraftBlockTypes.BlueConcrete,
];
for (let x = 0; x < 10; x++) {
for (let y = 0; y < 10; y++) {
for (let z = 0; z < 10; z++) {
const permutation = BlockPermutation.resolve(
concretes[Math.floor(Math.random() * concretes.length)]
);
structure.setBlockPermutation({ x, y, z }, permutation);
}
}
}
return structure;
}
const structure = getRandomStructure();
const player = world.getPlayers()[0];
// Place structure on player's location
world.structureManager.place(structure, player.dimension, player.location, {
animationMode: StructureAnimationMode.Blocks,
animationSeconds: 15,
});
Beta
The identifier of the template pool to start from.
The name of the jigsaw block to start from. This block must be included in at least one of the starting pool structure templates.
The maximum recursion depth for the jigsaw structure.
The dimension to place the jigsaw structure in.
The location where the jigsaw structure will begin generating relative to the targetJigsaw block.
Optional
options: JigsawPlaceOptionsOptional settings to use when generating the jigsaw structure.
Places a partial jigsaw structure in the world. This is useful for debugging connections between jigsaw blocks.
This function can't be called in read-only mode.
Beta
The identifier of the jigsaw structure.
The dimension to place the jigsaw structure in.
The location where the jigsaw structure will begin generating. Note that the y value will be overridden by the structure's start height unless the ignoreStarJigsawStructurePlaceOptions ignoreStartHeight option is set.
Optional
options: JigsawStructurePlaceOptionsOptional settings to use when generating the jigsaw structure.
Throws if generation fails due to invalid parameters or jigsaw configuration. Throws if the placement location contains blocks that are outside the world bounds.
import { world } from "@minecraft/server";
// Command for /place structure minecraft:trail_ruins 10 20 30
function placeTrailRuins() {
const overworld = world.getDimension("overworld");
// Spawn trail ruins structure in overworld
world.structureManager.placeJigsawStructure(
"minecraft:trail_ruins",
overworld,
{ x: 10, y: 20, z: 30 }
);
}
import { world } from "@minecraft/server";
// Command for /place structure minecraft:trial_chambers 10 20 30 true true
function placeTrialChambers() {
const overworld = world.getDimension("overworld");
// Spawn trial chambers structure in overworld
world.structureManager.placeJigsawStructure(
"minecraft:trial_chambers",
overworld,
{ x: 10, y: 20, z: 30 },
{ ignoreStartHeight: true, keepJigsaws: true }
);
}
Manager for Structure related APIs. Includes APIs for creating, getting, placing and deleting Structures.