mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-27 19:09:22 +00:00
@@ -235,6 +235,30 @@ index 7caf9ea3792089dcf890c2af0ac17ee1d5c85c16..3882bc7a8d1684b91876eb7c67999490
|
||||
|
||||
this.navigation.tick();
|
||||
this.customServerAiStep((ServerLevel)this.level());
|
||||
diff --git a/net/minecraft/world/entity/ai/control/LookControl.java b/net/minecraft/world/entity/ai/control/LookControl.java
|
||||
index 95c43931fb0f11136ab73df3c8716aac42d8f1d4..a0d729f18164f1863a5735a9322d3f3df9ab0c95 100644
|
||||
--- a/net/minecraft/world/entity/ai/control/LookControl.java
|
||||
+++ b/net/minecraft/world/entity/ai/control/LookControl.java
|
||||
@@ -35,6 +35,19 @@ public class LookControl implements Control {
|
||||
this.setLookAt(x, y, z, this.mob.getHeadRotSpeed(), this.mob.getMaxHeadXRot());
|
||||
}
|
||||
|
||||
+ // Leaf start - Async target finding
|
||||
+ public void setLookAtWithCooldown(double x, double y, double z, int lookAtCooldown) {
|
||||
+ float deltaYaw = this.mob.getHeadRotSpeed();
|
||||
+ float deltaPitch = this.mob.getMaxHeadXRot();
|
||||
+ this.wantedX = x;
|
||||
+ this.wantedY = y;
|
||||
+ this.wantedZ = z;
|
||||
+ this.yMaxRotSpeed = deltaYaw;
|
||||
+ this.xMaxRotAngle = deltaPitch;
|
||||
+ this.lookAtCooldown = lookAtCooldown;
|
||||
+ }
|
||||
+ // Leaf end - Async target finding
|
||||
+
|
||||
public void setLookAt(double x, double y, double z, float deltaYaw, float deltaPitch) {
|
||||
this.wantedX = x;
|
||||
this.wantedY = y;
|
||||
diff --git a/net/minecraft/world/entity/ai/goal/AvoidEntityGoal.java b/net/minecraft/world/entity/ai/goal/AvoidEntityGoal.java
|
||||
index 7651676e72fcec52d7c1f9f7d7b6f9e585015c4d..7b1f8e58f6b1fc34204b77cf3c902759aceb3350 100644
|
||||
--- a/net/minecraft/world/entity/ai/goal/AvoidEntityGoal.java
|
||||
@@ -908,7 +932,7 @@ index be59d0c27a83b329ec3f97c029cfb9c114e22472..28e4c81ba8411147fe326bcf331d9ac1
|
||||
if (llama == null) {
|
||||
return false;
|
||||
diff --git a/net/minecraft/world/entity/ai/goal/LookAtPlayerGoal.java b/net/minecraft/world/entity/ai/goal/LookAtPlayerGoal.java
|
||||
index 6463c3c9b08d6058f2843c225b08a40fc30a960b..1b9729d3ecf7ab5b364cab26f940ac77da880014 100644
|
||||
index 6463c3c9b08d6058f2843c225b08a40fc30a960b..44ba360fa0450aaa1783f1ac2f2b35c37bf55677 100644
|
||||
--- a/net/minecraft/world/entity/ai/goal/LookAtPlayerGoal.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/LookAtPlayerGoal.java
|
||||
@@ -48,32 +48,78 @@ public class LookAtPlayerGoal extends Goal {
|
||||
@@ -947,10 +971,7 @@ index 6463c3c9b08d6058f2843c225b08a40fc30a960b..1b9729d3ecf7ab5b364cab26f940ac77
|
||||
+ this.mob.getZ()
|
||||
+ );
|
||||
+ }
|
||||
|
||||
- ServerLevel serverLevel = getServerLevel(this.mob);
|
||||
- if (this.lookAtType == Player.class) {
|
||||
- this.lookAt = serverLevel.getNearestPlayer(this.lookAtContext, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ());
|
||||
+
|
||||
+ return this.lookAt != null;
|
||||
+ }
|
||||
+
|
||||
@@ -965,7 +986,10 @@ index 6463c3c9b08d6058f2843c225b08a40fc30a960b..1b9729d3ecf7ab5b364cab26f940ac77
|
||||
+ this.lookAt = target;
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
|
||||
- ServerLevel serverLevel = getServerLevel(this.mob);
|
||||
- if (this.lookAtType == Player.class) {
|
||||
- this.lookAt = serverLevel.getNearestPlayer(this.lookAtContext, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ());
|
||||
+ protected void getLookAsync() {
|
||||
+ final var mob = this.mob;
|
||||
+ final var ctx = mob.getGoalCtx();
|
||||
@@ -1008,6 +1032,21 @@ index 6463c3c9b08d6058f2843c225b08a40fc30a960b..1b9729d3ecf7ab5b364cab26f940ac77
|
||||
|
||||
@Override
|
||||
public boolean canContinueToUse() {
|
||||
@@ -94,7 +140,13 @@ public class LookAtPlayerGoal extends Goal {
|
||||
public void tick() {
|
||||
if (this.lookAt.isAlive()) {
|
||||
double d = this.onlyHorizontal ? this.mob.getEyeY() : this.lookAt.getEyeY();
|
||||
- this.mob.getLookControl().setLookAt(this.lookAt.getX(), d, this.lookAt.getZ());
|
||||
+ // Leaf start - Async target finding
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncTargetFinding.searchEntity) {
|
||||
+ this.mob.getLookControl().setLookAtWithCooldown(this.lookAt.getX(), d, this.lookAt.getZ(), 10);
|
||||
+ } else {
|
||||
+ this.mob.getLookControl().setLookAt(this.lookAt.getX(), d, this.lookAt.getZ());
|
||||
+ }
|
||||
+ // Leaf end - Async target finding
|
||||
this.lookTime--;
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
index f15da598cb1d7872fafb8b173e5134b9667c9a9f..a6cb3b316c797cf85496ba395295c002805f573e 100644
|
||||
--- a/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
|
||||
Reference in New Issue
Block a user