Private
constructorReadonly
typeThe BlockType that the permutation has.
This property can't be read in early-execution mode.
The type of liquid this function should be called for.
Whether this block is removed when touched by liquid.
This function can't be called in early-execution mode.
The type of liquid this function should be called for.
Whether this block can have a liquid placed over it.
This function can't be called in early-execution mode.
Returns the list of all of the block states that the permutation has.
This function can't be called in early-execution mode.
Optional
amount: numberNumber of instances of this block to place in the prototype item stack. Defaults to: 1
Retrieves a prototype item stack based on this block permutation that can be used with item Container/ContainerSlot APIs.
This function can't be called in early-execution mode.
Name of the block state who's value is to be returned.
Returns the state if the permutation has it, else
undefined
.
This function can't be called in early-execution mode.
This function can't be called in early-execution mode.
Returns true
if the permutation has the tag, else false
.
import { DimensionLocation } from "@minecraft/server";
function checkBlockTags(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
// Fetch the block
const block = targetLocation.dimension.getBlock(targetLocation);
// check that the block is loaded
if (block) {
log(`Block is dirt: ${block.hasTag("dirt")}`);
log(`Block is wood: ${block.hasTag("wood")}`);
log(`Block is stone: ${block.hasTag("stone")}`);
}
}
This function can't be called in early-execution mode.
The type of liquid this function should be called for.
Whether this block stops liquid from flowing.
This function can't be called in early-execution mode.
The type of liquid this function should be called for.
Whether this block is removed and spawns its item when touched by liquid.
This function can't be called in early-execution mode.
An optional set of states to compare against.
Optional
states: BlockStateArg<T>Returns a boolean whether a specified permutation matches this permutation. If states is not specified, matches checks against the set of types more broadly.
This function can't be called in early-execution mode.
// Script by WavePlayz
import { world } from "@minecraft/server";
/**
* Function to check if a given block is red wool
* @param {import('@minecraft/server').Block} block
* @returns true if a given block is red wool
*/
function isRedWool(block) {
// Define the type id of block we are checking for
let typeId = "wool";
// Define the block state we are looking for
// In this case, we want the color to be red
let states = { color: "red" };
// Check if the block matches the specified type and states
// The 'matches' method returns true if the block is of the specified type and has the specified states
return block.matches(typeId, states);
}
Identifier of the block property.
Value of the block property.
This function can't be called in early-execution mode.
Static
resolveIdentifier of the block to check.
Optional
states: BlockStateArg<T>Given a type identifier and an optional set of properties, will return a BlockPermutation object that is usable in other block APIs (e.g., block.setPermutation)
import { BlockPermutation, DimensionLocation } from "@minecraft/server";
import { Vector3Utils } from "@minecraft/math";
import { MinecraftBlockTypes } from "@minecraft/vanilla-data";
function addBlockColorCube(targetLocation: DimensionLocation) {
const allWoolBlocks: string[] = [
MinecraftBlockTypes.WhiteWool,
MinecraftBlockTypes.OrangeWool,
MinecraftBlockTypes.MagentaWool,
MinecraftBlockTypes.LightBlueWool,
MinecraftBlockTypes.YellowWool,
MinecraftBlockTypes.LimeWool,
MinecraftBlockTypes.PinkWool,
MinecraftBlockTypes.GrayWool,
MinecraftBlockTypes.LightGrayWool,
MinecraftBlockTypes.CyanWool,
MinecraftBlockTypes.PurpleWool,
MinecraftBlockTypes.BlueWool,
MinecraftBlockTypes.BrownWool,
MinecraftBlockTypes.GreenWool,
MinecraftBlockTypes.RedWool,
MinecraftBlockTypes.BlackWool,
];
const cubeDim = 7;
let colorIndex = 0;
for (let x = 0; x <= cubeDim; x++) {
for (let y = 0; y <= cubeDim; y++) {
for (let z = 0; z <= cubeDim; z++) {
colorIndex++;
targetLocation.dimension
.getBlock(Vector3Utils.add(targetLocation, { x, y, z }))
?.setPermutation(BlockPermutation.resolve(allWoolBlocks[colorIndex % allWoolBlocks.length]));
}
}
}
}
This function can't be called in early-execution mode.
Contains the combination of type BlockType and properties (also sometimes called block state) which describe a block (but does not belong to a specific Block).
Example: addTranslatedSign.ts