Jump to content

[1.6.4] Hiding armor only for players (not NPCs)


sttwolf

Recommended Posts

Hi, so I was wondering on how to hide the armor for players, and only for them, because I want to see armor on NPCs. This is because I run my own server, with really nice skins, and I don't want armor to ruin the RP. I've got plugins to show health and armor bars on top of players, so don't worry.

 

I believe I need to modify a function in RenderPlayer.java, the function setArmorModel

 

  
/**
     * Set the specified armor model as the player model. Args: player, armorSlot, partialTick
     */
    protected int setArmorModel(AbstractClientPlayer par1AbstractClientPlayer, int par2, float par3)
    {
        ItemStack var4 = par1AbstractClientPlayer.inventory.armorItemInSlot(3 - par2);

        if (var4 != null)
        {
            Item var5 = var4.getItem();

            if (var5 instanceof ItemArmor)
            {
                ItemArmor var6 = (ItemArmor)var5;
                this.bindTexture(RenderBiped.func_110857_a(var6, par2));
                ModelBiped var7 = par2 == 2 ? this.modelArmor : this.modelArmorChestplate;
                var7.bipedHead.showModel = par2 == 0;
                var7.bipedHeadwear.showModel = par2 == 0;
                var7.bipedBody.showModel = par2 == 1 || par2 == 2;
                var7.bipedRightArm.showModel = par2 == 1;
                var7.bipedLeftArm.showModel = par2 == 1;
                var7.bipedRightLeg.showModel = par2 == 2 || par2 == 3;
                var7.bipedLeftLeg.showModel = par2 == 2 || par2 == 3;
                this.setRenderPassModel(var7);
                var7.onGround = this.mainModel.onGround;
                var7.isRiding = this.mainModel.isRiding;
                var7.isChild = this.mainModel.isChild;
                float var8 = 1.0F;

                if (var6.getArmorMaterial() == EnumArmorMaterial.CLOTH)
                {
                    int var9 = var6.getColor(var4);
                    float var10 = (float)(var9 >> 16 & 255) / 255.0F;
                    float var11 = (float)(var9 >> 8 & 255) / 255.0F;
                    float var12 = (float)(var9 & 255) / 255.0F;
                    GL11.glColor3f(var8 * var10, var8 * var11, var8 * var12);

                    if (var4.isItemEnchanted())
                    {
                        return 31;
                    }

                    return 16;
                }

                GL11.glColor3f(var8, var8, var8);

                if (var4.isItemEnchanted())
                {
                    return 15;
                }

                return 1;
            }
        }

        return -1;
    }

 

The problem is that, when I modify it, armor are not showing, which is good, but skins also don't get displayed. What's wrong ? Thanks !

Link to comment
Share on other sites

I've found the render code for players to be fairly confusing.

 

You will want to modify some of the code in RenderBiped to not show armor instead of render player if I understand it correctly.

 

There is a set armor render player type event you might look at.  Might be as simple as cancelling that.  Haven't played with it though.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

I've found the render code for players to be fairly confusing.

 

You will want to modify some of the code in RenderBiped to not show armor instead of render player if I understand it correctly.

 

There is a set armor render player type event you might look at.  Might be as simple as cancelling that.  Haven't played with it though.

Is there a way to do it without forge ? Modifying the vanilla classes. I'm using a custom launcher, so this doesn't matter.

Link to comment
Share on other sites

You are on a Forge Forum so any answers will probably involve ...... Forge.

Yes of course, and I'm here because I once had problems with  modding on forge, and had good answers. So I ensure that there are competent people here. Well my question would be : Is there a way to do it without Forge ? See, my question now involves forge.

Link to comment
Share on other sites

What you are doing has to deal with rendering which is done client side not server side which is what you are asking.. If you were hopping to be able to do this without making your players dowload and install anything other than vanilla you will need to learn how to make packets that will tell the client how to render. But here we strongly suggest NOT modifying any vanilla classes because it will cause your mod or plugin to become incompatable with many other mods or plugins.

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.



×
×
  • Create New...

Important Information

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