forked from virt-mirrors/Sit
check the block below if occupied
This commit is contained in:
parent
8012f81e46
commit
012778ba2b
2 changed files with 8 additions and 8 deletions
|
@ -129,14 +129,17 @@ public class Logic {
|
|||
// get the entity's block pos
|
||||
BlockPos pos = Utl.Entity.getBlockPos(entity);
|
||||
// get the poses to check above the block
|
||||
BlockPos pos1 = new BlockPos(pos).add(0,1,0), pos2 = new BlockPos(pos).add(0,2,0);
|
||||
BlockPos pos1 = new BlockPos(pos).add(0,1,0), pos2 = new BlockPos(pos).add(0,2,0), posBelow = new BlockPos(pos);
|
||||
// doesn't check 2 blocks above if not sitting above .80 of the block
|
||||
if (pos.getY() > entity.getY() - .80) pos2 = pos2.add(0,-1,0);
|
||||
if (pos.getY() > entity.getY() - .80) {
|
||||
pos2 = pos2.add(0,-1,0);
|
||||
posBelow = posBelow.add(0,-1,0);
|
||||
}
|
||||
|
||||
// check if both poses are obstructed or not
|
||||
return Utl.isNotObstructed(entity.getWorld(),pos1) && Utl.isNotObstructed(entity.getWorld(),pos2)
|
||||
// also check if occupied
|
||||
&& Utl.isNotOccupied(pos1) && Utl.isNotOccupied(pos2);
|
||||
// also check if occupied, checking below to make sure you cant sit directly on top of another sit entity
|
||||
&& Utl.isNotOccupied(pos) && Utl.isNotOccupied(pos1) && Utl.isNotOccupied(pos2) && Utl.isNotOccupied(posBelow);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,10 +58,7 @@ public class Utl {
|
|||
* 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;
|
||||
return Data.getSitEntities().values().stream().noneMatch(entity -> entity.getBlockPos().equals(pos));
|
||||
}
|
||||
|
||||
public static class Num {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue