feat(hamster-chain-break): 树叶不计入耐久度
This commit is contained in:
@@ -62,14 +62,20 @@ public final class MainListener implements Listener {
|
|||||||
}
|
}
|
||||||
short maxDurability = stack.getType().getMaxDurability();
|
short maxDurability = stack.getType().getMaxDurability();
|
||||||
short durability = stack.getDurability();
|
short durability = stack.getDurability();
|
||||||
|
if (durability >= maxDurability) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (Block block : resultBlocks) {
|
for (Block block : resultBlocks) {
|
||||||
|
boolean leaves = block.getType().name().endsWith("_LEAVES");
|
||||||
if (block.breakNaturally(stack)) {
|
if (block.breakNaturally(stack)) {
|
||||||
|
if (!leaves) {
|
||||||
durability++;
|
durability++;
|
||||||
if (durability >= maxDurability) {
|
if (durability >= maxDurability) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (durability >= maxDurability) {
|
if (durability >= maxDurability) {
|
||||||
player.getInventory().setItemInMainHand(null);
|
player.getInventory().setItemInMainHand(null);
|
||||||
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
|
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
|
||||||
|
Reference in New Issue
Block a user