Script API - v1.26.10.23
    Preparing search index...

    Class StructureManager

    Index

    Constructors

    Methods

    • Parameters

      Returns Structure

      This function can't be called in read-only mode.

      This function can't be called in early-execution mode.

      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 ~ ~ ~
    • Parameters

      Returns Structure

      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.

      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,
      });
    • Parameters

      • identifier: string

      Returns Structure

      This function can't be called in read-only mode.

      This function can't be called in early-execution mode.

      import { world } from "@minecraft/server";

      world.structureManager.get("mystructure:test");
    • Returns string[]

      This function can't be called in read-only mode.

      This function can't be called in early-execution mode.

      import { world } from "@minecraft/server";

      world.structureManager.getWorldStructureIds().forEach((id) => {
      const structure = world.structureManager.get(id);
      structure.isValid;
      });
    • Parameters

      Returns void

      This function can't be called in read-only mode.

      This function can't be called in early-execution mode.

      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,
      });
      import { world } from "@minecraft/server";
      const player = world.getPlayers()[0];
      world.structureManager.place("mystructure:test", player.dimension, player.location);
    • Parameters

      Returns BlockBoundingBox

      This function can't be called in read-only mode.

      This function can throw errors.

      PlaceJigsawError

      This function can't be called in early-execution mode.

      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 }
      );
      }