Fixed NPC head rotation

This commit is contained in:
Goodbird committed 2024-04-24 09:47:50 +03:00
1 parent 574858716d
commit 357f848b72
3 files changed
+23 -2

No files matched your search

@@ -32,8 +32,8 @@ public class ModelCustom extends AnimatedGeoModel<EntityCustomModel> {
//We get the model data for an entity
EntityModelData extraData = (EntityModelData) animationEvent.getExtraDataOfType(EntityModelData.class).get(0);
//And we set the head bone rotation to the interpolated pitch and yaw rotations of an entity
head.setRotationY((extraData.netHeadYaw) * ((float) Math.PI / 180F));
head.setRotationX((extraData.headPitch) * ((float) Math.PI / 180F));
head.setRotationY((extraData.netHeadYaw) * ((float) Math.PI / 180F));
}
}
}
@@ -2,6 +2,8 @@ package com.goodbird.npcgecko.client.renderer;
import com.goodbird.npcgecko.client.model.ModelCustom;
import com.goodbird.npcgecko.entity.EntityCustomModel;
import com.mojang.realmsclient.gui.ChatFormatting;
import net.geckominecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
@@ -30,6 +32,26 @@ public class RenderCustomModel extends GeoEntityRenderer<EntityCustomModel> {
}
}
protected void applyRotations(EntityCustomModel entityLiving, float ageInTicks, float rotationYaw, float partialTicks) {
if (!entityLiving.isPlayerSleeping()) {
GlStateManager.rotate(-180, 0.0F, 1.0F, 0.0F);
}
if (entityLiving.deathTime > 0) {
float f = ((float)entityLiving.deathTime + partialTicks - 1.0F) / 20.0F * 1.6F;
f = net.minecraft.util.MathHelper.sqrt_float(f);
if (f > 1.0F) {
f = 1.0F;
}
GlStateManager.rotate(f * this.getDeathMaxRotation(entityLiving), 0.0F, 0.0F, 1.0F);
} else if (entityLiving.hasCustomNameTag()) {
String s = ChatFormatting.stripFormatting(entityLiving.getCommandSenderName());
if (("Dinnerbone".equals(s) || "Grumm".equals(s))) {
GlStateManager.translate(0.0, entityLiving.height + 0.1F, 0.0);
GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
}
}
}
public GeoBone[] getPathFromRoot(GeoBone bone) {
ArrayList<GeoBone> bones;
for(bones = new ArrayList<>(); bone != null; bone = bone.parent) {
@@ -125,7 +125,6 @@ public class MixinGeckoAddonClient {
GL11.glRotatef(180, 1,0,0);
GL11.glTranslated(0, -1.5,0);
(mainModel).entity.renderYawOffset = (mainModel).entity.prevRenderYawOffset = 0;
if (!npc.isInvisible())
{
if(mainModel.entity instanceof EntityCustomModel){