diff options
author | James Clarke <jamesrtclarke@me.com> | 2012-11-08 00:26:35 +0000 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2012-11-17 15:06:18 -0600 |
commit | a575e6b075ec9e63e942111657d6869e00ad42b5 (patch) | |
tree | c49d5e51e40de83fa9d547b8d67af7f67e8f373c | |
parent | 293474d99b4802bd38e6794b484d91212e8893c8 (diff) | |
download | craftbukkit-a575e6b075ec9e63e942111657d6869e00ad42b5.tar craftbukkit-a575e6b075ec9e63e942111657d6869e00ad42b5.tar.gz craftbukkit-a575e6b075ec9e63e942111657d6869e00ad42b5.tar.lz craftbukkit-a575e6b075ec9e63e942111657d6869e00ad42b5.tar.xz craftbukkit-a575e6b075ec9e63e942111657d6869e00ad42b5.zip |
Use correct itemstack for dispenser behavior chaining. Fixes BUKKIT-2886
When an event changes the item to be dispensed we check to see if the new
item has special behavior for dispensing and if so pass it on to that
behavior handler. However, we are actually checking the old itemstack and
passing the new itemstack so this check fails.
8 files changed, 27 insertions, 29 deletions
diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorBoat.java b/src/main/java/net/minecraft/server/DispenseBehaviorBoat.java index 2cb9e3d0..dfaf09ed 100644 --- a/src/main/java/net/minecraft/server/DispenseBehaviorBoat.java +++ b/src/main/java/net/minecraft/server/DispenseBehaviorBoat.java @@ -56,9 +56,10 @@ public class DispenseBehaviorBoat extends DispenseBehaviorItem { if (!event.getItem().equals(bukkitItem)) { itemstack.count++; // Chain to handler for new item - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + ItemStack eventStack = CraftItemStack.createNMSItemStack(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem()); if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + idispensebehavior.a(isourceblock, eventStack); return itemstack; } } diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorEmptyBucket.java b/src/main/java/net/minecraft/server/DispenseBehaviorEmptyBucket.java index 6e29c260..31348bd6 100644 --- a/src/main/java/net/minecraft/server/DispenseBehaviorEmptyBucket.java +++ b/src/main/java/net/minecraft/server/DispenseBehaviorEmptyBucket.java @@ -51,9 +51,10 @@ public class DispenseBehaviorEmptyBucket extends DispenseBehaviorItem { if (!event.getItem().equals(bukkitItem)) { // Chain to handler for new item - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + ItemStack eventStack = CraftItemStack.createNMSItemStack(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem()); if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + idispensebehavior.a(isourceblock, eventStack); return itemstack; } } diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorFilledBucket.java b/src/main/java/net/minecraft/server/DispenseBehaviorFilledBucket.java index 28bedc9a..8f1d9a84 100644 --- a/src/main/java/net/minecraft/server/DispenseBehaviorFilledBucket.java +++ b/src/main/java/net/minecraft/server/DispenseBehaviorFilledBucket.java @@ -42,9 +42,10 @@ public class DispenseBehaviorFilledBucket extends DispenseBehaviorItem { if (!event.getItem().equals(bukkitItem)) { // Chain to handler for new item - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + ItemStack eventStack = CraftItemStack.createNMSItemStack(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem()); if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + idispensebehavior.a(isourceblock, eventStack); return itemstack; } } diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorFireball.java b/src/main/java/net/minecraft/server/DispenseBehaviorFireball.java index 0824fc4f..cc0bf8bb 100644 --- a/src/main/java/net/minecraft/server/DispenseBehaviorFireball.java +++ b/src/main/java/net/minecraft/server/DispenseBehaviorFireball.java @@ -45,9 +45,10 @@ public class DispenseBehaviorFireball extends DispenseBehaviorItem { if (!event.getItem().equals(bukkitItem)) { itemstack.count++; // Chain to handler for new item - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + ItemStack eventStack = CraftItemStack.createNMSItemStack(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem()); if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + idispensebehavior.a(isourceblock, eventStack); return itemstack; } } diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorItem.java b/src/main/java/net/minecraft/server/DispenseBehaviorItem.java index 9cf23dd9..1337fefe 100644 --- a/src/main/java/net/minecraft/server/DispenseBehaviorItem.java +++ b/src/main/java/net/minecraft/server/DispenseBehaviorItem.java @@ -65,30 +65,21 @@ public class DispenseBehaviorItem implements IDispenseBehavior { entityitem.motX = event.getVelocity().getX(); entityitem.motY = event.getVelocity().getY(); entityitem.motZ = event.getVelocity().getZ(); - // CraftBukkit end - - world.addEntity(entityitem); - // CraftBukkit start if (!event.getItem().equals(bukkitItem)) { - if (event.getItem().getTypeId() == Item.BUCKET.id) { - int x = isourceblock.getBlockX() + enumfacing.c(); - int y = isourceblock.getBlockY(); - int z = isourceblock.getBlockZ() + enumfacing.e(); - Material material = world.getMaterial(x, y, z); - int data = world.getData(x, y, z); - if (!(Material.WATER.equals(material) || Material.LAVA.equals(material)) || data != 0) { - return true; - } - } // Chain to handler for new item - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + ItemStack eventStack = CraftItemStack.createNMSItemStack(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem()); if (idispensebehavior != IDispenseBehavior.a && idispensebehavior.getClass() != DispenseBehaviorItem.class) { - idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + idispensebehavior.a(isourceblock, eventStack); + } else { + world.addEntity(entityitem); } return false; } + world.addEntity(entityitem); + return true; // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorMinecart.java b/src/main/java/net/minecraft/server/DispenseBehaviorMinecart.java index c429abe9..cc92846e 100644 --- a/src/main/java/net/minecraft/server/DispenseBehaviorMinecart.java +++ b/src/main/java/net/minecraft/server/DispenseBehaviorMinecart.java @@ -56,9 +56,10 @@ public class DispenseBehaviorMinecart extends DispenseBehaviorItem { if (!event.getItem().equals(bukkitItem)) { itemstack.count++; // Chain to handler for new item - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + ItemStack eventStack = CraftItemStack.createNMSItemStack(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem()); if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + idispensebehavior.a(isourceblock, eventStack); return itemstack; } } diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorMonsterEgg.java b/src/main/java/net/minecraft/server/DispenseBehaviorMonsterEgg.java index 4895b81c..25e21d25 100644 --- a/src/main/java/net/minecraft/server/DispenseBehaviorMonsterEgg.java +++ b/src/main/java/net/minecraft/server/DispenseBehaviorMonsterEgg.java @@ -38,9 +38,10 @@ public class DispenseBehaviorMonsterEgg extends DispenseBehaviorItem { if (!event.getItem().equals(bukkitItem)) { itemstack.count++; // Chain to handler for new item - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + ItemStack eventStack = CraftItemStack.createNMSItemStack(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem()); if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + idispensebehavior.a(isourceblock, eventStack); return itemstack; } } diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorProjectile.java b/src/main/java/net/minecraft/server/DispenseBehaviorProjectile.java index ce801b10..3968dd0c 100644 --- a/src/main/java/net/minecraft/server/DispenseBehaviorProjectile.java +++ b/src/main/java/net/minecraft/server/DispenseBehaviorProjectile.java @@ -33,7 +33,8 @@ public abstract class DispenseBehaviorProjectile extends DispenseBehaviorItem { if (!event.getItem().equals(bukkitItem)) { itemstack.count++; // Chain to handler for new item - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + ItemStack eventStack = CraftItemStack.createNMSItemStack(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem()); if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); return itemstack; |