#[SOLVED] Widget texture not loading

17 messages · Page 1 of 1 (latest)

solar sapphire
#

Can anyone help me figure out why this texture is not getting loaded and it is just showing the black and purple background?

    private final ItemStack itemStack;

    public ItemSlotButtonWidget(int x, int y, int width, int height, ButtonTextures textures, PressAction onPress, ItemStack itemStack, Text tooltip) {
        super(x, y, width, height, textures, onPress, Text.empty());
        this.itemStack = itemStack;
        this.setTooltip(Tooltip.of(tooltip));
    }

    @Override
    public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
        super.renderWidget(context, mouseX, mouseY, delta);

        if (this.itemStack != null && !this.itemStack.isEmpty()) {
            ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();

            int itemX = this.getX() + (this.width - 16) / 2;
            int itemY = this.getY() + (this.height - 16) / 2;

            context.drawItem(this.itemStack, itemX, itemY);
        }
    }
}```
```private static final Identifier BASE = Identifier.tryParse("bazaarutils", "widgets/widget_normal.png");
    private static final Identifier HOVER = Identifier.tryParse("bazaarutils", "widgets/widget_hover.png");
    public static final ButtonTextures SLOT_BUTTON_TEXTURES = new ButtonTextures(
            BASE,
            HOVER);```
```ItemSlotButtonWidget button = new ItemSlotButtonWidget(
                        buttonX,
                        currentButtonY,
                        buttonSize, buttonSize,
                        Bookmark.SLOT_BUTTON_TEXTURES,
                        (btn) -> {blah blah},
                        itemForButton,
                        Text.of(bookmark.getName())
                );```



resources/assets/bazaarutils/textures/gui/sprites/widget/xxxx.png  is the directory
grim plinth
winter vapor
#

your identifiers have the path as widgets/widget_hover.png, whereas your assets are at widget/widget_hover.png (notice the plural widgets in the first)
also you shouldn’t have the .png suffix in the identifier

solar sapphire
#

now its

winter vapor
#

Remove the .png

solar sapphire
winter vapor
#

the path was correct before (apart from the plural of widgets), so remove the gui/sprites/

solar sapphire
#

OMFG

#

THAT WORKED

winter vapor
#

u don’t need the .png like i said, that would resolve to widget_hovered.png.png which isn’t what u want

solar sapphire
#

I spent two hours and it was the .png...

#

Thank you so much!

winter vapor
#

np!

solar sapphire
#

[SOLVED] Widget texture not loading