From 042b089712a9b8b85d37dcc626a37ee4fc76910b Mon Sep 17 00:00:00 2001 From: Virt <41426325+VirtCode@users.noreply.github.com> Date: Fri, 4 Apr 2025 11:55:54 +0200 Subject: [PATCH] allow disabling of y limit (default disabled lol) --- src/main/java/one/oth3r/sit/file/ServerConfig.java | 14 +++++++++++++- src/main/java/one/oth3r/sit/utl/Logic.java | 8 +++++--- src/main/resources/fabric.mod.json | 6 +++--- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/main/java/one/oth3r/sit/file/ServerConfig.java b/src/main/java/one/oth3r/sit/file/ServerConfig.java index dd183c5..7f591ed 100644 --- a/src/main/java/one/oth3r/sit/file/ServerConfig.java +++ b/src/main/java/one/oth3r/sit/file/ServerConfig.java @@ -154,6 +154,8 @@ public class ServerConfig implements CustomFile { } public static class YDifferenceLimit { + @SerializedName("enabled") + private boolean enabled = false; @SerializedName("above") private Double above = 1.0; @SerializedName("below") @@ -162,14 +164,24 @@ public class ServerConfig implements CustomFile { public YDifferenceLimit() { } - public YDifferenceLimit(Double above, Double below) { + public YDifferenceLimit(Double above, Double below, boolean enabled) { this.above = above; this.below = below; + this.enabled = enabled; } public YDifferenceLimit(YDifferenceLimit yDifferenceLimit) { this.above = yDifferenceLimit.above; this.below = yDifferenceLimit.below; + this.enabled = yDifferenceLimit.enabled; + } + + public boolean isEnabled() { + return this.enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; } public Double getAbove() { diff --git a/src/main/java/one/oth3r/sit/utl/Logic.java b/src/main/java/one/oth3r/sit/utl/Logic.java index b5b9a21..eccafbd 100644 --- a/src/main/java/one/oth3r/sit/utl/Logic.java +++ b/src/main/java/one/oth3r/sit/utl/Logic.java @@ -106,6 +106,11 @@ public class Logic { * check if the Y-level of the block is within the limits of the player, bounds are set in the {@link ServerConfig} */ public static boolean checkYLimits(ServerPlayerEntity player, BlockPos blockPos) { + ServerConfig.YDifferenceLimit yDifferenceLimit = FileData.getServerConfig().getYDifferenceLimit(); + + // check if enabled + if (!yDifferenceLimit.isEnabled()) return true; + double playerY = player.getBlockY(); double blockY = blockPos.getY(); // if the block is above the eye height @@ -116,9 +121,6 @@ public class Logic { // get the height difference (positive) double heightDifference = Math.abs(playerY - blockY); - // get the config limits - ServerConfig.YDifferenceLimit yDifferenceLimit = FileData.getServerConfig().getYDifferenceLimit(); - return (isAbove? yDifferenceLimit.getAbove() : yDifferenceLimit.getBelow()) >= heightDifference; } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 5c58928..75342bd 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -9,8 +9,8 @@ "Virt" ], "contact": { - "homepage": "https://modrinth.com/mod/sit!", - "sources": "https://github.com/Oth3r/Sit" + "homepage": "https://copeberg.org/virt/Sit", + "sources": "https://copeberg.org/virt/Sit" }, "license": "LGPL-3.0-only", "icon": "assets/sit-oth3r/icon.png", @@ -38,4 +38,4 @@ "mixins": [ "sit!.mixins.json" ] -} \ No newline at end of file +}