Jump to content

[1.12.2] Custom Armor Model not rendering correctly


Arthur Wesley

Recommended Posts

I'm trying to render a custom [chestplate] but it won't work properly. I made the code using Tabula mod, but what happens is that the rendered parts connected to the arms won't move, they just stay static.

Anything I miss?

 

Model class:

import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.GlStateManager;

public class ModelMSapphireArmor extends ModelBiped {

    public ModelRenderer Chestplate;
    public ModelRenderer ShoulderRight;
    public ModelRenderer MegaRight;
    public ModelRenderer MegaRight_1;
    public ModelRenderer MegaRight_2;

    public ModelMSapphireArmor() {
        this.textureWidth = 128;
        this.textureHeight = 128;
        this.MegaRight = new ModelRenderer(this, 110, 32);
        this.MegaRight.setRotationPoint(-3.0F, -2.0F, -2.0F);
        this.MegaRight.addBox(-9.0F, -4.8F, 0.9F, 2, 3, 2, 0.0F);
        this.MegaRight_1 = new ModelRenderer(this, 92, 32);
        this.MegaRight_1.setRotationPoint(-3.0F, -2.0F, -2.0F);
        this.MegaRight_1.addBox(-7.0F, -0.1F, 0.1F, 3, 3, 4, 0.0F);
        this.ShoulderRight = new ModelRenderer(this, 74, 42);
        this.ShoulderRight.setRotationPoint(-3.0F, -2.0F, -2.0F);
        this.ShoulderRight.addBox(-8.5F, 3.6F, -1.0F, 8, 10, 8, 0.0F);
        this.Chestplate = new ModelRenderer(this, 73, -4);
        this.Chestplate.setRotationPoint(-4.0F, 0.0F, -2.0F);
        this.Chestplate.addBox(-1.7F, 0.0F, -1.0F, 16, 22, 8, 0.0F);
        this.MegaRight_2 = new ModelRenderer(this, 76, 32);
        this.MegaRight_2.setRotationPoint(-3.0F, -2.0F, -2.0F);
        this.MegaRight_2.addBox(-8.5F, -2.5F, 0.5F, 3, 3, 3, 0.0F);

        this.bipedBody.addChild(Chestplate);
        this.bipedRightArm.addChild(ShoulderRight);
        this.bipedRightArm.addChild(MegaRight);
        this.bipedRightArm.addChild(MegaRight_1);
        this.bipedRightArm.addChild(MegaRight_2);
    }

    @Override
    public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
        this.MegaRight.render(f5);
        this.MegaRight_1.render(f5);
        GlStateManager.pushMatrix();
        GlStateManager.translate(this.ShoulderRight.offsetX, this.ShoulderRight.offsetY, this.ShoulderRight.offsetZ);
        GlStateManager.translate(this.ShoulderRight.rotationPointX * f5, this.ShoulderRight.rotationPointY * f5, this.ShoulderRight.rotationPointZ * f5);
        GlStateManager.scale(0.65D, 0.55D, 0.7D);
        GlStateManager.translate(-this.ShoulderRight.offsetX, -this.ShoulderRight.offsetY, -this.ShoulderRight.offsetZ);
        GlStateManager.translate(-this.ShoulderRight.rotationPointX * f5, -this.ShoulderRight.rotationPointY * f5, -this.ShoulderRight.rotationPointZ * f5);
        this.ShoulderRight.render(f5);
        GlStateManager.popMatrix();
        GlStateManager.pushMatrix();
        GlStateManager.translate(this.Chestplate.offsetX, this.Chestplate.offsetY, this.Chestplate.offsetZ);
        GlStateManager.translate(this.Chestplate.rotationPointX * f5, this.Chestplate.rotationPointY * f5, this.Chestplate.rotationPointZ * f5);
        GlStateManager.scale(0.65D, 0.55D, 0.7D);
        GlStateManager.translate(-this.Chestplate.offsetX, -this.Chestplate.offsetY, -this.Chestplate.offsetZ);
        GlStateManager.translate(-this.Chestplate.rotationPointX * f5, -this.Chestplate.rotationPointY * f5, -this.Chestplate.rotationPointZ * f5);
        this.Chestplate.render(f5);
        GlStateManager.popMatrix();
        this.MegaRight_2.render(f5);
    }

    public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
        modelRenderer.rotateAngleX = x;
        modelRenderer.rotateAngleY = y;
        modelRenderer.rotateAngleZ = z;
    }
}

 

Armor Render class:

import net.minecraft.client.model.ModelBiped;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import tutuicraft3.sapphirecraft.Main;
import tutuicraft3.sapphirecraft.init.ItemInit;
import tutuicraft3.sapphirecraft.util.interfaces.IHasModel;

public class ArmorModel extends ItemArmor implements IHasModel
{
    public ArmorModel(String name, CreativeTabs tab, ArmorMaterial materialIn, EntityEquipmentSlot equipmentSlotIn)
    {
        super(materialIn, 1, equipmentSlotIn);
        setUnlocalizedName(name);
        setRegistryName(name);
        setCreativeTab(tab);
        setMaxStackSize(1);

        ItemInit.ITEMS.add(this);
    }

    @Override
    public boolean hasEffect(ItemStack stack) {
        return true;
    }

    @Override
    public void registerModels()
    {
        Main.proxy.registerModel(this, 0);
    }

    @Override
    public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default)
    {
        if(itemStack != ItemStack.EMPTY)
        {
            if(itemStack.getItem() instanceof ItemArmor)
            {
                ModelMSapphireArmor model = new ModelMSapphireArmor();

                model.bipedHead.showModel = armorSlot == EntityEquipmentSlot.HEAD;

                model.isChild = _default.isChild;
                model.isRiding = _default.isRiding;
                model.isSneak = _default.isSneak;
                model.rightArmPose = _default.rightArmPose;
                model.leftArmPose = _default.leftArmPose;

                return model;
            }
        }

        return null;
    }

}

 

 

VIDEO

Edited by Arthur Wesley
More info.
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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