Don't set body yaw with head yaw

This commit is contained in:
fullwall 2023-12-11 23:17:34 +08:00
parent 50caa007e7
commit 06b0e2d800
31 changed files with 167 additions and 79 deletions

View File

@ -9,7 +9,7 @@
<artifactId>citizens-main</artifactId> <artifactId>citizens-main</artifactId>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<craftbukkit.version>1.20.2-R0.1-SNAPSHOT</craftbukkit.version> <craftbukkit.version>1.20.4-R0.1-SNAPSHOT</craftbukkit.version>
<placeholderapi.version>2.11.2</placeholderapi.version> <placeholderapi.version>2.11.2</placeholderapi.version>
<citizensapi.version>${project.version}</citizensapi.version> <citizensapi.version>${project.version}</citizensapi.version>
<worldguard.version>7.1.0-SNAPSHOT</worldguard.version> <worldguard.version>7.1.0-SNAPSHOT</worldguard.version>

View File

@ -438,7 +438,7 @@ public class CitizensNPC extends AbstractNPC {
Location npcLoc = getEntity().getLocation(); Location npcLoc = getEntity().getLocation();
if (isSpawned() && npcLoc.getWorld() == location.getWorld()) { if (isSpawned() && npcLoc.getWorld() == location.getWorld()) {
if (npcLoc.distance(location) < 1) { if (npcLoc.distance(location) < 1) {
NMS.setHeadYaw(getEntity(), location.getYaw()); NMS.setHeadAndBodyYaw(getEntity(), location.getYaw());
} }
if (getEntity().getType() == EntityType.PLAYER && !getEntity().isInsideVehicle() if (getEntity().getType() == EntityType.PLAYER && !getEntity().isInsideVehicle()
&& NMS.getPassengers(getEntity()).size() == 0) { && NMS.getPassengers(getEntity()).size() == 0) {

View File

@ -108,7 +108,7 @@ public class StraightLineNavigationStrategy extends AbstractPathStrategy {
} }
if (npc.getEntity().getType() != EntityType.ENDER_DRAGON) { if (npc.getEntity().getType() != EntityType.ENDER_DRAGON) {
NMS.setVerticalMovement(npc.getEntity(), 0.5); NMS.setVerticalMovement(npc.getEntity(), 0.5);
NMS.setHeadYaw(npc.getEntity(), currLoc.getYaw() + normalisedTargetYaw); NMS.setHeadAndBodyYaw(npc.getEntity(), currLoc.getYaw() + normalisedTargetYaw);
} }
} else if (npc.getEntity() instanceof LivingEntity) { } else if (npc.getEntity() instanceof LivingEntity) {
NMS.setDestination(npc.getEntity(), destVector.getX(), destVector.getY(), destVector.getZ(), NMS.setDestination(npc.getEntity(), destVector.getX(), destVector.getY(), destVector.getZ(),

View File

@ -54,9 +54,9 @@ import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.BoundingBox; import net.citizensnpcs.api.util.BoundingBox;
import net.citizensnpcs.api.util.EntityDim; import net.citizensnpcs.api.util.EntityDim;
import net.citizensnpcs.api.util.Messaging; import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity; import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.MirrorTrait; import net.citizensnpcs.trait.MirrorTrait;
import net.citizensnpcs.trait.PacketNPC; import net.citizensnpcs.trait.PacketNPC;
@ -198,6 +198,10 @@ public class NMS {
return BRIDGE.getBoundingBox(handle); return BRIDGE.getBoundingBox(handle);
} }
public static double getBoundingBoxHeight(Entity entity) {
return BRIDGE.getBoundingBoxHeight(entity);
}
public static BoundingBox getCollisionBox(Block block) { public static BoundingBox getCollisionBox(Block block) {
if (block.getType() == Material.AIR) if (block.getType() == Material.AIR)
return BoundingBox.EMPTY; return BoundingBox.EMPTY;
@ -462,10 +466,6 @@ public class NMS {
return BRIDGE.getHeadYaw(entity); return BRIDGE.getHeadYaw(entity);
} }
public static double getBoundingBoxHeight(Entity entity) {
return BRIDGE.getBoundingBoxHeight(entity);
}
public static float getHorizontalMovement(org.bukkit.entity.Entity bukkitEntity) { public static float getHorizontalMovement(org.bukkit.entity.Entity bukkitEntity) {
return BRIDGE.getHorizontalMovement(bukkitEntity); return BRIDGE.getHorizontalMovement(bukkitEntity);
} }
@ -790,6 +790,10 @@ public class NMS {
BRIDGE.setEndermanAngry(enderman, angry); BRIDGE.setEndermanAngry(enderman, angry);
} }
public static void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
BRIDGE.setHeadAndBodyYaw(entity, yaw);
}
public static void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) { public static void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
BRIDGE.setHeadYaw(entity, yaw); BRIDGE.setHeadYaw(entity, yaw);
} }

View File

@ -74,6 +74,10 @@ public interface NMSBridge {
public BoundingBox getBoundingBox(Entity handle); public BoundingBox getBoundingBox(Entity handle);
public default double getBoundingBoxHeight(Entity entity) {
return entity.getHeight();
}
public BoundingBox getCollisionBox(Block block); public BoundingBox getCollisionBox(Block block);
public Location getDestination(Entity entity); public Location getDestination(Entity entity);
@ -82,10 +86,6 @@ public interface NMSBridge {
public float getHeadYaw(Entity entity); public float getHeadYaw(Entity entity);
public default double getBoundingBoxHeight(Entity entity) {
return entity.getHeight();
}
public float getHorizontalMovement(Entity entity); public float getHorizontalMovement(Entity entity);
public CompoundTag getNBT(ItemStack item); public CompoundTag getNBT(ItemStack item);
@ -201,6 +201,8 @@ public interface NMSBridge {
public void setEndermanAngry(Enderman enderman, boolean angry); public void setEndermanAngry(Enderman enderman, boolean angry);
public void setHeadAndBodyYaw(Entity entity, float yaw);
public void setHeadYaw(Entity entity, float yaw); public void setHeadYaw(Entity entity, float yaw);
public void setKnockbackResistance(LivingEntity entity, double d); public void setKnockbackResistance(LivingEntity entity, double d);

View File

@ -331,7 +331,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
bg *= 0.98F; bg *= 0.98F;
bh *= 0.9F; bh *= 0.9F;
moveWithFallDamage(bf, bg); // movement method moveWithFallDamage(bf, bg); // movement method
NMS.setHeadYaw(getBukkitEntity(), yaw); NMS.setHeadAndBodyYaw(getBukkitEntity(), yaw);
if (jumpTicks > 0) { if (jumpTicks > 0) {
jumpTicks--; jumpTicks--;
} }

View File

@ -167,9 +167,9 @@ import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.ThrownPotionController;
import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.TippedArrowController; import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.TippedArrowController;
import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.WitherSkullController; import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.WitherSkullController;
import net.citizensnpcs.npc.EntityControllers; import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity; import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.BossBarTrait;
@ -446,6 +446,11 @@ public class NMSImpl implements NMSBridge {
return new BoundingBox(bb.a, bb.b, bb.c, bb.d, bb.e, bb.f); return new BoundingBox(bb.a, bb.b, bb.c, bb.d, bb.e, bb.f);
} }
@Override
public double getBoundingBoxHeight(org.bukkit.entity.Entity entity) {
return getHandle(entity).length;
}
@Override @Override
public BoundingBox getCollisionBox(org.bukkit.block.Block block) { public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
WorldServer world = ((CraftWorld) block.getWorld()).getHandle(); WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
@ -479,11 +484,6 @@ public class NMSImpl implements NMSBridge {
return getHandle((LivingEntity) entity).aQ; return getHandle((LivingEntity) entity).aQ;
} }
@Override
public double getBoundingBoxHeight(org.bukkit.entity.Entity entity) {
return getHandle(entity).length;
}
@Override @Override
public float getHorizontalMovement(org.bukkit.entity.Entity entity) { public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
if (!entity.getType().isAlive()) if (!entity.getType().isAlive())
@ -1201,16 +1201,23 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) { public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity)) if (!(entity instanceof LivingEntity))
return; return;
EntityLiving handle = (EntityLiving) getHandle(entity); EntityLiving handle = (EntityLiving) getHandle(entity);
yaw = Util.clamp(yaw); yaw = Util.clamp(yaw);
handle.aP = yaw; handle.aP = yaw;
if (!(handle instanceof EntityHuman)) { if (!(handle instanceof EntityHuman)) {
handle.aO = yaw; handle.aO = yaw; // TODO: why this
} }
handle.aQ = yaw; setHeadYaw(entity, yaw);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
((EntityLiving) getHandle(entity)).aQ = Util.clamp(yaw);
} }
@Override @Override

View File

@ -301,7 +301,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
bf *= 0.98F; bf *= 0.98F;
bg *= 0.9F; bg *= 0.9F;
moveWithFallDamage(be, bf); // movement method moveWithFallDamage(be, bf); // movement method
NMS.setHeadYaw(getBukkitEntity(), yaw); NMS.setHeadAndBodyYaw(getBukkitEntity(), yaw);
if (jumpTicks > 0) { if (jumpTicks > 0) {
jumpTicks--; jumpTicks--;
} }

View File

@ -182,9 +182,9 @@ import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.ThrownPotionController;
import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.TippedArrowController; import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.TippedArrowController;
import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.WitherSkullController; import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.WitherSkullController;
import net.citizensnpcs.npc.EntityControllers; import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity; import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.BossBarTrait;
@ -466,6 +466,11 @@ public class NMSImpl implements NMSBridge {
return new BoundingBox(bb.a, bb.b, bb.c, bb.d, bb.e, bb.f); return new BoundingBox(bb.a, bb.b, bb.c, bb.d, bb.e, bb.f);
} }
@Override
public double getBoundingBoxHeight(org.bukkit.entity.Entity entity) {
return getHandle(entity).length;
}
@Override @Override
public BoundingBox getCollisionBox(org.bukkit.block.Block block) { public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
WorldServer world = ((CraftWorld) block.getWorld()).getHandle(); WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
@ -499,11 +504,6 @@ public class NMSImpl implements NMSBridge {
return getHandle((LivingEntity) entity).aP; return getHandle((LivingEntity) entity).aP;
} }
@Override
public double getBoundingBoxHeight(org.bukkit.entity.Entity entity) {
return getHandle(entity).length;
}
@Override @Override
public float getHorizontalMovement(org.bukkit.entity.Entity entity) { public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
if (!entity.getType().isAlive()) if (!entity.getType().isAlive())
@ -1254,16 +1254,23 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) { public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity)) if (!(entity instanceof LivingEntity))
return; return;
EntityLiving handle = (EntityLiving) getHandle(entity); EntityLiving handle = (EntityLiving) getHandle(entity);
yaw = Util.clamp(yaw); yaw = Util.clamp(yaw);
handle.aO = yaw; handle.aO = yaw;
if (!(handle instanceof EntityHuman)) { if (!(handle instanceof EntityHuman)) {
handle.aN = yaw; handle.aN = yaw; // TODO: why this
} }
handle.aP = yaw; setHeadYaw(entity, yaw);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
((EntityLiving) getHandle(entity)).aP = Util.clamp(yaw);
} }
@Override @Override

View File

@ -318,7 +318,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
bg *= 0.98F; bg *= 0.98F;
bh *= 0.9F; bh *= 0.9F;
moveWithFallDamage(be, bf, bg); // movement method moveWithFallDamage(be, bf, bg); // movement method
NMS.setHeadYaw(getBukkitEntity(), yaw); NMS.setHeadAndBodyYaw(getBukkitEntity(), yaw);
if (jumpTicks > 0) { if (jumpTicks > 0) {
jumpTicks--; jumpTicks--;
} }

View File

@ -1261,16 +1261,23 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) { public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity)) if (!(entity instanceof LivingEntity))
return; return;
EntityLiving handle = (EntityLiving) getHandle(entity); EntityLiving handle = (EntityLiving) getHandle(entity);
yaw = Util.clamp(yaw); yaw = Util.clamp(yaw);
handle.aO = yaw; handle.aO = yaw;
if (!(handle instanceof EntityHuman)) { if (!(handle instanceof EntityHuman)) {
handle.aN = yaw; handle.aN = yaw; // TODO: why this
} }
handle.aP = yaw; setHeadYaw(entity, yaw);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
((EntityLiving) getHandle(entity)).aP = Util.clamp(yaw);
} }
@Override @Override

View File

@ -294,7 +294,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
bj *= 0.98F; bj *= 0.98F;
bk *= 0.9F; bk *= 0.9F;
moveWithFallDamage(bh, bi, bj); // movement method moveWithFallDamage(bh, bi, bj); // movement method
NMS.setHeadYaw(getBukkitEntity(), yaw); NMS.setHeadAndBodyYaw(getBukkitEntity(), yaw);
if (jumpTicks > 0) { if (jumpTicks > 0) {
jumpTicks--; jumpTicks--;
} }

View File

@ -1298,16 +1298,23 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) { public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity)) if (!(entity instanceof LivingEntity))
return; return;
EntityLiving handle = (EntityLiving) getHandle(entity); EntityLiving handle = (EntityLiving) getHandle(entity);
yaw = Util.clamp(yaw); yaw = Util.clamp(yaw);
handle.aR = yaw; handle.aR = yaw;
if (!(handle instanceof EntityHuman)) { if (!(handle instanceof EntityHuman)) {
handle.aQ = yaw; handle.aQ = yaw; // TODO: why this
} }
handle.aS = yaw; setHeadYaw(entity, yaw);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
((EntityLiving) getHandle(entity)).aS = Util.clamp(yaw);
} }
@Override @Override

View File

@ -298,7 +298,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
bd *= 0.98F; bd *= 0.98F;
be *= 0.9F; be *= 0.9F;
moveWithFallDamage(new Vec3D(this.bb, this.bc, this.bd)); // movement method moveWithFallDamage(new Vec3D(this.bb, this.bc, this.bd)); // movement method
NMS.setHeadYaw(getBukkitEntity(), yaw); NMS.setHeadAndBodyYaw(getBukkitEntity(), yaw);
if (jumpTicks > 0) { if (jumpTicks > 0) {
jumpTicks--; jumpTicks--;
} }

View File

@ -1332,16 +1332,23 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) { public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity)) if (!(entity instanceof LivingEntity))
return; return;
EntityLiving handle = (EntityLiving) getHandle(entity); EntityLiving handle = (EntityLiving) getHandle(entity);
yaw = Util.clamp(yaw); yaw = Util.clamp(yaw);
handle.aL = yaw; handle.aL = yaw;
if (!(handle instanceof EntityHuman)) { if (!(handle instanceof EntityHuman)) {
handle.aK = yaw; handle.aK = yaw; // TODO: why this
} }
handle.aM = yaw; setHeadYaw(entity, yaw);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
((EntityLiving) getHandle(entity)).aM = Util.clamp(yaw);
} }
@Override @Override

View File

@ -298,7 +298,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
aZ *= 0.98F; aZ *= 0.98F;
bb *= 0.98F; bb *= 0.98F;
moveWithFallDamage(new Vec3D(this.aZ, this.ba, this.bb)); // movement method moveWithFallDamage(new Vec3D(this.aZ, this.ba, this.bb)); // movement method
NMS.setHeadYaw(getBukkitEntity(), yaw); NMS.setHeadAndBodyYaw(getBukkitEntity(), yaw);
if (jumpTicks > 0) { if (jumpTicks > 0) {
jumpTicks--; jumpTicks--;
} }

View File

@ -1349,16 +1349,23 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) { public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity)) if (!(entity instanceof LivingEntity))
return; return;
EntityLiving handle = (EntityLiving) getHandle(entity); EntityLiving handle = (EntityLiving) getHandle(entity);
yaw = Util.clamp(yaw); yaw = Util.clamp(yaw);
handle.aJ = yaw; handle.aJ = yaw;
if (!(handle instanceof EntityHuman)) { if (!(handle instanceof EntityHuman)) {
handle.aI = yaw; handle.aI = yaw; // TODO: why this
} }
handle.aK = yaw; setHeadYaw(entity, yaw);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
((EntityLiving) getHandle(entity)).aK = Util.clamp(yaw);
} }
@Override @Override

View File

@ -267,7 +267,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
aR *= 0.98F; aR *= 0.98F;
aT *= 0.98F; aT *= 0.98F;
moveWithFallDamage(new Vec3D(this.aR, this.aS, this.aT)); // movement method moveWithFallDamage(new Vec3D(this.aR, this.aS, this.aT)); // movement method
NMS.setHeadYaw(getBukkitEntity(), yaw); NMS.setHeadAndBodyYaw(getBukkitEntity(), yaw);
if (jumpTicks > 0) { if (jumpTicks > 0) {
jumpTicks--; jumpTicks--;
} }

View File

@ -1378,7 +1378,7 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) { public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity)) if (!(entity instanceof LivingEntity))
return; return;
EntityLiving handle = (EntityLiving) getHandle(entity); EntityLiving handle = (EntityLiving) getHandle(entity);
@ -1387,7 +1387,14 @@ public class NMSImpl implements NMSBridge {
if (!(handle instanceof EntityHuman)) { if (!(handle instanceof EntityHuman)) {
handle.aA = yaw; // TODO: why this handle.aA = yaw; // TODO: why this
} }
handle.setHeadRotation(yaw); setHeadYaw(entity, yaw);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
((EntityLiving) getHandle(entity)).setHeadRotation(Util.clamp(yaw));
} }
@Override @Override

View File

@ -275,7 +275,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
xxa *= 0.98F; xxa *= 0.98F;
zza *= 0.98F; zza *= 0.98F;
moveWithFallDamage(new Vec3(this.xxa, this.yya, this.zza)); moveWithFallDamage(new Vec3(this.xxa, this.yya, this.zza));
NMS.setHeadYaw(getBukkitEntity(), getYRot()); NMS.setHeadAndBodyYaw(getBukkitEntity(), getYRot());
if (jumpTicks > 0) { if (jumpTicks > 0) {
jumpTicks--; jumpTicks--;
} }

View File

@ -1035,7 +1035,7 @@ public class NMSImpl implements NMSBridge {
return; return;
yaw = Util.clamp(yaw); yaw = Util.clamp(yaw);
handle.setYRot(yaw); handle.setYRot(yaw);
setHeadYaw(entity, yaw); setHeadAndBodyYaw(entity, yaw);
handle.setXRot(pitch); handle.setXRot(pitch);
} }
@ -1063,7 +1063,7 @@ public class NMSImpl implements NMSBridge {
yaw = yaw - 90; yaw = yaw - 90;
} }
if (headOnly) { if (headOnly) {
setHeadYaw(entity, (float) yaw); setHeadAndBodyYaw(entity, (float) yaw);
} else { } else {
look(entity, (float) yaw, (float) pitch); look(entity, (float) yaw, (float) pitch);
} }
@ -1378,7 +1378,7 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) { public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity)) if (!(entity instanceof org.bukkit.entity.LivingEntity))
return; return;
LivingEntity handle = (LivingEntity) getHandle(entity); LivingEntity handle = (LivingEntity) getHandle(entity);
@ -1387,7 +1387,14 @@ public class NMSImpl implements NMSBridge {
if (!(handle instanceof net.minecraft.world.entity.player.Player)) { if (!(handle instanceof net.minecraft.world.entity.player.Player)) {
handle.setYBodyRot(yaw); handle.setYBodyRot(yaw);
} }
handle.setYHeadRot(yaw); setHeadYaw(entity, yaw);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
((LivingEntity) getHandle(entity)).setYHeadRot(Util.clamp(yaw));
} }
@Override @Override

View File

@ -273,7 +273,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
xxa *= 0.98F; xxa *= 0.98F;
zza *= 0.98F; zza *= 0.98F;
moveWithFallDamage(new Vec3(this.xxa, this.yya, this.zza)); moveWithFallDamage(new Vec3(this.xxa, this.yya, this.zza));
NMS.setHeadYaw(getBukkitEntity(), getYRot()); NMS.setHeadAndBodyYaw(getBukkitEntity(), getYRot());
if (jumpTicks > 0) { if (jumpTicks > 0) {
jumpTicks--; jumpTicks--;
} }

View File

@ -1386,7 +1386,7 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) { public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity)) if (!(entity instanceof org.bukkit.entity.LivingEntity))
return; return;
LivingEntity handle = (LivingEntity) getHandle(entity); LivingEntity handle = (LivingEntity) getHandle(entity);
@ -1395,7 +1395,14 @@ public class NMSImpl implements NMSBridge {
if (!(handle instanceof net.minecraft.world.entity.player.Player)) { if (!(handle instanceof net.minecraft.world.entity.player.Player)) {
handle.setYBodyRot(yaw); handle.setYBodyRot(yaw);
} }
handle.setYHeadRot(yaw); setHeadYaw(entity, yaw);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
((LivingEntity) getHandle(entity)).setYHeadRot(Util.clamp(yaw));
} }
@Override @Override

View File

@ -273,7 +273,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
xxa *= 0.98F; xxa *= 0.98F;
zza *= 0.98F; zza *= 0.98F;
moveWithFallDamage(new Vec3(this.xxa, this.yya, this.zza)); moveWithFallDamage(new Vec3(this.xxa, this.yya, this.zza));
NMS.setHeadYaw(getBukkitEntity(), getYRot()); NMS.setHeadAndBodyYaw(getBukkitEntity(), getYRot());
if (jumpTicks > 0) { if (jumpTicks > 0) {
jumpTicks--; jumpTicks--;
} }

View File

@ -1527,7 +1527,7 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) { public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity)) if (!(entity instanceof org.bukkit.entity.LivingEntity))
return; return;
LivingEntity handle = (LivingEntity) getHandle(entity); LivingEntity handle = (LivingEntity) getHandle(entity);
@ -1536,7 +1536,14 @@ public class NMSImpl implements NMSBridge {
if (!(handle instanceof net.minecraft.world.entity.player.Player)) { if (!(handle instanceof net.minecraft.world.entity.player.Player)) {
handle.setYBodyRot(yaw); handle.setYBodyRot(yaw);
} }
handle.setYHeadRot(yaw); setHeadYaw(entity, yaw);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
((LivingEntity) getHandle(entity)).setYHeadRot(Util.clamp(yaw));
} }
@Override @Override

View File

@ -9,7 +9,7 @@
<artifactId>citizens-v1_20_R3</artifactId> <artifactId>citizens-v1_20_R3</artifactId>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<craftbukkit.version>1.20.3-R0.1-SNAPSHOT</craftbukkit.version> <craftbukkit.version>1.20.4-R0.1-SNAPSHOT</craftbukkit.version>
</properties> </properties>
<dependencies> <dependencies>

View File

@ -52,9 +52,7 @@ public class DolphinController extends MobEntityController {
public static class EntityDolphinNPC extends Dolphin implements NPCHolder { public static class EntityDolphinNPC extends Dolphin implements NPCHolder {
private boolean inProtectedTick; private boolean inProtectedTick;
private final CitizensNPC npc; private final CitizensNPC npc;
private MoveControl oldMoveController; private MoveControl oldMoveController;
public EntityDolphinNPC(EntityType<? extends Dolphin> types, Level level) { public EntityDolphinNPC(EntityType<? extends Dolphin> types, Level level) {

View File

@ -277,7 +277,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
xxa *= 0.98F; xxa *= 0.98F;
zza *= 0.98F; zza *= 0.98F;
moveWithFallDamage(new Vec3(this.xxa, this.yya, this.zza)); moveWithFallDamage(new Vec3(this.xxa, this.yya, this.zza));
NMS.setHeadYaw(getBukkitEntity(), getYRot()); NMS.setHeadAndBodyYaw(getBukkitEntity(), getYRot());
if (jumpTicks > 0) { if (jumpTicks > 0) {
jumpTicks--; jumpTicks--;
} }

View File

@ -1498,7 +1498,7 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) { public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity)) if (!(entity instanceof org.bukkit.entity.LivingEntity))
return; return;
LivingEntity handle = (LivingEntity) getHandle(entity); LivingEntity handle = (LivingEntity) getHandle(entity);
@ -1507,7 +1507,14 @@ public class NMSImpl implements NMSBridge {
if (!(handle instanceof net.minecraft.world.entity.player.Player)) { if (!(handle instanceof net.minecraft.world.entity.player.Player)) {
handle.setYBodyRot(yaw); handle.setYBodyRot(yaw);
} }
handle.setYHeadRot(yaw); setHeadYaw(entity, yaw);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
((LivingEntity) getHandle(entity)).setYHeadRot(Util.clamp(yaw));
} }
@Override @Override
@ -2552,11 +2559,11 @@ public class NMSImpl implements NMSBridge {
Map.class); Map.class);
private static final MethodHandle ATTRIBUTE_SUPPLIER = NMS.getFirstGetter(AttributeMap.class, private static final MethodHandle ATTRIBUTE_SUPPLIER = NMS.getFirstGetter(AttributeMap.class,
AttributeSupplier.class); AttributeSupplier.class);
private static final MethodHandle AVAILABLE_BEHAVIORS_BY_PRIORITY = NMS.getGetter(Brain.class, "f");
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.BEE, private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.BEE,
EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT,
EntityType.SLIME, EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST, EntityType.SLIME, EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST,
EntityType.SHULKER, EntityType.PHANTOM); EntityType.SHULKER, EntityType.PHANTOM);
private static final MethodHandle AVAILABLE_BEHAVIORS_BY_PRIORITY = NMS.getGetter(Brain.class, "f");
private static final MethodHandle BUKKITENTITY_FIELD_SETTER = NMS.getSetter(Entity.class, "bukkitEntity"); private static final MethodHandle BUKKITENTITY_FIELD_SETTER = NMS.getSetter(Entity.class, "bukkitEntity");
private static final MethodHandle CHUNKMAP_UPDATE_PLAYER_STATUS = NMS.getMethodHandle(ChunkMap.class, "a", true, private static final MethodHandle CHUNKMAP_UPDATE_PLAYER_STATUS = NMS.getMethodHandle(ChunkMap.class, "a", true,
ServerPlayer.class, boolean.class); ServerPlayer.class, boolean.class);

View File

@ -308,7 +308,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
ba *= 0.98F; ba *= 0.98F;
bb *= 0.9F; bb *= 0.9F;
moveWithFallDamage(aZ, ba); // movement method moveWithFallDamage(aZ, ba); // movement method
NMS.setHeadYaw(getBukkitEntity(), yaw); NMS.setHeadAndBodyYaw(getBukkitEntity(), yaw);
if (jumpTicks > 0) { if (jumpTicks > 0) {
jumpTicks--; jumpTicks--;
} }

View File

@ -156,9 +156,9 @@ import net.citizensnpcs.nms.v1_8_R3.entity.nonliving.TNTPrimedController;
import net.citizensnpcs.nms.v1_8_R3.entity.nonliving.ThrownExpBottleController; import net.citizensnpcs.nms.v1_8_R3.entity.nonliving.ThrownExpBottleController;
import net.citizensnpcs.nms.v1_8_R3.entity.nonliving.WitherSkullController; import net.citizensnpcs.nms.v1_8_R3.entity.nonliving.WitherSkullController;
import net.citizensnpcs.npc.EntityControllers; import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity; import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.util.EmptyChannel; import net.citizensnpcs.util.EmptyChannel;
@ -402,6 +402,11 @@ public class NMSImpl implements NMSBridge {
return new BoundingBox(bb.a, bb.b, bb.c, bb.d, bb.e, bb.f); return new BoundingBox(bb.a, bb.b, bb.c, bb.d, bb.e, bb.f);
} }
@Override
public double getBoundingBoxHeight(org.bukkit.entity.Entity entity) {
return getHandle(entity).length;
}
@Override @Override
public BoundingBox getCollisionBox(org.bukkit.block.Block block) { public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
WorldServer world = ((CraftWorld) block.getWorld()).getHandle(); WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
@ -433,11 +438,6 @@ public class NMSImpl implements NMSBridge {
return getHandle((LivingEntity) entity).aK; return getHandle((LivingEntity) entity).aK;
} }
@Override
public double getBoundingBoxHeight(org.bukkit.entity.Entity entity) {
return getHandle(entity).length;
}
@Override @Override
public float getHorizontalMovement(org.bukkit.entity.Entity entity) { public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
if (!entity.getType().isAlive()) if (!entity.getType().isAlive())
@ -1119,16 +1119,23 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) { public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity)) if (!(entity instanceof LivingEntity))
return; return;
EntityLiving handle = (EntityLiving) getHandle(entity); EntityLiving handle = (EntityLiving) getHandle(entity);
yaw = Util.clamp(yaw); yaw = Util.clamp(yaw);
handle.aJ = yaw; handle.aJ = yaw;
if (!(handle instanceof EntityHuman)) { if (!(handle instanceof EntityHuman)) {
handle.aI = yaw; handle.aI = yaw; // TODO: why this
} }
handle.aK = yaw; setHeadYaw(entity, yaw);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
((EntityLiving) getHandle(entity)).aK = Util.clamp(yaw);
} }
@Override @Override