Jump to content

[1.7.10] Updating Entity Model Size


qpwoeiruty

Recommended Posts

I have a model and when something is true it is supposed to get bigger. I have done this before by creating both sizes and hiding the one that is not needed, but I was wondering if there was a way to just update the model size instead of creating different ones.

Link to comment
Share on other sites

Here is the model class if that helps:

 

package com.blocklings.model;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;

import com.blocklings.entity.EntityBlockling;

public class ModelBlockling extends ModelBase {

ModelRenderer BlocklingBody1;
ModelRenderer BlocklingArmLeft1;
ModelRenderer BlocklingArmRight1;

public ModelBlockling() {

	textureWidth = 256;
	textureHeight = 128;

	BlocklingBody1 = new ModelRenderer(this, 0, 0);
	BlocklingBody1.addBox(-4F, -4F, -4F, 8, 8, ;
	BlocklingBody1.setRotationPoint(0F, 20F, 0F);
	BlocklingBody1.setTextureSize(256, 128);
	BlocklingBody1.mirror = true;
	setRotation(BlocklingBody1, 0F, 0F, 0F);
	BlocklingArmLeft1 = new ModelRenderer(this, 175, 0);
	BlocklingArmLeft1.addBox(-2F, 0F, -1F, 2, 5, 2);
	BlocklingArmLeft1.setRotationPoint(-3F, 18F, 0F);
	BlocklingArmLeft1.setTextureSize(256, 128);
	BlocklingArmLeft1.mirror = true;
	setRotation(BlocklingArmLeft1, 0F, 0F, 0.3490659F);
	BlocklingArmRight1 = new ModelRenderer(this, 100, 0);
	BlocklingArmRight1.addBox(0F, 0F, -1F, 2, 5, 2);
	BlocklingArmRight1.setRotationPoint(3F, 18F, 0F);
	BlocklingArmRight1.setTextureSize(256, 128);
	BlocklingArmRight1.mirror = true;
	setRotation(BlocklingArmRight1, 0F, 0F, -0.3490659F);

}

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);
	setRotationAngles(f, f1, f2, f3, f4, f5, entity);
	BlocklingBody1.render(f5);
	BlocklingArmLeft1.render(f5);
	BlocklingArmRight1.render(f5);

}

private void setRotation(ModelRenderer model, float x, float y, float z) {

	model.rotateAngleX = x;
	model.rotateAngleY = y;
	model.rotateAngleZ = z;

}

public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {

	super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);

}

public void setLivingAnimations(EntityLivingBase entityLivingBase, float par2, float par3, float par4) {
     
	EntityBlockling entityBlockling = (EntityBlockling)entityLivingBase;

	int level = entityBlockling.getLevel();

	if(level == 1) {

    		this.BlocklingArmLeft1.rotateAngleX = (-0.2F + 1.0F * this.func_78172_a(par2, 13.0F)) * par3;
  	    this.BlocklingArmRight1.rotateAngleX = (-0.2F - 1.0F * this.func_78172_a(par2, 13.0F)) * par3;

	} else {

		this.BlocklingArmLeft1.rotateAngleX = (-2000F + 1.0F * this.func_78172_a(par2, 13.0F)) * par3;
  	    this.BlocklingArmRight1.rotateAngleX = (-2000F - 1.0F * this.func_78172_a(par2, 13.0F)) * par3;

	}
  	    
}

private float func_78172_a(float par1, float par2) {

        return (Math.abs(par1 % par2 - par2 * 0.5F) - par2 * 0.25F) / (par2 * 0.25F);
        
    }

}

Link to comment
Share on other sites

Yes, the GL11 scaling will work fine for this.  Note though that it will not increase the collision box for the entity so I usually also adjust that.  Lastly, the scaling for the entity happens on the client side and often the server needs to know (i.e. for pathfinding) that the size (and collision box) have changed, so you probably need some sort of packet to sync client and server.  I usually have a scaleFactor float field in my entities and then use that (and sync that).

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.

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

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

Announcements



×
×
  • Create New...

Important Information

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