Improve block break/place detection in 1.8->1.9 (#3886)

Servers can send sound packets where the positions have a slight offset. This PR aims to improve the detection to account for that.

Closes https://github.com/ViaVersion/ViaFabricPlus/issues/333
This commit is contained in:
EnZaXD 2024-05-28 08:43:21 +02:00 committed by GitHub
parent 3f7d286606
commit d9446eed07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -143,8 +143,13 @@ public class EntityTracker1_9 extends EntityTrackerBase {
}
}
public boolean interactedBlockRecently(int x, int y, int z) {
return blockInteractions.contains(new BlockPosition(x, y, z));
public boolean interactedBlockRecently(final int x, final int y, final int z) {
for (final BlockPosition position : blockInteractions) {
if (Math.abs(position.x() - x) <= 1 && Math.abs(position.y() - y) <= 1 && Math.abs(position.z() - z) <= 1) {
return true;
}
}
return false;
}
public void addBlockInteraction(BlockPosition p) {