Jump to content

[1.15.2] Problems creating custom armor models


Recommended Posts

Hello, I have run into another small problem. I tried programming my own custom model for my armor (currently only for a helmet), but it gets render bad. It just takes the whole texture defined and "glues" it onto the model, even though I have defined texture offsets and boundaries. Plz help.


The code for the model:

package com.dpaul.mod.item.armor.model;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;

import net.minecraft.client.renderer.entity.model.BipedModel;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraft.entity.LivingEntity;

 * ModelCopperHelmet - DPaulModz Created using Tabula 7.1.0
public class CopperHelmetModel extends BipedModel<LivingEntity>
	public ModelRenderer shape15;
	public ModelRenderer shape16;
	public ModelRenderer shape17;
	public ModelRenderer shape18;
	public ModelRenderer shape19;

	public CopperHelmetModel(float size)
		this.textureWidth = 128;
		this.textureHeight = 128;
		this.shape18 = new ModelRenderer(this, 68, 32);
		this.shape18.setRotationPoint(-4.0F, -8.0F, 4.0F);
		this.shape18.addBox(-4F, -8F, 4F, 8, 8, 0.5F, size);
		this.shape16 = new ModelRenderer(this, 18, 32);
		this.shape16.setRotationPoint(4.0F, -8.0F, -4.0F);
		this.shape16.addBox(4F, -8F, -4F, 0.5F, 8, 8, size);
		this.shape15 = new ModelRenderer(this, 0, 32);
		this.shape15.setRotationPoint(-4.5F, -8.0F, -4.0F);
		this.shape15.addBox(-4.5F, -8F, -4F, 0.5F, 8, 8, size);
		this.shape17 = new ModelRenderer(this, 36, 32);
		this.shape17.setRotationPoint(-4.0F, -8.5F, -4.0F);
		this.shape17.addBox(-4F, -8.5F, -4F, 8, 0.5F, 8, size);
		this.shape19 = new ModelRenderer(this, 86, 32);
		this.shape19.setRotationPoint(-4.0F, -8.0F, -4.5F);
		this.shape19.addBox(-4F, -8F, -4.5F, 8, 8, 0.5F, size);
	public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha)
		super.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);

	 * This is a helper function from Tabula to set the rotation of model parts
	public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z)
		modelRenderer.rotateAngleX = x;
		modelRenderer.rotateAngleY = y;
		modelRenderer.rotateAngleZ = z;


The code for the helmet:

package com.dpaul.mod.item.armor;

import javax.annotation.Nullable;

import com.dpaul.mod.Main;
import com.dpaul.mod.item.armor.model.CopperHelmetModel;

import net.minecraft.client.renderer.entity.model.BipedModel;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

public class CopperHelmet extends ArmorItemBase
	public CopperHelmet()
		super("copper_helmet", ArmorMaterial.COPPER, EquipmentSlotType.HEAD, new Item.Properties().group(Main.tutorial_item_group));

	public <A extends BipedModel<?>> A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType armorSlot, A _default)
		CopperHelmetModel model = new CopperHelmetModel(1F);
        model.bipedHeadwear.showModel = armorSlot == EquipmentSlotType.HEAD;

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

        return (A) model;
	public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlotType slot, String type)
		return "tutorialmod:textures/models/armor/copper_helmet_overlay.png";


Image of the rendered model attached.




Link to comment
Share on other sites

  • 3 months later...
On 3/22/2020 at 2:08 PM, ChampionAsh5357 said:

That's probably because you didn't align anything relative to the head. When you add something as a child model, everything becomes relative to the that specific renderer and not the entire model. So you have reorient everything in terms of the specific renderer.

I think I am having the same problem with textures but I do not understand how to do this, could you elaborate please?

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.

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.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I am getting an error message that my mods and my server are not on the same minecraft version when they clearly are. My server and my mods are on 1.20.1 and the error says that the server is 1.20 even though it's on forge 47.2.30.  
    • .Omg, I'm so freaking blind I didn't notice that, it works now, thank you so much @Xoroshio
    • On the one off the last lines of code you have put && boots.isEmpty() Instead of && !boots.isEmpty() is that a typo?
    • I'm trying to apply effects to the emerald armor but it doesn't work, I read that the onArmorTick() method doesn't work anymore, but I tried with inventoryTick, onInventoryTick and onArmorTick but they don't apply the effect either, I don't know if I'm writing it wrong, so I need help to fix it. This is the code in question: public class ModArmorItem extends ArmorItem{ private static final Map<ArmorMaterial, MobEffectInstance> MATERIAL_TO_EFFECT_MAP = (new ImmutableMap.Builder<ArmorMaterial, MobEffectInstance>()) .put(ModArmorMaterials.EMERALD, new MobEffectInstance( MobEffects.HERO_OF_THE_VILLAGE, 200, 1, false, false, true)) .build(); public ModArmorItem(ArmorMaterial pMaterial, Type pType, Properties pProperties) { super(pMaterial, pType, pProperties); } @Override public void onArmorTick(ItemStack stack, Level world, Player player){ if (!world.isClientSide()) { if (hasFullSuitOfArmorOn(player)) { evaluateArmorEffects(player); } } } private void evaluateArmorEffects(Player player) { for (Map.Entry<ArmorMaterial,MobEffectInstance> entry : MATERIAL_TO_EFFECT_MAP.entrySet()){ ArmorMaterial mapArmorMaterial = entry.getKey(); MobEffectInstance mapStatusEffect = entry.getValue(); if (hasCorrectArmorOn(mapArmorMaterial, player)) { addStatusEffectForMaterial(player, mapArmorMaterial, mapStatusEffect); } } } private void addStatusEffectForMaterial(Player player, ArmorMaterial mapArmorMaterial, MobEffectInstance mapStatusEffect) { boolean hasPlayerEffect = player.hasEffect(mapStatusEffect.getEffect()); if (hasCorrectArmorOn(mapArmorMaterial, player) && !hasPlayerEffect) { player.addEffect(new MobEffectInstance(mapStatusEffect)); } } private boolean hasCorrectArmorOn(ArmorMaterial material, Player player) { for (ItemStack armorStack : player.getInventory().armor){ if (!(armorStack.getItem() instanceof ArmorItem)) { return false; } } ArmorItem helmet = ((ArmorItem)player.getInventory().getArmor(3).getItem()); ArmorItem brestplace = ((ArmorItem)player.getInventory().getArmor(2).getItem()); ArmorItem leggins = ((ArmorItem)player.getInventory().getArmor(1).getItem()); ArmorItem boots = ((ArmorItem)player.getInventory().getArmor(0).getItem()); return helmet.getMaterial() == material && brestplace.getMaterial() == material && leggins.getMaterial() == material && boots.getMaterial() == material; } private boolean hasFullSuitOfArmorOn(Player player){ ItemStack helmet = player.getInventory().getArmor(3); ItemStack breastplace = player.getInventory().getArmor(2); ItemStack leggins = player.getInventory().getArmor(1); ItemStack boots = player.getInventory().getArmor(0); return !helmet.isEmpty() && !breastplace.isEmpty() && !leggins.isEmpty() && boots.isEmpty(); } } And here is the armor   public static final RegistryObject<Item> EMERALD_HELMET = ITEMS.register( "emerald_helmet", () -> new ModArmorItem(ModArmorMaterials.EMERALD, ArmorItem.Type.HELMET, new Item.Properties()) ); public static final RegistryObject<Item> EMERALD_CHESTPLATE = ITEMS.register( "emerald_chestplate", () -> new ModArmorItem(ModArmorMaterials.EMERALD, ArmorItem.Type.CHESTPLATE, new Item.Properties()) ); public static final RegistryObject<Item> EMERALD_LEGGINS = ITEMS.register( "emerald_leggins", () -> new ModArmorItem(ModArmorMaterials.EMERALD, ArmorItem.Type.LEGGINGS, new Item.Properties()) ); public static final RegistryObject<Item> EMERALD_BOOTS = ITEMS.register( "emerald_boots", () -> new ModArmorItem(ModArmorMaterials.EMERALD, ArmorItem.Type.BOOTS, new Item.Properties()) ); I hope you can help me. Thanks.
    • so ive been having this issue for a little bit, and have honestly no clue on how to fix it. I'm using minecraft 1.20.1 for clarification.  Here is the latest log: https://pastebin.com/neMuxELv
  • Topics

  • Create New...

Important Information

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