Jump to content

[1.8.9] Throwable Entity "how to use a specificated Model"


terraya

Recommended Posts

Hello Dear Forum,

 

after whole day trying to make a "Throwable entity" work, it actualy work ...

 

"BUT" , how can i use my "ModelBall" ?

 

-- MY ENTITY --

 

public class ModelBall
  extends ModelBase
{
  ModelRenderer Shape1;
  ModelRenderer Shape2;
  ModelRenderer Shape3;
  ModelRenderer Shape4;
  ModelRenderer Shape5;
  ModelRenderer Shape6;
  ModelRenderer Shape7;
  
  public ModelBall()
  {
    this.textureWidth = 64;
    this.textureHeight = 64;
    
    this.Shape1 = new ModelRenderer(this, 0, 0);
    this.Shape1.addBox(0.0F, 0.0F, 0.0F, 4, 4, 4);
    this.Shape1.setRotationPoint(-1.0F, 0.0F, -3.0F);
    this.Shape1.setTextureSize(64, 64);
    this.Shape1.mirror = true;
    setRotation(this.Shape1, 0.0F, 0.0F, 0.0F);
    this.Shape2 = new ModelRenderer(this, 0, 0);
    this.Shape2.addBox(0.0F, 0.0F, 0.0F, 3, 1, 3);
    this.Shape2.setRotationPoint(-0.5F, -0.7F, -2.5F);
    this.Shape2.setTextureSize(64, 64);
    this.Shape2.mirror = true;
    setRotation(this.Shape2, 0.0F, 0.0F, 0.0F);
    this.Shape3 = new ModelRenderer(this, 0, 0);
    this.Shape3.addBox(0.0F, 0.0F, 0.0F, 3, 1, 3);
    this.Shape3.setRotationPoint(-0.5F, 3.7F, -2.5F);
    this.Shape3.setTextureSize(64, 64);
    this.Shape3.mirror = true;
    setRotation(this.Shape3, 0.0F, 0.0F, 0.0F);
    this.Shape4 = new ModelRenderer(this, 0, 0);
    this.Shape4.addBox(0.0F, 0.0F, 0.0F, 1, 3, 3);
    this.Shape4.setRotationPoint(-1.7F, 0.5F, -2.5F);
    this.Shape4.setTextureSize(64, 64);
    this.Shape4.mirror = true;
    setRotation(this.Shape4, 0.0F, 0.0F, 0.0F);
    this.Shape5 = new ModelRenderer(this, 0, 0);
    this.Shape5.addBox(0.0F, 0.0F, 0.0F, 1, 3, 3);
    this.Shape5.setRotationPoint(2.7F, 0.5F, -2.5F);
    this.Shape5.setTextureSize(64, 64);
    this.Shape5.mirror = true;
    setRotation(this.Shape5, 0.0F, 0.0F, 0.0F);
    this.Shape6 = new ModelRenderer(this, 0, 0);
    this.Shape6.addBox(0.0F, 0.0F, 0.0F, 3, 3, 1);
    this.Shape6.setRotationPoint(-0.5F, 0.5F, 0.7F);
    this.Shape6.setTextureSize(64, 64);
    this.Shape6.mirror = true;
    setRotation(this.Shape6, 0.0F, 0.0F, 0.0F);
    this.Shape7 = new ModelRenderer(this, 0, 0);
    this.Shape7.addBox(0.0F, 0.0F, 0.0F, 3, 3, 1);
    this.Shape7.setRotationPoint(-0.5F, 0.5F, -3.7F);
    this.Shape7.setTextureSize(64, 64);
    this.Shape7.mirror = true;
    setRotation(this.Shape7, 0.0F, 0.0F, 0.0F);
  }
  
  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);
    this.Shape1.render(f5);
    this.Shape2.render(f5);
    this.Shape3.render(f5);
    this.Shape4.render(f5);
    this.Shape5.render(f5);
    this.Shape6.render(f5);
    this.Shape7.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)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, null);
  }
}

 

--- TEST CLASS ---

public class TestThrowableItem extends Item
{
public TestThrowableItem(String string)
{
	super();
	this.setUnlocalizedName("throwable");
}

@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
        if (!par3EntityPlayer.capabilities.isCreativeMode)
        {
            --par1ItemStack.stackSize;
        }

        if (!par2World.isRemote)
        {
            par2World.spawnEntityInWorld(new Test2Skill(par2World, par3EntityPlayer));
        }

        return par1ItemStack;
    }

}

 

--- AND THE REGISTER ---

	  EntityRegistry.registerModEntity(Test2Skill.class, "throwable", 1, this, 80, 3, true);
  

 

 

 

(IF I WANT TO CHANGE THE REGISTERMODENTITY TO:)

	  EntityRegistry.registerModEntity(ModelBall.class, "throwable", 1, this, 80, 3, true);
  

it shows that it is not "appcliable" ... :/

 

Link to comment
Share on other sites

You need to create a

Render

class that renders the model for the entity and then register an

IRenderFactory

for it with

RenderingRegistry.registerEntityRenderingHandler(Class<T>, IRenderFactory<? super T>)

.

 

Look at vanilla for examples of

Render

classes.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

ok thats what i found, it looks pretty good but there is a error on each "RenderType01"

 

@SideOnly(Side.CLIENT)
public class RenderType01
  extends Render
{
  ResourceLocation texture;
  protected ModelBase model;
  float scalef;
  double red = 0.0D;
  double green = 0.0D;
  double blue = 0.0D;
  double alpha = 0.0D;
  
  public RenderType01(String texture, ModelBase model)
  {
    this.shadowSize = 0.5F;
    this.texture = new ResourceLocation("blockupdate:textures/entity/" + texture + ".png");
    this.model = model;
    this.scalef = 0.75F;
  }
  
  public RenderType01(String texture, ModelBase model, float scale)
  {
    this.shadowSize = 0.5F;
    this.texture = new ResourceLocation("blockupdate:textures/entity/" + texture + ".png");
    this.model = model;
    this.scalef = scale;
  }
  
  public RenderType01(ModelBase model, float scale, double red, double green, double blue, double alpha)
  {
    this.shadowSize = 0.5F;
    this.texture = null;
    this.model = model;
    this.scalef = scale;
    this.red = red;
    this.blue = blue;
    this.green = green;
    this.alpha = alpha;
  }
  
  protected ResourceLocation getEntityTexture(Entity entity)
  {
    if (this.texture != null) {
      return this.texture;
    }
    return null;
  }
}

 

 

the problem is "Implicit super constructor Render() is undefined. Must explicitly invoke another constructor"

 

i dont understand this , any suggestion?

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.