|
1 | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2 | 2 |
|
3 |
| -Date: Tue, 4 Feb 2025 14:24:54 +0500 |
| 3 | +Date: Tue, 11 Feb 2025 10:41:32 +0500 |
4 | 4 | Subject: [PATCH] Fix entities going out of sight
|
5 | 5 |
|
6 | 6 |
|
7 | 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 |
| 8 | +index 32752dfad24bc7883b1ab52e29834f1aa6fa60c6..38f52e1652d269fb35877f700e7d26422ec69dd0 100644 |
9 | 9 | --- a/src/main/java/net/minecraft/server/EntityLiving.java
|
10 | 10 | +++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
11 |
| -@@ -1798,7 +1798,34 @@ public abstract class EntityLiving extends Entity { |
| 11 | +@@ -1798,7 +1798,10 @@ public abstract class EntityLiving extends Entity { |
12 | 12 | }
|
13 | 13 |
|
14 | 14 | public boolean hasLineOfSight(Entity entity) {
|
15 | 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 |
| -+ } |
| 16 | ++ // PandaSpigot start |
| 17 | ++ final Vec3D vec = new Vec3D(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ); |
| 18 | ++ return this.world.rayTrace(vec, new Vec3D(entity.locX, entity.locY + (double) this.getHeadHeight(), entity.locZ)) == null; |
43 | 19 | + // PandaSpigot end
|
44 | 20 | }
|
45 | 21 |
|
46 | 22 | public Vec3D ap() {
|
| 23 | +diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java |
| 24 | +index b4f301a3eb660b9bf080c4f6b4e3bbaa3678a8d6..bcad57da69089f07e161df85ebe6b590c869a03c 100644 |
| 25 | +--- a/src/main/java/net/minecraft/server/EntityPlayer.java |
| 26 | ++++ b/src/main/java/net/minecraft/server/EntityPlayer.java |
| 27 | +@@ -296,6 +296,22 @@ public class EntityPlayer extends EntityHuman implements ICrafting { |
| 28 | + |
| 29 | + } |
| 30 | + |
| 31 | ++ // PandaSpigot start - Fix players going out of sight |
| 32 | ++ @Override |
| 33 | ++ public boolean hasLineOfSight(Entity entity) { |
| 34 | ++ final Vec3D vec = new Vec3D(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ); |
| 35 | ++ final double entityHeadHeight = entity.getHeadHeight(); |
| 36 | ++ |
| 37 | ++ for (int i = 1; i <= 3; i++) { |
| 38 | ++ double targetY = entity.locY + (entityHeadHeight / 3) * i; |
| 39 | ++ if (this.world.rayTrace(vec, new Vec3D(entity.locX, targetY, entity.locZ)) == null) { |
| 40 | ++ return true; |
| 41 | ++ } |
| 42 | ++ } |
| 43 | ++ return false; |
| 44 | ++ } |
| 45 | ++ // PandaSpigot end |
| 46 | ++ |
| 47 | + public void l() { |
| 48 | + try { |
| 49 | + super.t_(); |
0 commit comments