3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 04:20:08 +01:00
Paper/Spigot-Server-Patches/0351-Prevent-rayTrace-from-loading-chunks.patch

33 Zeilen
1.5 KiB
Diff

2019-05-06 04:58:04 +02:00
From 665d6fa6419fbe4df9cd3ff13a3eff4ea5ab815e Mon Sep 17 00:00:00 2001
2019-05-05 19:19:34 +02:00
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 809ca0983a..c44edda65a 100644
2019-05-05 19:19:34 +02:00
--- 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();
--
2.21.0