Posted April 16, 201411 yr for some stupid reason idk if its a minor mistake ive overlooked or forge limits but i can only render 2 overlays in game at any one time.... i have 2 overlays that render in a pair when a pickaxe is present in hand... as i have finished mostly all the work around pickaxes in my mod i decided to move on to the axe when i came across this problem.. the overlay for axe just will not render when the other two associated with the pickaxe are present..... although if i comment out (/****/) one of the pick axes guis the axes then works so it makes me think that it is either one a typo that i keep overlooking that somebody may find or maybe limitations EDIT: Before actually posting this i had a stroke of genius and fixed my problem so ill post the solution that i found for the sake of helping anyone else out with the same problem (Ive only been modding a week or two so this is probably just a stupid mistake thats extremely obvious) BUT i still am curious as to why i can only have two classes that render overlays? this question still stands in case i want to add completely different and separate overlays in the future what was i doing wrong (if anything) or is it just a limitation of forge??? THE FIX, instead of having two classes one for pickaxe one for axe i put in two if statements if player is holding axe reference the value associated to respective class.. if player is holding pickaxe reference the value associated to respective class i can probably do Much more cleaning up of the code as there are probably unnecessary code value declarations variables etc that are in the statements that shouldnt be but for now its working which solved my issue class one PICKAXE LEVEL OVERLAY (keep in mind this is the FIXED solution version of the file) package com.MCR.MinecraftReloaded.LevelingLib; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.gui.GuiIngame; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.item.ItemAxe; import net.minecraft.item.ItemPickaxe; import net.minecraftforge.client.event.RenderGameOverlayEvent; import org.lwjgl.opengl.GL11; import com.MCR.MinecraftReloaded.Items.ModItemLevelInfoDisplay; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class OverlayMiningLevel extends GuiIngame { OverlayMiningLevel Instance = this; public OverlayMiningLevel() { super(Minecraft.getMinecraft()); } @SubscribeEvent public void onRenderGameOverlay(RenderGameOverlayEvent event) { if (event.type == RenderGameOverlayEvent.ElementType.TEXT) { Instance.renderOverlay(); } } @SideOnly(Side.CLIENT) public void renderOverlay() { ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); int width = scaledresolution.getScaledWidth(); int height = scaledresolution.getScaledHeight(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); EntityClientPlayerMP player = this.mc.thePlayer; ////////////////////////////////////////////////////// //////////////////////////////////////////////////////// if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ItemAxe){ System.out.print("WoodCutting overlay main iftool statement is working") ; StorageWoodCuttingLevel woodcuttinglevel = StorageWoodCuttingLevel.get(player); int WoodCuttingLevel; if(woodcuttinglevel != null) WoodCuttingLevel = woodcuttinglevel.GetLevel(); else WoodCuttingLevel = 0; int x = 0; int y = 0; if(UtilsWoodCuttingLevel.TextArea == 1){ x = width - 40; y = 15; }else if (UtilsWoodCuttingLevel.TextArea == 2){ x = 40; y = 15; }else if (UtilsWoodCuttingLevel.TextArea == 3){ x = width - 40; y = height - 15; }else if (UtilsWoodCuttingLevel.TextArea == 4){ x = 40; y = height - 15; }else{ x = width - 40; y = 15; } String Pre = UtilsWoodCuttingLevel.LevelMark; this.drawCenteredString(this.mc.fontRenderer, Pre + WoodCuttingLevel, x, y, 0xffffff); GL11.glDisable(GL11.GL_BLEND); } ///////////////////////////////////////////////////////// /////////////////////////////////////////////////////// if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ModItemLevelInfoDisplay | player.inventory.getCurrentItem().getItem() instanceof ItemPickaxe){ System.out.print("Normal overlay working ") ; StorageMiningLevel level = StorageMiningLevel.get(player); int Level; if(level != null) Level = level.GetLevel(); else Level = 0; int x = 0; int y = 0; if(UtilsMiningLevel.TextArea == 1){ x = 40; y = 15; }else if (UtilsMiningLevel.TextArea == 2){ x = 40; y = 15; }else if (UtilsMiningLevel.TextArea == 3){ x = width - 40; y = height - 15; }else if (UtilsMiningLevel.TextArea == 4){ x = 40; y = height - 15; }else{ x = width - 40; y = 15; } String Pre = UtilsMiningLevel.LevelMark; this.drawCenteredString(this.mc.fontRenderer, Pre + Level, x, y, 0xffffff); GL11.glDisable(GL11.GL_BLEND); } } } class two PICKAXE EXPERIENCE package com.MCR.MinecraftReloaded.LevelingLib; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.gui.GuiIngame; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.item.ItemPickaxe; import net.minecraftforge.client.event.RenderGameOverlayEvent; import org.lwjgl.opengl.GL11; import com.MCR.MinecraftReloaded.Items.ModItemLevelInfoDisplay; public class OverlayMiningExperience extends GuiIngame { OverlayMiningExperience Instance = this; public OverlayMiningExperience() { super(Minecraft.getMinecraft()); } @SubscribeEvent public void onRenderGameOverlay(RenderGameOverlayEvent event) { if (event.type == RenderGameOverlayEvent.ElementType.TEXT) { Instance.renderOverlay(); } } @SideOnly(Side.CLIENT) public void renderOverlay() { ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); int width = scaledresolution.getScaledWidth(); int height = scaledresolution.getScaledHeight(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); EntityClientPlayerMP player = this.mc.thePlayer; if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ModItemLevelInfoDisplay | player.inventory.getCurrentItem().getItem() instanceof ItemPickaxe){ StorageMiningExperience Experience = StorageMiningExperience.get(player); int Exp; if(Experience != null) Exp = Experience.GetExperience(); else Exp = 0; int x = 0; int y = 0; if(UtilsMiningExperience.TextArea == 1){ x = 40; y = 30; }else if (UtilsMiningExperience.TextArea == 2){ x = 40; y = 15; }else if (UtilsMiningExperience.TextArea == 3){ x = width - 40; y = height - 15; }else if (UtilsMiningExperience.TextArea == 4){ x = 40; y = height - 15; }else{ x = width - 40; y = 15; } String Pre = UtilsMiningExperience.ExperienceMark; this.drawCenteredString(this.mc.fontRenderer, Pre + Exp, x, y, 0xffffff); GL11.glDisable(GL11.GL_BLEND); } } } third and final AXE LEVELING (it is now combined in the first class pickaxe leveling) package com.MCR.MinecraftReloaded.LevelingLib; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.gui.GuiIngame; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.item.ItemAxe; import net.minecraft.item.ItemPickaxe; import net.minecraftforge.client.event.RenderGameOverlayEvent; import org.lwjgl.opengl.GL11; import com.MCR.MinecraftReloaded.Items.ModItemLevelInfoDisplay; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class OverlayWoodCutting extends GuiIngame { OverlayWoodCutting Instance = this; public OverlayWoodCutting() { super(Minecraft.getMinecraft()); } @SubscribeEvent public void onRenderGameOverlay(RenderGameOverlayEvent event) { if (event.type == RenderGameOverlayEvent.ElementType.TEXT) { Instance.renderOverlay(); } } @SideOnly(Side.CLIENT) public void renderOverlay() { ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); int width = scaledresolution.getScaledWidth(); int height = scaledresolution.getScaledHeight(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); EntityClientPlayerMP player = this.mc.thePlayer; if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ItemAxe){ System.out.print("WoodCutting overlay main iftool statement is working") ; StorageWoodCuttingLevel woodcuttinglevel = StorageWoodCuttingLevel.get(player); int WoodCuttingLevel; if(woodcuttinglevel != null) WoodCuttingLevel = woodcuttinglevel.GetLevel(); else WoodCuttingLevel = 0; int x = 0; int y = 0; if(UtilsWoodCuttingLevel.TextArea == 1){ x = width - 40; y = 15; }else if (UtilsWoodCuttingLevel.TextArea == 2){ x = 40; y = 15; }else if (UtilsWoodCuttingLevel.TextArea == 3){ x = width - 40; y = height - 15; }else if (UtilsWoodCuttingLevel.TextArea == 4){ x = 40; y = height - 15; }else{ x = width - 40; y = 15; } String Pre = UtilsWoodCuttingLevel.LevelMark; this.drawCenteredString(this.mc.fontRenderer, Pre + WoodCuttingLevel, x, y, 0xffffff); GL11.glDisable(GL11.GL_BLEND); } } } any ideas on the matter would be appreciated
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.