TealNerd Posted September 27, 2014 Share Posted September 27, 2014 I'm trying to draw some strings on the screen (obviously), but when I add a previously declared String or int (e.g. "Health: " + health) it draws "Health: 0" regardless of what value the health variable actually has. Anyone know why this is or how I can fix it? Quote Link to comment Share on other sites More sharing options...
strumshot Posted September 27, 2014 Share Posted September 27, 2014 In general some code would help... but I'm guessing this is in a GUI and its not in sync with the server. You will have to override your update packet or manually write a packet to get the info from the server. Quote I'll need help, and I'll give help. Just ask, you know I will! Link to comment Share on other sites More sharing options...
TealNerd Posted September 27, 2014 Author Share Posted September 27, 2014 fr.drawString("Health: " + lowHealthVal[0] + "", xPos + 1, yPos, 16777215); lowHealthVal is an int array and the value should be 15 and I've put in console outputs all over the place and it should be 15 but it draws 0 on the screen Quote Link to comment Share on other sites More sharing options...
TealNerd Posted September 27, 2014 Author Share Posted September 27, 2014 There isn't really any, it's a client side mod only. I also have the problem where I have: Sting name = mc.thePlayer.getCommandSenderName(); which works, I know it does, and then: fr.drawString(name, xPos + 1, yPos, 16777215); draws absolutely nothing. If I add quotes to it fr.drawString("" + lowPots + "", xPos + 1, yPos, 16777215); it draws "null" on the screen. there is no synchronization issue Quote Link to comment Share on other sites More sharing options...
TealNerd Posted September 27, 2014 Author Share Posted September 27, 2014 Ok here's what I have in the file that isn't working properly @SubscribeEvent public void onRenderInvList(RenderGameOverlayEvent.Post e) { if(e.type != ElementType.EXPERIENCE) { return; } FontRenderer fr = mc.fontRenderer; String name = mc.thePlayer.getCommandSenderName(); System.out.println(name); int xPos = e.resolution.getScaledWidth / 2; int yPos = 10; fr.drawString("" + name + "", xPos, yPos, 16777215); } that is it, nothing else useful there that i can see. when I run the game it draws "null" but outputs "ForgeDevName" in the console Quote Link to comment Share on other sites More sharing options...
TealNerd Posted September 27, 2014 Author Share Posted September 27, 2014 well it's happening, right now, to me Quote Link to comment Share on other sites More sharing options...
strumshot Posted September 27, 2014 Share Posted September 27, 2014 I'm just spitballing here, but does drawstring have a SideOnly Client, and the event is subscribed on the server? edit: DrawString is definitely only executed on the client, I just don't know 100% that events are subscribed only on the server, but I feel that must be the case. As annoying as it is, I think you have to do this through packets. Its one of those times where on the surface it looks like magic is happening in that code, but we have to remember that unless otherwise specified, a lot of code gets executed twice! (server & client) Instead of assigning the variable in the subscribed event, I would send a packet to the client and assign it in the handler. I don't know, it still doesn't sound right, but either you are pasting code you aren't actually using or its something like this. Quote I'll need help, and I'll give help. Just ask, you know I will! Link to comment Share on other sites More sharing options...
strumshot Posted September 27, 2014 Share Posted September 27, 2014 Maybe debug it like this: @SubscribeEvent public void onRenderInvList(RenderGameOverlayEvent.Post e) { if(e.type != ElementType.EXPERIENCE) { return; } FontRenderer fr = mc.fontRenderer; String name = mc.thePlayer.getCommandSenderName(); if(e.world.IsRemote) System.out.println("Server: " + name); else System.out.println("Client: " + name); int xPos = e.resolution.getScaledWidth / 2; int yPos = 10; fr.drawString("" + name + "", xPos, yPos, 16777215); } I'm sure e.world isn't the right world reference, but you see where I'm going with it... edit: on second thought, I can only imagine "onRenderInvList(RenderGameOverlayEvent.Post e)" is on the client, so yeah, I've gotta leave this to those better than me. Quote I'll need help, and I'll give help. Just ask, you know I will! Link to comment Share on other sites More sharing options...
Recommended Posts
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.