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.
Dieser Commit ist enthalten in:
Ursprung
d34e289434
Commit
82965eb10f
@ -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);
|
||||
|
@ -80,11 +80,7 @@ public class EntityCow extends EntityAnimal {
|
||||
return false;
|
||||
}
|
||||
|
||||
CraftItemStack itemInHand = (CraftItemStack) event.getItemStack();
|
||||
byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData();
|
||||
itemstack = new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data);
|
||||
|
||||
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, itemstack);
|
||||
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, CraftItemStack.createNMSItemStack(event.getItemStack()));
|
||||
// CraftBukkit end
|
||||
|
||||
return true;
|
||||
|
@ -54,13 +54,10 @@ public class ItemBucket extends Item {
|
||||
if (entityhuman.abilities.canInstantlyBuild) {
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
CraftItemStack itemInHand = (CraftItemStack) event.getItemStack();
|
||||
byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData();
|
||||
// CraftBukkit end
|
||||
|
||||
world.setTypeId(i, j, k, 0);
|
||||
return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data); // CraftBukkit
|
||||
return CraftItemStack.createNMSItemStack(event.getItemStack()); // CraftBukkit
|
||||
}
|
||||
|
||||
if (world.getMaterial(i, j, k) == Material.LAVA && world.getData(i, j, k) == 0) {
|
||||
@ -74,13 +71,10 @@ public class ItemBucket extends Item {
|
||||
if (entityhuman.abilities.canInstantlyBuild) {
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
CraftItemStack itemInHand = (CraftItemStack) event.getItemStack();
|
||||
byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData();
|
||||
// CraftBukkit end
|
||||
|
||||
world.setTypeId(i, j, k, 0);
|
||||
return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data); // CraftBukkit
|
||||
return CraftItemStack.createNMSItemStack(event.getItemStack()); // CraftBukkit
|
||||
}
|
||||
} else {
|
||||
if (this.a < 0) {
|
||||
@ -91,9 +85,7 @@ public class ItemBucket extends Item {
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
CraftItemStack itemInHand = (CraftItemStack) event.getItemStack();
|
||||
byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData();
|
||||
return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data);
|
||||
return CraftItemStack.createNMSItemStack(event.getItemStack());
|
||||
}
|
||||
|
||||
int clickedX = i, clickedY = j, clickedZ = k;
|
||||
@ -151,10 +143,7 @@ public class ItemBucket extends Item {
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
CraftItemStack itemInHand = (CraftItemStack) event.getItemStack();
|
||||
byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData();
|
||||
|
||||
return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data);
|
||||
return CraftItemStack.createNMSItemStack(event.getItemStack());
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
@ -167,9 +156,7 @@ public class ItemBucket extends Item {
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
CraftItemStack itemInHand = (CraftItemStack) event.getItemStack();
|
||||
byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData();
|
||||
return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data);
|
||||
return CraftItemStack.createNMSItemStack(event.getItemStack());
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
|
@ -211,9 +211,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
|
||||
return;
|
||||
}
|
||||
|
||||
org.bukkit.inventory.ItemStack oldResult = furnaceSmeltEvent.getResult();
|
||||
ItemStack newResult = new ItemStack(oldResult.getTypeId(), oldResult.getAmount(), oldResult.getDurability());
|
||||
itemstack = newResult;
|
||||
itemstack = CraftItemStack.createNMSItemStack(furnaceSmeltEvent.getResult());
|
||||
|
||||
if (this.items[2] == null) {
|
||||
this.items[2] = itemstack.cloneItemStack();
|
||||
|
@ -19,7 +19,7 @@ public class CraftItem extends CraftEntity implements Item {
|
||||
}
|
||||
|
||||
public void setItemStack(ItemStack stack) {
|
||||
item.itemStack = new net.minecraft.server.ItemStack(stack.getTypeId(), stack.getAmount(), stack.getDurability());
|
||||
item.itemStack = CraftItemStack.createNMSItemStack(stack);
|
||||
}
|
||||
|
||||
public int getPickupDelay() {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren