mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-12 01:41:05 +01:00
SPIGOT-4838: BlockDispenseEvent not called when shears dispensed from dispenser
This commit is contained in:
parent
a584320126
commit
fac0eca52b
1 changed files with 34 additions and 4 deletions
|
@ -117,7 +117,9 @@
|
||||||
+ itemstack.add(1);
|
+ itemstack.add(1);
|
||||||
+ return itemstack;
|
+ return itemstack;
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
|
- isourceblock.getWorld().addEntity(new EntityFireworks(isourceblock.getWorld(), d0, d1, d2, itemstack));
|
||||||
|
- itemstack.subtract(1);
|
||||||
+ if (!event.getItem().equals(craftItem)) {
|
+ if (!event.getItem().equals(craftItem)) {
|
||||||
+ itemstack.add(1);
|
+ itemstack.add(1);
|
||||||
+ // Chain to handler for new item
|
+ // Chain to handler for new item
|
||||||
|
@ -128,9 +130,7 @@
|
||||||
+ return itemstack;
|
+ return itemstack;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
- isourceblock.getWorld().addEntity(new EntityFireworks(isourceblock.getWorld(), d0, d1, d2, itemstack));
|
|
||||||
- itemstack.subtract(1);
|
|
||||||
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
|
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
|
||||||
+ isourceblock.getWorld().addEntity(new EntityFireworks(isourceblock.getWorld(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), itemstack1));
|
+ isourceblock.getWorld().addEntity(new EntityFireworks(isourceblock.getWorld(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), itemstack1));
|
||||||
+ // itemstack.subtract(1); // Handled during event processing
|
+ // itemstack.subtract(1); // Handled during event processing
|
||||||
|
@ -482,3 +482,33 @@
|
||||||
this.dispensed = true;
|
this.dispensed = true;
|
||||||
if (world.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) world, blockposition)) {
|
if (world.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) world, blockposition)) {
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
|
@@ -380,6 +692,29 @@
|
||||||
|
@Override
|
||||||
|
protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||||
|
World world = isourceblock.getWorld();
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||||
|
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
||||||
|
+
|
||||||
|
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
|
||||||
|
+ if (!BlockDispenser.eventFired) {
|
||||||
|
+ world.getServer().getPluginManager().callEvent(event);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (event.isCancelled()) {
|
||||||
|
+ return itemstack;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!event.getItem().equals(craftItem)) {
|
||||||
|
+ // Chain to handler for new item
|
||||||
|
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||||
|
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
|
||||||
|
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
|
||||||
|
+ idispensebehavior.dispense(isourceblock, eventStack);
|
||||||
|
+ return itemstack;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
|
||||||
|
if (!world.e()) {
|
||||||
|
this.dispensed = false;
|
||||||
|
|
Loading…
Reference in a new issue