mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-11 09:23:42 +01:00
732b2f6b5a
A recent commit has been made that caused patches to be out of order, rebuilding
42 lines
2.5 KiB
Diff
42 lines
2.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Matthew Miller <mnmiller1@me.com>
|
|
Date: Sun, 17 Jan 2021 13:16:09 +1000
|
|
Subject: [PATCH] Implement BlockPreDispenseEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockDispenser.java b/src/main/java/net/minecraft/server/BlockDispenser.java
|
|
index 063453552b7b6c2395c8f9be27cdb71a15a56ca4..89325af931b5ca43729758e94e971b612f65eea2 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockDispenser.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockDispenser.java
|
|
@@ -55,6 +55,7 @@ public class BlockDispenser extends BlockTileEntity {
|
|
IDispenseBehavior idispensebehavior = this.a(itemstack);
|
|
|
|
if (idispensebehavior != IDispenseBehavior.NONE) {
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockPreDispenseEvent(worldserver, blockposition, itemstack, i)) return; // Paper - BlockPreDispenseEvent is called here
|
|
eventFired = false; // CraftBukkit - reset event status
|
|
tileentitydispenser.setItem(i, idispensebehavior.dispense(sourceblock, itemstack));
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index 63d329dca12f902e2fb2a62ee4c86aea6453f1a3..696ded96e6018bc5289cc20f72d6dc9395d3b6a6 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -13,6 +13,7 @@ import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
import javax.annotation.Nullable;
|
|
+import io.papermc.paper.event.block.BlockPreDispenseEvent;
|
|
import net.minecraft.server.BlockPosition;
|
|
import net.minecraft.server.BlockPropertyInstrument;
|
|
import net.minecraft.server.Container;
|
|
@@ -1770,5 +1771,11 @@ public class CraftEventFactory {
|
|
BlockFailedDispenseEvent event = new BlockFailedDispenseEvent(block);
|
|
return event.callEvent();
|
|
}
|
|
+
|
|
+ public static boolean handleBlockPreDispenseEvent(WorldServer worldserver, BlockPosition blockposition, ItemStack itemStack, int slot) {
|
|
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
+ BlockPreDispenseEvent event = new BlockPreDispenseEvent(block, org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), slot);
|
|
+ return event.callEvent();
|
|
+ }
|
|
// Paper end
|
|
}
|