mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-19 16:03:22 +02:00
get the player's actual reach when checking sitting
This commit is contained in:
parent
62fd879d0d
commit
6c02b090ac
2 changed files with 12 additions and 1 deletions
|
@ -77,7 +77,8 @@ public class Logic {
|
|||
* @return true if sitting was successful
|
||||
*/
|
||||
public static boolean sitLooking(ServerPlayerEntity player) {
|
||||
return sit(player, Utl.getBlockPosPlayerIsLookingAt(player.getServerWorld(),player,5),null);
|
||||
return sit(player, Utl.getBlockPosPlayerIsLookingAt(player.getServerWorld(),player,
|
||||
Utl.getPlayerReach(player)),null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.block.*;
|
|||
import net.minecraft.block.enums.BlockHalf;
|
||||
import net.minecraft.block.enums.SlabType;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.attribute.EntityAttributes;
|
||||
import net.minecraft.entity.decoration.DisplayEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
|
@ -482,4 +483,13 @@ public class Utl {
|
|||
|
||||
return new BlockPos(player.getBlockPos());
|
||||
}
|
||||
|
||||
public static double getPlayerReach(PlayerEntity player) {
|
||||
// use the BLOCK_INTERACTION_RANGE attribute if available
|
||||
if (player.getAttributeInstance(EntityAttributes.BLOCK_INTERACTION_RANGE) != null) {
|
||||
return player.getAttributeValue(EntityAttributes.BLOCK_INTERACTION_RANGE);
|
||||
}
|
||||
// fallback to 5
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue