2021-12-19 22:39:15 +01:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Nassim Jahnke <jahnke.nassim@gmail.com>
|
|
|
|
Date: Sun, 19 Dec 2021 21:11:20 +0100
|
|
|
|
Subject: [PATCH] Fix tripwire state inconsistency
|
|
|
|
|
2022-01-02 21:33:53 +01:00
|
|
|
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
|
2022-01-02 21:33:53 +01:00
|
|
|
index 6b40bf94fbaa18605b59b92ad1582e8dc3a6a9cd..7d89b9ed84209c161b2c6fec5304abbbf41f2e80 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
|
|
|
|
@@ -74,7 +74,7 @@ public class TripWireBlock extends Block {
|
|
|
|
@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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -89,6 +89,12 @@ public class TripWireBlock extends Block {
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2022-01-02 21:33:53 +01:00
|
|
|
@@ -104,7 +110,7 @@ public class TripWireBlock extends Block {
|
2021-12-19 22:39:15 +01:00
|
|
|
|
|
|
|
if (iblockdata1.is((Block) this.hook)) {
|
|
|
|
if (iblockdata1.getValue(TripWireHookBlock.FACING) == enumdirection.getOpposite()) {
|
|
|
|
- this.hook.calculateState(world, blockposition1, iblockdata1, false, true, k, state);
|
2022-01-02 21:33:53 +01:00
|
|
|
+ this.hook.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;
|
2022-01-02 21:33:53 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
2022-01-03 10:23:56 +01:00
|
|
|
index 02a3e1ced592784b9c66927c76376c7ab413367d..a4344bf2267112e3c1e31c07c9f6b8eae9666947 100644
|
2022-01-02 21:33:53 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
|
|
|
@@ -107,6 +107,12 @@ public class TripWireHookBlock extends Block {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void calculateState(Level world, BlockPos pos, BlockState state, boolean beingRemoved, boolean flag1, int i, @Nullable BlockState iblockdata1) {
|
|
|
|
+ // Paper start - fix tripwire inconsistency
|
|
|
|
+ this.calculateState(world, pos, state, beingRemoved, flag1, i, iblockdata1, false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void calculateState(Level world, BlockPos pos, BlockState state, boolean beingRemoved, boolean flag1, int i, @Nullable BlockState iblockdata1, boolean tripWireBeingRemoved) {
|
|
|
|
+ // Paper end
|
|
|
|
Direction enumdirection = (Direction) state.getValue(TripWireHookBlock.FACING);
|
|
|
|
boolean flag2 = (Boolean) state.getValue(TripWireHookBlock.ATTACHED);
|
|
|
|
boolean flag3 = (Boolean) state.getValue(TripWireHookBlock.POWERED);
|
|
|
|
@@ -140,6 +146,7 @@ public class TripWireHookBlock extends Block {
|
|
|
|
boolean flag7 = (Boolean) iblockdata2.getValue(TripWireBlock.POWERED);
|
|
|
|
|
|
|
|
flag5 |= flag6 && flag7;
|
2022-01-03 10:23:56 +01:00
|
|
|
+ if (k != i || !tripWireBeingRemoved || !flag6) // Paper - don't update the tripwire again if being removed and not disarmed
|
2022-01-02 21:33:53 +01:00
|
|
|
aiblockdata[k] = iblockdata2;
|
|
|
|
if (k == i) {
|
|
|
|
world.scheduleTick(pos, (Block) this, 10);
|