Adjust minecraft pathfinder to look less frequently and pathfind closer to destination in players

This commit is contained in:
fullwall 2022-06-21 23:52:25 +08:00
parent cd652db2f7
commit 318596c715
17 changed files with 35 additions and 28 deletions

View File

@ -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>

View File

@ -86,8 +86,8 @@ public class MCNavigationStrategy extends AbstractPathStrategy {
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;
}

View File

@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

View File

@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

View File

@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

View File

@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

View File

@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

View File

@ -16,7 +16,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

View File

@ -16,7 +16,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

View File

@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

View File

@ -110,14 +110,16 @@ public class PlayerMoveControl extends MoveControl {
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);

View File

@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

View File

@ -110,13 +110,15 @@ public class PlayerMoveControl extends MoveControl {
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;

View File

@ -16,7 +16,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>

View File

@ -84,6 +84,7 @@ public class PlayerMoveControl extends MoveControl {
@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;
@ -110,13 +111,15 @@ public class PlayerMoveControl extends MoveControl {
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;

View File

@ -18,7 +18,7 @@
<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
<url>https://repo.citizensnpcs.co</url>
</repository>
</repositories>