Jump to content

Recommended Posts

Posted

So I am trying to make an item that will change textures when it changes modes, and it crashes when I try.  I took a similar code from the bow pullback I have used, but it is not working because there are some bow specific properties that I tried to replace but it wasn't right.  How can I make it so when it changes modes, it changes textures

 

Icon code

 

  @SideOnly(Side.CLIENT)

    private IIcon[] iconArray;

   

    @SideOnly(Side.CLIENT)

    public void registerIcons(IIconRegister par1IconRegister)

    {

        this.itemIcon = par1IconRegister.registerIcon(this.getIconString() + "_standby");

        this.iconArray = new IIcon[iconString.length()];

     

        for (int i = 0; i < this.iconArray.length; ++i)

        {

            this.iconArray = par1IconRegister.registerIcon(this.getIconString() + "_" + iconArray);

        }

   

    }

    public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {

if(usingItem.stackTagCompound.getInteger("mode")==0){

return iconArray[0];

}

else if(usingItem.stackTagCompound.getInteger("mode")==2){

return iconArray[2];

}

else if(usingItem.stackTagCompound.getInteger("mode")==1){

return iconArray[1];

}

 

   

    return itemIcon;

   

    }

 

 

Thank you

Posted

It works when I use this in a bow

 

@SideOnly(Side.CLIENT)

    public void registerIcons(IIconRegister par1IconRegister)

    {

        this.itemIcon = par1IconRegister.registerIcon(this.getIconString() + "_standby");

        this.iconArray = new IIcon[bowPullIconNameArray.length];

     

        for (int i = 0; i < this.iconArray.length; ++i)

        {

            this.iconArray = par1IconRegister.registerIcon(this.getIconString() + "_" + bowPullIconNameArray);

        }

   

    }

 

And can you at least be helpful and tell me what is wrong...

Posted

Ok, thanks, My formatting is not like that in the code the copy paste must have messed it up. Also I have never used any of this Icon stuff before. I am sorry, I am new to forge coding and it does not help me learn by telling me that I suck at what I am trying to learn

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.