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

I've made a helmet with a custom model, however it isn't rendering properly. It renders and rotates with the movement of the player's head, but it's rendering at the bottom of the chest and it's scaled down. I've tried looking at how another mod did it, that got me where I am now(Before it was rendering in the right place at the right scale, but it wasn't moving with the players head). I also tried using OpenGL, but I couldn't figure out how to calculate the values to translate/scale the model.

 

ItemEarmuffs.java

package com.leviathan143.ellipsis.common.items;

import net.minecraft.client.audio.ISound;
import net.minecraft.client.audio.SoundCategory;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import com.leviathan143.ellipsis.Ellipsis.Constants;
import com.leviathan143.ellipsis.client.model.armour.ModelEarmuffs;
import com.leviathan143.ellipsis.common.blocks.IMuffler;

public class ItemEarmuffs extends ItemArmor implements IMuffler
{
public ItemEarmuffs() 
{
	super(ArmorMaterial.LEATHER, 0, 0);
}

private ModelEarmuffs modelEarmuffs = new ModelEarmuffs();

private static final String EARMUFFS_TEXTURE = Constants.MODID + ":textures/armour/earmuffs.png";

@Override
public boolean shouldMuffleSound(World world, BlockPos mufflerPos,
		ISound sound, SoundCategory category) 
{
	return true;
}

@Override
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) 
{
	if(armorType == 0) return true;
	return false;
}

@Override
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot, ModelBiped _default) 
{
	if(armorSlot == 4)
	{
		return modelEarmuffs;
	}
	return super.getArmorModel(entityLiving, itemStack, armorSlot, _default);
}

@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) 
{
	return EARMUFFS_TEXTURE;
}
}

 

ModelEarmuffs.java

package com.leviathan143.ellipsis.client.model.armour;

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


/**
* ModelEarmuffs - Leviathan143
* Created using Tabula 5.1.0
*/
public class ModelEarmuffs extends ModelBiped {
    public ModelRenderer headband;
    public ModelRenderer rightMuff;
    public ModelRenderer leftMuff;

    public ModelEarmuffs() 
    {
        this.textureWidth = 32;
        this.textureHeight = 16;
        this.leftMuff = new ModelRenderer(this, 11, 6);
        this.leftMuff.setRotationPoint(3.5F, 3.0F, 0.0F);
        this.leftMuff.addBox(0.0F, 0.0F, -1.5F, 2, 4, 3, 0.0F);
        this.rightMuff = new ModelRenderer(this, 0, 6);
        this.rightMuff.setRotationPoint(-3.5F, 3.0F, 0.0F);
        this.rightMuff.addBox(-2.0F, 0.0F, -1.5F, 2, 4, 3, 0.0F);
        this.rightMuff.mirror = true;
        this.headband = new ModelRenderer(this, 0, 0);
        this.headband.setRotationPoint(0.0F, -8.5F, 0.0F);
        this.headband.addBox(-5.0F, -0.5F, -0.5F, 10, 4, 1, 0.0F);
        this.headband.addChild(this.leftMuff);
        this.headband.addChild(this.rightMuff);
    }

    //I can't figure out what most of these floats are, so they have terrible names.
    @Override
    public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float scale) 
    {
    	this.bipedHead = headband;
    	this.bipedHeadwear.showModel = false;
    	super.render(entity, f, f1, f2, f3, f4, scale);
    }

    /**
     * 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 first model was the same as the current one except for the render method, which was this:

@Override
    public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float scale) 
    {
        this.headband.render(scale);
    }

  • Author

I hate to bump this, but I really need some help with this.

EDIT: Figured it out, I needed to make some changes to the model file, here's the fixed model:

package com.leviathan143.ellipsis.client.model.armour;

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


/**
* ModelEarmuffs - Leviathan143
* Created using Tabula 5.1.0
*/
public class ModelEarmuffs extends ModelBiped {
public ModelRenderer headband;
public ModelRenderer rightMuff;
public ModelRenderer leftMuff;

public ModelEarmuffs() 
{
	this.textureWidth = 32;
	this.textureHeight = 16;
	this.rightMuff = new ModelRenderer(this, 0, 6);
	this.rightMuff.mirror = true;
	this.rightMuff.setRotationPoint(0.0F, 0.0F, 0.0F);
	this.rightMuff.addBox(3.5F, -5.0F, -2.0F, 2, 4, 3, 0.0F);
	this.setRotateAngle(rightMuff, 0.0F, 3.141592653589793F, 0.0F);
	this.leftMuff = new ModelRenderer(this, 0, 6);
	this.leftMuff.mirror = true;
	this.leftMuff.setRotationPoint(0.0F, 0.0F, 0.0F);
	this.leftMuff.addBox(3.5F, -5.0F, -1.0F, 2, 4, 3, 0.0F);
	this.headband = new ModelRenderer(this, 0, 0);
	this.headband.setRotationPoint(0.0F, 0.0F, 0.0F);
	this.headband.addBox(-5.0F, -9.0F, 0.0F, 10, 4, 1, 0.0F);
	this.headband.addChild(this.rightMuff);
	this.headband.addChild(this.leftMuff);    }

//I can't figure out what most of these floats are, so they have terrible names.
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float scale) 
{
	GlStateManager.pushMatrix();
	super.setRotationAngles(f, f1, f2, f3, f4, scale, entity);
	this.bipedHead = headband;
	if(entity.isSneaking()) GlStateManager.translate(0.0F, 0.275F, 0.0F);
	headband.render(scale);
	GlStateManager.popMatrix();
}

/**
 * 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 main problem was that all the parts of your model need to have the same rotation point as the part of the model it goes on, my model did not do this.

 

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.