mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 07:48:53 +01:00
d8c3fb7e47
Needs updating to hook into new entity storage system
72 lines
4.4 KiB
Diff
72 lines
4.4 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 b67ba8f75e4a3358d7c2462918b85b0bf9b5a922..1ff9dbde24d6e15076c4e90a73ce5801c47ef3f2 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
@@ -440,4 +440,10 @@ public class PaperConfig {
|
|
allowPistonDuplication = getBoolean("settings.unsupported-settings.allow-piston-duplication", config.getBoolean("settings.unsupported-settings.allow-tnt-duplication", false));
|
|
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);
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
index a12af10e28f2d023ba6f916b5e7a53539416713f..822a8dbfaea0a312c4eb2849f2386ecd401b13e9 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
@@ -15,6 +15,7 @@ import java.util.Random;
|
|
import java.util.Set;
|
|
import javax.annotation.Nullable;
|
|
import net.minecraft.core.BlockPos;
|
|
+import net.minecraft.core.Direction;
|
|
import net.minecraft.core.Vec3i;
|
|
import net.minecraft.core.particles.ParticleTypes;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
@@ -35,6 +36,8 @@ import net.minecraft.world.level.block.BaseFireBlock;
|
|
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;
|
|
import net.minecraft.world.level.gameevent.GameEvent;
|
|
import net.minecraft.world.level.material.FluidState;
|
|
@@ -189,6 +192,15 @@ public class Explosion {
|
|
|
|
if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, 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) {
|
|
+ BlockEntity extension = this.level.getBlockEntity(blockposition);
|
|
+ if (extension instanceof PistonMovingBlockEntity && ((PistonMovingBlockEntity) extension).isHead()) {
|
|
+ Direction direction = iblockdata.getValue(PistonHeadBlock.FACING);
|
|
+ set.add(blockposition.relative(direction.getOpposite()));
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
d4 += d0 * 0.30000001192092896D;
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
|
|
index 87bedba9ab495edcce289c6665271d92b7165944..985f1112963c3b644a88788a6b4f8a9bd5f5c11a 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
|
|
@@ -66,6 +66,8 @@ public class PistonMovingBlockEntity extends BlockEntity {
|
|
return this.direction;
|
|
}
|
|
|
|
+ public final boolean isHead() { return this.isSourcePiston(); } // Paper - OBFHELPER
|
|
+
|
|
public boolean isSourcePiston() {
|
|
return this.isSourcePiston;
|
|
}
|