Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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)
	{
		super(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);
		
		this.bipedHead.addChild(shape15);
		this.bipedHead.addChild(shape16);
		this.bipedHead.addChild(shape17);
		this.bipedHead.addChild(shape18);
		this.bipedHead.addChild(shape19);
	}
	
	@Override
	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));
	}

	@SuppressWarnings("unchecked")
	@Nullable
	@Override
	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;
	}
	
	@Override
	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.

 

 

Screenshot_20200322_134208.png

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.

  • 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?

3 hours ago, clearcut said:

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

Please create your own post with your code, error logs (if any), and examples if you need more to explain your point.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.