forked from virt-mirrors/Sit
allow disabling of y limit (default disabled lol)
This commit is contained in:
parent
2f18f285ca
commit
042b089712
3 changed files with 21 additions and 7 deletions
|
@ -154,6 +154,8 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
|||
}
|
||||
|
||||
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<ServerConfig> {
|
|||
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() {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue