Jump to content

Custom Rendered Helmet won't attach to head


TrunkS
 Share

Recommended Posts

So, I made a helmet with custom render code some time ago which makes use of the getArmorModel() method in the Item class and a ModelBiped extending rendering class. It seems to work fine to that point but now comes the problem:

When I put on the helmet it attaches to the whole body model but not separately to the head. Like when I run around the helmet follows the orientation of the rest of the body but when I move the mouse and look in another direction the helmet still faces the direction I run towards.

Thanks in advance.

And no my name is not inspired by DBZ ^^

Link to comment
Share on other sites

Sorry for not posting the code but there's really not much code to it ^^

Btw I'm using a techne made model (very basic with no rotation) and I've made another helmet without custom rendering code to test if this problem is caused by the render code and indeed it is.

 

So anyway here's the code:

 

@Mod Class:

@Mod(modid = "TrunkSMod", name = "TrunkS Mod", version = "Dev v1")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)

public class mod_Particles
{
public static Item helmetTest;

Instance("TrunkSMod")
        public static mod_Particles instance;
       
        @PreInit
        public void preInit(FMLPreInitializationEvent event)
        {
                instance = this;
        }
@Init
        public void load(FMLInitializationEvent event)
        {
helmetTest = new ItemTrunksArmorHelmet(5005, EnumArmorMaterial.IRON, 0, 0).setCreativeTab(mod_Particles.tabParticles).setFull3D().setUnlocalizedName("helmetTest");
GameRegistry.registerItem(helmetTest, "helmetTest");
LanguageRegistry.addName(helmetTest, "Test Helmet");
}

@PostInit
        public void postInit(FMLPostInitializationEvent event)
        {
               
        }

 

ItemTrunksArmorHelmet Class:

public class ItemTrunksArmorHelmet extends ItemArmor
{
       
        public ItemTrunksArmorHelmet(int par1, EnumArmorMaterial enumToolMaterial, int par3, int par4)
        {
                super(par1, enumToolMaterial, par3, par4);     
        }
       
        @Override
        public ModelBiped getArmorModel(EntityLiving entityLiving, ItemStack stack, int armorSlot)
        {
                return new ItemHelmetTestRenderer();
        }
       
}

 

ItemHelmetTestRenderer Class:

public class ItemHelmetTestRenderer extends ModelBiped
{
        protected HelmetTestModel helmetModel;
       
        public ItemHelmetTestRenderer()
        {
            super();
            helmetModel = new HelmetTestModel();
        }
       
        public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
        {
               
                GL11.glPushMatrix();
               
                GL11.glTranslatef(0.0F, 0.01F, 0.05F);
               
                FMLClientHandler.instance().getClient().renderEngine.bindTexture("/trunkS/mod/textures/items/helmetTestTexture.png");
               
                helmetModel.render(par1Entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
               
                GL11.glPopMatrix();
                return;
               
        }


}

 

HelmetTestModel Class:

package trunkS.mod;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class HelmetTestModel extends ModelBase
{
  //fields
    ModelRenderer HeadRight;
    ModelRenderer VisorBrow1;
    ModelRenderer VisorRight1;
    ModelRenderer VisorLeft1;
    ModelRenderer VisorLeft2;
    ModelRenderer VisorRight2;
    ModelRenderer VisorLeft3;
    ModelRenderer VisorRight3;
    ModelRenderer Cheek1;
    ModelRenderer Cheek2;
    ModelRenderer HeadLeft;
    ModelRenderer HeadBack;
    ModelRenderer RimFrontRight;
    ModelRenderer RimFrontLeft;
    ModelRenderer RimRight;
    ModelRenderer RimLeft;
    ModelRenderer RimBack;
    ModelRenderer VisorBrow2;
    ModelRenderer DecoRimFrontLeft;
    ModelRenderer DecoRimFrontRight;
    ModelRenderer Top1;
    ModelRenderer Top2;
    ModelRenderer Top3;
    ModelRenderer DecoRimTopLeft;
    ModelRenderer DecoRimTopRight;
    ModelRenderer DecoRimBackLeft;
    ModelRenderer DecoRimBackRight;
    ModelRenderer WingLeft1;
    ModelRenderer WingLeft2;
    ModelRenderer WingLeft3;
    ModelRenderer WingLeft4;
    ModelRenderer WingRight1;
    ModelRenderer WingRight2;
    ModelRenderer WingRight3;
    ModelRenderer WingRight4;
    ModelRenderer Forehead;
    ModelRenderer SinglePixelRim;
    ModelRenderer SinglePixelRim2;

  public HelmetTestModel()
  {
    textureWidth = 128;
    textureHeight = 64;
   
      HeadRight = new ModelRenderer(this, 102, 0);
      HeadRight.addBox(0F, 0F, 0F, 1, 9, 10);
      HeadRight.setRotationPoint(4F, -9F, -5F);
      HeadRight.setTextureSize(128, 64);
      HeadRight.mirror = true;
      setRotation(HeadRight, 0F, 0F, 0F);
      VisorBrow1 = new ModelRenderer(this, 78, 0);
      VisorBrow1.addBox(0F, 0F, 0F, 10, 1, 1);
      VisorBrow1.setRotationPoint(-5F, -7F, -6F);
      VisorBrow1.setTextureSize(128, 64);
      VisorBrow1.mirror = true;
      setRotation(VisorBrow1, 0F, 0F, 0F);
      VisorRight1 = new ModelRenderer(this, 96, 3);
      VisorRight1.addBox(0F, 0F, 0F, 1, 2, 1);
      VisorRight1.setRotationPoint(4F, -6F, -6F);
      VisorRight1.setTextureSize(128, 64);
      VisorRight1.mirror = true;
      setRotation(VisorRight1, 0F, 0F, 0F);
      VisorLeft1 = new ModelRenderer(this, 91, 3);
      VisorLeft1.addBox(0F, 0F, 0F, 1, 2, 1);
      VisorLeft1.setRotationPoint(-5F, -6F, -6F);
      VisorLeft1.setTextureSize(128, 64);
      VisorLeft1.mirror = true;
      setRotation(VisorLeft1, 0F, 0F, 0F);
      VisorLeft2 = new ModelRenderer(this, 84, 3);
      VisorLeft2.addBox(0F, 0F, 0F, 2, 1, 1);
      VisorLeft2.setRotationPoint(-4F, -4F, -6F);
      VisorLeft2.setTextureSize(128, 64);
      VisorLeft2.mirror = true;
      setRotation(VisorLeft2, 0F, 0F, 0F);
      VisorRight2 = new ModelRenderer(this, 77, 3);
      VisorRight2.addBox(0F, 0F, 0F, 2, 1, 1);
      VisorRight2.setRotationPoint(2F, -4F, -6F);
      VisorRight2.setTextureSize(128, 64);
      VisorRight2.mirror = true;
      setRotation(VisorRight2, 0F, 0F, 0F);
      VisorLeft3 = new ModelRenderer(this, 71, 0);
      VisorLeft3.addBox(0F, 0F, 0F, 1, 3, 1);
      VisorLeft3.setRotationPoint(-2F, -3F, -6F);
      VisorLeft3.setTextureSize(128, 64);
      VisorLeft3.mirror = true;
      setRotation(VisorLeft3, 0F, 0F, 0F);
      VisorRight3 = new ModelRenderer(this, 66, 0);
      VisorRight3.addBox(0F, 0F, 0F, 1, 3, 1);
      VisorRight3.setRotationPoint(1F, -3F, -6F);
      VisorRight3.setTextureSize(128, 64);
      VisorRight3.mirror = true;
      setRotation(VisorRight3, 0F, 0F, 0F);
      Cheek1 = new ModelRenderer(this, 92, 7);
      Cheek1.addBox(0F, 0F, 0F, 3, 3, 1);
      Cheek1.setRotationPoint(-4F, -3F, -5F);
      Cheek1.setTextureSize(128, 64);
      Cheek1.mirror = true;
      setRotation(Cheek1, 0F, 0F, 0F);
      Cheek2 = new ModelRenderer(this, 83, 7);
      Cheek2.addBox(0F, 0F, 0F, 3, 3, 1);
      Cheek2.setRotationPoint(1F, -3F, -5F);
      Cheek2.setTextureSize(128, 64);
      Cheek2.mirror = true;
      setRotation(Cheek2, 0F, 0F, 0F);
      HeadLeft = new ModelRenderer(this, 102, 20);
      HeadLeft.addBox(0F, 0F, 0F, 1, 9, 10);
      HeadLeft.setRotationPoint(-5F, -9F, -5F);
      HeadLeft.setTextureSize(128, 64);
      HeadLeft.mirror = true;
      setRotation(HeadLeft, 0F, 0F, 0F);
      HeadBack = new ModelRenderer(this, 82, 13);
      HeadBack.addBox(0F, 0F, 0F, 8, 9, 1);
      HeadBack.setRotationPoint(-4F, -9F, 4F);
      HeadBack.setTextureSize(128, 64);
      HeadBack.mirror = true;
      setRotation(HeadBack, 0F, 0F, 0F);
      RimFrontRight = new ModelRenderer(this, 74, 7);
      RimFrontRight.addBox(0F, 0F, 0F, 3, 1, 1);
      RimFrontRight.setRotationPoint(1F, 0F, -6F);
      RimFrontRight.setTextureSize(128, 64);
      RimFrontRight.mirror = true;
      setRotation(RimFrontRight, 0F, 0F, 0F);
      RimFrontLeft = new ModelRenderer(this, 74, 10);
      RimFrontLeft.addBox(0F, 0F, 0F, 3, 1, 1);
      RimFrontLeft.setRotationPoint(-4F, 0F, -6F);
      RimFrontLeft.setTextureSize(128, 64);
      RimFrontLeft.mirror = true;
      setRotation(RimFrontLeft, 0F, 0F, 0F);
      RimRight = new ModelRenderer(this, 102, 41);
      RimRight.addBox(0F, 0F, 0F, 1, 1, 10);
      RimRight.setRotationPoint(5F, -1F, -5F);
      RimRight.setTextureSize(128, 64);
      RimRight.mirror = true;
      setRotation(RimRight, 0F, 0F, 0F);
      RimLeft = new ModelRenderer(this, 78, 24);
      RimLeft.addBox(0F, 0F, 0F, 1, 1, 10);
      RimLeft.setRotationPoint(-6F, -1F, -5F);
      RimLeft.setTextureSize(128, 64);
      RimLeft.mirror = true;
      setRotation(RimLeft, 0F, 0F, 0F);
      RimBack = new ModelRenderer(this, 78, 36);
      RimBack.addBox(0F, 0F, 0F, 10, 1, 1);
      RimBack.setRotationPoint(-5F, -1F, 5F);
      RimBack.setTextureSize(128, 64);
      RimBack.mirror = true;
      setRotation(RimBack, 0F, 0F, 0F);
      VisorBrow2 = new ModelRenderer(this, 67, 7);
      VisorBrow2.addBox(0F, 0F, 0F, 2, 1, 1);
      VisorBrow2.setRotationPoint(-1F, -6F, -6F);
      VisorBrow2.setTextureSize(128, 64);
      VisorBrow2.mirror = true;
      setRotation(VisorBrow2, 0F, 0F, 0F);
      DecoRimFrontLeft = new ModelRenderer(this, 76, 14);
      DecoRimFrontLeft.addBox(0F, 0F, 0F, 1, 4, 1);
      DecoRimFrontLeft.setRotationPoint(-2F, -11F, -6F);
      DecoRimFrontLeft.setTextureSize(128, 64);
      DecoRimFrontLeft.mirror = true;
      setRotation(DecoRimFrontLeft, 0F, 0F, 0F);
      DecoRimFrontRight = new ModelRenderer(this, 71, 14);
      DecoRimFrontRight.addBox(0F, 0F, 0F, 1, 4, 1);
      DecoRimFrontRight.setRotationPoint(1F, -11F, -6F);
      DecoRimFrontRight.setTextureSize(128, 64);
      DecoRimFrontRight.mirror = true;
      setRotation(DecoRimFrontRight, 0F, 0F, 0F);
      Top1 = new ModelRenderer(this, 64, 41);
      Top1.addBox(0F, 0F, 0F, 10, 1, ;
      Top1.setRotationPoint(-5F, -10F, -4F);
      Top1.setTextureSize(128, 64);
      Top1.mirror = true;
      setRotation(Top1, 0F, 0F, 0F);
      Top2 = new ModelRenderer(this, 46, 0);
      Top2.addBox(0F, 0F, 0F, 8, 1, 1);
      Top2.setRotationPoint(-4F, -10F, 4F);
      Top2.setTextureSize(128, 64);
      Top2.mirror = true;
      setRotation(Top2, 0F, 0F, 0F);
      Top3 = new ModelRenderer(this, 46, 4);
      Top3.addBox(0F, 0F, 0F, 8, 1, 1);
      Top3.setRotationPoint(-4F, -10F, -5F);
      Top3.setTextureSize(128, 64);
      Top3.mirror = true;
      setRotation(Top3, 0F, 0F, 0F);
      DecoRimTopLeft = new ModelRenderer(this, 54, 27);
      DecoRimTopLeft.addBox(0F, 0F, 0F, 1, 1, 10);
      DecoRimTopLeft.setRotationPoint(-2F, -11F, -5F);
      DecoRimTopLeft.setTextureSize(128, 64);
      DecoRimTopLeft.mirror = true;
      setRotation(DecoRimTopLeft, 0F, 0F, 0F);
      DecoRimTopRight = new ModelRenderer(this, 29, 27);
      DecoRimTopRight.addBox(0F, 0F, 0F, 1, 1, 10);
      DecoRimTopRight.setRotationPoint(1F, -11F, -5F);
      DecoRimTopRight.setTextureSize(128, 64);
      DecoRimTopRight.mirror = true;
      setRotation(DecoRimTopRight, 0F, 0F, 0F);
      DecoRimBackLeft = new ModelRenderer(this, 65, 14);
      DecoRimBackLeft.addBox(0F, 0F, 0F, 1, 9, 1);
      DecoRimBackLeft.setRotationPoint(-2F, -10F, 5F);
      DecoRimBackLeft.setTextureSize(128, 64);
      DecoRimBackLeft.mirror = true;
      setRotation(DecoRimBackLeft, 0F, 0F, 0F);
      DecoRimBackRight = new ModelRenderer(this, 59, 14);
      DecoRimBackRight.addBox(0F, 0F, 0F, 1, 9, 1);
      DecoRimBackRight.setRotationPoint(1F, -10F, 5F);
      DecoRimBackRight.setTextureSize(128, 64);
      DecoRimBackRight.mirror = true;
      setRotation(DecoRimBackRight, 0F, 0F, 0F);
      WingLeft1 = new ModelRenderer(this, 53, 9);
      WingLeft1.addBox(0F, 0F, 0F, 4, 1, 2);
      WingLeft1.setRotationPoint(-9F, -8F, -1F);
      WingLeft1.setTextureSize(128, 64);
      WingLeft1.mirror = true;
      setRotation(WingLeft1, 0F, 0F, 0F);
      WingLeft2 = new ModelRenderer(this, 42, 9);
      WingLeft2.addBox(0F, 0F, 0F, 3, 1, 2);
      WingLeft2.setRotationPoint(-8F, -7F, -1F);
      WingLeft2.setTextureSize(128, 64);
      WingLeft2.mirror = true;
      setRotation(WingLeft2, 0F, 0F, 0F);
      WingLeft3 = new ModelRenderer(this, 49, 14);
      WingLeft3.addBox(0F, 0F, 0F, 2, 1, 2);
      WingLeft3.setRotationPoint(-7F, -6F, -1F);
      WingLeft3.setTextureSize(128, 64);
      WingLeft3.mirror = true;
      setRotation(WingLeft3, 0F, 0F, 0F);
      WingLeft4 = new ModelRenderer(this, 51, 19);
      WingLeft4.addBox(0F, 0F, 0F, 1, 1, 2);
      WingLeft4.setRotationPoint(-6F, -5F, -1F);
      WingLeft4.setTextureSize(128, 64);
      WingLeft4.mirror = true;
      setRotation(WingLeft4, 0F, 0F, 0F);
      WingRight1 = new ModelRenderer(this, 32, 0);
      WingRight1.addBox(0F, 0F, 0F, 4, 1, 2);
      WingRight1.setRotationPoint(5F, -8F, -1F);
      WingRight1.setTextureSize(128, 64);
      WingRight1.mirror = true;
      setRotation(WingRight1, 0F, 0F, 0F);
      WingRight2 = new ModelRenderer(this, 33, 5);
      WingRight2.addBox(0F, 0F, 0F, 3, 1, 2);
      WingRight2.setRotationPoint(5F, -7F, -1F);
      WingRight2.setTextureSize(128, 64);
      WingRight2.mirror = true;
      setRotation(WingRight2, 0F, 0F, 0F);
      WingRight3 = new ModelRenderer(this, 40, 14);
      WingRight3.addBox(0F, 0F, 0F, 2, 1, 2);
      WingRight3.setRotationPoint(5F, -6F, -1F);
      WingRight3.setTextureSize(128, 64);
      WingRight3.mirror = true;
      setRotation(WingRight3, 0F, 0F, 0F);
      WingRight4 = new ModelRenderer(this, 43, 19);
      WingRight4.addBox(0F, 0F, 0F, 1, 1, 2);
      WingRight4.setRotationPoint(5F, -5F, -1F);
      WingRight4.setTextureSize(128, 64);
      WingRight4.mirror = true;
      setRotation(WingRight4, 0F, 0F, 0F);
      Forehead = new ModelRenderer(this, 11, 0);
      Forehead.addBox(0F, 0F, 0F, 8, 3, 1);
      Forehead.setRotationPoint(-4F, -9F, -5F);
      Forehead.setTextureSize(128, 64);
      Forehead.mirror = true;
      setRotation(Forehead, 0F, 0F, 0F);
      SinglePixelRim = new ModelRenderer(this, 0, 0);
      SinglePixelRim.addBox(0F, 0F, 0F, 1, 1, 1);
      SinglePixelRim.setRotationPoint(-5F, -1F, -6F);
      SinglePixelRim.setTextureSize(128, 64);
      SinglePixelRim.mirror = true;
      setRotation(SinglePixelRim, 0F, 0F, 0F);
      SinglePixelRim2 = new ModelRenderer(this, 5, 0);
      SinglePixelRim2.addBox(0F, 0F, 0F, 1, 1, 1);
      SinglePixelRim2.setRotationPoint(4F, -1F, -6F);
      SinglePixelRim2.setTextureSize(128, 64);
      SinglePixelRim2.mirror = true;
      setRotation(SinglePixelRim2, 0F, 0F, 0F);
  }

  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    HeadRight.render(f5);
    VisorBrow1.render(f5);
    VisorRight1.render(f5);
    VisorLeft1.render(f5);
    VisorLeft2.render(f5);
    VisorRight2.render(f5);
    VisorLeft3.render(f5);
    VisorRight3.render(f5);
    Cheek1.render(f5);
    Cheek2.render(f5);
    HeadLeft.render(f5);
    HeadBack.render(f5);
    RimFrontRight.render(f5);
    RimFrontLeft.render(f5);
    RimRight.render(f5);
    RimLeft.render(f5);
    RimBack.render(f5);
    VisorBrow2.render(f5);
    DecoRimFrontLeft.render(f5);
    DecoRimFrontRight.render(f5);
    Top1.render(f5);
    Top2.render(f5);
    Top3.render(f5);
    DecoRimTopLeft.render(f5);
    DecoRimTopRight.render(f5);
    DecoRimBackLeft.render(f5);
    DecoRimBackRight.render(f5);
    WingLeft1.render(f5);
    WingLeft2.render(f5);
    WingLeft3.render(f5);
    WingLeft4.render(f5);
    WingRight1.render(f5);
    WingRight2.render(f5);
    WingRight3.render(f5);
    WingRight4.render(f5);
    Forehead.render(f5);
    SinglePixelRim.render(f5);
    SinglePixelRim2.render(f5);
  }

  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }

  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
  }

}

And no my name is not inspired by DBZ ^^

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.