From 012778ba2bce8074606a3f8e0b8ed37ea5cd1f12 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Sat, 16 Nov 2024 15:26:55 -0600 Subject: [PATCH] check the block below if occupied --- src/main/java/one/oth3r/sit/utl/Logic.java | 11 +++++++---- src/main/java/one/oth3r/sit/utl/Utl.java | 5 +---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/one/oth3r/sit/utl/Logic.java b/src/main/java/one/oth3r/sit/utl/Logic.java index 4c9ce83..6063a58 100644 --- a/src/main/java/one/oth3r/sit/utl/Logic.java +++ b/src/main/java/one/oth3r/sit/utl/Logic.java @@ -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); } /** diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index b55f46a..7be286e 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -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 {