Paper/patches/server/0020-Drop-falling-block-and-tnt-entities-at-the-specified.patch
Nassim Jahnke 1358d1e914
Updated Upstream (CraftBukkit/Spigot) (#7580)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
881e06e5 PR-725: Add Item Unlimited Lifetime APIs

CraftBukkit Changes:
74c08312 SPIGOT-6962: Call EntityChangeBlockEvent when when FallingBlockEntity starts to fall
64db5126 SPIGOT-6959: Make /loot command ignore empty items for spawn
2d760831 Increase outdated build delay
9ed7e4fb SPIGOT-6138, SPIGOT-6415: Don't call CreatureSpawnEvent after cross-dimensional travel
fc4ad813 SPIGOT-6895: Trees grown with applyBoneMeal() don't fire the StructureGrowthEvent
59733a2e SPIGOT-6961: Actually return a copy of the ItemMeta

Spigot Changes:
ffceeae3 SPIGOT-6956: Drop unload queue patch as attempt at fixing stop issue
e19ddabd PR-1011: Add Item Unlimited Lifetime APIs
34d40b0e SPIGOT-2942: give command fires PlayerDropItemEvent, cancelling it causes Item Duplication
2022-03-13 08:47:54 +01:00

83 lines
4.4 KiB
Diff

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 9b908c5c66dc454faa479430a908dda0745638c8..6dec1bb96d695f28aae6517e4d78249169d2351a 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -170,4 +170,14 @@ public class PaperWorldConfig {
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 690a2a97e10bf1003b49f7e4806aab0bca206d99..6dc1500866e634364ac258956b07a880ecbf6c76 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -131,6 +131,17 @@ public class FallingBlockEntity extends Entity {
}
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);
+ }
+
+ this.discard();
+ return;
+ }
+ // Paper end
if (!this.level.isClientSide) {
BlockPos 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
index 9fa752370a43f6d91c019316914a033f213e7126..1f61dcc3d6f33f69fbebaaaee0554403c3e13adf 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -68,6 +68,12 @@ public class PrimedTnt extends Entity {
}
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) {
+ this.discard();
+ 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
index 01d3247501ad228882e9e0a03f964a18e051d4c4..4572a3cf0a067b64f2bd6c31139a773cddf4e872 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/MinecartTNT.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/MinecartTNT.java
@@ -45,6 +45,12 @@ public class MinecartTNT extends AbstractMinecart {
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) {
+ this.discard();
+ 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) {