diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/EntityHumanNPC.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/EntityHumanNPC.java index 331fed9e0..cd1f88eaf 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/EntityHumanNPC.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/EntityHumanNPC.java @@ -318,6 +318,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable } range = getAttribute(Attributes.FOLLOW_RANGE); } + getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.3D); range.setBaseValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble()); controllerJump = new PlayerControllerJump(this); diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/PlayerMoveControl.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/PlayerMoveControl.java index 6ce6f7f41..075c55c3b 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/PlayerMoveControl.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/PlayerMoveControl.java @@ -119,7 +119,6 @@ public class PlayerMoveControl extends MoveControl { 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); - speed.setBaseValue(0.3D * this.speed); float movement = (float) (this.speed * speed.getValue()); this.entity.setSpeed(movement); this.entity.zza = movement; diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/EntityHumanNPC.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/EntityHumanNPC.java index 8f649b003..f401dbed0 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/EntityHumanNPC.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/EntityHumanNPC.java @@ -319,6 +319,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable } range = getAttribute(Attributes.FOLLOW_RANGE); } + getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.3D); range.setBaseValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble()); controllerJump = new PlayerControllerJump(this); diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/PlayerLookControl.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/PlayerLookControl.java index b399490f5..4b54a2cb9 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/PlayerLookControl.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/PlayerLookControl.java @@ -10,11 +10,11 @@ public class PlayerLookControl { private final EntityHumanNPC a; private final PlayerBodyControl control; protected boolean looking; - protected float tpitch; protected double tx; protected double ty; - protected float tyaw; protected double tz; + protected float xMaxRotAngle; + protected float yMaxRotSpeed; public PlayerLookControl(EntityHumanNPC entityinsentient) { this.a = entityinsentient; @@ -33,8 +33,8 @@ public class PlayerLookControl { this.tx = var0; this.ty = var2; this.tz = var4; - this.tyaw = var6; - this.tpitch = var7; + this.yMaxRotSpeed = var6; + this.xMaxRotAngle = var7; this.looking = true; } @@ -66,15 +66,15 @@ public class PlayerLookControl { return this.tz; } - protected float g() { + protected float getXRotD() { double var0 = this.tx - this.a.getX(); - double var2 = this.ty - (this.a.getY() + this.a.getEyeY()); + double var2 = this.ty - this.a.getEyeY(); double var4 = this.tz - this.a.getZ(); double var6 = Mth.sqrt((float) (var0 * var0 + var4 * var4)); return (float) (-(Mth.atan2(var2, var6) * 57.2957763671875D)); } - protected float h() { + protected float getYRotD() { double var0 = this.tx - this.a.getX(); double var2 = this.tz - this.a.getZ(); return (float) (Mth.atan2(var2, var0) * 57.2957763671875D) - 90.0F; @@ -97,8 +97,8 @@ public class PlayerLookControl { } if (this.looking) { this.looking = false; - this.a.setXRot(this.rotateTowards(this.a.getXRot(), this.g(), this.tpitch)); - this.a.yHeadRot = this.rotateTowards(this.a.yHeadRot, this.h(), this.tyaw); + this.a.setXRot(this.rotateTowards(this.a.getXRot(), this.getXRotD(), this.xMaxRotAngle)); + this.a.yHeadRot = this.rotateTowards(this.a.yHeadRot, this.getYRotD(), this.yMaxRotSpeed); while (this.a.yHeadRot >= 180F) { this.a.yHeadRot -= 360F; } diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/PlayerMoveControl.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/PlayerMoveControl.java index 73df6c43f..25c46d349 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/PlayerMoveControl.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/PlayerMoveControl.java @@ -8,7 +8,6 @@ import net.minecraft.util.Mth; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.ai.attributes.AttributeInstance; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.control.MoveControl; import net.minecraft.world.entity.monster.Slime; @@ -17,7 +16,7 @@ public class PlayerMoveControl extends MoveControl { protected LivingEntity entity; private int jumpTicks; protected boolean moving; - protected double speed; + protected double speedMod; protected double tx; protected double ty; protected double tz; @@ -33,7 +32,7 @@ public class PlayerMoveControl extends MoveControl { @Override public double getSpeedModifier() { - return this.speed; + return this.speedMod; } @Override @@ -88,7 +87,7 @@ public class PlayerMoveControl extends MoveControl { this.tx = d0; this.ty = d1; this.tz = d2; - this.speed = d3; + this.speedMod = d3; this.moving = true; } @@ -111,16 +110,14 @@ 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.025) { + if (Math.abs(dY) < 1.0 && dXZ <= 0.1) { // 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()); - AttributeInstance speed = this.entity.getAttribute(Attributes.MOVEMENT_SPEED); - speed.setBaseValue(0.3D * this.speed); - float movement = (float) (this.speed * speed.getValue()); + float movement = (float) (this.speedMod * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue()); this.entity.setSpeed(movement); this.entity.zza = movement; if (shouldJump() || (dY >= NMS.getStepHeight(entity.getBukkitEntity()) && dXZ < 0.4D)) {