Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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!

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

  • Author

 

 

		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

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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.