Drop old item for 'offhand' editing

This commit is contained in:
fullwall 2016-03-31 18:19:34 +08:00
parent b558617c2b
commit 3443c0a719

View File

@ -66,6 +66,10 @@ public class EquipmentEditor extends Editor {
if (hand.getType() == Material.AIR || hand.getAmount() <= 0) {
return;
}
ItemStack old = npc.getTrait(Equipment.class).get(finalSlot);
if (old != null && old.getType() != Material.AIR) {
event.getPlayer().getWorld().dropItemNaturally(event.getPlayer().getLocation(), old);
}
npc.getTrait(Equipment.class).set(finalSlot,
new ItemStack(event.getPlayer().getInventory().getItemInMainHand().getType(), 1));
hand.setAmount(hand.getAmount() - 1);