Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Other posts on this subject seem to be outdated, as mentioned methods no longer exist.

 

I feel like this should be very simple but I need a background for a slot in a custom GUI. I just can't seem to understand how to add an image file from my mod resources to a sprite location. I know sprites have to be within atlas textures and I elected to stitch it to the atlas blocks PNG which I know is publicly referenced in PlayerContainer. I've gone into a TextureStitchEvent.Pre subscriber method and run

if(!event.getMap().getTextureLocation().equals(PlayerContainer.LOCATION_BLOCKS_TEXTURE)) return;

event.addSprite(new ResourceLocation(MOD_ID,"item/empty_item_slot_sword"));

but, unfortunately, this doesn't seem to add the sprite to the map and I think this is because I never give it the proper file location of the image. Very hard to be sure it doesn't work though but it doesn't appear as a background to the slots in my custom GUI both when I use this.setBackground or override getBackground. I'm not sure where I'm supposed to assign a sprite an image file or even if I need to. Vanilla's way of doing this is a bit tricky to understand and I don't see any of the empty_armor_slot PNGs being referenced anywhere except the LegacyPackWrapper (which maps new IDs to old IDs, probably to help with resource packs).

 

Any help would be very cool :)

  • Author
private static final ResourceLocation EMPTY_SWORD_TEXTURE = new ResourceLocation("item/empty_item_slot_sword");
@Override
public Pair<ResourceLocation, ResourceLocation> getBackground() {
    return Pair.of(PlayerContainer.LOCATION_BLOCKS_TEXTURE, EMPTY_SWORD_TEXTURE);
}

This is the relevant code for the background. The class itself extends SlotItemHandler which is a subclass of Slot. Not sure what else I have to do to make it work :(

  • Author

Noticed that right after posting and yep that fixed it. Cheers, sorry for wasting your time.

Guest
This topic is now closed to further replies.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.