mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 18:27:17 +01:00
Fixed Enchantments being lost on inventory.setItem
By: Nathan Adams <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
7cb34c4384
commit
107149bd07
2 changed files with 6 additions and 2 deletions
|
@ -53,13 +53,13 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
|
||||||
if (item == null || item.getTypeId() <= 0) {
|
if (item == null || item.getTypeId() <= 0) {
|
||||||
mcItems[i] = null;
|
mcItems[i] = null;
|
||||||
} else {
|
} 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) {
|
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) {
|
public boolean contains(int materialId) {
|
||||||
|
|
|
@ -207,4 +207,8 @@ public class CraftItemStack extends ItemStack {
|
||||||
public net.minecraft.server.ItemStack getHandle() {
|
public net.minecraft.server.ItemStack getHandle() {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static net.minecraft.server.ItemStack createNMSItemStack(ItemStack original) {
|
||||||
|
return new CraftItemStack(original).getHandle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue