From 94a06dccba20dfe6589ae07ab2a91b2b464b166d Mon Sep 17 00:00:00 2001 From: Pim van der Loos Date: Tue, 24 Nov 2020 13:32:56 +0100 Subject: [PATCH] Allow repairing wioth multiple items - Allow repairing AEs using more than 1 repair item at a time. Though it currently doesn't update the anvil GUI properly for whatever reason. However, when you take it out, it will have the correct durability. --- .../pim16aap2/armoredElytra/handlers/AnvilHandler.java | 9 +++------ .../armoredElytra/handlers/ArmoredElytraHandler.java | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/nl/pim16aap2/armoredElytra/handlers/AnvilHandler.java b/src/main/java/nl/pim16aap2/armoredElytra/handlers/AnvilHandler.java index 1a32489..186865a 100644 --- a/src/main/java/nl/pim16aap2/armoredElytra/handlers/AnvilHandler.java +++ b/src/main/java/nl/pim16aap2/armoredElytra/handlers/AnvilHandler.java @@ -164,27 +164,24 @@ public class AnvilHandler extends ArmoredElytraHandler implements Listener result = ArmoredElytra.getInstance().getNbtEditor() .addArmorNBTTags(result, newTier, plugin.getConfigLoader().unbreakable()); + event.setResult(result); + return; } } // If one of the input items is null and the other an armored elytra, remove the result. // This prevent some naming issues. - // TODO: Allow renaming armored elytras. if ((itemA == null ^ itemB == null) && ArmoredElytra.getInstance().getNbtEditor().getArmorTier(itemA == null ? itemB : itemA) != ArmorTier.NONE) event.setResult(null); - player.updateInventory(); } // Let the player take items out of the anvil. @EventHandler public void onInventoryClick(InventoryClickEvent e) { - if (e.getRawSlot() != 2) - return; - - if (!(e.getWhoClicked() instanceof Player)) + if (e.getRawSlot() != 2 || !(e.getWhoClicked() instanceof Player)) return; // Check if the event was a player who interacted with an anvil. diff --git a/src/main/java/nl/pim16aap2/armoredElytra/handlers/ArmoredElytraHandler.java b/src/main/java/nl/pim16aap2/armoredElytra/handlers/ArmoredElytraHandler.java index 8fc4fb5..0d34d5c 100644 --- a/src/main/java/nl/pim16aap2/armoredElytra/handlers/ArmoredElytraHandler.java +++ b/src/main/java/nl/pim16aap2/armoredElytra/handlers/ArmoredElytraHandler.java @@ -44,7 +44,7 @@ abstract class ArmoredElytraHandler mult *= (100.0f / plugin.getConfigLoader().NETHERITE_TO_FULL()); int maxDurability = Material.ELYTRA.getMaxDurability(); - int newDurability = (int) (curDur - (maxDurability * mult)); + int newDurability = (int) (curDur - repairItem.getAmount() * (maxDurability * mult)); return (short) (Math.max(newDurability, 0)); }