Posted February 4, 201312 yr How could i add to the hud? Creator of Jobo's ModLoader If I helped you could you please click the thank you button and applaud my karma.
February 4, 201312 yr You really need to be more specific with your question, what do you want to add to the hud? A button? a text? a minimap? some animating graphics? If you guys dont get it.. then well ya.. try harder...
February 4, 201312 yr Author Sorry about that i am a COMPLETE noob with the gui and hud stuff but what i am trying to add is a bar with a number on it and the bar decreases when you use an item(already got this working) so it is basically a mana bar if you want to think about it like that. Creator of Jobo's ModLoader If I helped you could you please click the thank you button and applaud my karma.
February 4, 201312 yr So what you currently have is a item which upon use reduces the amount of some variable? And now you want to draw a bar on the screen to show how much remains before the variable becomes 0? If you guys dont get it.. then well ya.. try harder...
February 4, 201312 yr Author yes exactly Creator of Jobo's ModLoader If I helped you could you please click the thank you button and applaud my karma.
February 4, 201312 yr I'm not 100% sure how to do this, but I believe it to be rather simple if you are familiar to tickHandlers. I can look into it after work if you haven't found a solution until I get back. Inn any case do you have a max value the variable could be? if so to know how much of the bar to draw is an easy % calculation, and once you figure out how to get something drawn on the HUD it's easy as pie to draw the bar you want to If you guys dont get it.. then well ya.. try harder...
February 4, 201312 yr Author I don't currently have a max for the variable but i could if needed and even just a simple draw this string to the screen would be nice then i could just look around through those classes and find more stuff. Creator of Jobo's ModLoader If I helped you could you please click the thank you button and applaud my karma.
February 4, 201312 yr FMLClientHandler.instance().getClient().ingameGUI. Call this somewhere it will be called every tick(inside a tick handler). And you can use the ingameGUI.drawXXXX methods to draw strings or textures to the screen. I believe that if you want to draw textures you will need to bind the texture by using the GL11 method glBindTexture, but I'm not sure. Hope this helps you to get a place where you can start looking and exploring the code Edit: Read this post http://www.minecraftforge.net/forum/index.php?topic=516.0 It's about tick handlers, just ignore it ModLoader answer inn post #2 and look at what CPW said If you guys dont get it.. then well ya.. try harder...
February 4, 201312 yr if I was to draw a string, it asks me to input a FontRenderer, a string, and 3 integers. what would I put fot the FontRenderer and the 3 integers FMLClientHandler.instance().getClient().ingameGUI.drawString(par1FontRenderer,par2String, par3Int, par4Int, par5int)
February 4, 201312 yr Author @MazeTar thanks for the help you are awesome! @endershadow fontrender is just simply a thing to get the font so just add private FontRenderer par1FontRenderer the first two integers looks like the coords and i am guessing that the third one is the color Edit: ya first two are coords and third is color but i can't figure out what to put for color Creator of Jobo's ModLoader If I helped you could you please click the thank you button and applaud my karma.
February 4, 201312 yr thanks. one problem, when I add FontRenderer font; it asks me to initialize it so I end up with this FontRenderer font = new FontRenderer(); but then it wants me to make that method public. if I make it public, will that make my mod a core mod? and if so, is there any way I can get around having to make it public
February 4, 201312 yr Author It shouldn't make you do that all i had to do was add private FontRenderer fontrenderer; but it should work like this private FontRenderer fontrenderer = new FontRenderer(); Creator of Jobo's ModLoader If I helped you could you please click the thank you button and applaud my karma.
February 4, 201312 yr Author I crash every time i try and use this 2013-02-04 12:29:11 [iNFO] [sTDERR] java.lang.NullPointerException 2013-02-04 12:29:11 [iNFO] [sTDERR] at cpw.mods.fml.common.SingleIntervalHandler.ticks(SingleIntervalHandler.java:28) 2013-02-04 12:29:11 [iNFO] [sTDERR] at cpw.mods.fml.common.FMLCommonHandler.tickStart(FMLCommonHandler.java:115) 2013-02-04 12:29:11 [iNFO] [sTDERR] at cpw.mods.fml.common.FMLCommonHandler.onPreClientTick(FMLCommonHandler.java:356) 2013-02-04 12:29:11 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1455) 2013-02-04 12:29:11 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:846) 2013-02-04 12:29:11 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:771) 2013-02-04 12:29:11 [iNFO] [sTDERR] at java.lang.Thread.run(Unknown Source) I looks like i might need to reinstall forge here is my tick handler package net.Dungeon; import java.util.EnumSet; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.TickType; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiIngame; public class DungeonTickHandler implements ITickHandler { Minecraft mc = Minecraft.getMinecraft(); @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { // TODO Auto-generated method stub FMLClientHandler.instance().getClient().ingameGUI.drawString(mc.fontRenderer,"Level : " + Dungeon.level, 100, 100, 0); } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { // TODO Auto-generated method stub } @Override public EnumSet<TickType> ticks() { // TODO Auto-generated method stub return EnumSet.of(TickType.RENDER); } @Override public String getLabel() { // TODO Auto-generated method stub return null; } } then i used this to register the tickhandler TickRegistry.registerTickHandler(level , Side.Client); i also for some reason had to do this DungeonTickHandler level; because it wouldn't accept this TickRegistry.registerTickHandler(DungeonTickHandler , Side.Client); Creator of Jobo's ModLoader If I helped you could you please click the thank you button and applaud my karma.
February 4, 201312 yr No you don't have to re install forge, that won't help. The problem is NOT with forge but with your own code. Forge does not ever suddenly break when you are coding something, unless you modify base classes(which means you modify forge, which you really shouldn't). So when there is a crash like that the problem is with your own code. Now the problem we are facing is that something is throwing a NullPointerException, this means it expected something but got Nothing, not even a value, just pure nothingness, Null. So when you look at the Stack Trace, you see it throws a Null pointer exception right after doing some stuff related to Ticks, and that seems logical since the things you did lately are all related to ticks. So look inn your TickHandler and see if you can find the place where it sends null and fix it. Possible hint: getLabel() is expecting a string but returning null, this might be the problem, try setting it to any kind of string When it comes to the fact that you have to instantiate the TickHandler you created that's quite natural, you need to call a =new DungeonTickHandler to get access to a new version of it, since it is NOT static. I'm not sure if the class should be static or not, but I'm sure you can find it out by testing or reading the javadocs/forge documentation If you guys dont get it.. then well ya.. try harder...
February 5, 201312 yr Author That doesn't fix it sadly and forge can break one time i was missing the gameregistry class right after a fresh install Creator of Jobo's ModLoader If I helped you could you please click the thank you button and applaud my karma.
February 5, 201312 yr Well do you have any way to get futher down the stacktrace to see what is causing the null pointer exception, just find the first line which contains on of your classes and you should find the source. Also have you tried using breakpoints and the debugger to find the error? What else have you tried? If you guys dont get it.. then well ya.. try harder...
February 5, 201312 yr WAIT!!! Did you say you DungeonTickHandler level; but never did level = new DungeonTickHandler; !!! Theres your null pointer right there! You never instantiate the level variable of type DungeonTickHandler to a new DungeonTickHandler. When you don't have it as a static class, you must instantiate it before use or else it will always be NULL. This is not beacuse of MCP or Forge, but basic Java, recommended reading/soruce: http://thenewboston.org/list.php?cat=31 If you guys dont get it.. then well ya.. try harder...
February 5, 201312 yr Author FacePalmed so hard there! I know this sounds stupid but i actually know quite a bit in java and after looking at that i just can't think how i forgot that i think it is becuase i was doing a bunch of ints before so they looked like public int whatever; Creator of Jobo's ModLoader If I helped you could you please click the thank you button and applaud my karma.
February 5, 201312 yr Believe me, I did the same, when I read your post earlier I didn't notice it untill now that I was reading it again and going "WTF?" Haha, well there the null pointer should be gone ^^ Is it working now? If you guys dont get it.. then well ya.. try harder...
February 5, 201312 yr Author ya works like a charm for everyone else who needs help this is what i did and it worked (thanks to Mazetar he did the whole thing) package net.Dungeon; import java.util.EnumSet; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.TickType; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiIngame; import net.minecraft.client.gui.GuiScreen; public class DungeonTickHandler implements ITickHandler { Minecraft mc = Minecraft.getMinecraft(); @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { // TODO Auto-generated method stub } @Override public EnumSet<TickType> ticks() { // TODO Auto-generated method stub return EnumSet.of(TickType.RENDER, TickType.CLIENT); } @Override public String getLabel() { // TODO Auto-generated method stub return "Dungeon TickHandler"; } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { // TODO Auto-generated method stub if(type.equals(EnumSet.of(TickType.RENDER))) { onRenderTick(); } else if(type.equals(EnumSet.of(TickType.CLIENT))) { GuiScreen guiScreen = this.mc.currentScreen; if(guiScreen == null) { onTickInGame(); } else { onTickInGUI(guiScreen); } } } private void onTickInGUI(GuiScreen guiScreen) { // TODO Auto-generated method stub } private void onTickInGame() { // TODO Auto-generated method stub } private void onRenderTick() { // TODO Auto-generated method stub mc.fontRenderer.drawStringWithShadow("Dungeon Tokens : " + Dungeon.token, 0, 0, 16777215); mc.fontRenderer.drawStringWithShadow("Dungeon Level : " + Dungeon.manalevel, 0, 10, 16777215); } } then in your @mod class add DungeonTickHandler tickhandler = new DungeonTickHandler(); @Init public void load(FMLInitializationEvent event) { TickRegistry.registerTickHandler(tickhandler, Side.CLIENT); } Creator of Jobo's ModLoader If I helped you could you please click the thank you button and applaud my karma.
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.