Jump to content

[Solved] Container slot background icon


Jay Avery

Recommended Posts

I want to give some of my slots custom background icons (like the vanilla armour slots have). I tried setting the backgroundName or backgroundLocation in the constructor - when I do the first, it renders as the missing image texture, when I do the second it has the usual blank background. Am I missing something obvious?

Edited by Jay Avery
Solved
Link to comment
Share on other sites

13 minutes ago, Leomelonseeds said:

You should read the vanilla minecraft classes and find out what they do.

I've already done that. The vanilla armour slots override Slot#getSlotTexture and return a string with the path to the texture. Doing that in my slots also resulted in the missing image texture. I've read through the Slot class but it seems to use a convoluted mixture of strings and ResourceLocations, and something to do with TextureAtlasSprites - I have no idea what those are.

Link to comment
Share on other sites

Finally got it working! I had to use TextureStitchEvent.Pre to register the sprite, like so:

@SubscribeEvent
public void textureStich(TextureStitchEvent.Pre event) {

    event.getMap().registerSprite(new ResourceLocation("jjmod:gui/backpack_slot"));
}

 

And also set the background name to the same string in the Slot constructor:

this.backgroundName = "jjmod:gui/backpack_slot";

 

Edited by Jay Avery
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.