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

So im working on a mod where a full set of the same type of armor should become invisible when the player is invisible.

Im only interested in how i make the armor invisible

 

Helmet.class

 

 

    @Override

    public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {

        if (player.isInvisible()) {

       

        }

    }

 

 

Make a custom armor renderer and just not render it  :)

Not all things in the world are red, there are round objects too!

  • Author

Can you give me an example of the basics?

 

I also have an update on the Helmet.class

 

 

 

@Override

    public void onArmorTick(World world, EntityPlayer player, ItemStack armor) {

        ItemStack boots = player.getCurrentArmor(0);

        ItemStack legs = player.getCurrentArmor(1);

        ItemStack chest = player.getCurrentArmor(2);

        ItemStack helmet = player.getCurrentArmor(3);

        int duration = 15;

        if(boots != null && legs != null && chest != null && helmet != null) {

            if(boots.getItem() == ManagerItem.scout_boots

            && legs.getItem() == ManagerItem.scout_leggings

            && chest.getItem() == ManagerItem.scout_chestplate

            && helmet.getItem() == ManagerItem.scout_helmet) {

                player.addPotionEffect(new PotionEffect(Potion.invisibility.id, duration++, 1));

            }

        }

        if(player.isInvisible()) {

       

        }

}

 

 

A real simple solution is this:

 

@Override
@SideOnly(Side.CLIENT) 
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { 
return new InvisibleArmorRender();
}

public class InvisibleArmorRender extends ModelBiped{
      public InvisibleArmorRender(){
            super();
      }

      public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float  par6, float par7){
      }
}

 

Put that in your armor class.

Not all things in the world are red, there are round objects too!

  • Author

The armor is now invisible, but it is invisible even when i'm not invisible

 

 

 

 

@Override

    public void onArmorTick(World world, EntityPlayer player, ItemStack armor) {

        ItemStack boots = player.getCurrentArmor(0);

        ItemStack legs = player.getCurrentArmor(1);

        ItemStack chest = player.getCurrentArmor(2);

        ItemStack helmet = player.getCurrentArmor(3);

        int duration = 15;

        if(boots != null && legs != null && chest != null && helmet != null) {

            if(boots.getItem() == ManagerItem.scout_boots

            && legs.getItem() == ManagerItem.scout_leggings

            && chest.getItem() == ManagerItem.scout_chestplate

            && helmet.getItem() == ManagerItem.scout_helmet) {

 

                if(player.isInvisible()) {

                getArmorModel(player, boots, 0);

                }

            }

        }

}

 

@Override

@SideOnly(Side.CLIENT)

public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) {

return new InvisibleArmorRender();

}

 

public class InvisibleArmorRender extends ModelBiped{

      public InvisibleArmorRender(){

            super();

      }

 

      public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float  par6, float par7){

      }

}

 

 

 

I need to make it so it only runs through the getModelArmor when i'm invisible, but i thought that this would do the trick :/

 

 

 

                if(player.isInvisible()) {

                getArmorModel(player, boots, 0);

                }

 

 

 

But it looks like it runs through the getArmorModel even without this

The armor is now invisible, but it is invisible even when i'm not invisible

 

 

 

 

@Override

    public void onArmorTick(World world, EntityPlayer player, ItemStack armor) {

        ItemStack boots = player.getCurrentArmor(0);

        ItemStack legs = player.getCurrentArmor(1);

        ItemStack chest = player.getCurrentArmor(2);

        ItemStack helmet = player.getCurrentArmor(3);

        int duration = 15;

        if(boots != null && legs != null && chest != null && helmet != null) {

            if(boots.getItem() == ManagerItem.scout_boots

            && legs.getItem() == ManagerItem.scout_leggings

            && chest.getItem() == ManagerItem.scout_chestplate

            && helmet.getItem() == ManagerItem.scout_helmet) {

 

                if(player.isInvisible()) {

                getArmorModel(player, boots, 0);

                }

            }

        }

}

 

@Override

@SideOnly(Side.CLIENT)

public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) {

return new InvisibleArmorRender();

}

 

public class InvisibleArmorRender extends ModelBiped{

      public InvisibleArmorRender(){

            super();

      }

 

      public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float  par6, float par7){

      }

}

 

 

 

I need to make it so it only runs through the getModelArmor when i'm invisible, but i thought that this would do the trick :/

 

 

 

                if(player.isInvisible()) {

                getArmorModel(player, boots, 0);

                }

 

 

 

But it looks like it runs through the getArmorModel even without this

 

try to add an if-statement at:

@Override
@SideOnly(Side.CLIENT) 
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { 
return new InvisibleArmorRender();
}

 

do something like this:

 

public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { 

if(player.isInvisible){	
return new InvisibleArmorRender();
}
else { return //and here the normal renderer }
}

"My Crew is World Wide." 「ヤング • エルトウ」

yeah, the getArmorModel is always called. its an override.

 

You must check in this if the player is invisible, if the the player is not, then just return.

public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) {

return new InvisibleArmorRender();
  }

 

So maybe you vill have to set an boolean in onArmorTick

Not all things in the world are red, there are round objects too!

  • Author

Thank you so much!

The solution was right in front of meh, but i put the if(player.isInvisible()) the wrong place.

 

 

 

 

@Override

@SideOnly(Side.CLIENT)

public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) {

        if(entityLiving.isInvisible()) {

 

    return new InvisibleArmorRender();

        }

        else {

        return null;

        }

}

 

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.