Skip to content

Commit

Permalink
make Look rotate the NPC's head reasonably
Browse files Browse the repository at this point in the history
Trust the Citizens Util stuff for NMS wherever possible. It's silly
having to try to update the NMS function names ourselves.
  • Loading branch information
mcmonkey4eva committed Aug 11, 2013
1 parent 5f2293e commit 833b33e
Showing 1 changed file with 2 additions and 22 deletions.
Expand Up @@ -9,6 +9,7 @@
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import net.citizensnpcs.util.NMS;

/**
* Utilities related to entity yaws and pitches.
Expand Down Expand Up @@ -46,29 +47,8 @@ public static void rotate(Entity entity, float yaw, float pitch)

if (entity instanceof LivingEntity)
{
EntityLiving handle = ((CraftLivingEntity) entity).getHandle();
handle.yaw = (float) yaw;
handle.pitch = (float) pitch;
// !--- START NMS OBFUSCATED
handle.aA = handle.yaw; // The head's yaw
// !--- END NMS OBFUSCATED

if (!(entity instanceof Player))
{
// Obfuscated variable used in head turning. If not set to
// be equal to the yaw, non-Player entities will not rotate.
// But do not use on Player entities, because it will break
// their rotation.
//
// In case it ever gets renamed, this EntityLiving line is
// the one with it:
//
// float f5 = MathHelper.g(this.yaw - this.ax);

handle.ax = handle.yaw;
}
NMS.look((LivingEntity)entity, yaw, pitch);
}

else
{
net.minecraft.server.v1_6_R2.Entity handle = ((CraftEntity) entity).getHandle();
Expand Down

0 comments on commit 833b33e

Please sign in to comment.