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

    A class that represents a particular dimension (e.g., The End) within a world.

    Index

    Constructors

    Properties

    id: string

    Identifier of the dimension.

    This property can throw when used.

    Methods

    • Beta

      Parameters

      • location: Vector3

        The location of the explosion.

      • radius: number

        Radius, in blocks, of the explosion to create.

      • OptionalexplosionOptions: ExplosionOptions

        Additional configurable options for the explosion.

      Returns void

      Creates an explosion at the specified location.

      This function can throw errors.

      overworld.createExplosion(targetLocation, 10, new mc.ExplosionOptions());
      const explosionLoc: mc.Vector3 = { x: targetLocation.x + 0.5, y: targetLocation.y + 0.5, z: targetLocation.z + 0.5 };

      const fireExplosionOptions = new mc.ExplosionOptions();

      // Explode with fire
      fireExplosionOptions.causesFire = true;

      overworld.createExplosion(explosionLoc, 15, fireExplosionOptions);
      const waterExplosionOptions = new mc.ExplosionOptions();

      // Explode in water
      waterExplosionOptions.allowUnderwater = true;

      const belowWaterLoc: mc.Vector3 = { x: targetLocation.x + 3, y: targetLocation.y + 1, z: targetLocation.z + 3 };

      overworld.createExplosion(belowWaterLoc, 10, waterExplosionOptions);
      const explosionOptions = new mc.ExplosionOptions();

      // Start by exploding without breaking blocks
      explosionOptions.breaksBlocks = false;

      const explodeNoBlocksLoc: mc.Vector3 = {
      x: Math.floor(targetLocation.x + 1),
      y: Math.floor(targetLocation.y + 2),
      z: Math.floor(targetLocation.z + 1),
      };

      overworld.createExplosion(explodeNoBlocksLoc, 15, explosionOptions);
    • Beta

      Parameters

      • begin: Vector3

        The lower northwest starting corner of the area.

      • end: Vector3

        The upper southeast ending corner of the area.

      • block: BlockPermutation | BlockType

        Type of block to fill the volume with.

      • Optionaloptions: BlockFillOptions

        A set of additional options, such as a matching block to potentially replace this fill block with.

      Returns number

      Returns number of blocks placed.

      Fills an area between begin and end with block of type block.

      This function can throw errors.

    • Beta

      Parameters

      • location: Vector3

        The location at which to return a block.

      Returns Block

      Block at the specified location.

      Returns a block instance at the given location. This method was introduced as of version 1.17.10.21.

      This function can throw errors.

    • Beta

      Parameters

      Returns Block

      Gets the first block that intersects with a vector emanating from a location.

      This function can throw errors.

    • Beta

      Parameters

      Returns EntityIterator

      An entity array.

      Returns a set of entities based on a set of conditions defined via the EntityQueryOptions set of filter criteria.

      This function can throw errors.

      const query = {
      type: "item",
      location: targetLocation,
      };
      const items = overworld.getEntities(query);

      for (const item of items) {
      const itemComp = item.getComponent("item") as any;

      if (itemComp) {
      if (itemComp.itemStack.id.endsWith("feather")) {
      console.log("Success! Found a feather", 1);
      }
      }
      }
    • Beta

      Parameters

      • location: Vector3

        The location at which to return entities.

      Returns Entity[]

      Zero or more entities at the specified location.

      Returns a set of entities at a particular location.

    • Beta

      Parameters

      Returns Entity[]

      Gets entities that intersect with a specified vector emanating from a location.

      This function can throw errors.

    • Parameters

      • commandString: string

        Command to run. Note that command strings should not start with slash.

      Returns Promise<CommandResult>

      For commands that return data, returns a CommandResult with an indicator of command results.

      Runs a particular command asynchronously from the context of the broader dimension. Note that there is a maximum queue of 128 asynchronous commands that can be run in a given tick.

      This function can throw errors.

    • Beta

      Parameters

      • identifier: string

        Identifier of the type of entity to spawn. If no namespace is specified, 'minecraft:' is assumed.

      • location: Vector3

        The location at which to create the entity.

      Returns Entity

      Newly created entity at the specified location.

      Creates a new entity (e.g., a mob) at the specified location.

      This function can throw errors.

      // create a horse and trigger the 'ageable_grow_up' event, ensuring the horse is created as an adult
      overworld.spawnEntity("minecraft:horse<minecraft:ageable_grow_up>", targetLocation);
      const fox = overworld.spawnEntity("minecraft:fox", {
      x: targetLocation.x + 1,
      y: targetLocation.y + 2,
      z: targetLocation.z + 3,
      });
      fox.addEffect(mc.MinecraftEffectTypes.speed, 10, 20);
      log("Created a fox.");

      const wolf = overworld.spawnEntity("minecraft:wolf", {
      x: targetLocation.x + 4,
      y: targetLocation.y + 2,
      z: targetLocation.z + 3,
      });
      wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, 20);
      wolf.isSneaking = true;
      log("Created a sneaking wolf.", 1);
      let ticks = 0;

      mc.world.events.tick.subscribe((event: mc.TickEvent) => {
      ticks++;

      // Minecraft runs at 20 ticks per second
      if (ticks % 1200 === 0) {
      overworld.runCommand("say Another minute passes...");
      }
      });
    • Beta

      Parameters

      • item: ItemStack
      • location: Vector3

        The location at which to create the item stack.

      Returns Entity

      Newly created item stack entity at the specified location.

      Creates a new item stack as an entity at the specified location.

      This function can throw errors.

      const oneItemLoc: mc.Vector3 = { x: 3, y: 2, z: 1 };
      const fiveItemsLoc: mc.Vector3 = { x: 1, y: 2, z: 1 };
      const diamondPickaxeLoc: mc.Vector3 = { x: 2, y: 2, z: 4 };

      const oneEmerald = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 1, 0);
      const onePickaxe = new mc.ItemStack(mc.MinecraftItemTypes.diamondPickaxe, 1, 0);
      const fiveEmeralds = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 5, 0);

      overworld.spawnItem(oneEmerald, oneItemLoc);
      overworld.spawnItem(fiveEmeralds, fiveItemsLoc);
      overworld.spawnItem(onePickaxe, diamondPickaxeLoc);
      const featherItem = new mc.ItemStack(mc.MinecraftItemTypes.feather, 1, 0);

      overworld.spawnItem(featherItem, targetLocation);
      log("New feather created!");
    • Beta

      Parameters

      • effectName: string

        Identifier of the particle to create.

      • location: Vector3

        The location at which to create the particle emitter.

      • molangVariables: MolangVariableMap

        A set of additional, customizable variables that can be adjusted for this particle emitter.

      Returns void

      Newly created entity at the specified location.

      Creates a new particle emitter at a specified location in the world.