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 {
|
||||
@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() {
|
||||
}
|
||||
|
|
|
@ -82,18 +82,19 @@ 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue