PrivateconstructorStaticgetIdentifier of the block type. Should follow a namespace:id pattern, such as minecraft:dirt.
BlockType object, or undefined if the block type is not available within this world.
This function can't be called in early-execution mode.
import { BlockTypes, Player, system } from "@minecraft/server";
// Run `/scriptevent example:getdirtblocktype` in chat to inspect the dirt block type.
system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
if (id !== "example:getdirtblocktype" || !(sourceEntity instanceof Player)) return;
const blockType = BlockTypes.get("minecraft:dirt");
if (!blockType) return;
sourceEntity.sendMessage(`Found block type: ${blockType.id}`);
});
StaticgetThis function can't be called in early-execution mode.
import { BlockTypes, Player, system } from "@minecraft/server";
// Run `/scriptevent example:listblocktypes` in chat to list registered block IDs.
system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
if (id !== "example:listblocktypes" || !(sourceEntity instanceof Player)) return;
const blockIds = BlockTypes.getAll().map((blockType) => blockType.id);
sourceEntity.sendMessage(`Block types (${blockIds.length}): ${blockIds.slice(0, 10).join(", ")}`);
});
Contains a catalog of Minecraft Block Types that are available in this world.
Source