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.
This commit is contained in:
Pim van der Loos 2020-11-24 13:32:56 +01:00
parent ebb6a9ce82
commit 94a06dccba
No known key found for this signature in database
GPG Key ID: C16F020ADAE6D5A8
2 changed files with 4 additions and 7 deletions

View File

@ -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.

View File

@ -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));
}