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

Hi. In my mod I have an armor set that i want to be invincible so the player takes no damage. Here's my code:

public static EnumArmorMaterial armorInvincible = EnumHelper.addArmorMaterial("Invincible", 0, new int[] {0, 0, 0, 0}, 30);

How do I do this?

  • Author

check if the player is wearing all the armor. and if they are, set the player invincible.

How do i set the player to invincible and check if their wearing the armor or at least what class would i look in?

 

if (player.getCurrentItemOrArmor(4) != null && player.getCurrentItemOrArmor(3) != null
    				&& player.getCurrentItemOrArmor(2) != null && player.getCurrentItemOrArmor(1) != null)
    		{
        		if(this.armorType == 0)
        		{
        			ItemStack helmet = player.getCurrentItemOrArmor(4);
        			ItemStack chest = player.getCurrentItemOrArmor(3);
        			ItemStack legs = player.getCurrentItemOrArmor(2);
        			ItemStack boots = player.getCurrentItemOrArmor(1);
        			
        			if (helmet.getItem() == HELMET && chest.getItem() == CHESTPLATE
        					&& legs.getItem() == LEGS && boots.getItem() == BOOTS)
        			{
        				player.capabilities.disableDamage = true;
                                }
                         }
                }
else if ((player.getCurrentItemOrArmor(4) == null || player.getCurrentItemOrArmor(3) == null
    				|| player.getCurrentItemOrArmor(2) == null || player.getCurrentItemOrArmor(1) == null)
    				&& !player.capabilities.isCreativeMode)
		{
        		         player.capabilities.disableDamage = false;
                        }

  • Author

if (player.getCurrentItemOrArmor(4) != null && player.getCurrentItemOrArmor(3) != null
    				&& player.getCurrentItemOrArmor(2) != null && player.getCurrentItemOrArmor(1) != null)
    		{
        		if(this.armorType == 0)
        		{
        			ItemStack helmet = player.getCurrentItemOrArmor(4);
        			ItemStack chest = player.getCurrentItemOrArmor(3);
        			ItemStack legs = player.getCurrentItemOrArmor(2);
        			ItemStack boots = player.getCurrentItemOrArmor(1);
        			
        			if (helmet.getItem() == HELMET && chest.getItem() == CHESTPLATE
        					&& legs.getItem() == LEGS && boots.getItem() == BOOTS)
        			{
        				player.capabilities.disableDamage = true;
                                }
                         }
                }
else if ((player.getCurrentItemOrArmor(4) == null || player.getCurrentItemOrArmor(3) == null
    				|| player.getCurrentItemOrArmor(2) == null || player.getCurrentItemOrArmor(1) == null)
    				&& !player.capabilities.isCreativeMode)
		{
        		         player.capabilities.disableDamage = false;
                        }

do i put this in my main class or in my armor class?

  • Author

put it in the onArmorTickUpdate method which is in the armor class

what if i used multiple armor classes would I put it in all of them?

  • Author

do you have multiple armor sets? or are you doing one armor class per item?

one armor class per item

you do know you can use one class for an entire set of armor. right? in fact, in my mod, I use one armor class for 5 sets of armor.

  • Author

you do know you can use one class for an entire set of armor. right? in fact, in my mod, I use one armor class for 5 sets of armor.

i found that out recently but I dont know how to i guess i will look it up and try that thanks for the code though i hope it works if it does i will add you to my mod credits

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.