diff --git a/src/main/java/io/github/togar2/pvp/entity/projectile/CustomEntityProjectile.java b/src/main/java/io/github/togar2/pvp/entity/projectile/CustomEntityProjectile.java index 4ffcf20..be8794b 100644 --- a/src/main/java/io/github/togar2/pvp/entity/projectile/CustomEntityProjectile.java +++ b/src/main/java/io/github/togar2/pvp/entity/projectile/CustomEntityProjectile.java @@ -14,6 +14,7 @@ import net.minestom.server.event.entity.projectile.ProjectileUncollideEvent; import net.minestom.server.instance.Chunk; import net.minestom.server.instance.block.Block; +import net.minestom.server.utils.chunk.ChunkCache; import net.minestom.server.utils.chunk.ChunkUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -212,8 +213,15 @@ protected void movementTick() { if (!isStuck()) { Vec diff = velocity.div(ServerFlag.SERVER_TICKS_PER_SECOND); + // Prevent entity infinitely in the void + if(instance.isInVoid(position)) { + scheduler().scheduleNextProcess(this::remove); + return; + } + ChunkCache blockGetter = new ChunkCache(instance, instance.getChunkAt(position), Block.AIR); + PhysicsResult physicsResult = ProjectileUtil.simulateMovement(position, diff, POINT_BOX, - instance.getWorldBorder(), instance, hasPhysics, previousPhysicsResult, true); + instance.getWorldBorder(), blockGetter, hasPhysics, previousPhysicsResult, true); this.previousPhysicsResult = physicsResult; Pos newPosition = physicsResult.newPosition();