Jump to content

Loaded texture just white


Recommended Posts

Hello everyone!


I wanted to create a little Easter-Egg like feature for one of my mods where the background of the gui screens (The one which is normally dirt) is replaced with other textures based on some values of the player.


I now encountered the problem that sometimes the texture is not used. Instead, a white surface is shown. This does not depend on the image I want to load.


Here's my code:


public void onGuiOpen(GuiOpenEvent e) {

((To test stuff I replaced the other calculation with a random one))

public static void replaceImage() {
    if (images.length == 0)

    int index = CommonUtils.random.nextInt(images.length);
    int firstindex = index;
    boolean accepted = false;
    boolean useDefault = false;

    do {
        ResourceLocation r = new ResourceLocation(images[index]);
        accepted = true; //Testing: accepts is always true
        if (!accepted) {
            index = (index + 1) % images.length;
            if (index == firstindex) {
                useDefault = true;
    } while (!accepted);

    String s = useDefault ? "textures/gui/options_background.png" : RandomOptionsScreen.images[index];

    Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(s));
    ModReflectionHelper.setField(Gui.class, null, ReflectionConstants.F_OPTIONS_BG, new ResourceLocation(s));
    Log.info_("Result:%s", s);



Any Ideas what I might have done wrong?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now


  • Create New...

Important Information

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