Posted June 1, 201510 yr 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: @SubscribeEvent public void onGuiOpen(GuiOpenEvent e) { RandomOptionsScreen.replaceImage(); } ((To test stuff I replaced the other calculation with a random one)) public static void replaceImage() { if (images.length == 0) return; int index = CommonUtils.random.nextInt(images.length); int firstindex = index; boolean accepted = false; boolean useDefault = false; Minecraft.getMinecraft().getTextureManager().deleteTexture(Gui.optionsBackground); 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; break; } Minecraft.getMinecraft().getTextureManager().deleteTexture(r); } } 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? http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
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.