geforkt von Mirrors/Paper
4793f774c8
Hopefully help 'technical minecrafters' find and understand these configs by adding notes to them, and fixing the incorrect config placement on the bedrock config.
94 Zeilen
5.7 KiB
Diff
94 Zeilen
5.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Thu, 11 Jun 2020 17:29:42 -0700
|
|
Subject: [PATCH] Fix piston physics inconsistency - MC-188840
|
|
|
|
Pistons invoke physics when they move blocks. The physics can cause
|
|
tnt blocks to ignite. However, pistons (when storing the blocks they "moved")
|
|
don't actually go back to the world state sometimes to check if something
|
|
like that happened. As a result they end up moving the tnt like it was
|
|
never ignited. This resulted in the ability to create machines
|
|
that can duplicate tnt, called "world eaters".
|
|
This patch makes the piston logic retrieve the block state from the world
|
|
prevent this from occuring.
|
|
|
|
This patch also sets the moved pos to air immediately after creating
|
|
the moving piston TE. This prevents the block from being updated from
|
|
other physics calls by the piston.
|
|
|
|
Tested against the following tnt duper design:
|
|
https://www.youtube.com/watch?v=mS7xxNGhjxs
|
|
|
|
This patch also affects every type of machine that utilises
|
|
this mechanic. For example, dead coral is removed by a physics
|
|
update when being moved while it is attached to slimeblocks.
|
|
|
|
Standard piston machines that don't destroy or modify the
|
|
blocks they move by physics updates should be entirely
|
|
unaffected.
|
|
|
|
This patch fixes https://bugs.mojang.com/browse/MC-188840
|
|
|
|
This patch also fixes rail duping and carpet duping.
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
index 353f453dba9603a45f7dd53d07f0da441331190a..741c06a27e664211a7023a6369f8e69cbb41a321 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
@@ -429,4 +429,10 @@ public class PaperConfig {
|
|
consoleHasAllPermissions = getBoolean("settings.console-has-all-permissions", consoleHasAllPermissions);
|
|
}
|
|
|
|
+ public static boolean allowPistonDuplication;
|
|
+ private static void allowPistonDuplication() {
|
|
+ config.set("settings.unsupported-settings.allow-piston-duplication-readme", "This setting controls if player should be able to use TNT duplication, but this also allows duplicating carpet, rails and potentially other items");
|
|
+ allowPistonDuplication = getBoolean("settings.unsupported-settings.allow-piston-duplication", config.getBoolean("settings.unsupported-settings.allow-tnt-duplication", false));
|
|
+ set("settings.unsupported-settings.allow-tnt-duplication", null);
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/BlockPiston.java b/src/main/java/net/minecraft/server/BlockPiston.java
|
|
index 6b1253fe7e8d4bb71d4d19c063d3e84c167c4d7b..c3133814f1349b2f70b12967b1b5abc88f71f98c 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockPiston.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockPiston.java
|
|
@@ -368,12 +368,24 @@ public class BlockPiston extends BlockDirectional {
|
|
}
|
|
|
|
for (k = list.size() - 1; k >= 0; --k) {
|
|
- blockposition3 = (BlockPosition) list.get(k);
|
|
- iblockdata1 = world.getType(blockposition3);
|
|
+ // Paper start - fix a variety of piston desync dupes
|
|
+ boolean allowDesync = com.destroystokyo.paper.PaperConfig.allowPistonDuplication;
|
|
+ BlockPosition oldPos = blockposition3 = (BlockPosition) list.get(k);
|
|
+ iblockdata1 = allowDesync ? world.getType(oldPos) : null;
|
|
+ // Paper end - fix a variety of piston desync dupes
|
|
blockposition3 = blockposition3.shift(enumdirection1);
|
|
map.remove(blockposition3);
|
|
world.setTypeAndData(blockposition3, (IBlockData) Blocks.MOVING_PISTON.getBlockData().set(BlockPiston.FACING, enumdirection), 68);
|
|
- world.setTileEntity(blockposition3, BlockPistonMoving.a((IBlockData) list1.get(k), enumdirection, flag, false));
|
|
+ // Paper start - fix a variety of piston desync dupes
|
|
+ if (!allowDesync) {
|
|
+ iblockdata1 = world.getType(oldPos);
|
|
+ map.replace(oldPos, iblockdata1);
|
|
+ }
|
|
+ world.setTileEntity(blockposition3, BlockPistonMoving.a(allowDesync ? list1.get(k) : iblockdata1, enumdirection, flag, false));
|
|
+ if (!allowDesync) {
|
|
+ world.setTypeAndData(oldPos, Blocks.AIR.getBlockData(), 2 | 4 | 16 | 1024); // set air to prevent later physics updates from seeing this block
|
|
+ }
|
|
+ // Paper end - fix a variety of piston desync dupes
|
|
aiblockdata[j++] = iblockdata1;
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityPiston.java b/src/main/java/net/minecraft/server/TileEntityPiston.java
|
|
index 5b941321a7fdc561e6b794a1dce5d600083c505d..e7b7e468fc874b0fbcd43f87d816a42420f9b05e 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntityPiston.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityPiston.java
|
|
@@ -256,7 +256,7 @@ public class TileEntityPiston extends TileEntity implements ITickable {
|
|
IBlockData iblockdata = Block.b(this.a, (GeneratorAccess) this.world, this.position);
|
|
|
|
if (iblockdata.isAir()) {
|
|
- this.world.setTypeAndData(this.position, this.a, 84);
|
|
+ this.world.setTypeAndData(this.position, this.a, com.destroystokyo.paper.PaperConfig.allowPistonDuplication ? 84 : (84 | 2)); // Paper - force notify (flag 2), it's possible the set type by the piston block (which doesn't notify) set this block to air
|
|
Block.a(this.a, iblockdata, this.world, this.position, 3);
|
|
} else {
|
|
if (iblockdata.b(BlockProperties.C) && (Boolean) iblockdata.get(BlockProperties.C)) {
|