Jump to content

Recommended Posts

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 :)

Posted
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 :(

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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