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:
parent
ebb6a9ce82
commit
94a06dccba
@ -164,27 +164,24 @@ public class AnvilHandler extends ArmoredElytraHandler implements Listener
|
|||||||
|
|
||||||
result = ArmoredElytra.getInstance().getNbtEditor()
|
result = ArmoredElytra.getInstance().getNbtEditor()
|
||||||
.addArmorNBTTags(result, newTier, plugin.getConfigLoader().unbreakable());
|
.addArmorNBTTags(result, newTier, plugin.getConfigLoader().unbreakable());
|
||||||
|
|
||||||
event.setResult(result);
|
event.setResult(result);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If one of the input items is null and the other an armored elytra, remove the result.
|
// If one of the input items is null and the other an armored elytra, remove the result.
|
||||||
// This prevent some naming issues.
|
// This prevent some naming issues.
|
||||||
// TODO: Allow renaming armored elytras.
|
|
||||||
if ((itemA == null ^ itemB == null) &&
|
if ((itemA == null ^ itemB == null) &&
|
||||||
ArmoredElytra.getInstance().getNbtEditor().getArmorTier(itemA == null ? itemB : itemA) != ArmorTier.NONE)
|
ArmoredElytra.getInstance().getNbtEditor().getArmorTier(itemA == null ? itemB : itemA) != ArmorTier.NONE)
|
||||||
event.setResult(null);
|
event.setResult(null);
|
||||||
player.updateInventory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let the player take items out of the anvil.
|
// Let the player take items out of the anvil.
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent e)
|
public void onInventoryClick(InventoryClickEvent e)
|
||||||
{
|
{
|
||||||
if (e.getRawSlot() != 2)
|
if (e.getRawSlot() != 2 || !(e.getWhoClicked() instanceof Player))
|
||||||
return;
|
|
||||||
|
|
||||||
if (!(e.getWhoClicked() instanceof Player))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Check if the event was a player who interacted with an anvil.
|
// Check if the event was a player who interacted with an anvil.
|
||||||
|
@ -44,7 +44,7 @@ abstract class ArmoredElytraHandler
|
|||||||
mult *= (100.0f / plugin.getConfigLoader().NETHERITE_TO_FULL());
|
mult *= (100.0f / plugin.getConfigLoader().NETHERITE_TO_FULL());
|
||||||
|
|
||||||
int maxDurability = Material.ELYTRA.getMaxDurability();
|
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));
|
return (short) (Math.max(newDurability, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user