2021-06-11 12:02:28 +00:00
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
2021-11-26 16:25:35 +00:00
index 4fb6b2153117f54a2b0ca940de4c0ee2fa85e20e..09755771f8a3b2f696dc9c33916546fc1d5ac4ba 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
2021-11-26 16:25:35 +00:00
@@ -468,4 +468,10 @@ public class PaperConfig {
maxPlayerAutoSavePerTick = (playerAutoSaveRate == -1 || playerAutoSaveRate > 100) ? 10 : 20;
}
2021-06-11 12:02:28 +00:00
}
2021-11-26 16:25:35 +00:00
+
2021-06-11 12:02:28 +00:00
+ 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);
+ }
2021-11-24 16:06:46 +00:00
}
2021-06-11 12:02:28 +00:00
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
2021-11-24 16:06:46 +00:00
index f0c789d339fe8402c9c2a684d7e0415fa298b20e..6795132318a4e8b4c7a33b6f4b89a730ea66b97f 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
2021-11-24 16:06:46 +00:00
@@ -34,6 +34,8 @@ import net.minecraft.world.level.block.BaseFireBlock;
2021-06-11 12:02:28 +00:00
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
+import net.minecraft.world.level.block.piston.PistonHeadBlock;
+import net.minecraft.world.level.block.piston.PistonMovingBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
2021-06-14 10:42:08 +00:00
import net.minecraft.world.level.gameevent.GameEvent;
2021-06-11 12:02:28 +00:00
import net.minecraft.world.level.material.FluidState;
2021-11-24 16:06:46 +00:00
@@ -188,6 +190,15 @@ public class Explosion {
2021-06-11 12:02:28 +00:00
2021-07-09 14:08:42 +00:00
if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockposition, iblockdata, f)) {
2021-06-11 12:02:28 +00:00
set.add(blockposition);
+ // Paper start - prevent headless pistons from forming
+ if (!com.destroystokyo.paper.PaperConfig.allowHeadlessPistons && iblockdata.getBlock() == Blocks.MOVING_PISTON) {
+ BlockEntity extension = this.level.getBlockEntity(blockposition);
2021-06-17 20:20:03 +00:00
+ if (extension instanceof PistonMovingBlockEntity && ((PistonMovingBlockEntity) extension).isSourcePiston()) {
2021-11-24 16:06:46 +00:00
+ net.minecraft.core.Direction direction = iblockdata.getValue(PistonHeadBlock.FACING);
2021-06-11 12:02:28 +00:00
+ set.add(blockposition.relative(direction.getOpposite()));
+ }
+ }
+ // Paper end
}
d4 += d0 * 0.30000001192092896D;