Custom armor model problems

Started by Aplhau on

Topic category: Troubleshooting, bugs, and solutions

Last seen on 00:36, 9. Dec 2021
Joined Jul 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Custom armor model problems
Sat, 05/01/2021 - 20:33 (edited)

I added a custom armor model into the game and it is a leg piece. Part of the leg model has a piece that follows the body(on purpose). The issue with this piece is that when shifting the piece moves forward except for staying with the body.

Code :

public class ItemUtahime extends ElementsJujutsuKaisenMod.ModElement {
    @GameRegistry.ObjectHolder("jujutsukaisenmod:utahimehelmet")
    public static final Item helmet = null;
    @GameRegistry.ObjectHolder("jujutsukaisenmod:utahimebody")
    public static final Item body = null;
    @GameRegistry.ObjectHolder("jujutsukaisenmod:utahimelegs")
    public static final Item legs = null;
    @GameRegistry.ObjectHolder("jujutsukaisenmod:utahimeboots")
    public static final Item boots = null;
    public ItemUtahime(ElementsJujutsuKaisenMod instance) {
        super(instance, 34);
    }

    @Override
    public void initElements() {
        ItemArmor.ArmorMaterial enuma = EnumHelper.addArmorMaterial("UTAHIME", "jujutsukaisenmod:kugisaki_", 25, new int[]{2, 7, 9, 2}, 9,
                (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("")), 0f);
        elements.items.add(() -> new ItemArmor(enuma, 0, EntityEquipmentSlot.CHEST) {
            @Override
            @SideOnly(Side.CLIENT)
            public ModelBiped getArmorModel(EntityLivingBase living, ItemStack stack, EntityEquipmentSlot slot, ModelBiped defaultModel) {
                ModelBiped armorModel = new ModelBiped();
                armorModel.bipedBody = new Modelutahime_jacket().body;
                armorModel.bipedLeftArm = new Modelutahime_jacket().leftarm;
                armorModel.bipedRightArm = new Modelutahime_jacket().rightarm;
                armorModel.isSneak = living.isSneaking();
                armorModel.isRiding = living.isRiding();
                armorModel.isChild = living.isChild();
                return armorModel;
            }

            @Override
            public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) {
                return "jujutsukaisenmod:textures/utahime_jacket.png";
            }
        }.setUnlocalizedName("utahimebody").setRegistryName("utahimebody").setCreativeTab(CreativeTabs.COMBAT));
        elements.items.add(() -> new ItemArmor(enuma, 0, EntityEquipmentSlot.LEGS) {
            @Override
            @SideOnly(Side.CLIENT)
            public ModelBiped getArmorModel(EntityLivingBase living, ItemStack stack, EntityEquipmentSlot slot, ModelBiped defaultModel) {
                ModelBiped armorModel = new ModelBiped();
                armorModel.bipedLeftLeg = new Modelutahime_pants().leftleg;
                armorModel.bipedRightLeg = new Modelutahime_pants().rightleg;
                armorModel.bipedBody = new Modelutahime_pants().bb_main;
                armorModel.isSneak = living.isSneaking();
                armorModel.isRiding = living.isRiding();
                armorModel.isChild = living.isChild();
                return armorModel;
            }

            @Override
            public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) {
                return "jujutsukaisenmod:textures/utahime_pants.png";
            }
        }.setUnlocalizedName("utahimelegs").setRegistryName("utahimelegs").setCreativeTab(CreativeTabs.COMBAT));
    }

    @SideOnly(Side.CLIENT)
    @Override
    public void registerModels(ModelRegistryEvent event) {
        ModelLoader.setCustomModelResourceLocation(body, 0, new ModelResourceLocation("jujutsukaisenmod:utahimebody", "inventory"));
        ModelLoader.setCustomModelResourceLocation(legs, 0, new ModelResourceLocation("jujutsukaisenmod:utahimelegs", "inventory"));
    }
    public static class Modelutahime_jacket extends ModelBase {
        private final ModelRenderer body;
        private final ModelRenderer rightarm;
        private final ModelRenderer rightarm_r1;
        private final ModelRenderer leftarm;
        private final ModelRenderer leftarm_r1;
        public Modelutahime_jacket() {
            textureWidth = 64;
            textureHeight = 64;
            body = new ModelRenderer(this);
            body.setRotationPoint(0.0F, 0.0F, 0.0F);
            body.cubeList.add(new ModelBox(body, 0, 32, -4.0F, 0.0F, -2.0F, 8, 9, 4, 0.1F, false));
            rightarm = new ModelRenderer(this);
            rightarm.setRotationPoint(-5.0F, 2.0F, 0.0F);
            rightarm.cubeList.add(new ModelBox(rightarm, 32, 0, -3.0F, -2.0F, -2.5F, 4, 13, 5, 0.1F, false));
            rightarm_r1 = new ModelRenderer(this);
            rightarm_r1.setRotationPoint(-1.0F, 4.0F, 0.0F);
            rightarm.addChild(rightarm_r1);
            setRotationAngle(rightarm_r1, 0.0F, 0.0F, 0.1309F);
            rightarm_r1.cubeList.add(new ModelBox(rightarm_r1, 46, 46, -2.8F, -6.0F, -2.5F, 4, 13, 5, 0.1F, false));
            leftarm = new ModelRenderer(this);
            leftarm.setRotationPoint(5.0F, 2.0F, 0.0F);
            leftarm.cubeList.add(new ModelBox(leftarm, 32, 0, -1.0F, -2.0F, -2.5F, 4, 13, 5, 0.1F, true));
            leftarm_r1 = new ModelRenderer(this);
            leftarm_r1.setRotationPoint(1.0F, 4.5F, 0.0F);
            leftarm.addChild(leftarm_r1);
            setRotationAngle(leftarm_r1, 0.0F, 0.0F, -0.1309F);
            leftarm_r1.cubeList.add(new ModelBox(leftarm_r1, 46, 46, -0.9F, -6.5F, -2.5F, 4, 13, 5, 0.1F, true));
        }

        @Override
        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);

        }

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

    public static class Modelutahime_pants extends ModelBase {
        private final ModelRenderer rightleg;
        private final ModelRenderer leftleg;
        private final ModelRenderer bb_main;
        public Modelutahime_pants() {
            textureWidth = 64;
            textureHeight = 64;
            rightleg = new ModelRenderer(this);
            rightleg.setRotationPoint(-1.9F, 12.0F, 0.0F);
            rightleg.cubeList.add(new ModelBox(rightleg, 0, 33, -2.0F, -1.0F, -2.0F, 4, 10, 4, 0.1F, false));
            rightleg.cubeList.add(new ModelBox(rightleg, 17, 33, -2.0F, -1.0F, -2.0F, 4, 10, 4, 0.3F, false));
            leftleg = new ModelRenderer(this);
            leftleg.setRotationPoint(1.9F, 12.0F, 0.0F);
            leftleg.cubeList.add(new ModelBox(leftleg, 0, 33, -2.0F, -1.0F, -2.0F, 4, 10, 4, 0.1F, true));
            leftleg.cubeList.add(new ModelBox(leftleg, 48, 50, -2.0F, -1.0F, -2.0F, 4, 10, 4, 0.3F, false));
            bb_main = new ModelRenderer(this);
            bb_main.setRotationPoint(0.0F, 9.5F, 0.0F);
            bb_main.cubeList.add(new ModelBox(bb_main, 40, 0, -4.0F, -1.5F, -2.0F, 8, 3, 4, 0.1F, false));
        }

        @Override
        public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
            rightleg.render(f5);
            leftleg.render(f5);
            bb_main.render(f5);

        }

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

 

Edited by Aplhau on Sat, 05/01/2021 - 20:33