Paper/Spigot-Server-Patches/0321-Prevent-rayTrace-from-loading-chunks.patch
MiniDigger c3640b1dc0
[1.16] Make it run (#3626)
* She compiles!

Also readded the armorstand ticking patch, thanks cat

* Update mob goal api

* Misc fixes to make it run

drop per playing mob spawns for now
2020-06-26 05:04:38 -07:00

30 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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 077fcb67f6248156aaebe7545e370ade4311b9e4..a59df0e48a9bcbb32c51ec0013f634d474f68e52 100644
--- a/src/main/java/net/minecraft/server/IBlockAccess.java
+++ b/src/main/java/net/minecraft/server/IBlockAccess.java
@@ -46,7 +46,15 @@ public interface IBlockAccess {
// CraftBukkit start - moved block handling into separate method for use by Block#rayTrace
default MovingObjectPositionBlock rayTraceBlock(RayTrace raytrace1, BlockPosition blockposition) {
- IBlockData iblockdata = this.getType(blockposition);
+ // Paper start - Prevent raytrace from loading chunks
+ IBlockData iblockdata = 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();