Fix tripwire state inconsistency

This commit is contained in:
Nassim Jahnke 2021-12-19 22:39:15 +01:00
parent 8c5be16686
commit 6178609e1d
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
1 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,45 @@
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
diff --git a/src/main/java/net/minecraft/world/level/block/TripWireBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireBlock.java
index 6b40bf94fbaa18605b59b92ad1582e8dc3a6a9cd..335129abd06086d128f803bb488672b35f357389 100644
--- 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;
@@ -104,7 +110,11 @@ public class TripWireBlock extends Block {
if (iblockdata1.is((Block) this.hook)) {
if (iblockdata1.getValue(TripWireHookBlock.FACING) == enumdirection.getOpposite()) {
- this.hook.calculateState(world, blockposition1, iblockdata1, false, true, k, state);
+ // Paper - fix state inconsistency
+ final int distance = beingRemoved ? -1 : k;
+ final BlockState self = beingRemoved ? null : state;
+ this.hook.calculateState(world, blockposition1, iblockdata1, false, true, distance, self);
+ // Paper end
}
} else if (iblockdata1.is((Block) this)) {
++k;