Posted April 17, 20169 yr In 1.7.10 the text in my mods GUI's always has been rendered correctly. After porting to 1.8.9 my custom labels only sometimes render it correctly. mc.fontRendererObj.drawString(label, 0, 0, color, shadow); My label extends a custom pane which extends the minecraft gui. Sometimes of the text is displayed correctly the other part looks pretty strange. The strangest thing is, that when I execute console commands (/time set 0... /weather clear) all the labels which previously bugged are now displayed how they should be.
April 17, 20169 yr Where are you rendering, we need whole code. Probably changing some GL states. 1.7.10 is no longer supported by forge, you are on your own.
April 17, 20169 yr Author I am rendering on "rightclick block or entity" This is the function: @Override public void drawSelf(int mx, int my) { int color = isPointInPane(mx, my) ? hoverColor : textColor; int offsetX = 0; int offsetY = 0; if (textAlignment.rightAligned) { offsetX = (getWidth() - getStringWidth()); } else if (textAlignment.horizontalCentered) { offsetX = (getWidth() - getStringWidth()) / 2; } if (textAlignment.bottomAligned) { offsetY = (getHeight() - getTextHeight()); } else if (textAlignment.verticalCentered) { offsetY = (getHeight() - getTextHeight()) / 2; } GL11.glPushMatrix(); GL11.glTranslated(getX() + offsetX, getY() + offsetY, 0); GL11.glScalef(scale, scale, scale); mc.fontRendererObj.drawString(label, 0, 0, color, shadow); GL11.glPopMatrix(); }
April 18, 20169 yr Author The Gui text is rendered correctly if whatever text enters the console. May be some code, may be some chat. The text renders exactly in the console text color.
April 18, 20169 yr Author I bound an entity object to a "custom window" object. This windows object is called when I right click my entity. /** * Called when the gui is opened by an player. */ @Override public void onOpened() { findPaneOfTypeByID(WINDOW_ID_NAME, Label.class).setLabel(citizen.getName()); createHealthBar(); createXpBar(); createSkillContent(); } This fills various different Label.class with text (Some of them work correctly, some not) This window extends a view with the method drawSelf. This draw methods calls all the drawSelf methods of its childs (Labels, Images etc) @Override protected void drawSelf(int mx, int my) { // Translate the drawing origin to our x,y GL11.glPushMatrix(); GL11.glTranslatef((float)x + padding, (float)y + padding, 0); // Translate Mouse into the View mx -= x + padding; my -= y + padding; for (Pane child : children) { if (childIsVisible(child)) { child.draw(mx, my); } } GL11.glPopMatrix(); } from there the drawSelf of the label is called. But all my images, icons and buttons works 100% correctly. Only text is sometimes displayed correctly, sometimes not.
April 18, 20169 yr You are still not showing what we NEED to see. MC is built by 2 logical sides, each built by 2 threads (main and netty): http://mcforge.readthedocs.org/en/latest/concepts/sides/ You can't just call rendering from anywhere without GL rendering context. Only way to do it properly is to either open custom GuiScreen (stuff like guis like GuiContainer, MainMenu, Options, etc.) or to draw directly onto screen using rendering events like: RenderGameOverlayEvent or other world-based (3d) rendering events. If you are not doing it like mentioned above, you are simply doing it wrong, but seeing that "it worked in past", you must have been doing it at least partially correct, just now it stopped working because it no longer is. So I need to ask again: What is responsible for rendering your gui. Is it some GuiScreen extension or are you using event - which one? We need much more than what you gave to track error down, rendering goes waaaaay back into base classes. 1.7.10 is no longer supported by forge, you are on your own.
April 18, 20169 yr Author Ah understood. The previously mentioned View extends the minecraft Gui. and we draw the stuff like you mentioned: "Opening a custom GuiScreen (stuff like guis like GuiContainer, MainMenu, Options, etc.)"
April 18, 20169 yr Author This init gui is called by entityInteraction (No magic in this code) public class Screen extends GuiScreen { @Override public void drawScreen(int mx, int my, float f) { if (window.hasLightbox()) { super.drawDefaultBackground(); } scale = new ScaledResolution(mc).getScaleFactor(); GL11.glPushMatrix(); GL11.glTranslatef(x, y, 0); window.draw(mx - x, my - y); GL11.glPopMatrix(); } @Override public void initGui() { x = (width - window.getWidth()) / 2; y = (height - window.getHeight()) / 2; Keyboard.enableRepeatEvents(true); window.onOpened(); } Which calls the onOpened in the Window. Which eventually calls MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent.Post(this, this.buttonList)); and then eventually public void showGuiScreen(Object clientGuiElement) { GuiScreen gui = (GuiScreen)clientGuiElement; this.client.displayGuiScreen(gui); } which contains our custom gui. and therefor, eventually the drawSelf from our custom guy (which I already posted) is called...
April 18, 20169 yr Author No, I do not call these events manually. After InitGui() has finished. These forge events are automatically called. Window.onOpen Instantiates the text.
April 21, 20169 yr Author Solved it. It seems that I have to execute mc.renderEngine.bindTexture(TEXTURE); before drawing any string. If any minecraft text is displayed(F3, chat, etc) this will automatically set the minecraft textures and therefore it will display the Strings conforming this texture. The problem with this is, if you want to draw any images, this may destroy the images.
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.