cocolabs / cocolib

Simple Minecraft modding library.
GNU General Public License v3.0
0 stars 1 forks source link

Black box shows up on crosshair when rendering #9

Closed Rellit-219 closed 4 years ago

Rellit-219 commented 4 years ago

image

This black box appears on the crosshair, no matter where you specify the position.

Implementation:

public static final ArrayList<SpriteObject> BAC_HUD_EMPTY_ICONS = new ArrayList<SpriteObject>();
public static final ArrayList<SpriteObject> BAC_HUD_FULL_ICONS = new ArrayList<SpriteObject>();

public static final void initIcons() {

    BAC_HUD_EMPTY_ICONS.clear();
    BAC_HUD_FULL_ICONS.clear();

    for (int i = 0; i < 9; i++) {

        BAC_HUD_EMPTY_ICONS.add(SpriteObject.Builder.create(Defines.MODID, "textures/gui/bac_hud_bar.png").withPos(Alignment.CENTER, 1 + (i * 9) + (i * 3), 10 * i).withUV(0, 0).withSize(9, 9).build());
        BAC_HUD_FULL_ICONS.add(SpriteObject.Builder.create(Defines.MODID, "textures/gui/bac_hud_bar.png").withPos(Alignment.CENTER, 1 + (i * 9) + (i * 3), 10 * i).withUV(9, 0).withSize(9, 9).build());

    }

}

@SubscribeEvent
public void onPreRenderOverlay(RenderGameOverlayEvent.Pre event) {

    @Nullable PlayerController controller = Minecraft.getInstance().playerController;

    if (controller != null && controller.gameIsSurvivalOrAdventure()) {

        for (SpriteObject empty_bac_icon : BAC_HUD_EMPTY_ICONS) {

            GuiElement.bindAndDrawTexture(empty_bac_icon);

        }

        for (SpriteObject full_bac_icon : BAC_HUD_FULL_ICONS) {

            GuiElement.bindAndDrawTexture(full_bac_icon);

        }
    }
}
matshou commented 4 years ago

The issue is most probably caused by missing texture files or incorrect UV coordinates.

Assuming the project is open source, can you show me the location of the textures via link?

Rellit-219 commented 4 years ago

This is the location for the referenced texture: https://github.com/boredhero/pv/tree/dev/src/main/resources/assets/vinum/textures/gui

matshou commented 4 years ago

The dimensions of valid textures have to be matching powers of two (i.e. 32x32, 64x64, 128x128).

Note that I haven't tested this out so the safest bet would be to use a standard vanilla 256x256 format for textures (which will work) and just pack each texture with as much assets as you can.

Rellit-219 commented 4 years ago

Will try thanks.

Rellit-219 commented 4 years ago

Yep that fixed it!