diff --git a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java index a1622685f..3b1369aff 100644 --- a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -911,29 +911,35 @@ public class NPCCommands { if (args.argsLength() == 2) { throw new CommandException(Messages.HOLOGRAM_INVALID_LINE); } + int idx = Math.max(0, args.getInteger(2)); if (idx >= trait.getLines().size()) { throw new CommandException(Messages.HOLOGRAM_INVALID_LINE); } + if (args.argsLength() == 3) { throw new CommandException(Messages.HOLOGRAM_TEXT_MISSING); } + trait.setLine(idx, args.getJoinedStrings(3)); Messaging.sendTr(sender, Messages.HOLOGRAM_LINE_SET, idx, args.getJoinedStrings(3)); } else if (args.getString(1).equalsIgnoreCase("add")) { if (args.argsLength() == 2) { throw new CommandException(Messages.HOLOGRAM_TEXT_MISSING); } + trait.addLine(args.getJoinedStrings(2)); Messaging.sendTr(sender, Messages.HOLOGRAM_LINE_ADD, args.getJoinedStrings(2)); } else if (args.getString(1).equalsIgnoreCase("remove")) { if (args.argsLength() == 2) { throw new CommandException(Messages.HOLOGRAM_INVALID_LINE); } + int idx = Math.max(0, args.getInteger(2)); if (idx >= trait.getLines().size()) { throw new CommandException(Messages.HOLOGRAM_INVALID_LINE); } + trait.removeLine(idx); Messaging.sendTr(sender, Messages.HOLOGRAM_LINE_REMOVED, idx); } else if (args.getString(1).equalsIgnoreCase("clear")) { diff --git a/main/src/main/java/net/citizensnpcs/npc/CitizensTraitFactory.java b/main/src/main/java/net/citizensnpcs/npc/CitizensTraitFactory.java index 836764933..7d61e1096 100644 --- a/main/src/main/java/net/citizensnpcs/npc/CitizensTraitFactory.java +++ b/main/src/main/java/net/citizensnpcs/npc/CitizensTraitFactory.java @@ -42,6 +42,7 @@ import net.citizensnpcs.trait.OcelotModifiers; import net.citizensnpcs.trait.Poses; import net.citizensnpcs.trait.Powered; import net.citizensnpcs.trait.RabbitType; +import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.Saddle; import net.citizensnpcs.trait.ScoreboardTrait; import net.citizensnpcs.trait.ScriptTrait; @@ -88,6 +89,7 @@ public class CitizensTraitFactory implements TraitFactory { registerTrait(TraitInfo.create(Poses.class)); registerTrait(TraitInfo.create(Powered.class)); registerTrait(TraitInfo.create(RabbitType.class)); + registerTrait(TraitInfo.create(RotationTrait.class)); registerTrait(TraitInfo.create(Saddle.class)); registerTrait(TraitInfo.create(ScoreboardTrait.class)); registerTrait(TraitInfo.create(ScriptTrait.class)); diff --git a/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java b/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java index e0206f27d..95cbcb33b 100644 --- a/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java @@ -1,6 +1,7 @@ package net.citizensnpcs.trait; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -59,16 +60,15 @@ public class HologramTrait extends Trait { */ public void addLine(String text) { lines.add(text); - onDespawn(); - onSpawn(); + reloadLineHolograms(); } /** * Clears all hologram lines */ public void clear() { - onDespawn(); lines.clear(); + reloadLineHolograms(); } private NPC createHologram(String line, double heightOffset) { @@ -132,7 +132,7 @@ public class HologramTrait extends Trait { * @return the hologram lines, in bottom-up order */ public List getLines() { - return lines; + return Collections.unmodifiableList(lines); } private double getMaxHeight() { @@ -174,6 +174,21 @@ public class HologramTrait extends Trait { if (npc.requiresNameHologram() && lastNameplateVisible) { nameNPC = createHologram(npc.getFullName(), 0); } + + for (int i = 0; i < lines.size(); i++) { + String line = lines.get(i); + lineHolograms.add(createHologram(Placeholders.replace(line, null, npc), getHeight(i))); + } + } + + private void reloadLineHolograms() { + for (NPC npc : lineHolograms) { + npc.destroy(); + } + lineHolograms.clear(); + + if (!npc.isSpawned()) + return; for (int i = 0; i < lines.size(); i++) { String line = lines.get(i); lineHolograms.add(createHologram(Placeholders.replace(line, null, npc), getHeight(i))); @@ -186,9 +201,12 @@ public class HologramTrait extends Trait { * @param idx */ public void removeLine(int idx) { + if (idx < 0 || idx >= lines.size()) + return; + lines.remove(idx); - onDespawn(); - onSpawn(); + + reloadLineHolograms(); } @Override @@ -267,8 +285,8 @@ public class HologramTrait extends Trait { */ public void setDirection(HologramDirection direction) { this.direction = direction; - onDespawn(); - onSpawn(); + + reloadLineHolograms(); } /** @@ -281,17 +299,17 @@ public class HologramTrait extends Trait { */ public void setLine(int idx, String text) { if (idx == lines.size()) { - lines.add(text); - } else { - lines.set(idx, text); - if (idx < lineHolograms.size()) { - lineHolograms.get(idx).setName(Placeholders.replace(text, null, npc)); - return; - } + addLine(text); + return; } - onDespawn(); - onSpawn(); + lines.set(idx, text); + if (idx < lineHolograms.size()) { + lineHolograms.get(idx).setName(Placeholders.replace(text, null, npc)); + return; + } + + reloadLineHolograms(); } /** @@ -303,8 +321,8 @@ public class HologramTrait extends Trait { */ public void setLineHeight(double height) { lineHeight = height; - onDespawn(); - onSpawn(); + + reloadLineHolograms(); } public enum HologramDirection { diff --git a/main/src/main/java/net/citizensnpcs/trait/RotationTrait.java b/main/src/main/java/net/citizensnpcs/trait/RotationTrait.java index d9f6c30c5..31f54ef0b 100644 --- a/main/src/main/java/net/citizensnpcs/trait/RotationTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/RotationTrait.java @@ -1,5 +1,8 @@ package net.citizensnpcs.trait; +import org.bukkit.Location; +import org.bukkit.entity.Entity; + import net.citizensnpcs.api.trait.Trait; import net.citizensnpcs.api.trait.TraitName; import net.citizensnpcs.util.NMS; @@ -7,12 +10,12 @@ import net.citizensnpcs.util.Util; @TraitName("rotationtrait") public class RotationTrait extends Trait { + protected float maxPitchRotationPerTick = 10; + protected float maxYawRotationPerTick = 40; protected boolean rotating; protected double tx; protected double ty; protected double tz; - protected float xMaxRotAngle = 10; - protected float yMaxRotSpeed = 40; public RotationTrait() { super("rotationtrait"); @@ -22,10 +25,6 @@ public class RotationTrait extends Trait { return NMS.getHeight(npc.getEntity()); } - private double getX() { - return npc.getStoredLocation().getX(); - } - protected float getTargetPitchDifference() { double dx = tx - getX(); double dy = ty - (getY() + getEyeY()); @@ -34,18 +33,35 @@ public class RotationTrait extends Trait { return (float) -Math.toDegrees(Math.atan2(dy, diag)); } - private double getY() { - return npc.getStoredLocation().getY(); - } - protected float getTargetYawDifference() { return (float) Math.toDegrees(Math.atan2(tz - getZ(), tx - getX())) - 90.0F; } + private double getX() { + return npc.getStoredLocation().getX(); + } + + private double getY() { + return npc.getStoredLocation().getY(); + } + private double getZ() { return npc.getStoredLocation().getZ(); } + public void rotateToFace(Entity target) { + Location loc = target.getLocation(); + loc.setY(loc.getY() + NMS.getHeight(target)); + rotateToFace(loc); + } + + public void rotateToFace(Location target) { + this.tx = target.getX(); + this.ty = target.getY(); + this.tz = target.getZ(); + this.rotating = true; + } + protected float rotateTowards(float target, float current, float maxRotPerTick) { float diff = Util.clamp(current - target); return target + clamp(diff, -maxRotPerTick, maxRotPerTick); @@ -62,8 +78,8 @@ public class RotationTrait extends Trait { } if (this.rotating) { this.rotating = false; - NMS.setHeadYaw(npc.getEntity(), - Util.clamp(rotateTowards(NMS.getHeadYaw(npc.getEntity()), getTargetYawDifference(), this.yMaxRotSpeed))); + NMS.setHeadYaw(npc.getEntity(), Util.clamp(rotateTowards(NMS.getHeadYaw(npc.getEntity()), + getTargetYawDifference(), this.maxYawRotationPerTick))); float d = Util.clamp(NMS.getHeadYaw(npc.getEntity()) - 40); if (d > NMS.getYaw(npc.getEntity())) { NMS.setBodyYaw(npc.getEntity(), d); @@ -80,8 +96,8 @@ public class RotationTrait extends Trait { NMS.setBodyYaw(npc.getEntity(), d); } } - NMS.setPitch(npc.getEntity(), - rotateTowards(npc.getStoredLocation().getPitch(), getTargetPitchDifference(), this.xMaxRotAngle)); + NMS.setPitch(npc.getEntity(), rotateTowards(npc.getStoredLocation().getPitch(), getTargetPitchDifference(), + this.maxPitchRotationPerTick)); } } diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java index 75300af78..73b609759 100644 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java +++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java @@ -27,7 +27,6 @@ import net.citizensnpcs.nms.v1_10_R1.network.EmptyNetworkManager; import net.citizensnpcs.nms.v1_10_R1.network.EmptySocket; import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl; import net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerJump; -import net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerLook; import net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerMove; import net.citizensnpcs.nms.v1_10_R1.util.PlayerNavigation; import net.citizensnpcs.npc.CitizensNPC; @@ -41,7 +40,6 @@ import net.citizensnpcs.util.Util; import net.minecraft.server.v1_10_R1.AttributeInstance; import net.minecraft.server.v1_10_R1.BlockPosition; import net.minecraft.server.v1_10_R1.DamageSource; -import net.minecraft.server.v1_10_R1.Entity; import net.minecraft.server.v1_10_R1.EntityHuman; import net.minecraft.server.v1_10_R1.EntityPlayer; import net.minecraft.server.v1_10_R1.EnumGamemode; @@ -62,7 +60,6 @@ import net.minecraft.server.v1_10_R1.WorldServer; public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity { private final Map bz = Maps.newEnumMap(PathType.class); private PlayerControllerJump controllerJump; - private PlayerControllerLook controllerLook; private PlayerControllerMove controllerMove; private final Map equipmentCache = Maps.newEnumMap(EnumItemSlot.class); private boolean isTracked = false; @@ -255,7 +252,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble()); controllerJump = new PlayerControllerJump(this); - controllerLook = new PlayerControllerLook(this); controllerMove = new PlayerControllerMove(this); navigation = new PlayerNavigation(this, world); invulnerableTicks = 0; @@ -391,21 +387,12 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data); } - public void setTargetLook(Entity target, float yawOffset, float renderOffset) { - controllerLook.a(target, yawOffset, renderOffset); - } - - public void setTargetLook(Location target) { - controllerLook.a(target.getX(), target.getY(), target.getZ(), 10, 40); - } - public void setTracked() { isTracked = true; } public void updateAI() { controllerMove.c(); - controllerLook.a(); controllerJump.b(); } diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java index 466ae2413..3207f96e2 100644 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java +++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java @@ -144,6 +144,7 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.skin.SkinnableEntity; +import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.PolarBearTrait; import net.citizensnpcs.trait.versioned.ShulkerTrait; @@ -745,7 +746,7 @@ public class NMSImpl implements NMSBridge { ((EntityInsentient) handle).aQ += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(to); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } @@ -769,7 +770,7 @@ public class NMSImpl implements NMSBridge { ((EntityLiving) handle).aQ += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/PlayerControllerLook.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/PlayerControllerLook.java deleted file mode 100644 index d5adad7a5..000000000 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/PlayerControllerLook.java +++ /dev/null @@ -1,125 +0,0 @@ -package net.citizensnpcs.nms.v1_10_R1.util; - -import net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC; -import net.minecraft.server.v1_10_R1.Entity; -import net.minecraft.server.v1_10_R1.EntityLiving; -import net.minecraft.server.v1_10_R1.MathHelper; - -public class PlayerControllerLook { - private final EntityHumanNPC a; - private float b; - private float c; - private boolean d; - private double e; - private double f; - private double g; - - public PlayerControllerLook(EntityHumanNPC entityinsentient) { - this.a = entityinsentient; - } - - public void a() { - if (!NMSImpl.isNavigationFinished(this.a.getNavigation())) - return; - // this.a.pitch = 0.0F; - if (this.d) { - this.d = false; - - double d1 = this.e - this.a.locX; - double d2 = this.f - (this.a.locY + this.a.getHeadHeight()); - double d3 = this.g - this.a.locZ; - double d4 = MathHelper.sqrt(d1 * d1 + d3 * d3); - - float f1 = (float) (MathHelper.b(d3, d1) * 57.2957763671875D) - 90.0F; - float f2 = (float) -(MathHelper.b(d2, d4) * 57.2957763671875D); - this.a.pitch = a(this.a.pitch, f2, this.c); - this.a.aQ = a(this.a.aQ, f1, this.b); - this.a.yaw = this.a.aQ; - while (this.a.aQ >= 180F) { - this.a.aQ -= 360F; - } - while (this.a.aQ < -180F) { - this.a.aQ += 360F; - } - } else { - // this.a.yaw = b(this.a.yaw, this.a.aK, -40F); - // this.a.aQ = a(this.a.aQ, this.a.aO, 10.0F); - } - float f3 = MathHelper.g(this.a.aQ - this.a.aO); - if (!this.a.getNavigation().n()) { - if (f3 < -75.0F) { - this.a.aQ = (this.a.aO - 75.0F); - } - if (f3 > 75.0F) { - this.a.aQ = (this.a.aO + 75.0F); - } - } - } - - public void a(double d0, double d1, double d2, float f, float f1) { - double d = Math.pow(this.e - d0, 2) + Math.pow(this.f - d1, 2) + Math.pow(this.g - d2, 2); - if (d < 0.01) { - // return; - } - this.e = d0; - this.f = d1; - this.g = d2; - this.b = f; - this.c = f1; - this.d = true; - } - - public void a(Entity entity, float f, float f1) { - this.e = entity.locX; - if ((entity instanceof EntityLiving)) - this.f = (entity.locY + entity.getHeadHeight()); - else { - this.f = ((entity.getBoundingBox().b + entity.getBoundingBox().e) / 2.0D); - } - - this.g = entity.locZ; - this.b = f; - this.c = f1; - this.d = true; - } - - private float a(float f, float f1, float f2) { - float f3 = MathHelper.g(f1 - f); - - if (f3 > f2) { - f3 = f2; - } - - if (f3 < -f2) { - f3 = -f2; - } - - return f + f3; - } - - public boolean b() { - return this.d; - } - - public float b(float var0, float var1, float var2) { - float var3 = c(var0, var1); - float var4 = MathHelper.a(var3, -var2, var2); - return var1 - var4; - } - - public float c(float var0, float var1) { - return MathHelper.g(var1 - var0); - } - - public double e() { - return this.e; - } - - public double f() { - return this.f; - } - - public double g() { - return this.g; - } -} \ No newline at end of file diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java index c2900e301..9971a2679 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java @@ -27,7 +27,6 @@ import net.citizensnpcs.nms.v1_11_R1.network.EmptyNetworkManager; import net.citizensnpcs.nms.v1_11_R1.network.EmptySocket; import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl; import net.citizensnpcs.nms.v1_11_R1.util.PlayerControllerJump; -import net.citizensnpcs.nms.v1_11_R1.util.PlayerControllerLook; import net.citizensnpcs.nms.v1_11_R1.util.PlayerControllerMove; import net.citizensnpcs.nms.v1_11_R1.util.PlayerNavigation; import net.citizensnpcs.npc.CitizensNPC; @@ -42,7 +41,6 @@ import net.minecraft.server.v1_11_R1.AttributeInstance; import net.minecraft.server.v1_11_R1.BlockPosition; import net.minecraft.server.v1_11_R1.ChatComponentText; import net.minecraft.server.v1_11_R1.DamageSource; -import net.minecraft.server.v1_11_R1.Entity; import net.minecraft.server.v1_11_R1.EntityHuman; import net.minecraft.server.v1_11_R1.EntityPlayer; import net.minecraft.server.v1_11_R1.EnumGamemode; @@ -64,7 +62,6 @@ import net.minecraft.server.v1_11_R1.WorldServer; public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity { private final Map bz = Maps.newEnumMap(PathType.class); private PlayerControllerJump controllerJump; - private PlayerControllerLook controllerLook; private PlayerControllerMove controllerMove; private final Map equipmentCache = Maps.newEnumMap(EnumItemSlot.class); private boolean isTracked = false; @@ -282,7 +279,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble()); controllerJump = new PlayerControllerJump(this); - controllerLook = new PlayerControllerLook(this); controllerMove = new PlayerControllerMove(this); navigation = new PlayerNavigation(this, world); invulnerableTicks = 0; @@ -397,21 +393,12 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data); } - public void setTargetLook(Entity target, float yawOffset, float renderOffset) { - controllerLook.a(target, yawOffset, renderOffset); - } - - public void setTargetLook(Location target) { - controllerLook.a(target.getX(), target.getY(), target.getZ(), 10, 40); - } - public void setTracked() { isTracked = true; } public void updateAI() { controllerMove.c(); - controllerLook.a(); controllerJump.b(); } diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java index c3a415a7f..61292556c 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java @@ -158,6 +158,7 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.skin.SkinnableEntity; +import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.LlamaTrait; import net.citizensnpcs.trait.versioned.PolarBearTrait; @@ -800,7 +801,7 @@ public class NMSImpl implements NMSBridge { ((EntityLiving) handle).aP += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(to); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } @@ -824,7 +825,7 @@ public class NMSImpl implements NMSBridge { ((EntityLiving) handle).aP += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/PlayerControllerLook.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/PlayerControllerLook.java deleted file mode 100644 index 30c3f6dbb..000000000 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/PlayerControllerLook.java +++ /dev/null @@ -1,125 +0,0 @@ -package net.citizensnpcs.nms.v1_11_R1.util; - -import net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC; -import net.minecraft.server.v1_11_R1.Entity; -import net.minecraft.server.v1_11_R1.EntityLiving; -import net.minecraft.server.v1_11_R1.MathHelper; - -public class PlayerControllerLook { - private final EntityHumanNPC a; - private float b; - private float c; - private boolean d; - private double e; - private double f; - private double g; - - public PlayerControllerLook(EntityHumanNPC entityinsentient) { - this.a = entityinsentient; - } - - public void a() { - if (!NMSImpl.isNavigationFinished(this.a.getNavigation())) - return; - // this.a.pitch = 0.0F; - if (this.d) { - this.d = false; - - double d1 = this.e - this.a.locX; - double d2 = this.f - (this.a.locY + this.a.getHeadHeight()); - double d3 = this.g - this.a.locZ; - double d4 = MathHelper.sqrt(d1 * d1 + d3 * d3); - - float f1 = (float) (MathHelper.c(d3, d1) * 57.2957763671875D) - 90.0F; - float f2 = (float) -(MathHelper.c(d2, d4) * 57.2957763671875D); - this.a.pitch = a(this.a.pitch, f2, this.c); - this.a.aP = a(this.a.aP, f1, this.b); - this.a.yaw = this.a.aP; - while (this.a.aP >= 180F) { - this.a.aP -= 360F; - } - while (this.a.aP < -180F) { - this.a.aP += 360F; - } - } else { - // this.a.yaw = this.b(this.a.yaw, this.a.aP, -40F); - // this.a.aP = a(this.a.aP, this.a.aN, 10.0F); - } - float f3 = MathHelper.g(this.a.aP - this.a.aN); - if (!this.a.getNavigation().n()) { - if (f3 < -75.0F) { - this.a.aP = (this.a.aN - 75.0F); - } - if (f3 > 75.0F) { - this.a.aP = (this.a.aN + 75.0F); - } - } - } - - public void a(double d0, double d1, double d2, float f, float f1) { - double d = Math.pow(this.e - d0, 2) + Math.pow(this.f - d1, 2) + Math.pow(this.g - d2, 2); - if (d < 0.01) { - // return; - } - this.e = d0; - this.f = d1; - this.g = d2; - this.b = f; - this.c = f1; - this.d = true; - } - - public void a(Entity entity, float f, float f1) { - this.e = entity.locX; - if ((entity instanceof EntityLiving)) - this.f = (entity.locY + entity.getHeadHeight()); - else { - this.f = ((entity.getBoundingBox().b + entity.getBoundingBox().e) / 2.0D); - } - - this.g = entity.locZ; - this.b = f; - this.c = f1; - this.d = true; - } - - private float a(float f, float f1, float f2) { - float f3 = MathHelper.g(f1 - f); - - if (f3 > f2) { - f3 = f2; - } - - if (f3 < -f2) { - f3 = -f2; - } - - return f + f3; - } - - public boolean b() { - return this.d; - } - - public float b(float var0, float var1, float var2) { - float var3 = c(var0, var1); - float var4 = MathHelper.a(var3, -var2, var2); - return var1 - var4; - } - - public float c(float var0, float var1) { - return MathHelper.g(var1 - var0); - } - - public double e() { - return this.e; - } - - public double f() { - return this.f; - } - - public double g() { - return this.g; - } -} \ No newline at end of file diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/EntityHumanNPC.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/EntityHumanNPC.java index bee7f275b..eb5d1d0f6 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/EntityHumanNPC.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/EntityHumanNPC.java @@ -29,7 +29,6 @@ import net.citizensnpcs.nms.v1_12_R1.network.EmptySocket; import net.citizensnpcs.nms.v1_12_R1.util.EmptyAdvancementDataPlayer; import net.citizensnpcs.nms.v1_12_R1.util.NMSImpl; import net.citizensnpcs.nms.v1_12_R1.util.PlayerControllerJump; -import net.citizensnpcs.nms.v1_12_R1.util.PlayerControllerLook; import net.citizensnpcs.nms.v1_12_R1.util.PlayerControllerMove; import net.citizensnpcs.nms.v1_12_R1.util.PlayerNavigation; import net.citizensnpcs.nms.v1_12_R1.util.PlayerlistTrackerEntry; @@ -46,7 +45,6 @@ import net.minecraft.server.v1_12_R1.BlockPosition; import net.minecraft.server.v1_12_R1.ChatComponentText; import net.minecraft.server.v1_12_R1.DamageSource; import net.minecraft.server.v1_12_R1.DataWatcher; -import net.minecraft.server.v1_12_R1.Entity; import net.minecraft.server.v1_12_R1.EntityHuman; import net.minecraft.server.v1_12_R1.EntityPlayer; import net.minecraft.server.v1_12_R1.EnumGamemode; @@ -68,7 +66,6 @@ import net.minecraft.server.v1_12_R1.WorldServer; public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity { private final Map bz = Maps.newEnumMap(PathType.class); private PlayerControllerJump controllerJump; - private PlayerControllerLook controllerLook; private PlayerControllerMove controllerMove; private final Map equipmentCache = Maps.newEnumMap(EnumItemSlot.class); private int jumpTicks = 0; @@ -302,7 +299,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble()); controllerJump = new PlayerControllerJump(this); - controllerLook = new PlayerControllerLook(this); controllerMove = new PlayerControllerMove(this); navigation = new PlayerNavigation(this, world); invulnerableTicks = 0; @@ -423,21 +419,12 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data); } - public void setTargetLook(Entity target, float yawOffset, float renderOffset) { - controllerLook.a(target, yawOffset, renderOffset); - } - - public void setTargetLook(Location target) { - controllerLook.a(target.getX(), target.getY(), target.getZ(), 10, 40); - } - public void setTracked(PlayerlistTrackerEntry entry) { this.trackerEntry = entry; } public void updateAI() { controllerMove.a(); - controllerLook.a(); controllerJump.b(); } diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java index 0d8c57325..afac0d27d 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java @@ -160,6 +160,7 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.skin.SkinnableEntity; +import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.LlamaTrait; import net.citizensnpcs.trait.versioned.ParrotTrait; @@ -807,7 +808,7 @@ public class NMSImpl implements NMSBridge { ((EntityLiving) handle).aP += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(to); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } @@ -832,7 +833,7 @@ public class NMSImpl implements NMSBridge { ((EntityLiving) handle).aP += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/PlayerControllerLook.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/PlayerControllerLook.java deleted file mode 100644 index 573b087b2..000000000 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/PlayerControllerLook.java +++ /dev/null @@ -1,125 +0,0 @@ -package net.citizensnpcs.nms.v1_12_R1.util; - -import net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC; -import net.minecraft.server.v1_12_R1.Entity; -import net.minecraft.server.v1_12_R1.EntityLiving; -import net.minecraft.server.v1_12_R1.MathHelper; - -public class PlayerControllerLook { - private final EntityHumanNPC a; - private float b; - private float c; - private boolean d; - private double e; - private double f; - private double g; - - public PlayerControllerLook(EntityHumanNPC entityinsentient) { - this.a = entityinsentient; - } - - public void a() { - if (!NMSImpl.isNavigationFinished(this.a.getNavigation())) - return; - // this.a.pitch = 0.0F; - if (this.d) { - this.d = false; - - double d1 = this.e - this.a.locX; - double d2 = this.f - (this.a.locY + this.a.getHeadHeight()); - double d3 = this.g - this.a.locZ; - double d4 = MathHelper.sqrt(d1 * d1 + d3 * d3); - - float f1 = (float) (MathHelper.c(d3, d1) * 57.2957763671875D) - 90.0F; - float f2 = (float) -(MathHelper.c(d2, d4) * 57.2957763671875D); - this.a.pitch = a(this.a.pitch, f2, this.c); - this.a.aP = a(this.a.aP, f1, this.b); - this.a.yaw = this.a.aP; - while (this.a.aP >= 180F) { - this.a.aP -= 360F; - } - while (this.a.aP < -180F) { - this.a.aP += 360F; - } - } else { - // this.a.yaw = this.b(this.a.yaw, this.a.aP, -40F); - // this.a.aP = a(this.a.aP, this.a.aN, 10.0F); - } - float f3 = MathHelper.g(this.a.aP - this.a.aN); - if (!this.a.getNavigation().o()) { - if (f3 < -75.0F) { - this.a.aP = (this.a.aN - 75.0F); - } - if (f3 > 75.0F) { - this.a.aP = (this.a.aN + 75.0F); - } - } - } - - public void a(double d0, double d1, double d2, float f, float f1) { - double d = Math.pow(this.e - d0, 2) + Math.pow(this.f - d1, 2) + Math.pow(this.g - d2, 2); - if (d < 0.01) { - // return; - } - this.e = d0; - this.f = d1; - this.g = d2; - this.b = f; - this.c = f1; - this.d = true; - } - - public void a(Entity entity, float f, float f1) { - this.e = entity.locX; - if ((entity instanceof EntityLiving)) - this.f = (entity.locY + entity.getHeadHeight()); - else { - this.f = ((entity.getBoundingBox().b + entity.getBoundingBox().e) / 2.0D); - } - - this.g = entity.locZ; - this.b = f; - this.c = f1; - this.d = true; - } - - private float a(float f, float f1, float f2) { - float f3 = MathHelper.g(f1 - f); - - if (f3 > f2) { - f3 = f2; - } - - if (f3 < -f2) { - f3 = -f2; - } - - return f + f3; - } - - public boolean b() { - return this.d; - } - - public float b(float var0, float var1, float var2) { - float var3 = c(var0, var1); - float var4 = MathHelper.a(var3, -var2, var2); - return var1 - var4; - } - - public float c(float var0, float var1) { - return MathHelper.g(var1 - var0); - } - - public double e() { - return this.e; - } - - public double f() { - return this.f; - } - - public double g() { - return this.g; - } -} \ No newline at end of file diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/EntityHumanNPC.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/EntityHumanNPC.java index 456c1a93d..f721e145d 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/EntityHumanNPC.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/EntityHumanNPC.java @@ -29,7 +29,6 @@ import net.citizensnpcs.nms.v1_13_R2.network.EmptySocket; import net.citizensnpcs.nms.v1_13_R2.util.EmptyAdvancementDataPlayer; import net.citizensnpcs.nms.v1_13_R2.util.NMSImpl; import net.citizensnpcs.nms.v1_13_R2.util.PlayerControllerJump; -import net.citizensnpcs.nms.v1_13_R2.util.PlayerControllerLook; import net.citizensnpcs.nms.v1_13_R2.util.PlayerControllerMove; import net.citizensnpcs.nms.v1_13_R2.util.PlayerNavigation; import net.citizensnpcs.nms.v1_13_R2.util.PlayerlistTrackerEntry; @@ -46,7 +45,6 @@ import net.minecraft.server.v1_13_R2.BlockPosition; import net.minecraft.server.v1_13_R2.ChatComponentText; import net.minecraft.server.v1_13_R2.DamageSource; import net.minecraft.server.v1_13_R2.DataWatcher; -import net.minecraft.server.v1_13_R2.Entity; import net.minecraft.server.v1_13_R2.EntityHuman; import net.minecraft.server.v1_13_R2.EntityPlayer; import net.minecraft.server.v1_13_R2.EnumGamemode; @@ -68,7 +66,6 @@ import net.minecraft.server.v1_13_R2.WorldServer; public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity { private final Map bz = Maps.newEnumMap(PathType.class); private PlayerControllerJump controllerJump; - private PlayerControllerLook controllerLook; private PlayerControllerMove controllerMove; private final Map equipmentCache = Maps.newEnumMap(EnumItemSlot.class); private int jumpTicks = 0; @@ -285,7 +282,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble()); controllerJump = new PlayerControllerJump(this); - controllerLook = new PlayerControllerLook(this); controllerMove = new PlayerControllerMove(this); navigation = new PlayerNavigation(this, world); invulnerableTicks = 0; @@ -398,14 +394,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data); } - public void setTargetLook(Entity target, float yawOffset, float renderOffset) { - controllerLook.a(target, yawOffset, renderOffset); - } - - public void setTargetLook(Location target) { - controllerLook.a(target.getX(), target.getY(), target.getZ(), 10, 40); - } - public void setTracked(PlayerlistTrackerEntry trackerEntry) { this.trackerEntry = trackerEntry; } @@ -429,7 +417,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable public void updateAI() { controllerMove.a(); - controllerLook.a(); controllerJump.b(); } diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java index d30a5093f..5660c406b 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java @@ -171,6 +171,7 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.skin.SkinnableEntity; +import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.LlamaTrait; import net.citizensnpcs.trait.versioned.ParrotTrait; @@ -843,7 +844,7 @@ public class NMSImpl implements NMSBridge { ((EntityLiving) handle).aS += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(to); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } @@ -867,7 +868,7 @@ public class NMSImpl implements NMSBridge { ((EntityLiving) handle).aS += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/PlayerControllerLook.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/PlayerControllerLook.java deleted file mode 100644 index 5379c3277..000000000 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/PlayerControllerLook.java +++ /dev/null @@ -1,127 +0,0 @@ -package net.citizensnpcs.nms.v1_13_R2.util; - -import net.citizensnpcs.api.util.BoundingBox; -import net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC; -import net.minecraft.server.v1_13_R2.Entity; -import net.minecraft.server.v1_13_R2.EntityLiving; -import net.minecraft.server.v1_13_R2.MathHelper; - -public class PlayerControllerLook { - private final EntityHumanNPC a; - private float b; - private float c; - private boolean d; - private double e; - private double f; - private double g; - - public PlayerControllerLook(EntityHumanNPC entityinsentient) { - this.a = entityinsentient; - } - - public void a() { - if (!NMSImpl.isNavigationFinished(this.a.getNavigation())) - return; - // this.a.pitch = 0.0F; - if (this.d) { - this.d = false; - - double d1 = this.e - this.a.locX; - double d2 = this.f - (this.a.locY + this.a.getHeadHeight()); - double d3 = this.g - this.a.locZ; - double d4 = MathHelper.sqrt(d1 * d1 + d3 * d3); - - float f1 = (float) (MathHelper.c(d3, d1) * 57.2957763671875D) - 90.0F; - float f2 = (float) -(MathHelper.c(d2, d4) * 57.2957763671875D); - this.a.pitch = a(this.a.pitch, f2, this.c); - this.a.aS = a(this.a.aS, f1, this.b); - this.a.yaw = this.a.aS; - while (this.a.aS >= 180F) { - this.a.aS -= 360F; - } - while (this.a.aS < -180F) { - this.a.aS += 360F; - } - } else { - // this.a.yaw = b(this.a.yaw, this.a.aS, -40F); - // this.a.aP = a(this.a.aS, this.a.aQ, 10.0F); - } - float f3 = MathHelper.g(this.a.aS - this.a.aQ); - if (!this.a.getNavigation().p()) { - if (f3 < -75.0F) { - this.a.aS = (this.a.aQ - 75.0F); - } - if (f3 > 75.0F) { - this.a.aS = (this.a.aQ + 75.0F); - } - } - } - - public void a(double d0, double d1, double d2, float f, float f1) { - double d = Math.pow(this.e - d0, 2) + Math.pow(this.f - d1, 2) + Math.pow(this.g - d2, 2); - if (d < 0.01) { - // return; - } - this.e = d0; - this.f = d1; - this.g = d2; - this.b = f; - this.c = f1; - this.d = true; - } - - public void a(Entity entity, float f, float f1) { - this.e = entity.locX; - if ((entity instanceof EntityLiving)) - this.f = (entity.locY + entity.getHeadHeight()); - else { - BoundingBox bb = NMSBoundingBox.wrap(entity.getBoundingBox()); - this.f = ((bb.minY + bb.maxY) / 2.0D); - } - - this.g = entity.locZ; - this.b = f; - this.c = f1; - this.d = true; - } - - private float a(float f, float f1, float f2) { - float f3 = MathHelper.g(f1 - f); - - if (f3 > f2) { - f3 = f2; - } - - if (f3 < -f2) { - f3 = -f2; - } - - return f + f3; - } - - public boolean b() { - return this.d; - } - - public float b(float var0, float var1, float var2) { - float var3 = c(var0, var1); - float var4 = MathHelper.a(var3, -var2, var2); - return var1 - var4; - } - - public float c(float var0, float var1) { - return MathHelper.g(var1 - var0); - } - - public double e() { - return this.e; - } - - public double f() { - return this.f; - } - - public double g() { - return this.g; - } -} \ No newline at end of file diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/EntityHumanNPC.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/EntityHumanNPC.java index 2e7a8f345..6d93ffe10 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/EntityHumanNPC.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/EntityHumanNPC.java @@ -28,7 +28,6 @@ import net.citizensnpcs.nms.v1_14_R1.network.EmptySocket; import net.citizensnpcs.nms.v1_14_R1.util.EmptyAdvancementDataPlayer; import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl; import net.citizensnpcs.nms.v1_14_R1.util.PlayerControllerJump; -import net.citizensnpcs.nms.v1_14_R1.util.PlayerControllerLook; import net.citizensnpcs.nms.v1_14_R1.util.PlayerControllerMove; import net.citizensnpcs.nms.v1_14_R1.util.PlayerNavigation; import net.citizensnpcs.nms.v1_14_R1.util.PlayerlistTracker; @@ -44,7 +43,6 @@ import net.minecraft.server.v1_14_R1.AttributeInstance; import net.minecraft.server.v1_14_R1.BlockPosition; import net.minecraft.server.v1_14_R1.ChatComponentText; import net.minecraft.server.v1_14_R1.DamageSource; -import net.minecraft.server.v1_14_R1.Entity; import net.minecraft.server.v1_14_R1.EntityHuman; import net.minecraft.server.v1_14_R1.EntityPlayer; import net.minecraft.server.v1_14_R1.EnumGamemode; @@ -67,7 +65,6 @@ import net.minecraft.server.v1_14_R1.WorldServer; public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity { private final Map bz = Maps.newEnumMap(PathType.class); private PlayerControllerJump controllerJump; - private PlayerControllerLook controllerLook; private PlayerControllerMove controllerMove; private final Map equipmentCache = Maps.newEnumMap(EnumItemSlot.class); private int jumpTicks = 0; @@ -276,7 +273,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble()); controllerJump = new PlayerControllerJump(this); - controllerLook = new PlayerControllerLook(this); controllerMove = new PlayerControllerMove(this); navigation = new PlayerNavigation(this, world); invulnerableTicks = 0; @@ -403,14 +399,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data); } - public void setTargetLook(Entity target, float yawOffset, float renderOffset) { - controllerLook.a(target, yawOffset, renderOffset); - } - - public void setTargetLook(Location target) { - controllerLook.a(target.getX(), target.getY(), target.getZ(), 10, 40); - } - public void setTracked(PlayerlistTracker tracker) { this.playerlistTracker = tracker; } @@ -433,7 +421,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable public void updateAI() { controllerMove.a(); - controllerLook.a(); controllerJump.b(); } diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java index 6f5fc0cc3..4a8aef29e 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java @@ -180,6 +180,7 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.skin.SkinnableEntity; +import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.CatTrait; import net.citizensnpcs.trait.versioned.FoxTrait; @@ -911,7 +912,7 @@ public class NMSImpl implements NMSBridge { ((EntityLiving) handle).aM += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(to); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } @@ -935,7 +936,7 @@ public class NMSImpl implements NMSBridge { ((EntityLiving) handle).aM += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerControllerLook.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerControllerLook.java deleted file mode 100644 index dd8e2f48d..000000000 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerControllerLook.java +++ /dev/null @@ -1,112 +0,0 @@ -package net.citizensnpcs.nms.v1_14_R1.util; - -import net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC; -import net.minecraft.server.v1_14_R1.Entity; -import net.minecraft.server.v1_14_R1.EntityLiving; -import net.minecraft.server.v1_14_R1.MathHelper; -import net.minecraft.server.v1_14_R1.Vec3D; - -public class PlayerControllerLook { - private final EntityHumanNPC a; - protected float b; - protected float c; - protected boolean d; - protected double e; - protected double f; - protected double g; - - public PlayerControllerLook(EntityHumanNPC entityinsentient) { - this.a = entityinsentient; - } - - public void a() { - if (!NMSImpl.isNavigationFinished(this.a.getNavigation())) - return; - if (this.b()) { - // this.a.pitch = 0.0F; - } - if (this.d) { - this.d = false; - this.a.aM = this.a(this.a.aM, this.h(), this.b); - this.a.yaw = this.a.aM; - this.a.pitch = this.a(this.a.pitch, this.g(), this.c); - } else { - // this.a.yaw = MathHelper.b(this.a.yaw, this.a.aM, -40F); - // this.a.aM = this.a(this.a.aM, this.a.aK, 10.0F); - } - - if (!this.a.getNavigation().n()) { - this.a.aM = MathHelper.b(this.a.aM, this.a.aK, 75); - } - } - - public void a(double var0, double var2, double var4) { - this.a(var0, var2, var4, 10, 40); - } - - public void a(double var0, double var2, double var4, float var6, float var7) { - double d = Math.pow(this.e - var0, 2) + Math.pow(this.f - var2, 2) + Math.pow(this.g - var4, 2); - if (d < 0.01) { - // return; - } - this.e = var0; - this.f = var2; - this.g = var4; - this.b = var6; - this.c = var7; - this.d = true; - } - - public void a(Entity var0, float var1, float var2) { - this.a(var0.locX, b(var0), var0.locZ, var1, var2); - } - - protected float a(float var0, float var1, float var2) { - float var3 = MathHelper.c(var0, var1); - float var4 = MathHelper.a(var3, -var2, var2); - return var0 + var4; - } - - public void a(Vec3D var0) { - this.a(var0.x, var0.y, var0.z); - } - - protected boolean b() { - return true; - } - - public boolean c() { - return this.d; - } - - public double d() { - return this.e; - } - - public double e() { - return this.f; - } - - public double f() { - return this.g; - } - - protected float g() { - double var0 = this.e - this.a.locX; - double var2 = this.f - (this.a.locY + this.a.getHeadHeight()); - double var4 = this.g - this.a.locZ; - double var6 = MathHelper.sqrt(var0 * var0 + var4 * var4); - return (float) (-(MathHelper.d(var2, var6) * 57.2957763671875D)); - } - - protected float h() { - double var0 = this.e - this.a.locX; - double var2 = this.g - this.a.locZ; - return (float) (MathHelper.d(var2, var0) * 57.2957763671875D) - 90.0F; - } - - private static double b(Entity var0) { - return var0 instanceof EntityLiving ? var0.locY + var0.getHeadHeight() - : (var0.getBoundingBox().minY + var0.getBoundingBox().maxY) / 2.0D; - } -} \ No newline at end of file diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/EntityHumanNPC.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/EntityHumanNPC.java index 4594fbcfa..75eced460 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/EntityHumanNPC.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/EntityHumanNPC.java @@ -28,7 +28,6 @@ import net.citizensnpcs.nms.v1_15_R1.network.EmptySocket; import net.citizensnpcs.nms.v1_15_R1.util.EmptyAdvancementDataPlayer; import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl; import net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerJump; -import net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerLook; import net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerMove; import net.citizensnpcs.nms.v1_15_R1.util.PlayerNavigation; import net.citizensnpcs.nms.v1_15_R1.util.PlayerlistTracker; @@ -44,7 +43,6 @@ import net.minecraft.server.v1_15_R1.AttributeInstance; import net.minecraft.server.v1_15_R1.BlockPosition; import net.minecraft.server.v1_15_R1.ChatComponentText; import net.minecraft.server.v1_15_R1.DamageSource; -import net.minecraft.server.v1_15_R1.Entity; import net.minecraft.server.v1_15_R1.EntityHuman; import net.minecraft.server.v1_15_R1.EntityPlayer; import net.minecraft.server.v1_15_R1.EnumGamemode; @@ -67,7 +65,6 @@ import net.minecraft.server.v1_15_R1.WorldServer; public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity { private final Map bz = Maps.newEnumMap(PathType.class); private PlayerControllerJump controllerJump; - private PlayerControllerLook controllerLook; private PlayerControllerMove controllerMove; private final Map equipmentCache = Maps.newEnumMap(EnumItemSlot.class); private int jumpTicks = 0; @@ -277,7 +274,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble()); controllerJump = new PlayerControllerJump(this); - controllerLook = new PlayerControllerLook(this); controllerMove = new PlayerControllerMove(this); navigation = new PlayerNavigation(this, world); invulnerableTicks = 0; @@ -403,14 +399,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data); } - public void setTargetLook(Entity target, float yawOffset, float renderOffset) { - controllerLook.a(target, yawOffset, renderOffset); - } - - public void setTargetLook(Location target) { - controllerLook.a(target.getX(), target.getY(), target.getZ()); - } - public void setTracked(PlayerlistTracker tracker) { this.playerlistTracker = tracker; } @@ -444,7 +432,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable public void updateAI() { controllerMove.a(); - controllerLook.a(); controllerJump.b(); } diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java index ae5ae1801..7f0030846 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java @@ -181,6 +181,7 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.skin.SkinnableEntity; +import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.BeeTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.CatTrait; @@ -923,7 +924,7 @@ public class NMSImpl implements NMSBridge { ((EntityLiving) handle).aK += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(to); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } @@ -947,7 +948,7 @@ public class NMSImpl implements NMSBridge { ((EntityLiving) handle).aK += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/PlayerControllerLook.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/PlayerControllerLook.java deleted file mode 100644 index 146827e0c..000000000 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/PlayerControllerLook.java +++ /dev/null @@ -1,117 +0,0 @@ -package net.citizensnpcs.nms.v1_15_R1.util; - -import net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC; -import net.minecraft.server.v1_15_R1.Entity; -import net.minecraft.server.v1_15_R1.EntityLiving; -import net.minecraft.server.v1_15_R1.MathHelper; -import net.minecraft.server.v1_15_R1.Vec3D; - -public class PlayerControllerLook { - private final EntityHumanNPC a; - protected float b; - protected float c; - protected boolean d; - protected double e; - protected double f; - protected double g; - - public PlayerControllerLook(EntityHumanNPC entityinsentient) { - this.a = entityinsentient; - } - - public void a() { - if (!NMSImpl.isNavigationFinished(this.a.getNavigation())) - return; - if (this.b()) { - // this.a.pitch = 0.0F; - } - if (this.d) { - this.d = false; - this.a.pitch = this.a(this.a.pitch, this.g(), this.c); - this.a.aK = this.a(this.a.aK, this.h(), this.b); - this.a.yaw = this.a.aK; - while (this.a.aK >= 180F) { - this.a.aK -= 360F; - } - while (this.a.aK < -180F) { - this.a.aK += 360F; - } - } else { - // this.a.yaw = MathHelper.b(this.a.yaw, this.a.aK, 40F); - // this.a.aK = this.a(this.a.aK, this.a.aI, 10.0F); - } - if (!this.a.getNavigation().m()) { - this.a.aK = MathHelper.b(this.a.aK, this.a.aI, 75); - } - } - - public void a(double var0, double var2, double var4) { - this.a(var0, var2, var4, 10, 40); - } - - public void a(double var0, double var2, double var4, float var6, float var7) { - double d = Math.pow(this.e - var0, 2) + Math.pow(this.f - var2, 2) + Math.pow(this.g - var4, 2); - if (d < 0.01) { - // return; - } - this.e = var0; - this.f = var2; - this.g = var4; - this.b = var6; - this.c = var7; - this.d = true; - } - - public void a(Entity var0, float var1, float var2) { - this.a(var0.locX(), b(var0), var0.locZ(), var1, var2); - } - - protected float a(float var0, float var1, float var2) { - float var3 = MathHelper.c(var0, var1); - float var4 = MathHelper.a(var3, -var2, var2); - return var0 + var4; - } - - public void a(Vec3D var0) { - this.a(var0.x, var0.y, var0.z); - } - - protected boolean b() { - return true; - } - - public boolean c() { - return this.d; - } - - public double d() { - return this.e; - } - - public double e() { - return this.f; - } - - public double f() { - return this.g; - } - - protected float g() { - double var0 = this.e - this.a.locX(); - double var2 = this.f - (this.a.locY() + this.a.getHeadHeight()); - double var4 = this.g - this.a.locZ(); - double var6 = MathHelper.sqrt(var0 * var0 + var4 * var4); - return (float) (-(MathHelper.d(var2, var6) * 57.2957763671875D)); - } - - protected float h() { - double var0 = this.e - this.a.locX(); - double var2 = this.g - this.a.locZ(); - return (float) (MathHelper.d(var2, var0) * 57.2957763671875D) - 90.0F; - } - - private static double b(Entity var0) { - return var0 instanceof EntityLiving ? var0.locY() + var0.getHeadHeight() - : (var0.getBoundingBox().minY + var0.getBoundingBox().maxY) / 2.0D; - } -} \ No newline at end of file diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/EntityHumanNPC.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/EntityHumanNPC.java index 303cfe327..be8c70226 100644 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/EntityHumanNPC.java +++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/EntityHumanNPC.java @@ -33,7 +33,6 @@ import net.citizensnpcs.nms.v1_16_R3.network.EmptySocket; import net.citizensnpcs.nms.v1_16_R3.util.EmptyAdvancementDataPlayer; import net.citizensnpcs.nms.v1_16_R3.util.NMSImpl; import net.citizensnpcs.nms.v1_16_R3.util.PlayerControllerJump; -import net.citizensnpcs.nms.v1_16_R3.util.PlayerControllerLook; import net.citizensnpcs.nms.v1_16_R3.util.PlayerControllerMove; import net.citizensnpcs.nms.v1_16_R3.util.PlayerNavigation; import net.citizensnpcs.nms.v1_16_R3.util.PlayerlistTracker; @@ -52,7 +51,6 @@ import net.minecraft.server.v1_16_R3.AttributeProvider; import net.minecraft.server.v1_16_R3.BlockPosition; import net.minecraft.server.v1_16_R3.ChatComponentText; import net.minecraft.server.v1_16_R3.DamageSource; -import net.minecraft.server.v1_16_R3.Entity; import net.minecraft.server.v1_16_R3.EntityHuman; import net.minecraft.server.v1_16_R3.EntityPlayer; import net.minecraft.server.v1_16_R3.EnumGamemode; @@ -75,7 +73,6 @@ import net.minecraft.server.v1_16_R3.WorldServer; public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity { private final Map bz = Maps.newEnumMap(PathType.class); private PlayerControllerJump controllerJump; - private PlayerControllerLook controllerLook; private PlayerControllerMove controllerMove; private final Map equipmentCache = Maps.newEnumMap(EnumItemSlot.class); private int jumpTicks = 0; @@ -306,7 +303,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble()); controllerJump = new PlayerControllerJump(this); - controllerLook = new PlayerControllerLook(this); controllerMove = new PlayerControllerMove(this); navigation = new PlayerNavigation(this, world); invulnerableTicks = 0; @@ -433,14 +429,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data); } - public void setTargetLook(Entity target, float yawOffset, float renderOffset) { - controllerLook.a(target, yawOffset, renderOffset); - } - - public void setTargetLook(Location target) { - controllerLook.a(target.getX(), target.getY(), target.getZ()); - } - public void setTracked(PlayerlistTracker tracker) { this.playerlistTracker = tracker; } @@ -474,7 +462,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable public void updateAI() { controllerMove.a(); - controllerLook.a(); controllerJump.b(); } diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java index 952b112e8..2b45f2459 100644 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java +++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java @@ -186,6 +186,7 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.skin.SkinnableEntity; +import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.BeeTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.CatTrait; @@ -943,7 +944,7 @@ public class NMSImpl implements NMSBridge { ((EntityLiving) handle).aC += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(to); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } @@ -967,7 +968,7 @@ public class NMSImpl implements NMSBridge { ((EntityLiving) handle).aC += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/PlayerControllerLook.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/PlayerControllerLook.java deleted file mode 100644 index 5f6739e2f..000000000 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/PlayerControllerLook.java +++ /dev/null @@ -1,141 +0,0 @@ -package net.citizensnpcs.nms.v1_16_R3.util; - -import net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC; -import net.minecraft.server.v1_16_R3.Entity; -import net.minecraft.server.v1_16_R3.EntityLiving; -import net.minecraft.server.v1_16_R3.MathHelper; -import net.minecraft.server.v1_16_R3.Vec3D; - -public class PlayerControllerLook { - private final EntityHumanNPC a; - protected float b; - protected float c; - private final PlayerBodyControl control; - protected boolean d; - protected double e; - protected double f; - protected double g; - - public PlayerControllerLook(EntityHumanNPC entityinsentient) { - this.a = entityinsentient; - this.control = new PlayerBodyControl(this.a); - } - - public void a() { - if (!NMSImpl.isNavigationFinished(this.a.getNavigation())) - return; - if (this.b()) { - // this.a.pitch = 0.0F; - } - if (this.d) { - this.d = false; - this.a.pitch = this.a(this.a.pitch, this.g(), this.c); - this.a.aC = this.a(this.a.aC, this.h(), this.b); - while (this.a.aC >= 180F) { - this.a.aC -= 360F; - } - while (this.a.aC < -180F) { - this.a.aC += 360F; - } - double d = this.a.aC - 40; - while (d >= 180F) { - d -= 360F; - } - while (d < -180F) { - d += 360F; - } - if (d > this.a.yaw) { - this.a.yaw = (float) d; - } - if (d != this.a.yaw) { - d = this.a.aC + 40; - while (d >= 180F) { - d -= 360F; - } - while (d < -180F) { - d += 360F; - } - if (d < this.a.yaw) { - this.a.yaw = (float) d; - } - } - // this.a.yaw = this.a(this.a.aC, this.h(), this.b); - } else { - // this.a.yaw = MathHelper.b(this.a.yaw, this.a.aC, 40F); - // this.a.aK = this.a(this.a.aC, this.a.aA, 10.0F); - } - if (!this.a.getNavigation().m()) { - this.a.aC = MathHelper.b(this.a.aC, this.a.aA, 75); - } - } - - public void a(double var0, double var2, double var4) { - this.a(var0, var2, var4, 10, 40); - } - - public void a(double var0, double var2, double var4, float var6, float var7) { - double d = Math.pow(this.e - var0, 2) + Math.pow(this.f - var2, 2) + Math.pow(this.g - var4, 2); - if (d < 0.01) { - // return; - } - this.e = var0; - this.f = var2; - this.g = var4; - this.b = var6; - this.c = var7; - this.d = true; - } - - public void a(Entity var0, float var1, float var2) { - this.a(var0.locX(), b(var0), var0.locZ(), var1, var2); - } - - protected float a(float var0, float var1, float var2) { - float var3 = MathHelper.c(var0, var1); - float var4 = MathHelper.a(var3, -var2, var2); - return var0 + var4; - } - - public void a(Vec3D var0) { - this.a(var0.x, var0.y, var0.z); - } - - protected boolean b() { - return true; - } - - public boolean c() { - return this.d; - } - - public double d() { - return this.e; - } - - public double e() { - return this.f; - } - - public double f() { - return this.g; - } - - protected float g() { - double var0 = this.e - this.a.locX(); - double var2 = this.f - (this.a.locY() + this.a.getHeadHeight()); - double var4 = this.g - this.a.locZ(); - double var6 = MathHelper.sqrt(var0 * var0 + var4 * var4); - return (float) (-(MathHelper.d(var2, var6) * 57.2957763671875D)); - } - - protected float h() { - double var0 = this.e - this.a.locX(); - double var2 = this.g - this.a.locZ(); - return (float) (MathHelper.d(var2, var0) * 57.2957763671875D) - 90.0F; - } - - private static double b(Entity var0) { - return var0 instanceof EntityLiving ? var0.locY() + var0.getHeadHeight() - : (var0.getBoundingBox().minY + var0.getBoundingBox().maxY) / 2.0D; - } -} \ No newline at end of file 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 0d7d10234..4d9ed3cd1 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 @@ -34,7 +34,6 @@ import net.citizensnpcs.nms.v1_17_R1.util.EmptyAdvancementDataPlayer; import net.citizensnpcs.nms.v1_17_R1.util.EmptyServerStatsCounter; import net.citizensnpcs.nms.v1_17_R1.util.NMSImpl; import net.citizensnpcs.nms.v1_17_R1.util.PlayerControllerJump; -import net.citizensnpcs.nms.v1_17_R1.util.PlayerLookControl; import net.citizensnpcs.nms.v1_17_R1.util.PlayerMoveControl; import net.citizensnpcs.nms.v1_17_R1.util.PlayerNavigation; import net.citizensnpcs.nms.v1_17_R1.util.PlayerlistTracker; @@ -74,7 +73,6 @@ import net.minecraft.world.phys.Vec3; public class EntityHumanNPC extends ServerPlayer implements NPCHolder, SkinnableEntity { private PlayerControllerJump controllerJump; - private PlayerLookControl controllerLook; private PlayerMoveControl controllerMove; private final Map equipmentCache = Maps.newEnumMap(EquipmentSlot.class); private int jumpTicks = 0; @@ -322,7 +320,6 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable range.setBaseValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble()); controllerJump = new PlayerControllerJump(this); - controllerLook = new PlayerLookControl(this); controllerMove = new PlayerMoveControl(this); navigation = new PlayerNavigation(this, level); this.invulnerableTime = 0; @@ -445,14 +442,6 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data); } - public void setTargetLook(Entity target, float yawOffset, float renderOffset) { - controllerLook.a(target, yawOffset, renderOffset); - } - - public void setTargetLook(Location target) { - controllerLook.a(target.getX(), target.getY(), target.getZ()); - } - public void setTracked(PlayerlistTracker tracker) { this.playerlistTracker = tracker; } @@ -484,7 +473,6 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable public void updateAI() { controllerMove.tick(); - controllerLook.a(); controllerJump.b(); } diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java index 5c63ed6c6..a786a2e6f 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java @@ -189,6 +189,7 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.skin.SkinnableEntity; +import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.AxolotlTrait; import net.citizensnpcs.trait.versioned.BeeTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; @@ -951,7 +952,7 @@ public class NMSImpl implements NMSBridge { ((LivingEntity) handle).yHeadRot += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(to); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } @@ -975,7 +976,7 @@ public class NMSImpl implements NMSBridge { ((LivingEntity) handle).yHeadRot += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/PlayerLookControl.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/PlayerLookControl.java deleted file mode 100644 index 7091d35c5..000000000 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/PlayerLookControl.java +++ /dev/null @@ -1,140 +0,0 @@ -package net.citizensnpcs.nms.v1_17_R1.util; - -import net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC; -import net.minecraft.util.Mth; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.phys.Vec3; - -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; - - public PlayerLookControl(EntityHumanNPC entityinsentient) { - this.a = entityinsentient; - this.control = new PlayerBodyControl(this.a); - } - - public void a() { - if (!this.a.getNavigation().isDone()) { - // TODO: use Citizens AI? - // this.a.yHeadRot = Mth.rotateIfNecessary(this.a.yHeadRot, this.a.yBodyRot, 75); - return; - } - if (this.b()) { - // this.a.setXRot(0.0F); - } - 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); - while (this.a.yHeadRot >= 180F) { - this.a.yHeadRot -= 360F; - } - while (this.a.yHeadRot < -180F) { - this.a.yHeadRot += 360F; - } - double d = this.a.yHeadRot - 40; - while (d >= 180F) { - d -= 360F; - } - while (d < -180F) { - d += 360F; - } - if (d > this.a.getYRot()) { - this.a.setYRot((float) d); - } - if (d != this.a.getYRot()) { - d = this.a.yHeadRot + 40; - while (d >= 180F) { - d -= 360F; - } - while (d < -180F) { - d += 360F; - } - if (d < this.a.getYRot()) { - this.a.setYRot((float) d); - } - } - // this.a.setYRot(this.a(this.a.yHeadRot, this.h(), this.b)); - } else { - // this.a.yHeadRot = rotateTowards(this.a.yHeadRot, this.a.yBodyRot, 10.0F); - } - } - - public void a(double var0, double var2, double var4) { - this.a(var0, var2, var4, 10, 40); - } - - public void a(double var0, double var2, double var4, float var6, float var7) { - double d = Math.pow(this.tx - var0, 2) + Math.pow(this.ty - var2, 2) + Math.pow(this.tz - var4, 2); - if (d < 0.01) { - // return; - } - this.tx = var0; - this.ty = var2; - this.tz = var4; - this.tyaw = var6; - this.tpitch = var7; - this.looking = true; - } - - public void a(Entity var0, float var1, float var2) { - this.a(var0.getX(), b(var0), var0.getZ(), var1, var2); - } - - public void a(Vec3 var0) { - this.a(var0.x, var0.y, var0.z); - } - - protected boolean b() { - return true; - } - - public boolean c() { - return this.looking; - } - - public double d() { - return this.tx; - } - - public double e() { - return this.ty; - } - - public double f() { - return this.tz; - } - - protected float g() { - double var0 = this.tx - this.a.getX(); - double var2 = this.ty - (this.a.getY() + 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() { - double var0 = this.tx - this.a.getX(); - double var2 = this.tz - this.a.getZ(); - return (float) (Mth.atan2(var2, var0) * 57.2957763671875D) - 90.0F; - } - - protected float rotateTowards(float var0, float var1, float var2) { - float var3 = Mth.degreesDifference(var0, var1); - float var4 = Mth.clamp(var3, -var2, var2); - return var0 + var4; - } - - private static double b(Entity var0) { - return var0 instanceof LivingEntity ? var0.getY() + var0.getEyeY() - : (var0.getBoundingBox().minY + var0.getBoundingBox().maxY) / 2.0D; - } -} \ No newline at end of file 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 1be476da7..bdbd05a65 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 @@ -35,7 +35,6 @@ import net.citizensnpcs.nms.v1_18_R2.util.EmptyAdvancementDataPlayer; import net.citizensnpcs.nms.v1_18_R2.util.EmptyServerStatsCounter; import net.citizensnpcs.nms.v1_18_R2.util.NMSImpl; import net.citizensnpcs.nms.v1_18_R2.util.PlayerControllerJump; -import net.citizensnpcs.nms.v1_18_R2.util.PlayerLookControl; import net.citizensnpcs.nms.v1_18_R2.util.PlayerMoveControl; import net.citizensnpcs.nms.v1_18_R2.util.PlayerNavigation; import net.citizensnpcs.nms.v1_18_R2.util.PlayerlistTracker; @@ -75,7 +74,6 @@ import net.minecraft.world.phys.Vec3; public class EntityHumanNPC extends ServerPlayer implements NPCHolder, SkinnableEntity { private PlayerControllerJump controllerJump; - private PlayerLookControl controllerLook; private PlayerMoveControl controllerMove; private final Map equipmentCache = Maps.newEnumMap(EquipmentSlot.class); private int jumpTicks = 0; @@ -324,7 +322,6 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable range.setBaseValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble()); controllerJump = new PlayerControllerJump(this); - controllerLook = new PlayerLookControl(this); controllerMove = new PlayerMoveControl(this); navigation = new PlayerNavigation(this, level); this.invulnerableTime = 0; @@ -445,14 +442,6 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data); } - public void setTargetLook(Entity target, float yawOffset, float renderOffset) { - controllerLook.a(target, yawOffset, renderOffset); - } - - public void setTargetLook(Location target) { - controllerLook.a(target.getX(), target.getY(), target.getZ()); - } - public void setTracked(PlayerlistTracker tracker) { this.playerlistTracker = tracker; } @@ -483,7 +472,6 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable public void updateAI() { controllerMove.tick(); - controllerLook.tick(); controllerJump.tick(); } diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java index b673bc025..e6bcc774f 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java @@ -191,6 +191,7 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.skin.SkinnableEntity; +import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.AxolotlTrait; import net.citizensnpcs.trait.versioned.BeeTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; @@ -957,7 +958,7 @@ public class NMSImpl implements NMSBridge { ((LivingEntity) handle).yHeadRot += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(to); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } @@ -982,7 +983,7 @@ public class NMSImpl implements NMSBridge { ((LivingEntity) handle).yHeadRot += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } 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 deleted file mode 100644 index 972d6497e..000000000 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/PlayerLookControl.java +++ /dev/null @@ -1,140 +0,0 @@ -package net.citizensnpcs.nms.v1_18_R2.util; - -import net.citizensnpcs.nms.v1_18_R2.entity.EntityHumanNPC; -import net.minecraft.util.Mth; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.phys.Vec3; - -public class PlayerLookControl { - private final EntityHumanNPC a; - private final PlayerBodyControl control; - protected boolean looking; - protected double tx; - protected double ty; - protected double tz; - protected float xMaxRotAngle; - protected float yMaxRotSpeed; - - public PlayerLookControl(EntityHumanNPC entityinsentient) { - this.a = entityinsentient; - this.control = new PlayerBodyControl(this.a); - } - - public void a(double var0, double var2, double var4) { - this.a(var0, var2, var4, 10, 40); - } - - public void a(double var0, double var2, double var4, float var6, float var7) { - double d = Math.pow(this.tx - var0, 2) + Math.pow(this.ty - var2, 2) + Math.pow(this.tz - var4, 2); - if (d < 0.01) { - // return; - } - this.tx = var0; - this.ty = var2; - this.tz = var4; - this.yMaxRotSpeed = var6; - this.xMaxRotAngle = var7; - this.looking = true; - } - - public void a(Entity var0, float var1, float var2) { - this.a(var0.getX(), b(var0), var0.getZ(), var1, var2); - } - - public void a(Vec3 var0) { - this.a(var0.x, var0.y, var0.z); - } - - protected boolean b() { - return true; - } - - public boolean c() { - return this.looking; - } - - public double d() { - return this.tx; - } - - public double e() { - return this.ty; - } - - public double f() { - return this.tz; - } - - protected float getXRotD() { - double var0 = this.tx - this.a.getX(); - double var2 = this.ty - (this.a.getY() + 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 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; - } - - protected float rotateTowards(float var0, float var1, float var2) { - float var3 = Mth.degreesDifference(var0, var1); - float var4 = Mth.clamp(var3, -var2, var2); - return var0 + var4; - } - - public void tick() { - if (!this.a.getNavigation().isDone()) { - // TODO: use Citizens AI? - // this.a.yHeadRot = Mth.rotateIfNecessary(this.a.yHeadRot, this.a.yBodyRot, 75); - return; - } - if (this.b()) { - // this.a.setXRot(0.0F); - } - if (this.looking) { - this.looking = false; - 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; - } - while (this.a.yHeadRot < -180F) { - this.a.yHeadRot += 360F; - } - double d = this.a.yHeadRot - 40; - while (d >= 180F) { - d -= 360F; - } - while (d < -180F) { - d += 360F; - } - if (d > this.a.getYRot()) { - this.a.setYRot((float) d); - } - if (d != this.a.getYRot()) { - d = this.a.yHeadRot + 40; - while (d >= 180F) { - d -= 360F; - } - while (d < -180F) { - d += 360F; - } - if (d < this.a.getYRot()) { - this.a.setYRot((float) d); - } - } - // this.a.setYRot(this.a(this.a.yHeadRot, this.h(), this.b)); - } else { - // this.a.yHeadRot = rotateTowards(this.a.yHeadRot, this.a.yBodyRot, 10.0F); - } - } - - private static double b(Entity var0) { - return var0 instanceof LivingEntity ? var0.getY() + var0.getEyeY() - : (var0.getBoundingBox().minY + var0.getBoundingBox().maxY) / 2.0D; - } -} \ No newline at end of file diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java index 8524a79a7..9f5ebf370 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java @@ -26,7 +26,6 @@ import net.citizensnpcs.nms.v1_8_R3.network.EmptyNetworkManager; import net.citizensnpcs.nms.v1_8_R3.network.EmptySocket; import net.citizensnpcs.nms.v1_8_R3.util.NMSImpl; import net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerJump; -import net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerLook; import net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerMove; import net.citizensnpcs.nms.v1_8_R3.util.PlayerNavigation; import net.citizensnpcs.nms.v1_8_R3.util.PlayerlistTrackerEntry; @@ -43,7 +42,6 @@ import net.minecraft.server.v1_8_R3.Block; import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.DamageSource; import net.minecraft.server.v1_8_R3.DataWatcher; -import net.minecraft.server.v1_8_R3.Entity; import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.EnumProtocolDirection; import net.minecraft.server.v1_8_R3.GenericAttributes; @@ -59,7 +57,6 @@ import net.minecraft.server.v1_8_R3.WorldSettings; public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity { private PlayerControllerJump controllerJump; - private PlayerControllerLook controllerLook; private PlayerControllerMove controllerMove; private final TIntObjectHashMap equipmentCache = new TIntObjectHashMap(); private int jumpTicks = 0; @@ -254,7 +251,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble()); controllerJump = new PlayerControllerJump(this); - controllerLook = new PlayerControllerLook(this); controllerMove = new PlayerControllerMove(this); navigation = new PlayerNavigation(this, world); invulnerableTicks = 0; @@ -363,14 +359,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data); } - public void setTargetLook(Entity target, float yawOffset, float renderOffset) { - controllerLook.a(target, yawOffset, renderOffset); - } - - public void setTargetLook(Location target) { - controllerLook.a(target.getX(), target.getY(), target.getZ(), 10, 40); - } - public void setTracked(PlayerlistTrackerEntry trackerEntry) { this.trackerEntry = trackerEntry; } @@ -394,7 +382,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable public void updateAI() { controllerMove.c(); - controllerLook.a(); controllerJump.b(); } diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java index 6010731a6..3bcf517ba 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java @@ -130,6 +130,7 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.skin.SkinnableEntity; +import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.util.Messages; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMSBridge; @@ -686,7 +687,7 @@ public class NMSImpl implements NMSBridge { ((EntityInsentient) handle).aK += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(to); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } @@ -709,7 +710,7 @@ public class NMSImpl implements NMSBridge { ((EntityLiving) handle).aK += 360F; } } else if (handle instanceof EntityHumanNPC) { - ((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F); + ((EntityHumanNPC) handle).getNPC().getOrAddTrait(RotationTrait.class).rotateToFace(to); } } diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/PlayerControllerLook.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/PlayerControllerLook.java deleted file mode 100644 index 0a3be90ae..000000000 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/PlayerControllerLook.java +++ /dev/null @@ -1,126 +0,0 @@ -package net.citizensnpcs.nms.v1_8_R3.util; - -import net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC; -import net.minecraft.server.v1_8_R3.Entity; -import net.minecraft.server.v1_8_R3.EntityLiving; -import net.minecraft.server.v1_8_R3.MathHelper; - -public class PlayerControllerLook { - private final EntityHumanNPC a; - private float b; - private float c; - private boolean d; - private double e; - private double f; - private double g; - - public PlayerControllerLook(EntityHumanNPC entityinsentient) { - this.a = entityinsentient; - } - - public void a() { - if (!NMSImpl.isNavigationFinished(this.a.getNavigation())) - return; - // this.a.pitch = 0.0F; - this.a.aI = this.a.aK; - if (this.d) { - this.d = false; - - double d1 = this.e - this.a.locX; - double d2 = this.f - (this.a.locY + this.a.getHeadHeight()); - double d3 = this.g - this.a.locZ; - double d4 = MathHelper.sqrt(d1 * d1 + d3 * d3); - - float f1 = (float) (MathHelper.b(d3, d1) * 57.2957763671875D) - 90.0F; - float f2 = (float) -(MathHelper.b(d2, d4) * 57.2957763671875D); - this.a.pitch = a(this.a.pitch, f2, this.c); - this.a.aK = a(this.a.aK, f1, this.b); - this.a.yaw = this.a.aK; - while (this.a.aK >= 180F) { - this.a.aK -= 360F; - } - while (this.a.aK < -180F) { - this.a.aK += 360F; - } - } else { - // this.a.yaw = b(this.a.yaw, this.a.aK, -40F); - // this.a.aK = a(this.a.aK, this.a.aI, 10.0F); - } - float f3 = MathHelper.g(this.a.aK - this.a.aI); - if (!this.a.getNavigation().m()) { - if (f3 < -75.0F) { - this.a.aK = (this.a.aI - 75.0F); - } - if (f3 > 75.0F) { - this.a.aK = (this.a.aI + 75.0F); - } - } - } - - public void a(double d0, double d1, double d2, float f, float f1) { - double d = Math.pow(this.e - d0, 2) + Math.pow(this.f - d1, 2) + Math.pow(this.g - d2, 2); - if (d < 0.01) { - // return; - } - this.e = d0; - this.f = d1; - this.g = d2; - this.b = f; - this.c = f1; - this.d = true; - } - - public void a(Entity entity, float f, float f1) { - this.e = entity.locX; - if ((entity instanceof EntityLiving)) - this.f = (entity.locY + entity.getHeadHeight()); - else { - this.f = ((entity.getBoundingBox().b + entity.getBoundingBox().e) / 2.0D); - } - - this.g = entity.locZ; - this.b = f; - this.c = f1; - this.d = true; - } - - private float a(float f, float f1, float f2) { - float f3 = MathHelper.g(f1 - f); - - if (f3 > f2) { - f3 = f2; - } - - if (f3 < -f2) { - f3 = -f2; - } - - return f + f3; - } - - public boolean b() { - return this.d; - } - - public float b(float var0, float var1, float var2) { - float var3 = c(var0, var1); - float var4 = MathHelper.a(var3, -var2, var2); - return var1 - var4; - } - - public float c(float var0, float var1) { - return MathHelper.g(var1 - var0); - } - - public double e() { - return this.e; - } - - public double f() { - return this.f; - } - - public double g() { - return this.g; - } -} \ No newline at end of file