Jump to content

Recommended Posts

Posted (edited)

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
Posted (edited)

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

Edited by Leomelonseeds

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Posted
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.

Posted (edited)

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
Posted

Cool, glad you got it working without our help. Next time try solving on your own before posting here.

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

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.