Paper/patches/server/0729-Fix-tripwire-state-inconsistency.patch

79 Zeilen
4.7 KiB
Diff

2021-12-19 22:39:15 +01:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nassim Jahnke <nassim@njahnke.dev>
2021-12-19 22:39:15 +01:00
Date: Sun, 19 Dec 2021 21:11:20 +0100
Subject: [PATCH] Fix tripwire state inconsistency
This patch prevents updating and re-setting the tripwire when being removed in certain conditions
2021-12-19 22:39:15 +01:00
diff --git a/src/main/java/net/minecraft/world/level/block/TripWireBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireBlock.java
2023-12-06 16:17:00 +01:00
index bbb7d1b03c78758d608e89129aacec151242831c..1a0c5fb62e80681604110e95c1ae7b3684c21946 100644
2021-12-19 22:39:15 +01:00
--- a/src/main/java/net/minecraft/world/level/block/TripWireBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/TripWireBlock.java
2023-12-06 16:17:00 +01:00
@@ -87,7 +87,7 @@ public class TripWireBlock extends Block {
2021-12-19 22:39:15 +01:00
@Override
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean moved) {
if (!moved && !state.is(newState.getBlock())) {
- this.updateSource(world, pos, (BlockState) state.setValue(TripWireBlock.POWERED, true));
+ this.updateSource(world, pos, (BlockState) state.setValue(TripWireBlock.POWERED, true), true); // Paper - fix state inconsistency
}
}
2023-12-06 16:17:00 +01:00
@@ -102,6 +102,12 @@ public class TripWireBlock extends Block {
2021-12-19 22:39:15 +01:00
}
private void updateSource(Level world, BlockPos pos, BlockState state) {
+ // Paper start - fix state inconsistency
+ this.updateSource(world, pos, state, false);
+ }
+
+ private void updateSource(Level world, BlockPos pos, BlockState state, boolean beingRemoved) {
+ // Paper end
Direction[] aenumdirection = new Direction[]{Direction.SOUTH, Direction.WEST};
int i = aenumdirection.length;
int j = 0;
2023-12-06 16:17:00 +01:00
@@ -117,7 +123,7 @@ public class TripWireBlock extends Block {
2021-12-19 22:39:15 +01:00
2023-12-06 16:17:00 +01:00
if (iblockdata1.is(this.hook)) {
2021-12-19 22:39:15 +01:00
if (iblockdata1.getValue(TripWireHookBlock.FACING) == enumdirection.getOpposite()) {
2023-12-06 16:17:00 +01:00
- TripWireHookBlock.calculateState(world, blockposition1, iblockdata1, false, true, k, state);
+ TripWireHookBlock.calculateState(world, blockposition1, iblockdata1, false, true, k, state, beingRemoved); // Paper - fix state inconsistency
2021-12-19 22:39:15 +01:00
}
} else if (iblockdata1.is((Block) this)) {
++k;
diff --git a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
2023-12-06 20:10:59 +01:00
index 02b62ac13d4968f80cb0ae3702755d0f1d95e692..f922db802ae9fd05ce4b3b8d16531d9f7f458412 100644
--- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
2023-12-06 16:17:00 +01:00
@@ -118,7 +118,13 @@ public class TripWireHookBlock extends Block {
TripWireHookBlock.calculateState(world, pos, state, false, false, -1, (BlockState) null);
}
2023-12-06 16:17:00 +01:00
- public static void calculateState(Level world, BlockPos pos, BlockState state, boolean flag, boolean flag1, int i, @Nullable BlockState iblockdata1) {
+ public static void calculateState(Level world, BlockPos pos, BlockState state, boolean beingRemoved, boolean flag1, int i, @Nullable BlockState iblockdata1) {
+ // Paper start - fix tripwire inconsistency
2023-12-06 16:17:00 +01:00
+ calculateState(world, pos, state, beingRemoved, flag1, i, iblockdata1, false);
+ }
+
2023-12-06 16:17:00 +01:00
+ public static void calculateState(Level world, BlockPos pos, BlockState state, boolean beingRemoved, boolean flag1, int i, @Nullable BlockState iblockdata1, boolean tripWireBeingRemoved) {
+ // Paper end
2023-12-06 16:17:00 +01:00
Optional<Direction> optional = state.getOptionalValue(TripWireHookBlock.FACING);
2023-12-06 16:17:00 +01:00
if (optional.isPresent()) {
2023-12-06 20:10:59 +01:00
@@ -126,7 +132,7 @@ public class TripWireHookBlock extends Block {
boolean flag2 = (Boolean) state.getOptionalValue(TripWireHookBlock.ATTACHED).orElse(false);
boolean flag3 = (Boolean) state.getOptionalValue(TripWireHookBlock.POWERED).orElse(false);
Block block = state.getBlock();
- boolean flag4 = !flag;
+ boolean flag4 = !beingRemoved; // Paper
boolean flag5 = false;
int j = 0;
BlockState[] aiblockdata = new BlockState[42];
2023-12-06 16:17:00 +01:00
@@ -156,6 +162,7 @@ public class TripWireHookBlock extends Block {
boolean flag7 = (Boolean) iblockdata2.getValue(TripWireBlock.POWERED);
flag5 |= flag6 && flag7;
+ if (k != i || !tripWireBeingRemoved || !flag6) // Paper - don't update the tripwire again if being removed and not disarmed
aiblockdata[k] = iblockdata2;
if (k == i) {
world.scheduleTick(pos, block, 10);