Jump to content

[SOLVED][1.8] Invis armor when player is invis


skyfir3

Recommended Posts

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()) {

       

        }

    }

 

 

Link to comment
Share on other sites

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()) {

       

        }

}

 

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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." 「ヤング • エルトウ」

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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;

        }

}

 

Link to comment
Share on other sites

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.