mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-19 16:03:22 +02:00
use player y instead of player eye y
This commit is contained in:
parent
e8ac5722ea
commit
e76629af32
2 changed files with 10 additions and 9 deletions
|
@ -155,9 +155,9 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
|
|
||||||
public static class YDifferenceLimit {
|
public static class YDifferenceLimit {
|
||||||
@SerializedName("above")
|
@SerializedName("above")
|
||||||
private Double above = 0.1;
|
private Double above = 1.0;
|
||||||
@SerializedName("below")
|
@SerializedName("below")
|
||||||
private Double below = 3.0;
|
private Double below = 1.0;
|
||||||
|
|
||||||
public YDifferenceLimit() {
|
public YDifferenceLimit() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -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}
|
* 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) {
|
public static boolean checkYLimits(ServerPlayerEntity player, BlockPos blockPos) {
|
||||||
double playerEyeY = player.getEyeY();
|
double playerY = player.getBlockY();
|
||||||
double blockY = blockPos.getY();
|
double blockY = blockPos.getY();
|
||||||
// if the block is above the eye height
|
// 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)
|
// get the height difference (positive)
|
||||||
double heightDifference = Math.abs(playerEyeY - blockY);
|
double heightDifference = Math.abs(playerY - blockY);
|
||||||
// get the config limits
|
// get the config limits
|
||||||
ServerConfig.YDifferenceLimit yDifferenceLimit = FileData.getServerConfig().getYDifferenceLimit();
|
ServerConfig.YDifferenceLimit yDifferenceLimit = FileData.getServerConfig().getYDifferenceLimit();
|
||||||
|
|
||||||
// debug
|
return (isAbove? yDifferenceLimit.getAbove() : yDifferenceLimit.getBelow()) >= heightDifference;
|
||||||
Data.LOGGER.info("{} {} can sit? {}", heightDifference, isAbove ? "Above" : "Below", (isAbove? yDifferenceLimit.getAbove(): yDifferenceLimit.getBelow()) >= heightDifference);
|
|
||||||
|
|
||||||
return (isAbove? yDifferenceLimit.getAbove(): yDifferenceLimit.getBelow()) >= heightDifference;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue