From 41d7d8e3a39897e5b519f6c393ef2e1557a5e303 Mon Sep 17 00:00:00 2001 From: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> Date: Sat, 13 May 2023 20:22:06 -0700 Subject: [PATCH] Prevent 2x placement due to extended collision box Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> --- ...BedrockInventoryTransactionTranslator.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockInventoryTransactionTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockInventoryTransactionTranslator.java index 645c76100..269d1713d 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockInventoryTransactionTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockInventoryTransactionTranslator.java @@ -173,6 +173,27 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator belowBlockPos = blockPos.add(0, -2, 0); + case 2 -> belowBlockPos = blockPos.add(0, -1, 1); + case 3 -> belowBlockPos = blockPos.add(0, -1, -1); + case 4 -> belowBlockPos = blockPos.add(1, -1, 0); + case 5 -> belowBlockPos = blockPos.add(-1, -1, 0); + } + + if (belowBlockPos != null) { + int belowBlock = session.getGeyser().getWorldManager().getBlockAt(session, belowBlockPos); + BlockDefinition extendedCollisionDefinition = session.getBlockMappings().getExtendedCollisionBoxes().get(belowBlock); + if (extendedCollisionDefinition != null && (System.currentTimeMillis() - session.getLastInteractionTime()) < 200) { + restoreCorrectBlock(session, blockPos, packet); + return; + } + } + } + // Check to make sure the client isn't spamming interaction // Based on Nukkit 1.0, with changes to ensure holding down still works boolean hasAlreadyClicked = System.currentTimeMillis() - session.getLastInteractionTime() < 110.0 && @@ -257,6 +278,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator