Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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

  • Author

Thanks, but what does this code do?

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

 

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

  • Author

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.