ZacDoesStuff Posted April 19, 2014 Posted April 19, 2014 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! Quote
TLHPoE Posted April 19, 2014 Posted April 19, 2014 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. Quote Kain
ZacDoesStuff Posted April 20, 2014 Author Posted April 20, 2014 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 Quote
coolAlias Posted April 20, 2014 Posted April 20, 2014 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 } Quote http://i.imgur.com/NdrFdld.png[/img]
Recommended Posts
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.