From b7fd3933e4b20fefcefd9f21003ff1d020d5e7c0 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Mon, 26 Sep 2011 03:07:06 -0400 Subject: [PATCH] data improvements By: Tahg --- .../main/java/org/bukkit/craftbukkit/CraftWorld.java | 2 +- .../bukkit/craftbukkit/inventory/CraftInventory.java | 3 ++- .../bukkit/craftbukkit/inventory/CraftItemStack.java | 12 ++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index f7ec199474..63ecd69908 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -687,7 +687,7 @@ public class CraftWorld implements World { } else if (Egg.class.isAssignableFrom(clazz)) { entity = new EntityEgg(world, x, y, z); } else if (FallingSand.class.isAssignableFrom(clazz)) { - entity = new EntityFallingSand(world, x, y, z, 0); + entity = new EntityFallingSand(world, x, y, z, 0, 0); } else if (Fireball.class.isAssignableFrom(clazz)) { entity = new EntityFireball(world); ((EntityFireball) entity).setPositionRotation(x, y, z, yaw, pitch); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index 439c671e52..ae0c1f5393 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -199,12 +199,13 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { public int firstPartial(ItemStack item) { ItemStack[] inventory = getContents(); + ItemStack filteredItem = new CraftItemStack(item); if (item == null) { return -1; } for (int i = 0; i < inventory.length; i++) { ItemStack cItem = inventory[i]; - if (cItem != null && cItem.getTypeId() == item.getTypeId() && cItem.getAmount() < cItem.getMaxStackSize() && cItem.getDurability() == item.getDurability()) { + if (cItem != null && cItem.getTypeId() == filteredItem.getTypeId() && cItem.getAmount() < cItem.getMaxStackSize() && cItem.getDurability() == filteredItem.getDurability()) { return i; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index 078c0b04c6..ebe28caced 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -10,11 +10,15 @@ public class CraftItemStack extends ItemStack { super( item != null ? item.id: 0, item != null ? item.count : 0, - (short)(item != null ? item.damage : 0) + (short)(item != null ? item.getData() : 0) ); this.item = item; } + public CraftItemStack(ItemStack item) { + this(item.getTypeId(), item.getAmount(), item.getDurability()); + } + /* 'Overwritten' constructors from ItemStack, yay for Java sucking */ public CraftItemStack(final int type) { this(type, 0); @@ -105,15 +109,15 @@ public class CraftItemStack extends ItemStack { // Ignore damage if item is null if (item != null) { super.setDurability(durability); - item.damage = durability; + item.b(durability); } } @Override public short getDurability() { if (item != null) { - super.setDurability((short) item.damage); // sync, needed? - return (short) item.damage; + super.setDurability((short) item.getData()); // sync, needed? + return (short) item.getData(); } else { return -1; }