Paper/patches/server/0018-Drop-falling-block-and-tnt-entities-at-the-specified.patch

83 lines
4.4 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Tue, 1 Mar 2016 14:14:15 -0600
Subject: [PATCH] Drop falling block and tnt entities at the specified height
* Dec 2, 2020 Added tnt nerf for tnt minecarts - Machine_Maker
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 9eb44bd14a5fd351d1514f4de8bc7ba328b0253d..128b7cb5ed01f31555b169a6132a39fe4bfb90c7 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -129,4 +129,14 @@ public class PaperWorldConfig {
2021-06-11 14:02:28 +02:00
keepSpawnInMemory = getBoolean("keep-spawn-loaded", true);
log("Keep spawn chunk loaded: " + keepSpawnInMemory);
}
+
+ public int fallingBlockHeightNerf;
+ public int entityTNTHeightNerf;
+ private void heightNerfs() {
+ fallingBlockHeightNerf = getInt("falling-block-height-nerf", 0);
+ entityTNTHeightNerf = getInt("tnt-entity-height-nerf", 0);
+
+ if (fallingBlockHeightNerf != 0) log("Falling Block Height Limit set to Y: " + fallingBlockHeightNerf);
+ if (entityTNTHeightNerf != 0) log("TNT Entity Height Limit set to Y: " + entityTNTHeightNerf);
+ }
}
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 27707ccea8763dbfdfe80da45f26127e58bc7316..91c0e425de193be1e4e9779d1c92c8ea577e29e0 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
2021-06-12 00:37:16 +02:00
@@ -127,6 +127,17 @@ public class FallingBlockEntity extends Entity {
2021-06-11 14:02:28 +02:00
}
this.move(MoverType.SELF, this.getDeltaMovement());
+
+ // Paper start - Configurable EntityFallingBlock height nerf
+ if (this.level.paperConfig.fallingBlockHeightNerf != 0 && this.getY() > this.level.paperConfig.fallingBlockHeightNerf) {
+ if (this.dropItem && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
+ this.spawnAtLocation(block);
+ }
+
2021-06-12 00:37:16 +02:00
+ this.discard();
2021-06-11 14:02:28 +02:00
+ return;
+ }
+ // Paper end
if (!this.level.isClientSide) {
blockposition = this.blockPosition();
boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock;
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
2021-06-12 00:37:16 +02:00
index 540fe28b16ff0208e23ecdd50fc5fa05960c0299..394164f50256ad9a167e15531a9202875abb6cb6 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
2021-06-12 00:37:16 +02:00
@@ -68,6 +68,12 @@ public class PrimedTnt extends Entity {
2021-06-11 14:02:28 +02:00
}
this.move(MoverType.SELF, this.getDeltaMovement());
+ // Paper start - Configurable TNT entity height nerf
+ if (this.level.paperConfig.entityTNTHeightNerf != 0 && this.getY() > this.level.paperConfig.entityTNTHeightNerf) {
2021-06-12 00:37:16 +02:00
+ this.discard();
2021-06-11 14:02:28 +02:00
+ return;
+ }
+ // Paper end
this.setDeltaMovement(this.getDeltaMovement().scale(0.98D));
if (this.onGround) {
this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, -0.5D, 0.7D));
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/MinecartTNT.java b/src/main/java/net/minecraft/world/entity/vehicle/MinecartTNT.java
2021-06-12 00:37:16 +02:00
index 01d3247501ad228882e9e0a03f964a18e051d4c4..4572a3cf0a067b64f2bd6c31139a773cddf4e872 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/vehicle/MinecartTNT.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/MinecartTNT.java
2021-06-12 00:37:16 +02:00
@@ -45,6 +45,12 @@ public class MinecartTNT extends AbstractMinecart {
2021-06-11 14:02:28 +02:00
public void tick() {
super.tick();
if (this.fuse > 0) {
+ // Paper start - Configurable TNT entity height nerf
+ if (this.level.paperConfig.entityTNTHeightNerf != 0 && this.getY() > this.level.paperConfig.entityTNTHeightNerf) {
2021-06-12 00:37:16 +02:00
+ this.discard();
2021-06-11 14:02:28 +02:00
+ return;
+ }
+ // Paper end
--this.fuse;
this.level.addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5D, this.getZ(), 0.0D, 0.0D, 0.0D);
} else if (this.fuse == 0) {