实验性
只读
实验性
dimension只读
实验性
is只读
实验性
is只读
实验性
is只读
实验性
is只读
实验性
location只读
实验性
permutation只读
实验性
type只读
实验性
type只读
实验性
x只读
实验性
y只读
实验性
z实验性
被检查放置可行性的BlockPermutation或BlockType或方块标识符。
Block type or block permutation to check placement for.
可选
faceToPlaceOn: Direction被检查放置的方向(可选)。
Optional specific face of this block to check placement against.
如果在此面可以放置这样的方块则返回 true
。
Returns true
if the block type or permutation can be
placed on this block, else false
.
检查在该方块的指定面上放置BlockPermutation或BlockType或指定标识符的方块是否可行。
Checks to see whether it is valid to place the specified block type or block permutation, on a specified face on this block
实验性
组件的标识符 (例如 'minecraft:inventory')。 如果未指定命名空间前缀,将默认使用 'minecraft:'。 可用的组件标识符可以在 BlockComponentTypes 枚举中找到。
The identifier of the component (e.g., 'minecraft:inventory'). If no namespace prefix is specified, 'minecraft:' is assumed. Available component IDs can be found as part of the BlockComponentTypes enum.
如果该组件存在于该方块,则返回该组件。 否则返回 undefined。
Returns the component if it exists on the block, otherwise undefined.
实验性
可选
amount: number要设置在物品对象-ItemStack中的这个方块的数量。
Number of instances of this block to place in the item stack.
可选
withData: boolean是否包括物品对象的附加数据。
Whether additional data facets of the item stack are included.
一个带有指定数量和数据的物品对象。 如果方块类型不兼容,则返回 undefined。
An itemStack with the specified amount of items and data. Returns undefined if block type is incompatible.
创建一个基于该方块的原型物品对象-ItemStack,可以与 Container/ContainerSlot 接口 一起使用。
Creates a prototype item stack based on this block that can be used with Container/ContainerSlot APIs.
实验性
要检查的标签。
Tag to check for.
如果该方块的BlockPermutation具有该标签,则返回 true
,否则返回 false
。
Returns true
if the permutation of this block has the tag,
else false
.
检查该方块的BlockPermutation是否具有特定的标签。
Checks to see if the permutation of this block has a specific tag.
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")}`);
}
}
实验性
Block type identifier to match this API against.
可选
states: Record<string, string | number | boolean>Optional set of block states to test this block against.
Returns true if the block matches the specified criteria.
实验性
包含方块一组属性状态的BlockPermutation。
Permutation that contains a set of property states for the Block.
在维度中将方块设置为BlockPermutation的状态。
Sets the block in the dimension to the state of the permutation.
无法在只读模式下调用此函数,详见 WorldBeforeEvents。
实验性
要应用的方块类型的标识符或方块类型,
例如,minecraft:powered_repeater
。
Identifier of the type of block to apply - for example, minecraft:powered_repeater.
实验性
true if the block should have water within it.
Sets whether this block has a water logged state - for example, whether stairs are submerged within water.
无法在只读模式下调用此函数,详见 WorldBeforeEvents。
实验性
包含一组方块属性状态的BlockPermutation。
Permutation that contains a set of property states for the Block.
如果成功设置了方块的BlockPermutation,
则返回 true
,否则返回 false
。
Returns true
if the block permutation data was
successfully set, else false
.
首先检查放置是否有效, 如何尝试在维度中将方块设置为BlockPermutation的状态,
Tries to set the block in the dimension to the state of the permutation by first checking if the placement is valid.
无法在只读模式下调用此函数,详见 WorldBeforeEvents。
表示世界维度中的特定位置的方块。 方块对象对应了唯一的 X、Y、Z 与维度,可用于读取或修改此位置的方块状态。 此类型在 1.17.10.21 有重大更新。
Represents a block in a dimension. A block represents a unique X, Y, and Z within a dimension and get/sets the state of the block at that location. This type was significantly updated in version 1.17.10.21.