Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

how to make a cutsom entity model hold an item.


BoonieQuafter-CrAfTeR
 Share

Recommended Posts

package  com.OlympiansMod.entity;



import org.lwjgl.opengl.GL11;

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

public class ZeusModel extends ModelBase
{
    protected ModelRenderer head;
    protected ModelRenderer body;
    protected ModelRenderer rightarm;
    protected ModelRenderer leftarm;
    protected ModelRenderer rightleg;
    protected ModelRenderer leftleg;
private int heldItemLeft;
private int heldItemRight;


    public ZeusModel()
    {
    	 this.textureWidth = 64;
    	    this.textureHeight = 128;
    	    
    	      this.head = new ModelRenderer(this, 0, 0);
    	      this.head.mirror = true;
    	      this.head.addBox(-4F, -8F, -4F, 10, 10, 10);
    	      this.head.setRotationPoint(-1F, -10F, 0F);
    	      this.head.setTextureSize(64, 128);

    	      this.body = new ModelRenderer(this, 2, 20);
    	      this.body.mirror = true;
    	      this.body.addBox(-4F, 0F, -2F, 12, 16, 6);
    	      this.body.setRotationPoint(-2F, -8F, 0F);
    	      this.body.setTextureSize(64, 128);

    	      this.rightarm = new ModelRenderer(this, 40, 0);
    	      this.rightarm.mirror = true;
    	      this.rightarm.addBox(-3F, -2F, -2F, 6, 16, 6);
    	      this.rightarm.setRotationPoint(-9F, -6F, 0F);
    	      this.rightarm.setTextureSize(64, 128);

    	      this.leftarm = new ModelRenderer(this, 40, 22);
    	      this.leftarm.mirror = true;
    	      this.leftarm.addBox(-1F, -2F, -2F, 6, 16, 6);
    	      this.leftarm.setRotationPoint(7F, -6F, 0F);
    	      this.leftarm.setTextureSize(64, 128);

    	      this.rightleg = new ModelRenderer(this, 40, 44);
    	      this.rightleg.mirror = true;
    	      this.rightleg.addBox(-2F, 0F, -2F, 6, 16, 6);
    	      this.rightleg.setRotationPoint(-4F, 8F, 0F);
    	      this.rightleg.setTextureSize(64, 128);

    	      this.leftleg = new ModelRenderer(this, 40, 66);
    	      this.leftleg.mirror = true;
    	      this.leftleg.addBox(-2F, 0F, -2F, 6, 16, 6);
    	      this.leftleg.setRotationPoint(2F, 8F, 0F);
    	      this.leftleg.setTextureSize(64, 128);
    }

  
  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);
    this.head.render(f5);
    this.body.render(f5);
    this.rightarm.render(f5);
    this.leftarm.render(f5);
    this.rightleg.render(f5);
    this.leftleg.render(f5);
  }
  
  public static 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);
    this.head.rotateAngleY = f3 / (180F / (float)Math.PI);
    this.head.rotateAngleX = f4 / (180F / (float)Math.PI);
rightleg.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
    leftleg.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;
    rightarm.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
    leftarm.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;

    if (this.heldItemRight != 0)
    {
        this.rightarm.rotateAngleX = this.rightarm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemRight;
    }
    Zeus zeus = (Zeus)entity;
    int i = zeus.getattackTimer(); 

    if (i > 0)
    {
    	 float f6 = 0.0F;
         float f7 = 0.0F;
         this.rightarm.rotateAngleZ = 0.0F;
       
         this.rightarm.rotateAngleY = -(0.1F - f6 * 0.6F);

         this.rightarm.rotateAngleX = -((float)Math.PI / 2F);
  
         this.rightarm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F;

         this.rightarm.rotateAngleZ += MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F;

         this.rightarm.rotateAngleX += MathHelper.sin(f2 * 0.067F) * 0.05F;
    }else{
    	
    }
    int j = zeus.getattackTimer2();
    if (j > 0)
    {
    	
    	 float f6 = 1.0F - this.onGround;
         f6 *= f6;
         f6 *= f6;
         f6 = 1.0F - f6;
         float f7 = MathHelper.sin(f6 * (float)Math.PI);
         float f8 = MathHelper.sin(this.onGround * (float)Math.PI) * -(this.head.rotateAngleX - 0.7F) * 0.75F;
    	 this.leftarm.rotateAngleX = (float)((double)this.leftarm.rotateAngleX - ((double)f7 * 1.2D + (double)f8));
         this.leftarm.rotateAngleY += this.body.rotateAngleY * 2.0F;
         this.leftarm.rotateAngleZ = MathHelper.sin(this.onGround * (float)Math.PI) * -0.4F;
    
    }
}



  private float func_78172_a(float p_78172_1_, float p_78172_2_) 
  {
      return (Math.abs(p_78172_1_ % p_78172_2_ - p_78172_2_ * 0.5F) - p_78172_2_ * 0.25F) / (p_78172_2_ * 0.25F);
  }



  }
  


 

how this model cant hold an item? ingame it doesn't render..

Im serious don't look at it!!

Link to comment
Share on other sites

Slow down and be more clear.

 

If 1.8, do what Dies said and use the layer.  Look at renderplayer for an example.  You just add the layer.

 

If 1.7.10, what render are you using?  If you extend renderbiped, it will handle it for you unless you do something really odd.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

sorry yeah , im working in 1.7.10. except I don't think that I can extend off renderbiped unless my model extends biped, which was my problem in the first place, extending the model of biped made the model super weird, although I did make it techne.. anyways, since I thought that was the problem(techne model), I extended the model of biped, and copied the measurements, or dimensions of the model and pasted them in place of the biped dimensions.(like the skeleton does, extends off the biped model and makes the arms skinnier) but yeah im not sure what to do from here, if nothing works out properly in the end, I will have to code the model, so yeah it would be really nice to get the render biped to work.

Im serious don't look at it!!

Link to comment
Share on other sites

ok, now describe a bit more.

 

What is your entity?  What did you extend?  Livingbase, ect?  There should be no issues other than some animation for legs/arms that can be fixed easily.

 

For your render and model, you can extend modelbiped in most cases. 

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

Render Class

package com.OlympiansMod.entity;

import com.OlympiansMod.lib.Refstrings;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

public class RenderZeus extends RenderLiving{
private static final ResourceLocation mobTextures = new ResourceLocation(Refstrings.MODID + ":textures/entity/Zeus.png");

public RenderZeus(ZeusModel model, float par2) {
	super(model, par2);

}
protected ResourceLocation getEntityTexture(Zeus entity){
	return mobTextures;
}
protected ResourceLocation getEntityTexture(Entity entity){
	return this.getEntityTexture((Zeus)entity); 
}


}

 

ModelClass:

package  com.OlympiansMod.entity;



import org.lwjgl.opengl.GL11;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;

public class ZeusModel extends ModelBase
{
    protected ModelRenderer head;
    protected ModelRenderer body;
    protected ModelRenderer rightarm;
    protected ModelRenderer leftarm;
    protected ModelRenderer rightleg;
    protected ModelRenderer leftleg;
    public int heldItemLeft;
    public int heldItemRight;


    public ZeusModel()
    {
    	 this.textureWidth = 64;
    	    this.textureHeight = 128;
    	    
    	      this.head = new ModelRenderer(this, 0, 0);
    	      this.head.mirror = true;
    	      this.head.addBox(-4F, -8F, -4F, 10, 10, 10);
    	      this.head.setRotationPoint(-1F, -10F, 0F);
    	      this.head.setTextureSize(64, 128);

    	      this.body = new ModelRenderer(this, 2, 20);
    	      this.body.mirror = true;
    	      this.body.addBox(-4F, 0F, -2F, 12, 16, 6);
    	      this.body.setRotationPoint(-2F, -8F, 0F);
    	      this.body.setTextureSize(64, 128);

    	      this.rightarm = new ModelRenderer(this, 40, 0);
    	      this.rightarm.mirror = true;
    	      this.rightarm.addBox(-3F, -2F, -2F, 6, 16, 6);
    	      this.rightarm.setRotationPoint(-9F, -6F, 0F);
    	      this.rightarm.setTextureSize(64, 128);

    	      this.leftarm = new ModelRenderer(this, 40, 22);
    	      this.leftarm.mirror = true;
    	      this.leftarm.addBox(-1F, -2F, -2F, 6, 16, 6);
    	      this.leftarm.setRotationPoint(7F, -6F, 0F);
    	      this.leftarm.setTextureSize(64, 128);

    	      this.rightleg = new ModelRenderer(this, 40, 44);
    	      this.rightleg.mirror = true;
    	      this.rightleg.addBox(-2F, 0F, -2F, 6, 16, 6);
    	      this.rightleg.setRotationPoint(-4F, 8F, 0F);
    	      this.rightleg.setTextureSize(64, 128);

    	      this.leftleg = new ModelRenderer(this, 40, 66);
    	      this.leftleg.mirror = true;
    	      this.leftleg.addBox(-2F, 0F, -2F, 6, 16, 6);
    	      this.leftleg.setRotationPoint(2F, 8F, 0F);
    	      this.leftleg.setTextureSize(64, 128);
    }

  
  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);
    this.head.render(f5);
    this.body.render(f5);
    this.rightarm.render(f5);
    this.leftarm.render(f5);
    this.rightleg.render(f5);
    this.leftleg.render(f5);
  }
  
  public static 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)
  {
    Zeus zeus = (Zeus)entity;

    int i = zeus.getattackTimer(); 
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    this.head.rotateAngleY = f3 / (180F / (float)Math.PI);
    this.head.rotateAngleX = f4 / (180F / (float)Math.PI);
rightleg.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
    leftleg.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;
    rightarm.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
    leftarm.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;

    if (this.heldItemRight != 0)
    {
    	
        this.rightarm.rotateAngleX = this.rightarm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemRight;
    }


    if (i > 0)
    {
    	 float f6 = 0.0F;
         float f7 = 0.0F;
         this.rightarm.rotateAngleZ = 0.0F;
       
         this.rightarm.rotateAngleY = -(0.1F - f6 * 0.6F);

         this.rightarm.rotateAngleX = -((float)Math.PI / 2F);
  
         this.rightarm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F;

         this.rightarm.rotateAngleZ += MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F;

         this.rightarm.rotateAngleX += MathHelper.sin(f2 * 0.067F) * 0.05F;
    }else{
    	
    }
    int j = zeus.getattackTimer2();
    if (j > 0)
    {
    	
    	 float f6 = 1.0F - this.onGround;
         f6 *= f6;
         f6 *= f6;
         f6 = 1.0F - f6;
         float f7 = MathHelper.sin(f6 * (float)Math.PI);
         float f8 = MathHelper.sin(this.onGround * (float)Math.PI) * -(this.head.rotateAngleX - 0.7F) * 0.75F;
    	 this.leftarm.rotateAngleX = (float)((double)this.leftarm.rotateAngleX - ((double)f7 * 1.2D + (double)f8));
         this.leftarm.rotateAngleY += this.body.rotateAngleY * 2.0F;
         this.leftarm.rotateAngleZ = MathHelper.sin(this.onGround * (float)Math.PI) * -0.4F;
    
    }
}



  private float func_78172_a(float p_78172_1_, float p_78172_2_) 
  {
      return (Math.abs(p_78172_1_ % p_78172_2_ - p_78172_2_ * 0.5F) - p_78172_2_ * 0.25F) / (p_78172_2_ * 0.25F);
  }



  }
  


 

Client proxy:

package com.OlympiansMod.Main;

import java.util.EnumSet;

import javax.swing.plaf.basic.BasicComboBoxUI.KeyHandler;

















import org.lwjgl.input.Keyboard;

import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.world.World;

import com.OlympiansMod.Item.ModItems;
import com.OlympiansMod.PlayerInventory.DNAContainer;
import com.OlympiansMod.PlayerInventory.SlotGui;
import com.OlympiansMod.Potionstuff.WizardsFatigue;
import com.OlympiansMod.entity.Arachne;
import com.OlympiansMod.entity.ArachneModel;
import com.OlympiansMod.entity.Dioceltian;
import com.OlympiansMod.entity.EntityBullet;
import com.OlympiansMod.entity.EntityGreekFire;
import com.OlympiansMod.entity.EntityMasterBolt;
import com.OlympiansMod.entity.EntitySGolem;
import com.OlympiansMod.entity.EntitySGuardian;
import com.OlympiansMod.entity.EntityThunderBolt;
import com.OlympiansMod.entity.EntityUndead;
import com.OlympiansMod.entity.GreekUndead;
import com.OlympiansMod.entity.MasterBoltModel;
import com.OlympiansMod.entity.ModelDioclectian;
import com.OlympiansMod.entity.ModelPosiedon;
import com.OlympiansMod.entity.ModelUndeadGreek;
import com.OlympiansMod.entity.Poseidon;
import com.OlympiansMod.entity.RenderArachne;
import com.OlympiansMod.entity.RenderDioclectian;
import com.OlympiansMod.entity.RenderMasterBolt;
import com.OlympiansMod.entity.RenderPoseidon;
import com.OlympiansMod.entity.RenderSGolem;
import com.OlympiansMod.entity.RenderSGuardian;
import com.OlympiansMod.entity.RenderThunderBolt;
import com.OlympiansMod.entity.RenderUndead;
import com.OlympiansMod.entity.RenderUndeadGreek;
import com.OlympiansMod.entity.RenderZeus;
import com.OlympiansMod.entity.RenderZeusExtended;
import com.OlympiansMod.entity.SGolemModel;
import com.OlympiansMod.entity.SGuardianModel;
import com.OlympiansMod.entity.SlownessSpell;
import com.OlympiansMod.entity.SpellBombardo;
import com.OlympiansMod.entity.SpellChicken;
import com.OlympiansMod.entity.SpellIncendio;
import com.OlympiansMod.entity.Undead;
import com.OlympiansMod.entity.Zeus;
import com.OlympiansMod.entity.ZeusExtended;
import com.OlympiansMod.entity.ZeusExtendedModel;
import com.OlympiansMod.entity.ZeusModel;

import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;


public class ClientProxy extends ServerProxy{
public void registerRenderInfo(){
	RenderingRegistry.registerEntityRenderingHandler(Zeus.class, new RenderZeus(new ZeusModel(), 0));
	                       
}
}


i get an error on renderzeus ect. when extending the render off biped. but that hardly matters because the real problem is with the model, when extending from biped, and changing all of the parts of the model to biped parts, and keeping the model dimensions some how my model gets extremely messed up. the head and legs ect. get scrambled.

Im serious don't look at it!!

Link to comment
Share on other sites

 

Why???

protected ResourceLocation getEntityTexture(Zeus entity){
	return mobTextures;
}
protected ResourceLocation getEntityTexture(Entity entity){
	return this.getEntityTexture((Zeus)entity); 
}
[\code]

just
[code]
         protected ResourceLocation getEntityTexture(Entity entity){
	return mobTextures; 
}
[\code]

The following needs to extend ModelBiped.
public class ZeusModel extends ModelBase

I don't remember the vanilla dimensions but are you resizing the entity at all?  If not, don't even have your own model, just send a new modelbiped in your render.

Even if you do want to resize your entity, i would do what I said above first and get that working.

Long time Bukkit & Forge Programmer

Happy to try and help

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.