From 560b13ca080357a7c996b1f27c4e71143f6a6182 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 Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> --- .../entity/item/FallingBlockEntity.java.patch | 23 ++++++++++++++++--- .../world/entity/item/PrimedTnt.java.patch | 16 ++++++++++--- .../entity/vehicle/MinecartTNT.java.patch | 15 +++++++++++- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch index da4d2151e8..1c4abc0ace 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -42,7 +42,24 @@ } else { Block block = this.blockState.getBlock(); -@@ -174,7 +186,7 @@ +@@ -147,6 +159,16 @@ + this.applyGravity(); + this.move(MoverType.SELF, this.getDeltaMovement()); + this.applyEffectsFromBlocks(); ++ // Paper start - Configurable falling blocks height nerf ++ if (this.level().paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) { ++ if (this.dropItem && this.level() instanceof final ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { ++ this.spawnAtLocation(serverLevel, block); ++ } ++ ++ this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD); ++ return; ++ } ++ // Paper end - Configurable falling blocks height nerf + this.handlePortal(); + Level world = this.level(); + +@@ -174,7 +196,7 @@ this.spawnAtLocation(worldserver, (ItemLike) block); } @@ -51,7 +68,7 @@ } } else { BlockState iblockdata = this.level().getBlockState(blockposition); -@@ -191,9 +203,15 @@ +@@ -191,9 +213,15 @@ this.blockState = (BlockState) this.blockState.setValue(BlockStateProperties.WATERLOGGED, true); } @@ -68,7 +85,7 @@ if (block instanceof Fallable) { ((Fallable) block).onLand(this.level(), blockposition, this.blockState, iblockdata, this); } -@@ -221,19 +239,19 @@ +@@ -221,19 +249,19 @@ } } } else if (this.dropItem && worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch index 32b54af646..b8d49aed9a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch @@ -21,7 +21,7 @@ public PrimedTnt(EntityType<? extends PrimedTnt> type, Level world) { super(type, world); -@@ -94,6 +101,7 @@ +@@ -94,10 +101,17 @@ @Override public void tick() { @@ -29,7 +29,17 @@ this.handlePortal(); this.applyGravity(); this.move(MoverType.SELF, this.getDeltaMovement()); -@@ -107,10 +115,13 @@ + this.applyEffectsFromBlocks(); ++ // Paper start - Configurable TNT height nerf ++ if (this.level().paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) { ++ this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD); ++ return; ++ } ++ // Paper end - Configurable TNT height nerf + this.setDeltaMovement(this.getDeltaMovement().scale(0.98D)); + if (this.onGround()) { + this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, -0.5D, 0.7D)); +@@ -107,10 +121,13 @@ this.setFuse(i); if (i <= 0) { @@ -44,7 +54,7 @@ } else { this.updateInWaterStateAndDoFluidPushing(); if (this.level().isClientSide) { -@@ -121,7 +132,13 @@ +@@ -121,7 +138,13 @@ } private void explode() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch index f255ea88dc..7fdf216d8a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch @@ -19,7 +19,20 @@ public MinecartTNT(EntityType<? extends MinecartTNT> type, Level world) { super(type, world); -@@ -117,8 +122,16 @@ +@@ -51,6 +56,12 @@ + public void tick() { + super.tick(); + if (this.fuse > 0) { ++ // Paper start - Configurable TNT height nerf ++ if (this.level().paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) { ++ this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD); ++ return; ++ } ++ // Paper end - Configurable TNT height nerf + --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) { +@@ -117,8 +128,16 @@ if (world instanceof ServerLevel worldserver) { double d1 = Math.min(Math.sqrt(power), 5.0D);