Jump to content

[1.15.2] Getting sprite from texture atlas


drazuam

Recommended Posts

I'm trying to register a sprite to a Texture Atlas to draw later on.  Here is my stitching code:

@Mod.EventBusSubscriber(modid = MODID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
public class SymbolTextures {

    public static final ResourceLocation DEBUG = new ResourceLocation(MODID , "textures/symbols/symbol_x.png");

    @SubscribeEvent
    public static void onStitchEvent(TextureStitchEvent.Pre event)
    {
        ResourceLocation stitching = event.getMap().getTextureLocation();
        if(!stitching.equals(AtlasTexture.LOCATION_BLOCKS_TEXTURE))
        {
            return;
        }

        //TODO do this programmatically from registry
        boolean added = event.addSprite(DEBUG);

    }

}

(added ends up as true here)

 

And here is where I'm trying to grab it:

    public static void renderSymbol(DrawnSymbol symbol, MatrixStack matrix)
    {
        assert Minecraft.getInstance().world != null;


        IRenderTypeBuffer buffer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource();
        IVertexBuilder builder = buffer.getBuffer(RenderType.getTranslucent());
        TextureAtlasSprite sprite = Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(symbol.getTexture());
	}

 

in this case, symbol.getTexture() will return SymbolTextures.DEBUG.  I only ever get "minecraft:missingno" returned as sprite.  Does anybody have some experience with this?  Am I doing something wrong?

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.