Fixed Enchantments being lost on inventory.setItem

This commit is contained in:
Nathan Adams 2011-11-28 05:17:05 +00:00
parent 99771b7b72
commit fe3756f7a0
2 changed files with 6 additions and 2 deletions

View File

@ -53,13 +53,13 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
if (item == null || item.getTypeId() <= 0) {
mcItems[i] = null;
} else {
mcItems[i] = new net.minecraft.server.ItemStack(item.getTypeId(), item.getAmount(), item.getDurability());
mcItems[i] = CraftItemStack.createNMSItemStack(item);
}
}
}
public void setItem(int index, ItemStack item) {
getInventory().setItem(index, (item == null ? null : new net.minecraft.server.ItemStack(item.getTypeId(), item.getAmount(), item.getDurability())));
getInventory().setItem(index, (item == null ? null : CraftItemStack.createNMSItemStack(item)));
}
public boolean contains(int materialId) {

View File

@ -207,4 +207,8 @@ public class CraftItemStack extends ItemStack {
public net.minecraft.server.ItemStack getHandle() {
return item;
}
public static net.minecraft.server.ItemStack createNMSItemStack(ItemStack original) {
return new CraftItemStack(original).getHandle();
}
}