Consolidate body yaw implementations

This commit is contained in:
fullwall 2023-12-22 12:41:14 +08:00
parent d005c228ff
commit 007c92f797
13 changed files with 96 additions and 86 deletions

View File

@ -18,7 +18,7 @@ import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.trait.trait.MobType;
import net.citizensnpcs.api.trait.trait.Owner;
import net.citizensnpcs.api.trait.trait.PlayerFilter;
import net.citizensnpcs.api.trait.trait.Spawned;
import net.citizensnpcs.api.trait.trait.Spawned;
import net.citizensnpcs.trait.Age;
import net.citizensnpcs.trait.Anchors;
import net.citizensnpcs.trait.ArmorStandTrait;
@ -91,7 +91,7 @@ public class CitizensTraitFactory implements TraitFactory {
registerTrait(TraitInfo.create(Inventory.class));
registerTrait(TraitInfo.create(LookClose.class));
registerTrait(TraitInfo.create(PaintingTrait.class));
registerTrait(TraitInfo.create(MirrorTrait.class).optInToStats());
registerTrait(TraitInfo.create(MirrorTrait.class).optInToStats());
registerTrait(TraitInfo.create(MountTrait.class));
registerTrait(TraitInfo.create(MobType.class).asDefaultTrait());
registerTrait(TraitInfo.create(OcelotModifiers.class));

View File

@ -1164,6 +1164,13 @@ public class NMSImpl implements NMSBridge {
@Override
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
getHandle(entity).yaw = yaw;
if (entity instanceof EntityLiving) {
EntityLiving handle = (EntityLiving) getHandle(entity);
handle.aP = yaw;
if (!(handle instanceof EntityHuman)) {
handle.aO = yaw; // TODO: why this
}
}
}
@Override
@ -1202,14 +1209,8 @@ public class NMSImpl implements NMSBridge {
@Override
public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))
return;
EntityLiving handle = (EntityLiving) getHandle(entity);
yaw = Util.clamp(yaw);
handle.aP = yaw;
if (!(handle instanceof EntityHuman)) {
handle.aO = yaw; // TODO: why this
}
setBodyYaw(entity, yaw);
setHeadYaw(entity, yaw);
}

View File

@ -1217,6 +1217,13 @@ public class NMSImpl implements NMSBridge {
@Override
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
getHandle(entity).yaw = yaw;
if (entity instanceof EntityLiving) {
EntityLiving handle = (EntityLiving) getHandle(entity);
handle.aO = yaw;
if (!(handle instanceof EntityHuman)) {
handle.aN = yaw; // TODO: why this
}
}
}
@Override
@ -1255,14 +1262,8 @@ public class NMSImpl implements NMSBridge {
@Override
public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))
return;
EntityLiving handle = (EntityLiving) getHandle(entity);
yaw = Util.clamp(yaw);
handle.aO = yaw;
if (!(handle instanceof EntityHuman)) {
handle.aN = yaw; // TODO: why this
}
setBodyYaw(entity, yaw);
setHeadYaw(entity, yaw);
}

View File

@ -1224,6 +1224,13 @@ public class NMSImpl implements NMSBridge {
@Override
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
getHandle(entity).yaw = yaw;
if (entity instanceof EntityLiving) {
EntityLiving handle = (EntityLiving) getHandle(entity);
handle.aO = yaw;
if (!(handle instanceof EntityHuman)) {
handle.aN = yaw; // TODO: why this
}
}
}
@Override
@ -1262,14 +1269,8 @@ public class NMSImpl implements NMSBridge {
@Override
public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))
return;
EntityLiving handle = (EntityLiving) getHandle(entity);
yaw = Util.clamp(yaw);
handle.aO = yaw;
if (!(handle instanceof EntityHuman)) {
handle.aN = yaw; // TODO: why this
}
setBodyYaw(entity, yaw);
setHeadYaw(entity, yaw);
}

View File

@ -1261,6 +1261,13 @@ public class NMSImpl implements NMSBridge {
@Override
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
getHandle(entity).yaw = yaw;
if (entity instanceof EntityLiving) {
EntityLiving handle = (EntityLiving) getHandle(entity);
handle.aR = yaw;
if (!(handle instanceof EntityHuman)) {
handle.aQ = yaw; // TODO: why this
}
}
}
@Override
@ -1299,14 +1306,8 @@ public class NMSImpl implements NMSBridge {
@Override
public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))
return;
EntityLiving handle = (EntityLiving) getHandle(entity);
yaw = Util.clamp(yaw);
handle.aR = yaw;
if (!(handle instanceof EntityHuman)) {
handle.aQ = yaw; // TODO: why this
}
setBodyYaw(entity, yaw);
setHeadYaw(entity, yaw);
}

View File

@ -1288,6 +1288,13 @@ public class NMSImpl implements NMSBridge {
@Override
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
getHandle(entity).yaw = yaw;
if (entity instanceof EntityLiving) {
EntityLiving handle = (EntityLiving) getHandle(entity);
handle.aL = yaw;
if (!(handle instanceof EntityHuman)) {
handle.aK = yaw; // TODO: why this
}
}
}
@Override
@ -1333,14 +1340,8 @@ public class NMSImpl implements NMSBridge {
@Override
public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))
return;
EntityLiving handle = (EntityLiving) getHandle(entity);
yaw = Util.clamp(yaw);
handle.aL = yaw;
if (!(handle instanceof EntityHuman)) {
handle.aK = yaw; // TODO: why this
}
setBodyYaw(entity, yaw);
setHeadYaw(entity, yaw);
}

View File

@ -1305,6 +1305,13 @@ public class NMSImpl implements NMSBridge {
@Override
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
getHandle(entity).yaw = yaw;
if (entity instanceof EntityLiving) {
EntityLiving handle = (EntityLiving) getHandle(entity);
handle.aJ = yaw;
if (!(handle instanceof EntityHuman)) {
handle.aI = yaw; // TODO: why this
}
}
}
@Override
@ -1350,14 +1357,8 @@ public class NMSImpl implements NMSBridge {
@Override
public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))
return;
EntityLiving handle = (EntityLiving) getHandle(entity);
yaw = Util.clamp(yaw);
handle.aJ = yaw;
if (!(handle instanceof EntityHuman)) {
handle.aI = yaw; // TODO: why this
}
setBodyYaw(entity, yaw);
setHeadYaw(entity, yaw);
}

View File

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

View File

@ -1034,7 +1034,6 @@ public class NMSImpl implements NMSBridge {
if (handle == null)
return;
yaw = Util.clamp(yaw);
handle.setYRot(yaw);
setHeadAndBodyYaw(entity, yaw);
handle.setXRot(pitch);
}
@ -1340,7 +1339,12 @@ public class NMSImpl implements NMSBridge {
@Override
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
getHandle(entity).setYRot(yaw);
Entity handle = getHandle(entity);
if (handle instanceof LivingEntity) {
((LivingEntity) handle).yBodyRotO = yaw;
}
handle.setYBodyRot(yaw);
handle.setYRot(yaw);
}
@Override
@ -1379,14 +1383,8 @@ public class NMSImpl implements NMSBridge {
@Override
public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
LivingEntity handle = (LivingEntity) getHandle(entity);
yaw = Util.clamp(yaw);
handle.yBodyRotO = yaw;
if (!(handle instanceof net.minecraft.world.entity.player.Player)) {
handle.setYBodyRot(yaw);
}
setBodyYaw(entity, yaw);
setHeadYaw(entity, yaw);
}

View File

@ -1347,8 +1347,14 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
getHandle(entity).setYRot(yaw);
Entity handle = getHandle(entity);
if (handle instanceof LivingEntity) {
((LivingEntity) handle).yBodyRotO = yaw;
}
handle.setYBodyRot(yaw);
handle.setYRot(yaw);
}
@Override
@ -1387,14 +1393,8 @@ public class NMSImpl implements NMSBridge {
@Override
public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
LivingEntity handle = (LivingEntity) getHandle(entity);
yaw = Util.clamp(yaw);
handle.yBodyRotO = yaw;
if (!(handle instanceof net.minecraft.world.entity.player.Player)) {
handle.setYBodyRot(yaw);
}
setBodyYaw(entity, yaw);
setHeadYaw(entity, yaw);
}

View File

@ -1460,7 +1460,12 @@ public class NMSImpl implements NMSBridge {
@Override
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
getHandle(entity).setYRot(yaw);
Entity handle = getHandle(entity);
if (handle instanceof LivingEntity) {
((LivingEntity) handle).yBodyRotO = yaw;
}
handle.setYBodyRot(yaw);
handle.setYRot(yaw);
}
@Override
@ -1528,8 +1533,10 @@ public class NMSImpl implements NMSBridge {
@Override
public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
if (!(entity instanceof org.bukkit.entity.LivingEntity)) {
getHandle(entity).setYRot(yaw);
return;
}
LivingEntity handle = (LivingEntity) getHandle(entity);
yaw = Util.clamp(yaw);
handle.yBodyRotO = yaw;

View File

@ -1431,7 +1431,12 @@ public class NMSImpl implements NMSBridge {
@Override
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
getHandle(entity).setYRot(yaw);
Entity handle = getHandle(entity);
if (handle instanceof LivingEntity) {
((LivingEntity) handle).yBodyRotO = yaw;
}
handle.setYBodyRot(yaw);
handle.setYRot(yaw);
}
@Override
@ -1499,14 +1504,8 @@ public class NMSImpl implements NMSBridge {
@Override
public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof org.bukkit.entity.LivingEntity))
return;
LivingEntity handle = (LivingEntity) getHandle(entity);
yaw = Util.clamp(yaw);
handle.yBodyRotO = yaw;
if (!(handle instanceof net.minecraft.world.entity.player.Player)) {
handle.setYBodyRot(yaw);
}
setBodyYaw(entity, yaw);
setHeadYaw(entity, yaw);
}

View File

@ -1084,6 +1084,13 @@ public class NMSImpl implements NMSBridge {
@Override
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
getHandle(entity).yaw = yaw;
if (entity instanceof EntityLiving) {
EntityLiving handle = (EntityLiving) getHandle(entity);
handle.aJ = yaw;
if (!(handle instanceof EntityHuman)) {
handle.aI = yaw; // TODO: why this
}
}
}
@Override
@ -1120,14 +1127,8 @@ public class NMSImpl implements NMSBridge {
@Override
public void setHeadAndBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))
return;
EntityLiving handle = (EntityLiving) getHandle(entity);
yaw = Util.clamp(yaw);
handle.aJ = yaw;
if (!(handle instanceof EntityHuman)) {
handle.aI = yaw; // TODO: why this
}
setBodyYaw(entity, yaw);
setHeadYaw(entity, yaw);
}