Beta
Readonly
Beta
blockimport { world, BlockPermutation } from "@minecraft/server";
world.beforeEvents.worldInitialize.subscribe((event) => {
event.blockTypeRegistry.registerCustomComponent("jayly:custom_block", {
onStepOn(data) {
data.block.setPermutation(
BlockPermutation.resolve("minecraft:emerald_block")
);
},
});
});
Readonly
Beta
itemimport {
BlockPermutation,
ItemComponentMineBlockEvent,
ItemCustomComponent,
world,
} from "@minecraft/server";
class MineDiamondComponent implements ItemCustomComponent {
onMineBlock(e: ItemComponentMineBlockEvent): void {
const { minedBlockPermutation, block } = e;
if (minedBlockPermutation.matches("minecraft:diamond_ore")) {
block.setPermutation(BlockPermutation.resolve("minecraft:stone"));
}
}
}
world.beforeEvents.worldInitialize.subscribe((event) => {
event.itemComponentRegistry.registerCustomComponent(
"jayly:custom_item",
new MineDiamondComponent()
);
});
Contains information and methods that can be used at the initialization of the scripting environment for a World. Also, use the supplied blockRegistry object to register block custom components within the scope of the World Initialize execution.