use player y instead of player eye y

This commit is contained in:
Oth3r 2025-02-13 15:59:46 -06:00
commit e76629af32
2 changed files with 10 additions and 9 deletions

View file

@ -155,9 +155,9 @@ public class ServerConfig implements CustomFile<ServerConfig> {
public static class YDifferenceLimit {
@SerializedName("above")
private Double above = 0.1;
private Double above = 1.0;
@SerializedName("below")
private Double below = 3.0;
private Double below = 1.0;
public YDifferenceLimit() {
}

View file

@ -82,19 +82,20 @@ 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) {
double playerEyeY = player.getEyeY();
double playerY = player.getBlockY();
double blockY = blockPos.getY();
// if the block is above the eye height
boolean isAbove = playerEyeY < blockY;
boolean isAbove = playerY < blockY;
// return true if equal
if (playerY == blockY) return true;
// get the height difference (positive)
double heightDifference = Math.abs(playerEyeY - blockY);
double heightDifference = Math.abs(playerY - blockY);
// get the config limits
ServerConfig.YDifferenceLimit yDifferenceLimit = FileData.getServerConfig().getYDifferenceLimit();
// debug
Data.LOGGER.info("{} {} can sit? {}", heightDifference, isAbove ? "Above" : "Below", (isAbove? yDifferenceLimit.getAbove(): yDifferenceLimit.getBelow()) >= heightDifference);
return (isAbove? yDifferenceLimit.getAbove(): yDifferenceLimit.getBelow()) >= heightDifference;
return (isAbove? yDifferenceLimit.getAbove() : yDifferenceLimit.getBelow()) >= heightDifference;
}
/**