2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-02-26 01:40:23 +00:00
|
|
|
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
|
2021-01-11 19:12:09 +00:00
|
|
|
index ec77151d0dde422024ae5226ad7e3fb18c08f7c0..89bb995909882a4b35e2d07e5a47739c1d4f46f2 100644
|
2019-02-26 01:40:23 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2021-01-11 19:12:09 +00:00
|
|
|
@@ -500,8 +500,20 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
2019-02-26 01:40:23 +00:00
|
|
|
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) {
|
2019-05-05 23:24:37 +00:00
|
|
|
+ com.destroystokyo.paper.event.block.BlockDestroyEvent event = new com.destroystokyo.paper.event.block.BlockDestroyEvent(MCUtil.toBukkitBlock(this, blockposition), fluid.getBlockData().createCraftBlockData(), flag);
|
2019-02-26 01:40:23 +00:00
|
|
|
+ if (!event.callEvent()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ playEffect = event.playEffect();
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
|
2020-06-25 14:09:55 +00:00
|
|
|
- if (!(iblockdata.getBlock() instanceof BlockFireAbstract)) {
|
|
|
|
+ if (playEffect && !(iblockdata.getBlock() instanceof BlockFireAbstract)) { // Paper
|
|
|
|
this.triggerEffect(2001, blockposition, Block.getCombinedId(iblockdata));
|
|
|
|
}
|
2019-05-05 17:19:34 +00:00
|
|
|
|