Paper/Spigot-Server-Patches/0334-Prevent-rayTrace-from-loading-chunks.patch
Aikar e4d10a6d67
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
122289ff Add FaceAttachable interface to handle Grindstone facing in common with Switches
a6db750e SPIGOT-5647: ZombieVillager entity should have getVillagerType()

CraftBukkit Changes:
bbe3d58e SPIGOT-5650: Lectern.setPage(int) causes a NullPointerException
3075579f Add FaceAttachable interface to handle Grindstone facing in common with Switches
95bd4238 SPIGOT-5647: ZombieVillager entity should have getVillagerType()
4d975ac3 SPIGOT-5617: setBlockData does not work when NotPlayEvent is called by redstone current
2020-04-02 17:09:17 -04:00

33 lines
1.5 KiB
Diff

From 0b18f2ae0645cbe0db754c2d68e86cac35d6c836 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 0dff023529..29cdc00875 100644
--- a/src/main/java/net/minecraft/server/IBlockAccess.java
+++ b/src/main/java/net/minecraft/server/IBlockAccess.java
@@ -41,7 +41,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();
--
2.25.1