Jump to content

Recommended Posts

Posted (edited)

How do I draw text on the screen? Basically, what does the function arguments of the function Minecraft.getInstance().fontRenderer.drawString() mean? Here is the code I used (UtilitiesMod is a static reference to my main mod class):

// Code to draw the text
fontRenderer.drawString(UtilitiesMod.netherPosStack, "Position (nether): "+UtilitiesMod.mcInstance.player.getPosX()/8+" "+UtilitiesMod.mcInstance.player.getPosY()/8+" "+UtilitiesMod.mcInstance.player.getPosZ()/8,1,0-(UtilitiesMod.mcInstance.currentScreen.height/2),14);
// Main class (code for the MatrixStack variables)
public static MatrixStack overworldPosStack=new MatrixStack();
public static MatrixStack netherPosStack=new MatrixStack();

 

Edited by andrussy44
Change "a portion of it" to exactly what portion it was.
Posted
46 minutes ago, andrussy44 said:

Basically, what does the function arguments of the function Minecraft.getInstance().fontRenderer.drawString() mean?

the first param is a matrixStack

the second is the String you want to draw

the third is the starting x position of the string, and the fourth is the starting y position

and the fifth is the color, it is better to write it in hexadecimal than decimal, you use 0x to say you're writing a hex number. if you still don't get it, you can search on hexadecimal color

 

and also: don't create your own matrixStacks, use the ones that are passed to you, you should always have a matrixStack in the context you'd want to call drawString

Posted
1 minute ago, andrussy44 said:

Thanks, but what does this code do?


// UtilitiesMod.overworldPosStack is the matrix stack I am using for this
UtilitiesMod.overworldPosStack.scale(0,0,0);

 

it scales what is going to be rendered with that matrix stack to 0 on x axis, 0 on the y axis, and 0 on the z axis, therefore making it infinetelly small

Posted (edited)

Thanks for all of this. However, I don't know how to make sure that the text will not overlap. Is it possible to specify a specific font size?

Edited by andrussy44
Expand on this post
Posted
16 hours ago, andrussy44 said:

Thanks for all of this. However, I don't know how to make sure that the text will not overlap. Is it possible to specify a specific font size?

you can use MatrixStack#scale, as said before, to make the text smaller

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.