mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-21 02:17:42 +01:00
71 lines
4.3 KiB
Diff
71 lines
4.3 KiB
Diff
From e9a526238a869c9b1238f4278f7086fc292e11e8 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Fri, 12 Jun 2020 11:45:41 -0700
|
|
Subject: [PATCH] PaperPR - fixup! Protect Bedrock and End Portal/Frames from
|
|
being destroyed
|
|
|
|
---
|
|
src/main/java/net/minecraft/server/Block.java | 3 ++-
|
|
.../java/net/minecraft/server/BlockPiston.java | 17 +++++++++++++++--
|
|
2 files changed, 17 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
|
|
index 8985d0ee9d..97e553b38c 100644
|
|
--- a/src/main/java/net/minecraft/server/Block.java
|
|
+++ b/src/main/java/net/minecraft/server/Block.java
|
|
@@ -37,7 +37,8 @@ public class Block implements IMaterial {
|
|
this != Blocks.BEDROCK &&
|
|
this != Blocks.END_PORTAL_FRAME &&
|
|
this != Blocks.END_PORTAL &&
|
|
- this != Blocks.END_GATEWAY;
|
|
+ this != Blocks.END_GATEWAY &&
|
|
+ this != Blocks.MOVING_PISTON; // try to prevent creation of headless pistons
|
|
}
|
|
public co.aikar.timings.Timing timing;
|
|
public co.aikar.timings.Timing getTiming() {
|
|
diff --git a/src/main/java/net/minecraft/server/BlockPiston.java b/src/main/java/net/minecraft/server/BlockPiston.java
|
|
index 80a4cf1641..0b7bed5e92 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockPiston.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockPiston.java
|
|
@@ -175,6 +175,12 @@ public class BlockPiston extends BlockDirectional {
|
|
@Override
|
|
public boolean a(IBlockData iblockdata, World world, BlockPosition blockposition, int i, int j) {
|
|
EnumDirection enumdirection = (EnumDirection) iblockdata.get(BlockPiston.FACING);
|
|
+ // Purpur start - prevent retracting when we're facing the wrong way (we were replaced before retraction could occur)
|
|
+ EnumDirection directionQueuedAs = EnumDirection.fromType1(j & 7); // Purpur - copied from below
|
|
+ if (!com.destroystokyo.paper.PaperConfig.allowBlockPermanentBreakingExploits && enumdirection != directionQueuedAs) {
|
|
+ return false;
|
|
+ }
|
|
+ // Purpur end - prevent retracting when we're facing the wrong way
|
|
|
|
if (!world.isClientSide) {
|
|
boolean flag = this.a(world, blockposition, enumdirection);
|
|
@@ -204,7 +210,7 @@ public class BlockPiston extends BlockDirectional {
|
|
}
|
|
|
|
world.setTypeAndData(blockposition, (IBlockData) ((IBlockData) Blocks.MOVING_PISTON.getBlockData().set(BlockPistonMoving.a, enumdirection)).set(BlockPistonMoving.b, this.sticky ? BlockPropertyPistonType.STICKY : BlockPropertyPistonType.DEFAULT), 3);
|
|
- world.setTileEntity(blockposition, BlockPistonMoving.a((IBlockData) this.getBlockData().set(BlockPiston.FACING, EnumDirection.fromType1(j & 7)), enumdirection, false, true));
|
|
+ world.setTileEntity(blockposition, BlockPistonMoving.a((IBlockData) this.getBlockData().set(BlockPiston.FACING, EnumDirection.fromType1(j & 7)), enumdirection, false, true)); // Purpur - diff on change, j is facing direction
|
|
if (this.sticky) {
|
|
BlockPosition blockposition1 = blockposition.b(enumdirection.getAdjacentX() * 2, enumdirection.getAdjacentY() * 2, enumdirection.getAdjacentZ() * 2);
|
|
IBlockData iblockdata1 = world.getType(blockposition1);
|
|
@@ -232,7 +238,14 @@ public class BlockPiston extends BlockDirectional {
|
|
}
|
|
}
|
|
} else {
|
|
- world.a(blockposition.shift(enumdirection), false);
|
|
+ // Purpur start - fix headless pistons breaking blocks
|
|
+ BlockPosition headPos = blockposition.shift(enumdirection);
|
|
+ if (com.destroystokyo.paper.PaperConfig.allowBlockPermanentBreakingExploits || world.getType(headPos) == Blocks.PISTON_HEAD.getBlockData().set(FACING, enumdirection)) { // double check to make sure we're not a headless piston.
|
|
+ world.setAir(headPos, false);
|
|
+ } else {
|
|
+ ((WorldServer)world).getChunkProvider().flagDirty(headPos); // ... fix client desync
|
|
+ }
|
|
+ // Purpur end - fix headless pistons breaking blocks
|
|
}
|
|
|
|
world.playSound((EntityHuman) null, blockposition, SoundEffects.BLOCK_PISTON_CONTRACT, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.15F + 0.6F);
|
|
--
|
|
2.26.2
|
|
|