From 516d8e573e6319d942a2758c30f9c1aa8d5e0965 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Sat, 15 Jan 2022 16:28:52 -0500 Subject: [PATCH] Config option to disable Bedrock scaffolding/godbridging --- .../configuration/GeyserConfiguration.java | 2 ++ .../GeyserJacksonConfiguration.java | 3 +++ .../BedrockInventoryTransactionTranslator.java | 18 +++++++++++++++++- core/src/main/resources/config.yml | 3 +++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/geysermc/geyser/configuration/GeyserConfiguration.java b/core/src/main/java/org/geysermc/geyser/configuration/GeyserConfiguration.java index 3fc7971b0..06d6bdbc5 100644 --- a/core/src/main/java/org/geysermc/geyser/configuration/GeyserConfiguration.java +++ b/core/src/main/java/org/geysermc/geyser/configuration/GeyserConfiguration.java @@ -76,6 +76,8 @@ public interface GeyserConfiguration { boolean isShowCoordinates(); + boolean isDisableBedrockScaffolding(); + EmoteOffhandWorkaroundOption getEmoteOffhandWorkaround(); String getDefaultLocale(); diff --git a/core/src/main/java/org/geysermc/geyser/configuration/GeyserJacksonConfiguration.java b/core/src/main/java/org/geysermc/geyser/configuration/GeyserJacksonConfiguration.java index 55721f894..825edf43e 100644 --- a/core/src/main/java/org/geysermc/geyser/configuration/GeyserJacksonConfiguration.java +++ b/core/src/main/java/org/geysermc/geyser/configuration/GeyserJacksonConfiguration.java @@ -105,6 +105,9 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration @JsonProperty("show-coordinates") private boolean showCoordinates = true; + @JsonProperty("disable-bedrock-scaffolding") + private boolean disableBedrockScaffolding = false; + @JsonDeserialize(using = EmoteOffhandWorkaroundOption.Deserializer.class) @JsonProperty("emote-offhand-workaround") private EmoteOffhandWorkaroundOption emoteOffhandWorkaround = EmoteOffhandWorkaroundOption.DISABLED; 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 c730b12ad..29308f9ec 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 @@ -109,6 +109,23 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator { + Vector3i blockPos = BlockUtils.getBlockPosition(packet.getBlockPosition(), packet.getBlockFace()); + + if (session.getGeyser().getConfig().isDisableBedrockScaffolding()) { + float yaw = session.getPlayerEntity().getYaw(); + boolean isGodBridging = switch (packet.getBlockFace()) { + case 2 -> yaw <= -135f || yaw > 135f; + case 3 -> yaw <= 45f && yaw > -45f; + case 4 -> yaw > 45f && yaw <= 135f; + case 5 -> yaw <= -45f && yaw > -135f; + default -> false; + }; + if (isGodBridging) { + 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 && @@ -138,7 +155,6 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator