Paper/Spigot-Server-Patches/0326-Fire-BlockPistonRetractEvent-for-all-empty-pistons.patch
Daniel Ennis c97ce029e9
1.16.2 Release (#4123)
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues.

Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong.

This is now resolved.

Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me.

Please as always, backup your worlds and test before updating to 1.16.2!

If you update to 1.16.2, there is no going back to an older build than this.

---------------------------------

Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com>
Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com>
Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com>
Co-authored-by: stonar96 <minecraft.stonar96@gmail.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Jason <jasonpenilla2@me.com>
Co-authored-by: kashike <kashike@vq.lc>
Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com>
Co-authored-by: KennyTV <kennytv@t-online.de>
Co-authored-by: commandblockguy <commandblockguy1@gmail.com>
Co-authored-by: DigitalRegent <misterwener@gmail.com>
Co-authored-by: ishland <ishlandmc@yeah.net>
2020-08-24 22:40:19 -04:00

48 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach@zachbr.io>
Date: Thu, 31 Jan 2019 16:33:36 -0500
Subject: [PATCH] Fire BlockPistonRetractEvent for all empty pistons
There is an explicit check in the handling code for empty pistons that
prevents sticky pistons from firing the event. However when we look back
at the history we see that this check was originally added so that ONLY
sticky pistons would fire the retract event. I'm not sure why.
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/1092acbddf07edfa4100bc6824504ac75088e913
Over the course of several updates, the meaning of that field appears to
have changed from "is NOT sticky" to "is sticky". So now its having the
opposite effect. Only normal pistons fire the retraction event. And like
all things in CB, it's just been carried around since.
If we are to believe the history, the correct fix for this issue is to
flip it so it only fires for sticky pistons, but that puts us in a
bind. It's already firing for non-sticky pistons, changing it now would
likely result in breakage. Furthermore, there is little documentation as
to WHY that was ever intended to be the case.
Instead we opt to remove the check entirely so that the event fires for
all piston types.
diff --git a/src/main/java/net/minecraft/server/BlockPiston.java b/src/main/java/net/minecraft/server/BlockPiston.java
index 9f56471cdd180950d279883b8da71700604a9e31..417d1a6c3dbd23905672a847939d92a953bbc91c 100644
--- a/src/main/java/net/minecraft/server/BlockPiston.java
+++ b/src/main/java/net/minecraft/server/BlockPiston.java
@@ -112,7 +112,7 @@ public class BlockPiston extends BlockDirectional {
}
// CraftBukkit start
- if (!this.sticky) {
+ //if (!this.sticky) { // Paper - Prevents empty sticky pistons from firing retract - history behind is odd
org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.<org.bukkit.block.Block>of(), CraftBlock.notchToBlockFace(enumdirection));
world.getServer().getPluginManager().callEvent(event);
@@ -120,7 +120,7 @@ public class BlockPiston extends BlockDirectional {
if (event.isCancelled()) {
return;
}
- }
+ //} // Paper
// PAIL: checkME - what happened to setTypeAndData?
// CraftBukkit end
world.playBlockAction(blockposition, this, b0, enumdirection.c());