check for other players when sitting

This commit is contained in:
Oth3r 2024-11-15 12:47:21 -06:00
commit f361a84d03
2 changed files with 13 additions and 1 deletions

View file

@ -134,7 +134,9 @@ public class Logic {
if (pos.getY() > entity.getY() - .80) pos2 = pos2.add(0,-1,0); if (pos.getY() > entity.getY() - .80) pos2 = pos2.add(0,-1,0);
// check if both poses are obstructed or not // check if both poses are obstructed or not
return Utl.isNotObstructed(entity.getWorld(),pos1) && Utl.isNotObstructed(entity.getWorld(),pos2); return Utl.isNotObstructed(entity.getWorld(),pos1) && Utl.isNotObstructed(entity.getWorld(),pos2)
// also check if occupied
&& Utl.isNotOccupied(pos1) && Utl.isNotOccupied(pos2);
} }
/** /**

View file

@ -54,6 +54,16 @@ public class Utl {
return state.getCollisionShape(world,blockPos).isEmpty(); return state.getCollisionShape(world,blockPos).isEmpty();
} }
/**
* checks the list of sit entities and sees if any of them are occupying the block pos
*/
public static boolean isNotOccupied(BlockPos pos) {
for (DisplayEntity.TextDisplayEntity entity : Data.getSitEntities().values()) {
if (entity.getBlockPos().equals(pos)) return false;
}
return true;
}
public static class Num { public static class Num {
public static boolean isInt(String string) { public static boolean isInt(String string) {