From f249fd2973ff2c6be2c74983a8b1c849709b6843 Mon Sep 17 00:00:00 2001 From: Under Date: Wed, 20 Dec 2023 13:06:38 -0600 Subject: [PATCH] Add Config to allow servers to re-enable support for client-side 'hacks' like Staff Of Traveling Keybind mod. (#142) * Update Config.java Adding config to allow not validating travel staff packets. * Update TravelController.java Disable validation if server config deems it so. * spotlessApply fix * Wrong ordering and spotlessApply --- src/main/java/crazypants/enderio/config/Config.java | 8 ++++++++ .../crazypants/enderio/teleport/TravelController.java | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/crazypants/enderio/config/Config.java b/src/main/java/crazypants/enderio/config/Config.java index 3980e855..783eb227 100644 --- a/src/main/java/crazypants/enderio/config/Config.java +++ b/src/main/java/crazypants/enderio/config/Config.java @@ -161,6 +161,7 @@ public final class Config { public static String[] travelStaffBlinkBlackList = new String[] { "minecraft:bedrock", "Thaumcraft:blockWarded" }; public static float travelAnchorZoomScale = 0.2f; public static boolean travelStaffSearchOptimize = true; + public static boolean validateTravelEventServerside = true; /** The max distance for travelling to a Travel Anchor. */ public static int teleportStaffMaxDistance = 2048; @@ -1214,6 +1215,13 @@ public final class Config { + "This config is experimental, so if you encounter any strange behavior, please report to GTNH developer.") .getBoolean(travelStaffSearchOptimize); + validateTravelEventServerside = config.get( + sectionStaff.name, + "validateTravelEventServerside", + validateTravelEventServerside, + "If set to true: Server will validate if player actually can teleport. False will allow hacking, but also allows Staff of Traveling Keybind mod to work.") + .getBoolean(validateTravelEventServerside); + teleportStaffMaxDistance = config .get( sectionStaff.name, diff --git a/src/main/java/crazypants/enderio/teleport/TravelController.java b/src/main/java/crazypants/enderio/teleport/TravelController.java index c4774ea8..b2426e45 100644 --- a/src/main/java/crazypants/enderio/teleport/TravelController.java +++ b/src/main/java/crazypants/enderio/teleport/TravelController.java @@ -124,6 +124,10 @@ public class TravelController { */ public String validatePacketTravelEvent(EntityPlayerMP toTp, int x, int y, int z, int powerUse, boolean conserveMotion, TravelSource source) { + + // If config indicates to allow for 'hacking' the travel packet, then don't do any validation. + if (!Config.validateTravelEventServerside) return null; + BlockCoord target = new BlockCoord(x, y, z); double dist = getDistanceSquared(toTp, target); // allow 15% overshoot to account for rounding