From 50d294d2c40846fbbfb0dd3eb1e2e2dbdd8c4744 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 26 Nov 2018 19:21:58 -0500 Subject: [PATCH] Prevent rayTrace from loading chunks ray tracing into an unloaded chunk should be treated as a miss this saves a ton of lag for when AI tries to raytrace near unloaded chunks. diff --git a/src/main/java/net/minecraft/server/IBlockAccess.java b/src/main/java/net/minecraft/server/IBlockAccess.java index 8753bea614..039f27312a 100644 --- a/src/main/java/net/minecraft/server/IBlockAccess.java +++ b/src/main/java/net/minecraft/server/IBlockAccess.java @@ -27,7 +27,15 @@ public interface IBlockAccess { default MovingObjectPositionBlock rayTrace(RayTrace raytrace) { return (MovingObjectPositionBlock) a(raytrace, (raytrace1, blockposition) -> { - IBlockData iblockdata = this.getType(blockposition); + // Paper start - Prevent raytrace from loading chunks + IBlockData iblockdata = ((World)this).getTypeIfLoaded(blockposition); + if (iblockdata == null) { + // copied the last function parameter (listed below) + Vec3D vec3d = raytrace1.b().d(raytrace1.a()); + + return MovingObjectPositionBlock.a(raytrace1.a(), EnumDirection.a(vec3d.x, vec3d.y, vec3d.z), new BlockPosition(raytrace1.a())); + } + // Paper end Fluid fluid = this.getFluid(blockposition); Vec3D vec3d = raytrace1.b(); Vec3D vec3d1 = raytrace1.a(); @@ -96,7 +104,7 @@ public interface IBlockAccess { double d13 = d10 * (i1 > 0 ? 1.0D - MathHelper.h(d4) : MathHelper.h(d4)); double d14 = d11 * (j1 > 0 ? 1.0D - MathHelper.h(d5) : MathHelper.h(d5)); - Object object; + T object; // Paper - decompile fix (TODO move to mcdev) do { if (d12 > 1.0D && d13 > 1.0D && d14 > 1.0D) { -- 2.21.0