#block cancel with after event
1 messages · Page 1 of 1 (latest)
to cancel the block should I just setblock the location with the block they broke
that'd work right?
U should do with beforeEvents of playerBreakBlock and event.cancel = true to cancel the block action that has been broken by the player
beforeEvents with playerBreakBlock doesnt work how I like it
It's very weird when mining
In beforeEvents some properties (can edited) will be in read-only mode
You need to push it into system.run(() => {//ur code})U can know which property (can edited)will not work in read-only mode at the learning page (red line in the photo)
Example a snippet of your code in beforeEvents```js
if (Math.random() < 0.00077) {
system.run(() => {
const item = new ItemStack("minecraft:ominous_trial_key");
item.nameTag = "§r§dMine Crate Key";
player.getComponent("inventory").container.addItem(item);
player.sendMessage("§5§l!§r§d You found a mine crate key!");
player.playSound("random.levelup");
})
}
Srr, but i not good English to understand what u just said. I dont understand something very "weird"