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
This commit is contained in:
Under authored and GitHub committed 2023-12-20 20:06:38 +01:00
1 parent 9f3f8243f9
commit f249fd2973
2 files changed
+12

No files matched your search

@@ -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,
@@ -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