PaperMC/patches/server/0486-Prevent-headless-pistons-from-being-created.patch

52 lines
3.2 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02: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
2022-03-11 21:13:46 +01:00
index d404105573f3cda57e8eb6cad70d248d4e5e1bdf..ff855232e9b94d1b05d7abb8fd5ce243cc0cd324 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -469,4 +469,10 @@ public class PaperConfig {
maxPlayerAutoSavePerTick = (playerAutoSaveRate == -1 || playerAutoSaveRate > 100) ? 10 : 20;
}
2021-06-11 14:02:28 +02:00
}
+
2021-06-11 14:02:28 +02: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-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index 0d6f33319521101bd10352d597b5e3e063ec443f..29f6c10e2c2626a9726d295acf12efea2b463cd3 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -35,6 +35,8 @@ import net.minecraft.world.level.block.BaseFireBlock;
2021-06-11 14:02:28 +02: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 12:42:08 +02:00
import net.minecraft.world.level.gameevent.GameEvent;
2021-06-11 14:02:28 +02:00
import net.minecraft.world.level.material.FluidState;
@@ -189,6 +191,15 @@ public class Explosion {
2021-06-11 14:02:28 +02:00
if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockposition, iblockdata, f)) {
2021-06-11 14:02:28 +02: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 22:20:03 +02:00
+ if (extension instanceof PistonMovingBlockEntity && ((PistonMovingBlockEntity) extension).isSourcePiston()) {
+ net.minecraft.core.Direction direction = iblockdata.getValue(PistonHeadBlock.FACING);
2021-06-11 14:02:28 +02:00
+ set.add(blockposition.relative(direction.getOpposite()));
+ }
+ }
+ // Paper end
}
d4 += d0 * 0.30000001192092896D;