mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
Fix some improper item cloning instances that would have dropped enchantments
By: Celtic Minstrel <celtic.minstrel.ca@some.place>
This commit is contained in:
parent
a247a422c1
commit
5a2b483937
3 changed files with 4 additions and 4 deletions
|
@ -68,8 +68,8 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItemOnCursor(ItemStack item) {
|
public void setItemOnCursor(ItemStack item) {
|
||||||
CraftItemStack stack = new CraftItemStack(item.getType(), item.getAmount(), item.getDurability());
|
CraftItemStack stack = new CraftItemStack(item);
|
||||||
getHandle().inventory.setCarried(stack.getType() == Material.AIR ? null : stack.getHandle());
|
getHandle().inventory.setCarried(stack.getHandle());
|
||||||
if (this instanceof CraftPlayer) {
|
if (this instanceof CraftPlayer) {
|
||||||
((EntityPlayer) getHandle()).broadcastCarriedItem(); // Send set slot for cursor
|
((EntityPlayer) getHandle()).broadcastCarriedItem(); // Send set slot for cursor
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,7 +266,7 @@ public class CraftInventory implements Inventory {
|
||||||
} else {
|
} else {
|
||||||
// More than a single stack!
|
// More than a single stack!
|
||||||
if (item.getAmount() > getMaxItemStack()) {
|
if (item.getAmount() > getMaxItemStack()) {
|
||||||
CraftItemStack stack = new CraftItemStack(item.getTypeId(), getMaxItemStack(), item.getDurability());
|
CraftItemStack stack = new CraftItemStack(item);
|
||||||
stack.addUnsafeEnchantments(item.getEnchantments());
|
stack.addUnsafeEnchantments(item.getEnchantments());
|
||||||
setItem(firstFree, stack);
|
setItem(firstFree, stack);
|
||||||
item.setAmount(item.getAmount() - getMaxItemStack());
|
item.setAmount(item.getAmount() - getMaxItemStack());
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn
|
||||||
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);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mcItems[i] = null;
|
mcItems[i] = null;
|
||||||
|
|
Loading…
Reference in a new issue