Jump to content

drawStringWithShadow help


TealNerd

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

I'll need help, and I'll give help. Just ask, you know I will!

Link to comment
Share on other sites

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.

I'll need help, and I'll give help. Just ask, you know I will!

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.