Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
35 Zeilen
2.3 KiB
Diff
35 Zeilen
2.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Madeline 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/world/level/block/DispenserBlock.java b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
|
|
index d86a5f80171e13c2b1a1fd90b4c1471fadd957b4..edcdaac8078d131cffacae25764a1c3c6ad79923 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
|
|
@@ -98,6 +98,7 @@ public class DispenserBlock extends BaseEntityBlock {
|
|
DispenseItemBehavior idispensebehavior = this.getDispenseMethod(itemstack);
|
|
|
|
if (idispensebehavior != DispenseItemBehavior.NOOP) {
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockPreDispenseEvent(world, pos, itemstack, i)) return; // Paper - BlockPreDispenseEvent is called here
|
|
DispenserBlock.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 851ac82b242d513015487c15476a66d2b8b2158d..b6648899c2146dbd41c3e4cafabeb3f7db129738 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -2004,5 +2004,11 @@ public class CraftEventFactory {
|
|
io.papermc.paper.event.block.BlockFailedDispenseEvent event = new io.papermc.paper.event.block.BlockFailedDispenseEvent(block);
|
|
return event.callEvent();
|
|
}
|
|
+
|
|
+ public static boolean handleBlockPreDispenseEvent(ServerLevel serverLevel, BlockPos pos, ItemStack itemStack, int slot) {
|
|
+ org.bukkit.block.Block block = serverLevel.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
|
|
+ io.papermc.paper.event.block.BlockPreDispenseEvent event = new io.papermc.paper.event.block.BlockPreDispenseEvent(block, org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), slot);
|
|
+ return event.callEvent();
|
|
+ }
|
|
// Paper end
|
|
}
|