Skip to content

Commit

Permalink
Entity line of sight update
Browse files Browse the repository at this point in the history
  • Loading branch information
sprytex authored Jan 8, 2025
1 parent 518db0b commit 0d181fe
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions patches/0108-Entity-line-of-sight-update.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Jan 9 00:00:00 2025
From: Michael <[email protected]>
Date: Wed, 9 Jan 2025 12:34:56 +0500
Subject: [PATCH] Update line of sight method to use Vec3D.a().

diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index abcdef1234567890abcdef1234567890abcdef12..fedcba0987654321fedcba9876543210fedcba98 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -150,7 +150,7 @@ public class EntityLiving extends Entity {
public boolean hasLineOfSight(Entity entity) {
- final Vec3D vec = new Vec3D(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ);
+ final Vec3D vec = Vec3D.a(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ);
final double entityHeadHeight = entity.getHeadHeight();

- return this.world.rayTrace(vec, new Vec3D(entity.locX, entity.locY + (double) this.getHeadHeight(), entity.locZ)) == null;
+ return this.world.rayTrace(vec, Vec3D.a(entity.locX, entity.locY + (double) this.getHeadHeight(), entity.locZ)) == null;
}
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index abcdef1234567890abcdef1234567890abcdef12..fedcba0987654321fedcba9876543210fedcba98 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -62,7 +62,7 @@ public class EntityPlayer extends EntityLiving {
@Override
public boolean hasLineOfSight(Entity entity) {
- final Vec3D vec = new Vec3D(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ);
+ final Vec3D vec = Vec3D.a(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ);
final double entityHeadHeight = entity.getHeadHeight();

for (int i = 1; i <= 3; i++) {
double targetY = entity.locY + (entityHeadHeight / 3) * i;
- if (this.world.rayTrace(vec, new Vec3D(entity.locX, targetY, entity.locZ)) == null) {
+ if (this.world.rayTrace(vec, Vec3D.a(entity.locX, targetY, entity.locZ)) == null) {
return true;
}
}
return false;
}

0 comments on commit 0d181fe

Please sign in to comment.