Paper/Spigot-Server-Patches/0323-BlockDestroyEvent.patch
Shane Freeder 0ea3083817
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
1e843b72 #510: Add NamespacedKey#fromString() to fetch from user input
a4d18241 #581: Add methods to modify despawn delay for wandering villagers

CraftBukkit Changes:
0cd8f19f #802: Add methods to modify despawn delay for wandering villagers
d5c5d998 SPIGOT-6362: ConcurrentModificationException: null --> Server Crash
8c7d69fe SPIGOT-5228: Entities that are removed during chunk unloads are not properly removed from the chunk.
2021-02-16 17:13:49 +00:00

39 lines
2.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 6 Feb 2019 00:20:33 -0500
Subject: [PATCH] BlockDestroyEvent
Adds an event for when the server is going to destroy a current block,
potentially causing it to drop. This event can be cancelled to avoid
the block destruction, such as preventing signs from popping when
floating in the air.
This can replace many uses of BlockPhysicsEvent
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index d6bce67fff263d2c04be29020a8dc66fa260a53e..6c0e179f4a6c14cf0cedc5a57e959d13a40ca42b 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -500,8 +500,20 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
return false;
} else {
Fluid fluid = this.getFluid(blockposition);
+ // Paper start - while the above setAir method is named same and looks very similar
+ // they are NOT used with same intent and the above should not fire this event. The above method is more of a BlockSetToAirEvent,
+ // it doesn't imply destruction of a block that plays a sound effect / drops an item.
+ boolean playEffect = true;
+ if (com.destroystokyo.paper.event.block.BlockDestroyEvent.getHandlerList().getRegisteredListeners().length > 0) {
+ com.destroystokyo.paper.event.block.BlockDestroyEvent event = new com.destroystokyo.paper.event.block.BlockDestroyEvent(MCUtil.toBukkitBlock(this, blockposition), fluid.getBlockData().createCraftBlockData(), flag);
+ if (!event.callEvent()) {
+ return false;
+ }
+ playEffect = event.playEffect();
+ }
+ // Paper end
- if (!(iblockdata.getBlock() instanceof BlockFireAbstract)) {
+ if (playEffect && !(iblockdata.getBlock() instanceof BlockFireAbstract)) { // Paper
this.triggerEffect(2001, blockposition, Block.getCombinedId(iblockdata));
}