mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-31 00:20:44 +01:00
Prevent headless pistons from being created
Prevent headless pistons from being created by explosions or tree/mushroom growth.
This commit is contained in:
parent
300af129c1
commit
54ce8682aa
1 changed files with 24 additions and 8 deletions
|
@ -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<ServerExplosion.StackCollector> 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<BlockPos> list = this.calculateExplodedPositions();
|
||||
|
||||
@@ -288,6 +400,7 @@
|
||||
@@ -288,6 +409,7 @@
|
||||
}
|
||||
|
||||
private static void addOrAppendStack(List<ServerExplosion.StackCollector> droppedItemsOut, ItemStack item, BlockPos pos) {
|
||||
|
@ -237,7 +253,7 @@
|
|||
Iterator iterator = droppedItemsOut.iterator();
|
||||
|
||||
do {
|
||||
@@ -372,4 +485,85 @@
|
||||
@@ -372,4 +494,85 @@
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue