diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index cbaf930536..869ea6ac62 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1016,7 +1016,7 @@ public class CraftEventFactory { public static EntityBreedEvent callEntityBreedEvent(EntityLiving child, EntityLiving mother, EntityLiving father, EntityLiving breeder, ItemStack bredWith, int experience) { org.bukkit.entity.LivingEntity breederEntity = (LivingEntity)(breeder == null ? null : breeder.getBukkitEntity()); - CraftItemStack bredWithStack = bredWith == null ? null : CraftItemStack.asCraftMirror(bredWith).clone(); + CraftItemStack bredWithStack = (bredWith.isEmpty()) ? null : CraftItemStack.asCraftMirror(bredWith).clone(); EntityBreedEvent event = new EntityBreedEvent((LivingEntity) child.getBukkitEntity(), (LivingEntity) mother.getBukkitEntity(), (LivingEntity) father.getBukkitEntity(), breederEntity, bredWithStack, experience); child.world.getServer().getPluginManager().callEvent(event); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index 2b5494c4b1..cf411a0903 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -46,7 +46,7 @@ public class CraftInventory implements Inventory { public ItemStack getItem(int index) { net.minecraft.server.ItemStack item = getInventory().getItem(index); - return item == null ? null : CraftItemStack.asCraftMirror(item); + return CraftItemStack.asCraftMirror(item); } @Override @@ -65,7 +65,7 @@ public class CraftInventory implements Inventory { int size = Math.min(items.length, mcItems.size()); for (int i = 0; i < size; i++) { - items[i] = (mcItems.get(i) == net.minecraft.server.ItemStack.a) ? null : CraftItemStack.asCraftMirror(mcItems.get(i)); + items[i] = CraftItemStack.asCraftMirror(mcItems.get(i)); } return items; } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java index 00f9bb5e45..997eaf66b3 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java @@ -28,19 +28,19 @@ public class CraftInventoryAnvil extends CraftInventory implements AnvilInventor public ItemStack getItem(int slot) { if (slot < getIngredientsInventory().getSize()) { net.minecraft.server.ItemStack item = getIngredientsInventory().getItem(slot); - return item == null ? null : CraftItemStack.asCraftMirror(item); + return CraftItemStack.asCraftMirror(item); } else { net.minecraft.server.ItemStack item = getResultInventory().getItem(slot - getIngredientsInventory().getSize()); - return item == null ? null : CraftItemStack.asCraftMirror(item); + return CraftItemStack.asCraftMirror(item); } } @Override public void setItem(int index, ItemStack item) { if (index < getIngredientsInventory().getSize()) { - getIngredientsInventory().setItem(index, (item == null ? null : CraftItemStack.asNMSCopy(item))); + getIngredientsInventory().setItem(index, CraftItemStack.asNMSCopy(item)); } else { - getResultInventory().setItem((index - getIngredientsInventory().getSize()), (item == null ? null : CraftItemStack.asNMSCopy(item))); + getResultInventory().setItem((index - getIngredientsInventory().getSize()), CraftItemStack.asNMSCopy(item)); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java index fafc9f6be4..f4e5ddf43c 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java @@ -70,19 +70,19 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn public CraftItemStack getItem(int index) { if (index < getResultInventory().getSize()) { net.minecraft.server.ItemStack item = getResultInventory().getItem(index); - return item == null ? null : CraftItemStack.asCraftMirror(item); + return CraftItemStack.asCraftMirror(item); } else { net.minecraft.server.ItemStack item = getMatrixInventory().getItem(index - getResultInventory().getSize()); - return item == null ? null : CraftItemStack.asCraftMirror(item); + return CraftItemStack.asCraftMirror(item); } } @Override public void setItem(int index, ItemStack item) { if (index < getResultInventory().getSize()) { - getResultInventory().setItem(index, (item == null ? null : CraftItemStack.asNMSCopy(item))); + getResultInventory().setItem(index, CraftItemStack.asNMSCopy(item)); } else { - getMatrixInventory().setItem((index - getResultInventory().getSize()), (item == null ? null : CraftItemStack.asNMSCopy(item))); + getMatrixInventory().setItem((index - getResultInventory().getSize()), CraftItemStack.asNMSCopy(item)); } } @@ -99,8 +99,7 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn public ItemStack getResult() { net.minecraft.server.ItemStack item = getResultInventory().getItem(0); - if(item != null) return CraftItemStack.asCraftMirror(item); - return null; + return CraftItemStack.asCraftMirror(item); } public void setMatrix(ItemStack[] contents) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index 866e54dd9e..178a626dc0 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -57,7 +57,7 @@ public final class CraftItemStack extends ItemStack { * Copies the NMS stack to return as a strictly-Bukkit stack */ public static ItemStack asBukkitCopy(net.minecraft.server.ItemStack original) { - if (original == net.minecraft.server.ItemStack.a) { + if (original.isEmpty()) { return new ItemStack(Material.AIR); } ItemStack stack = new ItemStack(CraftMagicNumbers.getMaterial(original.getItem()), original.getCount(), (short) original.getData()); @@ -68,7 +68,7 @@ public final class CraftItemStack extends ItemStack { } public static CraftItemStack asCraftMirror(net.minecraft.server.ItemStack original) { - return new CraftItemStack(original); + return (original.isEmpty()) ? null : new CraftItemStack(original); } public static CraftItemStack asCraftCopy(ItemStack original) {