Jump to content

[1.7.10]Checking for player...Help?[Solved]


SureShotM

Recommended Posts

So I want to have it where I check to see if a player is wearing a custom armor and if they are the armor uses a different texture then for all other players.

 

I tried this:

@Override
    public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
    {
        if ((((EntityPlayer)entity).getDisplayName() == "SureShotM")) {
            Texture = Reference.MOD_ID + ":textures/armor/" + this.textureName + "_" + (this.armorType == 2 ? "4" : "3") + ".png";
        }
        else {
            Texture = Reference.MOD_ID + ":textures/armor/" + this.textureName + "_" + (this.armorType == 2 ? "2" : "1") + ".png";
        }
        return Texture;
    }

but it doesn't seem to work

~SureShotM/Leo~ gaming coding all around fun!

Link to comment
Share on other sites

I just searched through all the possible functions and I did run across the UUID, I was debating on using that but this is just a personal mod for a group of friends, so I will most likely use the username, since they wont change theirs ever. I'm debating on adding the names to a config so if they do decide to change there username they can just add the new one to the config. Again this is more of a debate on all of our ends to figure out what we want. Also Texture is being declared like this.

 

public class ArmorMianite extends ItemArmor
{
    public String textureName;
    public String Texture;
    public ArmorMianite(String unlocalizedName, ArmorMaterial material, String textureName, int type)
    {
        super(material, 0, type);
        this.textureName = textureName;
        setUnlocalizedName(unlocalizedName);
        this.setTextureName(Reference.MOD_ID + ":" + unlocalizedName);
        this.setCreativeTab(CreativeTabMianite.Mianite_Tab);
        this.setMaxStackSize(1);
    }
    @Override
    public String getUnlocalizedName()
    {
        return String.format("item.%s%s", Reference.MOD_ID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
    }
    @Override
    public String getUnlocalizedName(ItemStack itemStack)
    {
        return String.format("item.%s%s", Reference.MOD_ID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
    }
    @Override
    @SideOnly(Side.CLIENT)
    public void registerIcons(IIconRegister iconRegister)
    {
        itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
    }
    protected String getUnwrappedUnlocalizedName(String unlocalizedName)
    {
        return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
    }

    @Override
    public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
    {
        if ((((EntityPlayer)entity).isInvisible())) {
            Texture = Reference.MOD_ID + ":textures/armor/" + this.textureName + "_" + (this.armorType == 2 ? "4" : "3") + ".png";
        }
        else {
            Texture = Reference.MOD_ID + ":textures/armor/" + this.textureName + "_" + (this.armorType == 2 ? "2" : "1") + ".png";
        }
        return Texture;
    }

 

Also if we decide to use the username how do I get the username instead of the display name, I am currently using the if player is invisible as a place holder.

~SureShotM/Leo~ gaming coding all around fun!

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.