Jump to content

Slot Background (Icon) Not Working (Solved)


wookiederk

Recommended Posts

I'm Trying to get an Icon to register for my custom slot. Heres My Code (simplified it below):

Icon armorIcon;
@SideOnly(Side.CLIENT)
    public void registerIcons(IconRegister par1IconRegister) {
    	armorIcon = par1IconRegister.registerIcon("textures/items/slot_empty_boots.png");
    	
    }

    @SideOnly(Side.CLIENT)

    /**
     * Returns the icon index on items.png that is used as background image of the slot.
     */
    public Icon getBackgroundIconIndex()
    {
        return armorIcon;
    }

It turns out blank. Any help appreciated :P

Link to comment
Share on other sites

Is the texture white, or transparent. Make sure that you put the texture in the right place. I think you need to put I in /mcp71/src/minecraft/textures/items/your file. The path you put in is the exact path from your zip or the src/minecraft/ folder.

Link to comment
Share on other sites

    armorIcon = par1IconRegister.registerIcon("textures/items/slot_empty_boots.png");

 

That is not how you call registerIcon.

 

You're supposed to pass it a string in this format:

 

"MODNAME:ITEMNAME"

 

No .png, no full path.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Check your error log.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

No crashes :/

 

Still check your logs. some errors don't neccessarily cause crashes.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Nothing out of the ordinary, but this was definitely interesting:

/**
     * Returns the icon index on items.png that is used as background image of the slot.
     */ 

It returns the icon index! (which I thought was outdated)  That being said, how would I use it to properly load an Icon?

Link to comment
Share on other sites

Sorry I wasn't clear.

 

You do put an Icon in the background of the container slot, it's just a matter of where you declare the icon you want to use.  Originally I was registering the icon in my chest Block and that just did not work.

 

Look at my mod project at:

 

https://github.com/dark2phoenix/RescueChest

 

I register the icon in dummy item I call ItemHotBar.  I then reference the icon I created in ItemHotBar when I'm creating my custom slot SlotHotBar.

 

See if that works for you.

Link to comment
Share on other sites

Sorry I wasn't clear.

 

You do put an Icon in the background of the container slot, it's just a matter of where you declare the icon you want to use.  Originally I was registering the icon in my chest Block and that just did not work.

 

Look at my mod project at:

 

https://github.com/dark2phoenix/RescueChest

 

I register the icon in dummy item I call ItemHotBar.  I then reference the icon I created in ItemHotBar when I'm creating my custom slot SlotHotBar.

 

See if that works for you.

 

There's also another way on how to register an Icon, without needing an Item:

https://gist.github.com/SanAndreasP/380a80911debb88204c5

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Sorry I wasn't clear.

 

You do put an Icon in the background of the container slot, it's just a matter of where you declare the icon you want to use.  Originally I was registering the icon in my chest Block and that just did not work.

 

Look at my mod project at:

 

https://github.com/dark2phoenix/RescueChest

 

I register the icon in dummy item I call ItemHotBar.  I then reference the icon I created in ItemHotBar when I'm creating my custom slot SlotHotBar.

 

See if that works for you.

 

Thanks that worked!

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.