Jump to content

Recommended Posts

Posted

Within my armour class, how would I test for the player wearing a full set of armour? I have this:

 

public void onArmorTickUpdate(World world, EntityPlayer player, ItemStack itemStack)

    {

int i = EntityLiving.getArmorPosition(itemStack) - 1;

        ItemStack itemstack1 = player.getCurrentArmor(i);

 

        if (itemstack1.itemID != CanadianMod.skates.itemID...

 

But that seems to only be returning one time at a time.

 

Suggestions would be great!

Posted

Why are you doing this?

 

if (itemstack1.itemID != CanadianMod.skates.itemID

 

This would return true if it wasn't skates.

 

Anyways, you have to check all armor slots.

 

		ItemStack helmet = this.getEquipmentInSlot(4);
		ItemStack chestplate = this.getEquipmentInSlot(3);
		ItemStack leggings = this.getEquipmentInSlot(2);
		ItemStack boots = this.getEquipmentInSlot(1);

 

Also make sure to check if the item stack isn't null!

 

From what I can tell, you don't really know Java. I would recommend learning Java before modding Minecraft.

Kain

Posted

 

 

		ItemStack helmet = this.getEquipmentInSlot(4);
		ItemStack chestplate = this.getEquipmentInSlot(3);
		ItemStack leggings = this.getEquipmentInSlot(2);
		ItemStack boots = this.getEquipmentInSlot(1);

 

 

 

It's saying .getEquimentInSlot does not exist

Posted

In 1.6.4, you can use either getCurrentArmor(armor slot) or getCurrentItemOrArmor(armor slot minus 1), with the first method available only to EntityPlayer, and the second to all EntityLivingBase. Otherwise, the previous answer is correct.

 

I suggest you also to check first if the stack is not null, otherwise accessing even .itemID will crash; and second I suggest using getItem() == YourMod.yourItem rather than itemID, as then your mod will be easier to update to 1.7.2 if you ever decide to do so.

 

ItemStack boots = player.getCurrentArmor(0);
// legs = 1, chest = 2, helm = 3

if (boots != null && boots.getItem() == YourMod.yourBootsItem && (same checks for legs, chest, helm)) {
// you've got your full set
}

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.