Jump to content

Recommended Posts

Posted

Hello again everyone

 

As the title says, I was wandering how you would give a piece of armour a custom model.

 

I already have the armour piece, and it can be equipped/is working fine, and I have a Techne model that I have imported into eclipse and fixed up, but where do I go from there?

 

Any help is greatly appreciated,

 

-Whyneb360

Posted

Do I put the method in the armour class, or under the item itself in my items class (that has all the items for my mod)?

 

Also, where do I translate it and set the texture?

 

P.S. If you could supply some example code, it would definitely help

 

Thanks,

 

- Whyneb360

Posted

I did, to make my backpack wearable..

 

	@Override
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) {
	return yourmodel;
}

 

 

I try my best, so apologies if I said something obviously stupid!

Posted

No, should it be?

 

EDIT: Sorry, I thought you were referring to the method. Yes, my Model class is public, but not static:

 

public ModelRCPChest()
  {
    textureWidth = 64;
    textureHeight = 32;

 

 

Posted

Yes, there needs to be a static instance to reference it from another class.

 

But also, the method returns modelBiped, so it looks like you need to create one and set the properties to the correct parts based on the armor slot. I'm just guessing on that though.

Posted

I can't make the model class static, but I am also unsure as to what you mean when you say 'bipedHeadwear'

 

Is this another method I have to create, or something I have to reference?

 

Thanks

Posted

Never mind about the static, I thought you were trying to reference an instance of the model.

 

I was just assuming the TechneModel was not a ModelBiped, and you would have to set the properties manually. Are you doing "return new ModelRCPChest();"

Posted

As a result of the getArmorModel method? I am now.

 

Tested that out in the game, and odd things ensued - The default white leather armor became part of my skin, but that was sadly not what I was looking for.

Posted

Sure:

 

public class ModelRCPChest extends ModelBiped
{
  //fields
    ModelRenderer shape1;
    ModelRenderer shape2;
    ModelRenderer shape3;
    ModelRenderer shape4;
    ModelRenderer shape5;
    ModelRenderer shape6;
    ModelRenderer shape7;
    ModelRenderer shape8;
    ModelRenderer shape9;
    ModelRenderer shape10;
    ModelRenderer shpae11;
    ModelRenderer shpae12;
    ModelRenderer shpae13;
    ModelRenderer shape14;
    ModelRenderer shpaer15;
    ModelRenderer shpae16;
    ModelRenderer shpaer17;
  
  public ModelRCPChest()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      shape1 = new ModelRenderer(this, 38, 1);
      shape1.addBox(-4.5F, -4F, -3.5F, 6, 5, 7);
      shape1.setRotationPoint(-5F, 2F, 0F);
      shape1.setTextureSize(64, 32);
      shape1.mirror = true;
      setRotation(shape1, 0F, 0F, -0.3490659F);
      shape2 = new ModelRenderer(this, 38, 1);
      shape2.addBox(-1.5F, -4F, -3.5F, 6, 5, 7);
      shape2.setRotationPoint(5F, 2F, 0F);
      shape2.setTextureSize(64, 32);
      shape2.mirror = true;
      setRotation(shape2, 0F, 0F, 0.3490659F);
      shape3 = new ModelRenderer(this, 45, 14);
      shape3.addBox(-0.5F, 0F, -2.5F, 4, 7, 5);
      shape3.setRotationPoint(5F, 2F, 0F);
      shape3.setTextureSize(64, 32);
      shape3.mirror = true;
      setRotation(shape3, 0F, 0F, 0F);
      shape4 = new ModelRenderer(this, 45, 14);
      shape4.addBox(-3.5F, 0F, -2.5F, 4, 7, 5);
      shape4.setRotationPoint(-5F, 2F, 0F);
      shape4.setTextureSize(64, 32);
      shape4.mirror = true;
      setRotation(shape4, 0F, 0F, 0F);
      shape5 = new ModelRenderer(this, 1, 15);
      shape5.addBox(-4.5F, 0F, -2.5F, 9, 11, 5);
      shape5.setRotationPoint(0F, 0F, 0F);
      shape5.setTextureSize(64, 32);
      shape5.mirror = true;
      setRotation(shape5, 0F, 0F, 0F);
      shape6 = new ModelRenderer(this, 1, 7);
      shape6.addBox(-5F, 8F, -3F, 10, 1, 6);
      shape6.setRotationPoint(0F, 0F, 0F);
      shape6.setTextureSize(64, 32);
      shape6.mirror = true;
      setRotation(shape6, 0F, 0F, 0F);
      shape7 = new ModelRenderer(this, 1, 7);
      shape7.addBox(-5F, 5F, -3F, 10, 1, 6);
      shape7.setRotationPoint(0F, 0F, 0F);
      shape7.setTextureSize(64, 32);
      shape7.mirror = true;
      setRotation(shape7, 0F, 0F, 0F);
      shape8 = new ModelRenderer(this, 1, 7);
      shape8.addBox(-5F, 2F, -3F, 10, 1, 6);
      shape8.setRotationPoint(0F, 0F, 0F);
      shape8.setTextureSize(64, 32);
      shape8.mirror = true;
      setRotation(shape8, 0F, 0F, 0F);
      shape9 = new ModelRenderer(this, 1, 7);
      shape9.addBox(-5F, 11F, -3F, 10, 1, 6);
      shape9.setRotationPoint(0F, 0F, 0F);
      shape9.setTextureSize(64, 32);
      shape9.mirror = true;
      setRotation(shape9, 0F, 0F, 0F);
      shape10 = new ModelRenderer(this, 1, 0);
      shape10.addBox(2.4F, 3.4F, -6.4F, 1, 3, 3);
      shape10.setRotationPoint(5F, 2F, 0F);
      shape10.setTextureSize(64, 32);
      shape10.mirror = true;
      setRotation(shape10, 0.7853982F, 0F, 0F);
      shpae11 = new ModelRenderer(this, 1, 0);
      shpae11.addBox(-3.4F, 3.4F, -6.4F, 1, 3, 3);
      shpae11.setRotationPoint(-5F, 2F, 0F);
      shpae11.setTextureSize(64, 32);
      shpae11.mirror = true;
      setRotation(shpae11, 0.7853982F, 0F, 0F);
      shpae12 = new ModelRenderer(this, 10, 1);
      shpae12.addBox(3F, -0.5F, 3F, 2, 2, 1);
      shpae12.setRotationPoint(0F, 0F, 0F);
      shpae12.setTextureSize(64, 32);
      shpae12.mirror = true;
      setRotation(shpae12, 0F, 0F, 0.7853982F);
      shpae13 = new ModelRenderer(this, 10, 1);
      shpae13.addBox(5F, 2F, 3F, 2, 2, 1);
      shpae13.setRotationPoint(0F, 0F, 0F);
      shpae13.setTextureSize(64, 32);
      shpae13.mirror = true;
      setRotation(shpae13, 0F, 0F, 0.7853982F);
      shape14 = new ModelRenderer(this, 10, 1);
      shape14.addBox(-0.2F, 2.7F, 3F, 2, 2, 1);
      shape14.setRotationPoint(0F, 0F, 0F);
      shape14.setTextureSize(64, 32);
      shape14.mirror = true;
      setRotation(shape14, 0F, 0F, 0.7853982F);
      shpaer15 = new ModelRenderer(this, 10, 1);
      shpaer15.addBox(2.3F, 4.8F, 3F, 2, 2, 1);
      shpaer15.setRotationPoint(0F, 0F, 0F);
      shpaer15.setTextureSize(64, 32);
      shpaer15.mirror = true;
      setRotation(shpaer15, 0F, 0F, 0.7853982F);
      shpae16 = new ModelRenderer(this, 31, 15);
      shpae16.addBox(-2.8F, 12F, -2.5F, 1, 5, 5);
      shpae16.setRotationPoint(0F, 0F, 0F);
      shpae16.setTextureSize(64, 32);
      shpae16.mirror = true;
      setRotation(shpae16, 0F, 0F, 0.1745329F);
      shpaer17 = new ModelRenderer(this, 31, 15);
      shpaer17.addBox(1.8F, 11.9F, -2.5F, 1, 5, 5);
      shpaer17.setRotationPoint(0F, 0F, 0F);
      shpaer17.setTextureSize(64, 32);
      shpaer17.mirror = true;
      setRotation(shpaer17, 0F, 0F, -0.1745329F);
  }
  
  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);
    shape1.render(f5);
    shape2.render(f5);
    shape3.render(f5);
    shape4.render(f5);
    shape5.render(f5);
    shape6.render(f5);
    shape7.render(f5);
    shape8.render(f5);
    shape9.render(f5);
    shape10.render(f5);
    shpae11.render(f5);
    shpae12.render(f5);
    shpae13.render(f5);
    shape14.render(f5);
    shpaer15.render(f5);
    shpae16.render(f5);
    shpaer17.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);
  }

}

 

There you go

 

EDIT: Okay, so I redid the model code (and changed it above), and now it renders the model, but it is a bit small, the arms don't move, and it is still textured as the white leather armour

Posted

Okay, so after lots of trial and error, I have this:

 

public class ElementalArmor extends ItemArmor{


public ElementalArmor(ArmorMaterial var1, int var2, int var3) {
	super(var1, var2, var3);
} 

public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) {
	if(itemStack != null) { 
		if(itemStack.getItem() instanceof ElementalArmor) {
			int type = ((ItemArmor)itemStack.getItem()).armorType;
			if(type == 0) {
				return null;
			}
			if(type == 1) {
				return new ModelRCPChest();
			}
			if(type == 2) {
				return null;
			}
			if(type == 3) {
				return null;
			}
		}
	}
	return null;

}

@Override 
public String getArmorTexture(ItemStack itemstack, Entity entity, int slot, String type) {
	if(itemstack != null) { 
		if(itemstack.getItem() instanceof ElementalArmor) {
			int type1 = ((ItemArmor)itemstack.getItem()).armorType;
			if(type1 == 0) {
				return null;
			}
			if(type1 == 1) {
				return Constants.MODID + ":textures/armor/policeArmorChest.png";
			}
			if(type1 == 2) {
				return null;
			}
			if(type1 == 3) {
				return null;
			}
		}
	}
	return null;

}
}

 

and it works... sort of. The texture is working, and the model is there, but aside from rendering the model that I want for the chest, it also adds random parts of the textures to the legs and head. So to summarise, model and texture work, but extra stuff appears for no apparent reason.

Posted

Could you please provide an ingame screenshot, and a techne one of your model? I would like to understand a bit more

I try my best, so apologies if I said something obviously stupid!

Posted

Okay guys, I figured it out. Thank you so much for your help, and if anyone at all wants to know how to do this, I will post a tutorial on my mod's wikia page (Though it may take a week or so)

 

Thanks

- Whyneb360

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.