mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-03 06:40:19 +08:00
2dd5dccf00
This restores the behaviour to vanilla by default, but may be changed if one wants to. Fixes #5259.
58 lines
3.3 KiB
Diff
58 lines
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 fdbd8b89bb8bf3b61f60b812b90483c98a3d5ccb..faa1b775e45563b93ac1d5b904938b1f5ad8d80c 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
@@ -441,6 +441,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 72de544c0782e4daff222a0ca04e5bc870cf148c..5ca4d03215c979a4d122a32178a1859b4d9c3334 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) {
|
|
+ TileEntity extension = this.world.getTileEntity(blockposition);
|
|
+ if (extension instanceof TileEntityPiston && ((TileEntityPiston) 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;
|
|
}
|