Skip to content

Commit f12f4d6

Browse files
committed
Merge branch 'master' of https://github.com/ptbnate/PandaSpigot
2 parents 714dcac + c5d3cca commit f12f4d6

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: ptbnate <[email protected]>
3+
Date: Tue, 4 Feb 2025 14:24:54 +0500
4+
Subject: [PATCH] Fix entities going out of sight
5+
6+
7+
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
8+
index 32752dfad24bc7883b1ab52e29834f1aa6fa60c6..8dc930dc17aa235e0147b2a5a3043b049d3e404b 100644
9+
--- a/src/main/java/net/minecraft/server/EntityLiving.java
10+
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
11+
@@ -1798,7 +1798,34 @@ public abstract class EntityLiving extends Entity {
12+
}
13+
14+
public boolean hasLineOfSight(Entity entity) {
15+
- return this.world.rayTrace(new Vec3D(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ), new Vec3D(entity.locX, entity.locY + (double) entity.getHeadHeight(), entity.locZ)) == null;
16+
+ // PandaSpigot start - Fix issue with entities going out of sight
17+
+ Vec3D vec = new Vec3D(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ);
18+
+
19+
+ if (entity instanceof EntityPlayer) {
20+
+ // Head height is 1,5725
21+
+ // Split it into three to get a more accurate line of sight -> 0.52416667
22+
+
23+
+ double parts = entity.getHeadHeight() / 3;
24+
+
25+
+ Vec3D vec3 = new Vec3D(entity.locX, entity.locY, entity.locZ);
26+
+
27+
+ return this.world.rayTrace(
28+
+ vec,
29+
+ vec3.add(0.0D, (parts * 3), 0.0D)
30+
+ ) == null || this.world.rayTrace(
31+
+ vec,
32+
+ vec3.add(0.0D, (parts * 2), 0.0D)
33+
+ ) == null || this.world.rayTrace(
34+
+ vec,
35+
+ vec3.add(0.0D, (parts * 1), 0.0D)
36+
+ ) == null;
37+
+ } else {
38+
+ return this.world.rayTrace(
39+
+ vec,
40+
+ new Vec3D(entity.locX, entity.locY + (double) this.getHeadHeight(), entity.locZ)
41+
+ ) == null;
42+
+ }
43+
+ // PandaSpigot end
44+
}
45+
46+
public Vec3D ap() {

0 commit comments

Comments
 (0)