From 2e645f04e735f1af394fe82a6d67376f6e3a7046 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Fri, 10 Sep 2021 09:27:11 -0400 Subject: [PATCH] Fix entities stuck in the ground closes #607 --- build.gradle | 2 +- .../volmit/iris/engine/object/IrisEntity.java | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 1ab17285d..b115bbcce 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ plugins { } group 'com.volmit.iris' -version '1.8.7' +version '1.8.8' def apiVersion = '1.17' def name = getRootProject().getName() // Defined in settings.gradle def main = 'com.volmit.iris.Iris' diff --git a/src/main/java/com/volmit/iris/engine/object/IrisEntity.java b/src/main/java/com/volmit/iris/engine/object/IrisEntity.java index 497e0e19d..bc40d2e98 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisEntity.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisEntity.java @@ -63,6 +63,7 @@ import org.bukkit.util.Vector; import java.util.Collection; import java.util.Random; +import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; @@ -183,12 +184,23 @@ public class IrisEntity extends IrisRegistrant { if (!Chunks.isSafe(at)) { return null; } - if (isSpawnEffectRiseOutOfGround()) { - Location b = at.clone(); - double sy = b.getY() - 5; - Location start = new Location(b.getWorld(), b.getX(), sy, b.getZ()); - at = start; + AtomicReference f = new AtomicReference<>(at); + try { + J.sfut(() -> { + if(Chunks.hasPlayersNearby(f.get())) + { + Location b = f.get().clone(); + Location start = new Location(b.getWorld(), b.getX(), b.getY() - 5, b.getZ()); + f.set(start); + } + }).get(); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } + at = f.get(); } Entity ee = doSpawn(at); @@ -347,6 +359,7 @@ public class IrisEntity extends IrisRegistrant { } Location finalAt1 = at; + J.s(() -> { if (isSpawnEffectRiseOutOfGround() && e instanceof LivingEntity && Chunks.hasPlayersNearby(finalAt1)) { Location start = finalAt1.clone(); @@ -381,6 +394,7 @@ public class IrisEntity extends IrisRegistrant { } }); + return e; }