From 54ce8682aa683d537638b3a6226ff5a40002fb3f Mon Sep 17 00:00:00 2001 From: commandblockguy 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. --- .../world/level/ServerExplosion.java.patch | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch b/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch index cc2588d14c..36deb65d8a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch @@ -62,7 +62,23 @@ if (!this.level.isInWorldBounds(blockposition)) { break; -@@ -171,7 +186,7 @@ +@@ -149,6 +164,15 @@ + + if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockposition, iblockdata, f)) { + set.add(blockposition); ++ // Paper start - prevent headless pistons from forming ++ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && iblockdata.getBlock() == Blocks.MOVING_PISTON) { ++ net.minecraft.world.level.block.entity.BlockEntity extension = this.level.getBlockEntity(blockposition); ++ if (extension instanceof net.minecraft.world.level.block.piston.PistonMovingBlockEntity blockEntity && blockEntity.isSourcePiston()) { ++ net.minecraft.core.Direction direction = iblockdata.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING); ++ set.add(blockposition.relative(direction.getOpposite())); ++ } ++ } ++ // Paper end - prevent headless pistons from forming + } + + d4 += d0 * 0.30000001192092896D; +@@ -171,7 +195,7 @@ int l = Mth.floor(this.center.y + (double) f + 1.0D); int i1 = Mth.floor(this.center.z - (double) f - 1.0D); int j1 = Mth.floor(this.center.z + (double) f + 1.0D); @@ -71,7 +87,7 @@ Iterator iterator = list.iterator(); while (iterator.hasNext()) { -@@ -192,10 +207,38 @@ +@@ -192,10 +216,38 @@ d3 /= d4; boolean flag = this.damageCalculator.shouldDamageEntity(this, entity); float f1 = this.damageCalculator.getKnockbackMultiplier(entity); @@ -112,7 +128,7 @@ } double d5 = (1.0D - d0) * (double) f2 * (double) f1; -@@ -204,7 +247,7 @@ +@@ -204,7 +256,7 @@ if (entity instanceof LivingEntity) { LivingEntity entityliving = (LivingEntity) entity; @@ -121,7 +137,7 @@ } else { d6 = d5; } -@@ -214,11 +257,19 @@ +@@ -214,11 +266,19 @@ d3 *= d6; Vec3 vec3d = new Vec3(d1, d2, d3); @@ -142,7 +158,7 @@ this.hitPlayers.put(entityhuman, vec3d); } } -@@ -235,10 +286,62 @@ +@@ -235,10 +295,62 @@ List list1 = new ArrayList(); Util.shuffle(positions, this.level.random); @@ -205,7 +221,7 @@ this.level.getBlockState(blockposition).onExplosionHit(this.level, blockposition, this, (itemstack, blockposition1) -> { ServerExplosion.addOrAppendStack(list1, itemstack, blockposition1); -@@ -262,13 +365,22 @@ +@@ -262,13 +374,22 @@ BlockPos blockposition = (BlockPos) iterator.next(); if (this.level.random.nextInt(3) == 0 && this.level.getBlockState(blockposition).isAir() && this.level.getBlockState(blockposition.below()).isSolidRender()) { @@ -229,7 +245,7 @@ this.level.gameEvent(this.source, (Holder) GameEvent.EXPLODE, this.center); List list = this.calculateExplodedPositions(); -@@ -288,6 +400,7 @@ +@@ -288,6 +409,7 @@ } private static void addOrAppendStack(List droppedItemsOut, ItemStack item, BlockPos pos) { @@ -237,7 +253,7 @@ Iterator iterator = droppedItemsOut.iterator(); do { -@@ -372,4 +485,85 @@ +@@ -372,4 +494,85 @@ } }