Paper/Spigot-Server-Patches/0559-Prevent-headless-pistons-from-being-created.patch
Mariell Hoversholm 74f507f4e3 Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears 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:
e461dcfe #555: Item - add getters/setters for owner/thrower

CraftBukkit Changes:
055870c4 #758: Item - add getters/setters for owner/thrower
2020-10-14 10:44:15 -04:00

58 Zeilen
3.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: commandblockguy <commandblockguy1@gmail.com>
Date: Fri, 14 Aug 2020 14:44:14 -0500
Subject: [PATCH] Prevent headless pistons from being created
Prevent headless pistons from being created by explosions or tree/mushroom growth.
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 669653b5cfb057b277e509b630fd73a843b42b24..a01b28d47669cbc36a9e6c47deb5135bec231948 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -436,6 +436,12 @@ public class PaperConfig {
set("settings.unsupported-settings.allow-tnt-duplication", null);
}
+ public static boolean allowHeadlessPistons;
+ private static void allowHeadlessPistons() {
+ config.set("settings.unsupported-settings.allow-headless-pistons-readme", "This setting controls if players should be able to create headless pistons.");
+ allowHeadlessPistons = getBoolean("settings.unsupported-settings.allow-headless-pistons", false);
+ }
+
public static int playerAutoSaveRate = -1;
public static int maxPlayerAutoSavePerTick = 10;
private static void playerAutoSaveRate() {
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
index f263177e3d41fd5720c430be3dcb1b5e2adb0134..b7cfa6fb188d36ecbad0389bb51e5f1016b9eabd 100644
--- a/src/main/java/net/minecraft/server/Explosion.java
+++ b/src/main/java/net/minecraft/server/Explosion.java
@@ -135,6 +135,15 @@ public class Explosion {
if (f > 0.0F && this.l.a(this, this.world, blockposition, iblockdata, f) && blockposition.getY() < 256 && blockposition.getY() >= 0) { // CraftBukkit - don't wrap explosions
set.add(blockposition);
+ // Paper start - prevent headless pistons from forming
+ if (!com.destroystokyo.paper.PaperConfig.allowHeadlessPistons && iblockdata.getBlock() == Blocks.MOVING_PISTON) {
+ TileEntityPiston extension = (TileEntityPiston)this.world.getTileEntity(blockposition);
+ if (extension.isHead()) {
+ EnumDirection direction = iblockdata.get(BlockPistonExtension.FACING);
+ set.add(blockposition.shift(direction.opposite()));
+ }
+ }
+ // Paper end
}
d4 += d0 * 0.30000001192092896D;
diff --git a/src/main/java/net/minecraft/server/TileEntityPiston.java b/src/main/java/net/minecraft/server/TileEntityPiston.java
index 7d86f0fe55063f6875db9c6f99f4f72ed4144536..b0d52d7405ca24938ca753897f89e6fad575d04d 100644
--- a/src/main/java/net/minecraft/server/TileEntityPiston.java
+++ b/src/main/java/net/minecraft/server/TileEntityPiston.java
@@ -42,6 +42,8 @@ public class TileEntityPiston extends TileEntity implements ITickable {
return this.b;
}
+ public final boolean isHead() { return this.h(); } // Paper - OBFHELPER
+
public boolean h() {
return this.g;
}