Offhand/helmet should clone the item properly

This commit is contained in:
fullwall 2016-04-04 15:08:00 +08:00
parent 2863d4b64c
commit ae43427e51

View File

@ -70,8 +70,9 @@ public class EquipmentEditor extends Editor {
if (old != null && old.getType() != Material.AIR) { if (old != null && old.getType() != Material.AIR) {
event.getPlayer().getWorld().dropItemNaturally(event.getPlayer().getLocation(), old); event.getPlayer().getWorld().dropItemNaturally(event.getPlayer().getLocation(), old);
} }
npc.getTrait(Equipment.class).set(finalSlot, ItemStack newStack = hand.clone();
new ItemStack(event.getPlayer().getInventory().getItemInMainHand().getType(), 1)); newStack.setAmount(1);
npc.getTrait(Equipment.class).set(finalSlot, newStack);
hand.setAmount(hand.getAmount() - 1); hand.setAmount(hand.getAmount() - 1);
event.getPlayer().getInventory().setItemInMainHand(hand); event.getPlayer().getInventory().setItemInMainHand(hand);
} }