aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0838-Call-missing-BlockDispenseEvent.patch
diff options
context:
space:
mode:
authorNassim Jahnke <[email protected]>2024-06-16 12:56:00 +0200
committerNassim Jahnke <[email protected]>2024-06-16 12:56:00 +0200
commitdc684c60d16f66ea84467ec8e253f2a36a17a7c8 (patch)
treee516f1bd4bfbdb37a5aeee42384aade111eca3e1 /patches/server/0838-Call-missing-BlockDispenseEvent.patch
parent752f957e12e4ceb8b7d2043a4a7dbce786b7b98f (diff)
downloadPaper-dc684c60d16f66ea84467ec8e253f2a36a17a7c8.tar.gz
Paper-dc684c60d16f66ea84467ec8e253f2a36a17a7c8.zip
Remove bad server.scheduleOnMain disconnect calls from old patches
The new behavior of disconnect to block the current thread until the disconnect succeeded is better than throwing it off to happen at some point
Diffstat (limited to 'patches/server/0838-Call-missing-BlockDispenseEvent.patch')
-rw-r--r--patches/server/0838-Call-missing-BlockDispenseEvent.patch88
1 files changed, 88 insertions, 0 deletions
diff --git a/patches/server/0838-Call-missing-BlockDispenseEvent.patch b/patches/server/0838-Call-missing-BlockDispenseEvent.patch
new file mode 100644
index 0000000000..97050595b8
--- /dev/null
+++ b/patches/server/0838-Call-missing-BlockDispenseEvent.patch
@@ -0,0 +1,88 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Lulu13022002 <[email protected]>
+Date: Sat, 29 Oct 2022 15:41:56 +0200
+Subject: [PATCH] Call missing BlockDispenseEvent
+
+
+diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
+index 96db0b1041a4c0f054d4f3f2bdced960b119664e..78951f50188528718cdb3dbbaabe3f9f2760ffe3 100644
+--- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
++++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
+@@ -867,6 +867,13 @@ public interface DispenseItemBehavior {
+ this.setSuccess(true);
+ if (iblockdata.is(Blocks.RESPAWN_ANCHOR)) {
+ if ((Integer) iblockdata.getValue(RespawnAnchorBlock.CHARGE) != 4) {
++ // Paper start - Call missing BlockDispenseEvent
++ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(pointer, blockposition, stack, this);
++ if (result != null) {
++ this.setSuccess(false);
++ return result;
++ }
++ // Paper end - Call missing BlockDispenseEvent
+ RespawnAnchorBlock.charge((Entity) null, worldserver, blockposition, iblockdata);
+ stack.shrink(1);
+ } else {
+@@ -944,6 +951,13 @@ public interface DispenseItemBehavior {
+ Optional<BlockState> optional = HoneycombItem.getWaxed(iblockdata);
+
+ if (optional.isPresent()) {
++ // Paper start - Call missing BlockDispenseEvent
++ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(pointer, blockposition, stack, this);
++ if (result != null) {
++ this.setSuccess(false);
++ return result;
++ }
++ // Paper end - Call missing BlockDispenseEvent
+ worldserver.setBlockAndUpdate(blockposition, (BlockState) optional.get());
+ worldserver.levelEvent(3003, blockposition, 0);
+ stack.shrink(1);
+@@ -971,6 +985,12 @@ public interface DispenseItemBehavior {
+ if (!worldserver.getBlockState(blockposition1).is(BlockTags.CONVERTABLE_TO_MUD)) {
+ return this.defaultDispenseItemBehavior.dispense(pointer, stack);
+ } else {
++ // Paper start - Call missing BlockDispenseEvent
++ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(pointer, blockposition1, stack, this);
++ if (result != null) {
++ return result;
++ }
++ // Paper end - Call missing BlockDispenseEvent
+ if (!worldserver.isClientSide) {
+ for (int k = 0; k < 5; ++k) {
+ worldserver.sendParticles(ParticleTypes.SPLASH, (double) blockposition.getX() + worldserver.random.nextDouble(), (double) (blockposition.getY() + 1), (double) blockposition.getZ() + worldserver.random.nextDouble(), 1, 0.0D, 0.0D, 0.0D, 1.0D);
+diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+index 214a1b8901947e8c08e8d7fc3f19e866a21350c8..35b6443d15678ec84271dcebf29b98b36df97a6e 100644
+--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
++++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+@@ -2129,6 +2129,32 @@ public class CraftEventFactory {
+ }
+ // Paper end
+
++ // Paper start - Call missing BlockDispenseEvent
++ @Nullable
++ public static ItemStack handleBlockDispenseEvent(net.minecraft.core.dispenser.BlockSource pointer, BlockPos to, ItemStack itemStack, net.minecraft.core.dispenser.DispenseItemBehavior instance) {
++ org.bukkit.block.Block bukkitBlock = CraftBlock.at(pointer.level(), pointer.pos());
++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemStack.copyWithCount(1));
++
++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), CraftVector.toBukkit(to));
++ if (!net.minecraft.world.level.block.DispenserBlock.eventFired) {
++ if (!event.callEvent()) {
++ return itemStack;
++ }
++ }
++
++ if (!event.getItem().equals(craftItem)) {
++ // Chain to handler for new item
++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
++ net.minecraft.core.dispenser.DispenseItemBehavior itemBehavior = net.minecraft.world.level.block.DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
++ if (itemBehavior != net.minecraft.core.dispenser.DispenseItemBehavior.NOOP && itemBehavior != instance) {
++ itemBehavior.dispense(pointer, eventStack);
++ return itemStack;
++ }
++ }
++ return null;
++ }
++ // Paper end - Call missing BlockDispenseEvent
++
+ // Paper start - add EntityFertilizeEggEvent
+ /**
+ * Calls the {@link io.papermc.paper.event.entity.EntityFertilizeEggEvent}.