mirror of
https://github.com/PaperMC/Paper.git
synced 2026-11-25 10:29:41 -05:00
Stop converting ItemStack to nms ItemStack by hand
This should fix many issues with enchantments being lost, as the method used takes care of enchantments. Additionally, use the new nms ItemStack constructor in places where appropriate. Fixes (at least part of) BUKKIT-7. Need to identify any further places to fix.
This commit is contained in:
1 parent
d34e289434
commit
82965eb10f
5 files changed
+11
-30
No files matched your search
@@ -102,7 +102,7 @@ public class BlockDispenser extends BlockContainer {
|
||||
itemstack = tileentitydispenser.getContents()[dispenseSlot];
|
||||
|
||||
// Copy item stack, because we want it to have 1 item
|
||||
itemstack = new ItemStack(itemstack.id, 1, itemstack.getData());
|
||||
itemstack = new ItemStack(itemstack.id, 1, itemstack.getData(), itemstack.getEnchantments());
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -139,7 +139,7 @@ public class BlockDispenser extends BlockContainer {
|
||||
motY = event.getVelocity().getY();
|
||||
motZ = event.getVelocity().getZ();
|
||||
|
||||
itemstack = new ItemStack(event.getItem().getTypeId(), event.getItem().getAmount(), event.getItem().getDurability());
|
||||
itemstack = CraftItemStack.createNMSItemStack(event.getItem());
|
||||
// CraftBukkit end
|
||||
|
||||
if (itemstack.id == Item.ARROW.id) {
|
||||
@@ -244,7 +244,7 @@ public class BlockDispenser extends BlockContainer {
|
||||
}
|
||||
|
||||
itemstack.count -= i1;
|
||||
EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.id, i1, itemstack.getData()));
|
||||
EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.id, i1, itemstack.getData(), itemstack.getEnchantments())); // CraftBukkit - make sure enchantments are copied over
|
||||
float f3 = 0.05F;
|
||||
|
||||
entityitem.motX = (double) ((float) this.a.nextGaussian() * f3);
|
||||
|
||||
Reference in new issue
Block a user