Skip to content

Commit

Permalink
Adjust minecraft pathfinder to look less frequently and pathfind clos…
Browse files Browse the repository at this point in the history
…er to destination in players
  • Loading branch information
fullwall committed Jun 21, 2022
1 parent cd652db commit 318596c
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 28 deletions.
2 changes: 1 addition & 1 deletion main/pom.xml
Expand Up @@ -36,7 +36,7 @@
</repository>
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>sk89q-repo</id>
Expand Down
Expand Up @@ -86,8 +86,8 @@ public boolean update() {
double dX = target.getX() - loc.getX();
double dZ = target.getZ() - loc.getZ();
double dY = target.getY() - loc.getY();
double xzDistance = dX * dX + dZ * dZ;
if (Math.abs(dY) < 1 && Math.sqrt(xzDistance) <= parameters.distanceMargin()) {
double xzDistance = Math.sqrt(dX * dX + dZ * dZ);
if (Math.abs(dY) < 1 && xzDistance <= parameters.distanceMargin()) {
stop();
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion v1_10_R1/pom.xml
Expand Up @@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

Expand Down
2 changes: 1 addition & 1 deletion v1_11_R1/pom.xml
Expand Up @@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

Expand Down
2 changes: 1 addition & 1 deletion v1_12_R1/pom.xml
Expand Up @@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

Expand Down
2 changes: 1 addition & 1 deletion v1_13_R2/pom.xml
Expand Up @@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

Expand Down
2 changes: 1 addition & 1 deletion v1_14_R1/pom.xml
Expand Up @@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

Expand Down
2 changes: 1 addition & 1 deletion v1_15_R1/pom.xml
Expand Up @@ -16,7 +16,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

Expand Down
2 changes: 1 addition & 1 deletion v1_16_R3/pom.xml
Expand Up @@ -16,7 +16,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

Expand Down
2 changes: 1 addition & 1 deletion v1_17_R1/pom.xml
Expand Up @@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

Expand Down
Expand Up @@ -110,14 +110,16 @@ public void tick() {
double dX = this.tx - this.entity.getX();
double dZ = this.tz - this.entity.getZ();
double dY = this.ty - this.entity.getY();
double dXZ = dX * dX + dZ * dZ;
if (Math.abs(dY) < 1.0 && dXZ < 0.0075) {
double dXZ = Math.sqrt(dX * dX + dZ * dZ);
if (Math.abs(dY) < 1.0 && dXZ < 0.01) {
this.entity.zza = 0.0F;
return;
}
float f = (float) (Mth.atan2(dZ, dX) * 57.2957763671875D) - 90.0F;
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot());
if (dXZ > 0.4) {
float f = (float) (Mth.atan2(dZ, dX) * 57.2957763671875D) - 90.0F;
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot());
}
AttributeInstance speed = this.entity.getAttribute(Attributes.MOVEMENT_SPEED);
float movement = (float) (this.speed * speed.getValue());
this.entity.setSpeed(movement);
Expand Down
2 changes: 1 addition & 1 deletion v1_18_R2/pom.xml
Expand Up @@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

Expand Down
Expand Up @@ -110,13 +110,15 @@ public void tick() {
double dZ = this.tz - this.entity.getZ();
double dY = this.ty - this.entity.getY();
double dXZ = Math.sqrt(dX * dX + dZ * dZ);
if (Math.abs(dY) < 1.0 && dXZ < 0.09) {
if (Math.abs(dY) < 1.0 && dXZ < 0.01) {
// this.entity.zza = 0.0F;
return;
}
float f = (float) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F;
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot());
if (dXZ > 0.4) {
float f = (float) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F;
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot());
}
float movement = (float) (this.speedMod * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
this.entity.setSpeed(movement);
this.entity.zza = movement;
Expand Down
2 changes: 1 addition & 1 deletion v1_19_R1/pom.xml
Expand Up @@ -16,7 +16,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

Expand Down
Expand Up @@ -84,6 +84,7 @@ else if (f4 > 360.0F) {

@Override
public void setWantedPosition(double d0, double d1, double d2, double d3) {
System.out.println("set pos: " + d0 + " " + d2);
this.tx = d0;
this.ty = d1;
this.tz = d2;
Expand All @@ -110,13 +111,15 @@ public void tick() {
double dZ = this.tz - this.entity.getZ();
double dY = this.ty - this.entity.getY();
double dXZ = Math.sqrt(dX * dX + dZ * dZ);
if (Math.abs(dY) < 1.0 && dXZ < 0.09) {
if (Math.abs(dY) < 1.0 && dXZ < 0.01) {
// this.entity.zza = 0.0F;
return;
}
float f = (float) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F;
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot());
if (dXZ > 0.4) {
float f = (float) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F;
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot());
}
float movement = (float) (this.speedMod * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
this.entity.setSpeed(movement);
this.entity.zza = movement;
Expand Down
Expand Up @@ -147,7 +147,7 @@ private boolean canWalkAbove(int var0, int var1, int var2, int var3, int var4, i
}
return true;
}
private boolean canWalkOn(int var0, int var1, int var2, int var3, int var4, int var5, Vec3 var6, double var7,
double var9) {
int var11 = var0 - var3 / 2;
Expand Down
2 changes: 1 addition & 1 deletion v1_8_R3/pom.xml
Expand Up @@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

Expand Down

0 comments on commit 318596c

Please sign in to comment.