2021-06-14 21:58:32 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2021-09-20 11:30:04 +02:00
|
|
|
From: Madeline Miller <mnmiller1@me.com>
|
2021-06-14 21:58:32 +02:00
|
|
|
Date: Sun, 17 Jan 2021 13:16:09 +1000
|
2024-01-19 22:13:42 +01:00
|
|
|
Subject: [PATCH] Add BlockPreDispenseEvent
|
2021-06-14 21:58:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
|
2024-04-24 15:46:45 +02:00
|
|
|
index 94bcbaf7daf7dfe566f508d1170a433930d9d49a..f6edfea463b3725d3a79aca38825e86dbf82175c 100644
|
2021-06-14 21:58:32 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
|
2024-04-24 15:46:45 +02:00
|
|
|
@@ -110,6 +110,7 @@ public class DispenserBlock extends BaseEntityBlock {
|
|
|
|
DispenseItemBehavior idispensebehavior = this.getDispenseMethod(world, itemstack);
|
2021-06-14 21:58:32 +02:00
|
|
|
|
2023-09-22 07:41:27 +02:00
|
|
|
if (idispensebehavior != DispenseItemBehavior.NOOP) {
|
2024-01-20 23:13:41 +01:00
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockPreDispenseEvent(world, pos, itemstack, i)) return; // Paper - Add BlockPreDispenseEvent
|
2023-09-22 07:41:27 +02:00
|
|
|
DispenserBlock.eventFired = false; // CraftBukkit - reset event status
|
|
|
|
tileentitydispenser.setItem(i, idispensebehavior.dispense(sourceblock, itemstack));
|
|
|
|
}
|
2024-02-10 22:19:22 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/DropperBlock.java b/src/main/java/net/minecraft/world/level/block/DropperBlock.java
|
2024-06-13 23:42:02 +02:00
|
|
|
index 083ddfb8fffa04dad6eeca2274f290a08e62b5eb..45fafee2cf1893dccf477939dad05e9e1938ec8c 100644
|
2024-02-10 22:19:22 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/DropperBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/DropperBlock.java
|
2024-04-24 15:46:45 +02:00
|
|
|
@@ -71,6 +71,7 @@ public class DropperBlock extends DispenserBlock {
|
2024-02-10 22:19:22 +01:00
|
|
|
ItemStack itemstack1;
|
|
|
|
|
|
|
|
if (iinventory == null) {
|
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockPreDispenseEvent(world, pos, itemstack, i)) return; // Paper - Add BlockPreDispenseEvent
|
|
|
|
itemstack1 = DropperBlock.DISPENSE_BEHAVIOUR.dispense(sourceblock, itemstack);
|
|
|
|
} else {
|
|
|
|
// CraftBukkit start - Fire event when pushing items into other inventories
|
2021-06-14 21:58:32 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2024-06-14 19:15:52 +02:00
|
|
|
index b6456c7fdd97925a8b68bdb80ff53c441f7996c7..fd889f0af29703c85a78b8189881516d54d147a6 100644
|
2021-06-14 21:58:32 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2024-06-14 19:15:52 +02:00
|
|
|
@@ -2065,5 +2065,11 @@ public class CraftEventFactory {
|
2021-06-14 21:58:32 +02:00
|
|
|
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) {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ org.bukkit.block.Block block = CraftBlock.at(serverLevel, pos);
|
2021-06-14 21:58:32 +02:00
|
|
|
+ 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
|
|
|
|
}
|