Fix sharp tools BlockEvent filter (#2419)

Signed-off-by: Mqrius <Nuntius.Marii@Gmail.com>
This commit is contained in:
Mqrius 2025-12-14 19:03:13 +01:00 committed by GitHub
parent 4fbd9755ed
commit bcd3a0c356
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -503,19 +503,20 @@ BlockEvents.rightClicked(event => {
}); });
// Makes scythes, hoes, and knives take damage when cutting grass // Makes scythes, hoes, and knives take damage when cutting grass
BlockEvents.broken('tfc:mineable_with_sharp_tool', event => { BlockEvents.broken(event => {
let player = event.player; const { server, item, player, block } = event;
let toolUsed = player.mainHandItem;
if (!toolUsed.hasTag('tfc:sharp_tools')) { if (!block.hasTag('tfc:mineable_with_sharp_tool') || !toolUsed.hasTag('tfc:sharp_tools')) {
return; return;
} }
let toolUsed = player.mainHandItem;
if (!player.isCreative()) { if (!player.isCreative()) {
toolUsed.damageValue++; toolUsed.damageValue++;
if (toolUsed.damageValue >= toolUsed.maxDamage) { if (toolUsed.damageValue >= toolUsed.maxDamage) {
event.server.runCommandSilent(`playsound minecraft:item.shield.break player ${player.username} ${player.x} ${player.y} ${player.z} 1 1 1`); server.runCommandSilent(`playsound minecraft:item.shield.break player ${player.username} ${player.x} ${player.y} ${player.z} 1 1 1`);
toolUsed.count--; toolUsed.count--;
} }
} }
}); });