Jump to content

[1.8.9]Unsure how to fit bounding box and texture offsets to custom entity model


Recommended Posts

Hi guys I'm new to MC modding and I've been dicking around with forge modding ( for a few days. I'm having 2 issues with my custom entity. In game when I press F3+B to view the bounding box, it seems as if my entities bb is just a square on the ground, meaning I can't hit it unless I punch it's feet. How can I change the bbox to match my entity in game?


The other issue is texture offsets. I can't really get a feel to how this works but I created my model in Techne then using a couple of tutorials on the internet tried to recreate the model using a child hierarchy where everything is parented to the torso in code only. I did not export the Techne model as java and use that. I did however generate the texture file with Techne by exporting as a texture and drawing/reimporting etc. However when I set the texture offsets in my BaseModelCat class (copying them from the texture offsets in Techne) they don't turn out correctly at all. Here is the model in Techne, the model in game, the texture image, and the BaseModelCat class:








package com.gerg.catology.client.model;

import org.lwjgl.opengl.GL11;

import com.gerg.catology.entity.passive.BaseCatEntity;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

//all cats look the same just different textures.
//just extend this class to make a new cat.
public class BaseModelCat extends ModelBase {

public ModelRenderer head;
public ModelRenderer torso;
public ModelRenderer brleg;
public ModelRenderer blleg;
public ModelRenderer flleg;
public ModelRenderer frleg;
public ModelRenderer nose;
public ModelRenderer tail1;
public ModelRenderer tail2;
public ModelRenderer tail3;
public ModelRenderer tail4;
public ModelRenderer tail5;
public ModelRenderer rear;
public ModelRenderer lear;

public int texture_width = 64;
public int texture_height = 32;

public double distanceMovedTotal = 0.0D;

//cycles of animation per block moved
protected static final double CYCLES_PER_BLOCK = 3.0D;

public BaseModelCat() {

	torso = new ModelRenderer(this);
	torso.addBox(-3F, -3F, -8F, 6, 6, 16);
	torso.setRotationPoint(0F, 15F, 0F);
	torso.setTextureSize(texture_width, texture_height);
	torso.setTextureOffset(0, 0);

	head = new ModelRenderer(this);
	head.addBox(-4F, -3F, -6F, 8, 6, 6);
	head.setRotationPoint(0F, 13F, -8F);
	head.setTextureSize(texture_width, texture_height);
	head.setTextureOffset(30, 0);

	nose = new ModelRenderer(this);
	nose.addBox(-2F, -2F, -1F, 4, 3, 1);
	nose.setRotationPoint(0F, 15F, -14F);
	nose.setTextureSize(texture_width, texture_height);
	nose.setTextureOffset(1, 28);

	lear = new ModelRenderer(this);
	lear.addBox(-1F, -1F, -0.5F, 2, 2, 1);
	lear.setRotationPoint(-2F, 10F, -9.5F);
	lear.setTextureSize(texture_width, texture_height);
	lear.setTextureOffset(0, 0);
	lear.rotateAngleZ = 45F;

	rear = new ModelRenderer(this);
	rear.addBox(-1F, -1F, -0.5F, 2, 2, 1);
	rear.setRotationPoint(2F, 10F, -9.5F);
	rear.setTextureSize(texture_width, texture_height);
	rear.setTextureOffset(0, 0);
	rear.rotateAngleZ = 45F;

	flleg = new ModelRenderer(this);
	flleg.addBox(-1.5F, 0F, -1.5F, 3, 10, 3);
	flleg.setRotationPoint(-3F, 14f, -5.5F);
	flleg.setTextureSize(texture_width, texture_height);
	flleg.setTextureOffset(52, 19);

	frleg = new ModelRenderer(this);
	frleg.addBox(-1.5F, 0F, -1.5F, 3, 10, 3);
	frleg.setRotationPoint(3F, 14f, -5.5F);
	frleg.setTextureSize(texture_width, texture_height);
	frleg.setTextureOffset(52, 19);

	blleg = new ModelRenderer(this);
	blleg.addBox(-1.5F, 0F, -1.5F, 3, 10, 3);
	blleg.setRotationPoint(-2.5F, 14F, 4.5F);
	blleg.setTextureSize(texture_width, texture_height);
	blleg.setTextureOffset(52, 19);

	brleg = new ModelRenderer(this);
	brleg.addBox(-1.5F, 0F, -1.5F, 3, 10, 3);
	brleg.setRotationPoint(2.5F, 14F, 4.5F);
	brleg.setTextureSize(texture_width, texture_height);
	brleg.setTextureOffset(52, 19);

	tail1 = new ModelRenderer(this);
	tail1.addBox(-1F, -0.5F, 0F, 2, 1, 4);
	tail1.setRotationPoint(0F, 12.5F, 8F);
	tail1.setTextureSize(texture_width, texture_height);
	tail1.setTextureOffset(22, 27);

	tail2 = new ModelRenderer(this);
	tail2.addBox(-1F, -0.5F, 0F, 2, 1, 4);
	tail2.setRotationPoint(0F, 12.5F, 11F);
	tail2.setTextureSize(texture_width, texture_height);
	tail2.setTextureOffset(22, 27);

	tail3 = new ModelRenderer(this);
	tail3.addBox(-1F, -0.5F, 0F, 2, 1, 4);
	tail3.setRotationPoint(0F, 12.5F, 14F);
	tail3.setTextureSize(texture_width, texture_height);
	tail3.setTextureOffset(22, 27);

	tail4 = new ModelRenderer(this);
	tail4.addBox(-1F, -0.5F, 0F, 2, 1, 4);
	tail4.setRotationPoint(0F, 12.5F, 17F);
	tail4.setTextureSize(texture_width, texture_height);
	tail4.setTextureOffset(22, 27);

	tail5 = new ModelRenderer(this);
	tail5.addBox(-1F, -0.5F, 0F, 2, 1, 4);
	tail5.setRotationPoint(0F, 12.5F, 20F);
	tail5.setTextureSize(texture_width, texture_height);
	tail5.setTextureOffset(37, 27);

	//start parenting things to the torso starting with
	//extremities and working inwards
	convertToChild(tail4, tail5);
	convertToChild(tail3, tail4);
	convertToChild(tail2, tail3);
	convertToChild(tail1, tail2);
	convertToChild(torso, tail1);
	convertToChild(torso, flleg);
	convertToChild(torso, frleg);
	convertToChild(torso, blleg);
	convertToChild(torso, brleg);
	convertToChild(head, nose);
	convertToChild(head, lear);
	convertToChild(head, rear);
	convertToChild(torso, head);		

//basically just used to cast from Entity to BaseCatEntity
//that way you can access fields from the BaseCatEntity in renderCat
public void render(Entity parEntity, float parTime, float parSwingSuppress, float par4, float parHeadAngleY, float parHeadAngleX, float par7){
	renderCat((BaseCatEntity)parEntity, parTime, parSwingSuppress, par4, parHeadAngleY, parHeadAngleX, par7);

public void renderCat(BaseCatEntity parEntity, float parTime, float parSwingSuppress, float par4, float parHeadAngleY, float parHeadAngleX, float par7) {
	setRotationAngles(parTime, parSwingSuppress, par4, parHeadAngleY, parHeadAngleX, par7, parEntity);

	//scale the whole thing for big or small entities
	float scale_factor = parEntity.getScaleFactor();
	GL11.glScalef(scale_factor, scale_factor, scale_factor);

	//if the animal is still a wee baby
	/*if (this.isChild) {

	else {



public void setRotationAngles(float parTime, float parSwingSuppress, float par3, float parHeadAngleY, float parHeadAngleX, float par6, Entity parEntity){

	//animate if moving


protected void updateDistanceMovedTotal(Entity parEntity) {
	distanceMovedTotal += parEntity.getDistance(parEntity.prevPosX, parEntity.prevPosY, parEntity.prevPosZ);

protected double getDistanceMovedTotal(Entity parEntity) {
	return distanceMovedTotal;

protected float degToRad(float degrees) {
	return degrees * (float)Math.PI / 180F;

//useful for converting from techne models to the hierarchical models
//that are built here. make sure to always convert extremeties to children
//first and work your way through to the main parent part (torso for basecat)
protected void convertToChild(ModelRenderer parParent, ModelRenderer parChild) {
   // move child rotation point to be relative to parent
   parChild.rotationPointX -= parParent.rotationPointX;
   parChild.rotationPointY -= parParent.rotationPointY;
   parChild.rotationPointZ -= parParent.rotationPointZ;
   // make rotations relative to parent
   parChild.rotateAngleX -= parParent.rotateAngleX;
   parChild.rotateAngleY -= parParent.rotateAngleY;
   parChild.rotateAngleZ -= parParent.rotateAngleZ;
   // create relationship


Link to comment
Share on other sites

You need to do this in the Entity, not the Model.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.


Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.


DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Oh okay thanks for the suggestion Draco18s, I also fixed my texture offset issue by just using the ModelRenderer constructor that takes the the offset as params. I was originally calling new ModelRenderer(this) then addBox -> setRotationPoint -> setTextureSize -> setTextureOffset. I guess that's not the correct way to go.

Link to comment
Share on other sites

This topic is now closed to further replies.


  • Create New...

Important Information

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