2021-06-11 12:02:28 +00:00
|
|
|
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/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java
|
2021-11-30 07:32:30 +00:00
|
|
|
index a60b8043540cacfa8cc3baba0872eefd4fc9464d..3bf658ad473ebfcb4f4ca6efff2ee068167b1a62 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/BlockGetter.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java
|
2021-06-13 08:26:58 +00:00
|
|
|
@@ -75,7 +75,15 @@ public interface BlockGetter extends LevelHeightAccessor {
|
2021-06-11 12:02:28 +00:00
|
|
|
|
|
|
|
// CraftBukkit start - moved block handling into separate method for use by Block#rayTrace
|
2021-11-24 00:20:31 +00:00
|
|
|
default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) {
|
2021-06-11 12:02:28 +00:00
|
|
|
- BlockState iblockdata = this.getBlockState(blockposition);
|
|
|
|
+ // Paper start - Prevent raytrace from loading chunks
|
|
|
|
+ BlockState iblockdata = this.getTypeIfLoaded(blockposition);
|
|
|
|
+ if (iblockdata == null) {
|
|
|
|
+ // copied the last function parameter (listed below)
|
|
|
|
+ Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo());
|
|
|
|
+
|
|
|
|
+ return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), new BlockPos(raytrace1.getTo()));
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
FluidState fluid = this.getFluidState(blockposition);
|
|
|
|
Vec3 vec3d = raytrace1.getFrom();
|
|
|
|
Vec3 vec3d1 = raytrace1.getTo();
|