From 3aa7c3bb231295a68bf403ab34f4b0dcc9e2696d Mon Sep 17 00:00:00 2001 From: Byteflux Date: Tue, 1 Mar 2016 14:14:15 -0600 Subject: [PATCH] Drop falling block and tnt entities at the specified height diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java index 0094d1a87..4da846719 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -113,4 +113,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/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 4540bf9f9..d358ab26a 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -1794,6 +1794,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper return this.a(new ItemStack(item, i, 0), f); } + @Nullable public final EntityItem dropItem(ItemStack itemstack, float offset) { return this.a(itemstack, offset); } // Paper - OBFHELPER @Nullable public EntityItem a(ItemStack itemstack, float f) { if (itemstack.isEmpty()) { diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java index 579e51a0a..2ba5d51a5 100644 --- a/src/main/java/net/minecraft/server/EntityFallingBlock.java +++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java @@ -84,6 +84,17 @@ public class EntityFallingBlock extends Entity { } this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ); + + // Paper start - Configurable EntityFallingBlock height nerf + if (this.world.paperConfig.fallingBlockHeightNerf != 0 && this.locY > this.world.paperConfig.fallingBlockHeightNerf) { + if (this.dropItem && this.world.getGameRules().getBoolean("doEntityDrops")) { + this.dropItem(new ItemStack(block, 1, block.getDropData(this.block)), 0.0F); + } + + this.die(); + } + // Paper end + if (!this.world.isClientSide) { blockposition = new BlockPosition(this); boolean flag = this.block.getBlock() == Blocks.dS; diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java index 44b2d4735..0d70dd1d2 100644 --- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java +++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java @@ -57,6 +57,13 @@ public class EntityTNTPrimed extends Entity { } this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ); + + // Paper start - Configurable TNT entity height nerf + if (this.world.paperConfig.entityTNTHeightNerf != 0 && this.locY > this.world.paperConfig.entityTNTHeightNerf) { + this.die(); + } + // Paper end + this.motX *= 0.9800000190734863D; this.motY *= 0.9800000190734863D; this.motZ *= 0.9800000190734863D; -- 2.18.0