0

I have isolated the issue in the following line of code:

Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow(etc)

I'm extremely confused as to why it's artifacting the xp bar, health bar, food bar and armour bar. Here's a portion of my code:

// the main code
public void postInit(FMLPostInitializationEvent event) {
    MinecraftForge.EVENT_BUS.register(new MyMod());
}

// MyMod class
public uiCreator;
public MyMod() {
    uiCreator = new UICreator();
}

@SubscribeEvent
public void onGui(RenderGameOverlayEvent event) {
    uiCreator.Create();
}

// UICreator class
public void Create() {
    GlStateManager.scale(1.5, 1.5, 1.5);
    Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow("MyMod", 2, 2, 0xffffff);
    GlStateManager.scale(1 / 1.5, 1 / 1.5, 1 / 1.5);
}

Effectively, the line which is causing the artifacting is Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow("MyMod", 2, 2, 0xffffff);. I don't understand why. I'm certain it's this line, as removing/commenting out any other portions of code do not fix the artifacting until I comment this line out. I'm extremely confused as to why this is occuring. If anyone has any form of insight, I'd greatly appreciate it

Artifacting Info Bar

Community
  • 1
  • 1
Frontear
  • 1,150
  • 12
  • 25

1 Answers1

0

The problem is as follows:

When you attempt to drawString, it replaces the textures with a text texture. Due to this, anything rendered afterwards ends up looking like text instead of proper icons because the texture was replaced in Memory. In order to avoid this, use RenderGameOverlayEvent.Post and check if event is getting the type of TEXT render.

Frontear
  • 1,150
  • 12
  • 25