import { world, system, EntityEquippableComponent, EquipmentSlot, ItemStack, GameMode, BlockEvent } from "@minecraft/server";
world.afterEvents.playerBreakBlock.subscribe((event) => {
world.sendMessage("break block");
if (!event.block.hasTag("unstableCore")) return;
world.sendMessage("have tag")
const blocksAccepted = [
{
blockIdentifier: "unstableCore:uranium_ore",
tools: {
type: "pickaxe",
toolsMatch: ["polaout:iron_pickaxe", "polaout:diamond_pickaxe", "polaout:netherite_pickaxe"]
},
lootDrop: {
value: true,
loot: "unstableCore:raw_uranium"
}
}
]
if (!event.brokenBlockPermutation.matches.hasTag("unstableCore")) return;
for(var blocksIndex = 0; blocksIndex < blocksAccepted.length; blocksAccepted++) {
var isValid = event.brokenBlockPermutation.matches(blocksAccepted[blocksIndex].blockIdentifier)
var toolUsed = event.itemStackBeforeBreak.typeId;
if (isValid) {
for(var toolIndex = 0; toolIndex < blocksAccepted[blockIndex].tools.toolsMatch.length; toolIndex++) {
if (!blocksAccepted[blocksIndex].tools.toolsMatch[toolIndex] === toolUsed) return world.sendMessage("wrong pickaxe");;
world.sendMessage("right pickaxe");
}
}
}
});