Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/patches/server/0283-Prevent-rayTrace-from-loading-chunks.patch

30 Zeilen
1.7 KiB
Diff

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