3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

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.
Dieser Commit ist enthalten in:
James Clarke 2012-11-08 00:26:35 +00:00 committet von Travis Watkins
Ursprung 293474d99b
Commit a575e6b075
8 geänderte Dateien mit 27 neuen und 29 gelöschten Zeilen

Datei anzeigen

@ -56,9 +56,10 @@ public class DispenseBehaviorBoat extends DispenseBehaviorItem {
if (!event.getItem().equals(bukkitItem)) { if (!event.getItem().equals(bukkitItem)) {
itemstack.count++; itemstack.count++;
// Chain to handler for new item // 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) { if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); idispensebehavior.a(isourceblock, eventStack);
return itemstack; return itemstack;
} }
} }

Datei anzeigen

@ -51,9 +51,10 @@ public class DispenseBehaviorEmptyBucket extends DispenseBehaviorItem {
if (!event.getItem().equals(bukkitItem)) { if (!event.getItem().equals(bukkitItem)) {
// Chain to handler for new item // 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) { if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); idispensebehavior.a(isourceblock, eventStack);
return itemstack; return itemstack;
} }
} }

Datei anzeigen

@ -42,9 +42,10 @@ public class DispenseBehaviorFilledBucket extends DispenseBehaviorItem {
if (!event.getItem().equals(bukkitItem)) { if (!event.getItem().equals(bukkitItem)) {
// Chain to handler for new item // 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) { if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); idispensebehavior.a(isourceblock, eventStack);
return itemstack; return itemstack;
} }
} }

Datei anzeigen

@ -45,9 +45,10 @@ public class DispenseBehaviorFireball extends DispenseBehaviorItem {
if (!event.getItem().equals(bukkitItem)) { if (!event.getItem().equals(bukkitItem)) {
itemstack.count++; itemstack.count++;
// Chain to handler for new item // 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) { if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); idispensebehavior.a(isourceblock, eventStack);
return itemstack; return itemstack;
} }
} }

Datei anzeigen

@ -65,30 +65,21 @@ public class DispenseBehaviorItem implements IDispenseBehavior {
entityitem.motX = event.getVelocity().getX(); entityitem.motX = event.getVelocity().getX();
entityitem.motY = event.getVelocity().getY(); entityitem.motY = event.getVelocity().getY();
entityitem.motZ = event.getVelocity().getZ(); entityitem.motZ = event.getVelocity().getZ();
// CraftBukkit end
world.addEntity(entityitem);
// CraftBukkit start
if (!event.getItem().equals(bukkitItem)) { 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 // 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) { 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; return false;
} }
world.addEntity(entityitem);
return true; return true;
// CraftBukkit end // CraftBukkit end
} }

Datei anzeigen

@ -56,9 +56,10 @@ public class DispenseBehaviorMinecart extends DispenseBehaviorItem {
if (!event.getItem().equals(bukkitItem)) { if (!event.getItem().equals(bukkitItem)) {
itemstack.count++; itemstack.count++;
// Chain to handler for new item // 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) { if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); idispensebehavior.a(isourceblock, eventStack);
return itemstack; return itemstack;
} }
} }

Datei anzeigen

@ -38,9 +38,10 @@ public class DispenseBehaviorMonsterEgg extends DispenseBehaviorItem {
if (!event.getItem().equals(bukkitItem)) { if (!event.getItem().equals(bukkitItem)) {
itemstack.count++; itemstack.count++;
// Chain to handler for new item // 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) { if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); idispensebehavior.a(isourceblock, eventStack);
return itemstack; return itemstack;
} }
} }

Datei anzeigen

@ -33,7 +33,8 @@ public abstract class DispenseBehaviorProjectile extends DispenseBehaviorItem {
if (!event.getItem().equals(bukkitItem)) { if (!event.getItem().equals(bukkitItem)) {
itemstack.count++; itemstack.count++;
// Chain to handler for new item // 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) { if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem()));
return itemstack; return itemstack;