From bda0f8dee7f9d2c07eb22e4c02137e947315ffea Mon Sep 17 00:00:00 2001 From: zhangyuheng Date: Sun, 6 Oct 2024 20:25:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=20Unbreakable=20?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lunadeer/liteworldedit/Jobs/Job.java | 14 ++++++++++---- .../cn/lunadeer/liteworldedit/Jobs/Remove.java | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/cn/lunadeer/liteworldedit/Jobs/Job.java b/src/main/java/cn/lunadeer/liteworldedit/Jobs/Job.java index 9e278b3..1b14fd8 100644 --- a/src/main/java/cn/lunadeer/liteworldedit/Jobs/Job.java +++ b/src/main/java/cn/lunadeer/liteworldedit/Jobs/Job.java @@ -91,9 +91,11 @@ public class Job { } // 如果耐久小于10,提示玩家 pickaxe_damage = (Damageable) pickaxe_meta; - if (pickaxe_damage.getDamage() >= 2031 - 10) { - LoggerX.debug(index + " 下界合金镐耐久太低!"); - continue; + if (!pickaxe_meta.isUnbreakable()) { + if (pickaxe_damage.getDamage() >= 2031 - 10) { + LoggerX.debug(index + " 下界合金镐耐久太低!"); + continue; + } } pickaxe = p; break; @@ -104,9 +106,13 @@ public class Job { public static ItemStack useNetherPickaxe(ItemStack pickaxe) { int durability = pickaxe.getEnchantmentLevel(Enchantment.DURABILITY); double random = Math.random(); + Damageable pickaxe_damage = (Damageable) pickaxe.getItemMeta(); + if (pickaxe_damage.isUnbreakable()) { + // 无限耐久则不损坏 + return pickaxe; + } if (random < 1.0 / (durability + 1)) { // 扣除耐久 - Damageable pickaxe_damage = (Damageable) pickaxe.getItemMeta(); pickaxe_damage.setDamage(pickaxe_damage.getDamage() + 1); pickaxe.setItemMeta(pickaxe_damage); } diff --git a/src/main/java/cn/lunadeer/liteworldedit/Jobs/Remove.java b/src/main/java/cn/lunadeer/liteworldedit/Jobs/Remove.java index ad90dab..00da5b1 100644 --- a/src/main/java/cn/lunadeer/liteworldedit/Jobs/Remove.java +++ b/src/main/java/cn/lunadeer/liteworldedit/Jobs/Remove.java @@ -34,7 +34,7 @@ public class Remove extends Job { } // 获取玩家背包中的下届合金镐 HashMap pickaxes = getNetherPickaxes(_creator); - if (pickaxes.size() == 0) { + if (pickaxes.isEmpty()) { return JobErrCode.NO_PICKAXE; } ItemStack pickaxe = getUsableNetherPickaxe(pickaxes, _creator);