data improvements

By: Tahg <tahgtahv@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2011-09-26 03:07:06 -04:00
parent 35a5504f20
commit b7fd3933e4
3 changed files with 11 additions and 6 deletions

View file

@ -687,7 +687,7 @@ public class CraftWorld implements World {
} else if (Egg.class.isAssignableFrom(clazz)) { } else if (Egg.class.isAssignableFrom(clazz)) {
entity = new EntityEgg(world, x, y, z); entity = new EntityEgg(world, x, y, z);
} else if (FallingSand.class.isAssignableFrom(clazz)) { } 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)) { } else if (Fireball.class.isAssignableFrom(clazz)) {
entity = new EntityFireball(world); entity = new EntityFireball(world);
((EntityFireball) entity).setPositionRotation(x, y, z, yaw, pitch); ((EntityFireball) entity).setPositionRotation(x, y, z, yaw, pitch);

View file

@ -199,12 +199,13 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
public int firstPartial(ItemStack item) { public int firstPartial(ItemStack item) {
ItemStack[] inventory = getContents(); ItemStack[] inventory = getContents();
ItemStack filteredItem = new CraftItemStack(item);
if (item == null) { if (item == null) {
return -1; return -1;
} }
for (int i = 0; i < inventory.length; i++) { for (int i = 0; i < inventory.length; i++) {
ItemStack cItem = inventory[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; return i;
} }
} }

View file

@ -10,11 +10,15 @@ public class CraftItemStack extends ItemStack {
super( super(
item != null ? item.id: 0, item != null ? item.id: 0,
item != null ? item.count : 0, item != null ? item.count : 0,
(short)(item != null ? item.damage : 0) (short)(item != null ? item.getData() : 0)
); );
this.item = item; this.item = item;
} }
public CraftItemStack(ItemStack item) {
this(item.getTypeId(), item.getAmount(), item.getDurability());
}
/* 'Overwritten' constructors from ItemStack, yay for Java sucking */ /* 'Overwritten' constructors from ItemStack, yay for Java sucking */
public CraftItemStack(final int type) { public CraftItemStack(final int type) {
this(type, 0); this(type, 0);
@ -105,15 +109,15 @@ public class CraftItemStack extends ItemStack {
// Ignore damage if item is null // Ignore damage if item is null
if (item != null) { if (item != null) {
super.setDurability(durability); super.setDurability(durability);
item.damage = durability; item.b(durability);
} }
} }
@Override @Override
public short getDurability() { public short getDurability() {
if (item != null) { if (item != null) {
super.setDurability((short) item.damage); // sync, needed? super.setDurability((short) item.getData()); // sync, needed?
return (short) item.damage; return (short) item.getData();
} else { } else {
return -1; return -1;
} }