Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [SOLVED]How to draw a string in center
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
yyk419476391

[SOLVED]How to draw a string in center

By yyk419476391, April 17, 2018 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

yyk419476391    0

yyk419476391

yyk419476391    0

  • Tree Puncher
  • yyk419476391
  • Members
  • 0
  • 16 posts
Posted April 17, 2018 (edited)

i want to draw a string in center when player is playing

but it won't draw in correct location,it always draw in right,when i resize game to small,it draw in correct location

Edited April 18, 2018 by yyk419476391
Question solved
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6693

diesieben07

diesieben07    6693

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6693
  • 45741 posts
Posted April 17, 2018

Show your code.

  • Quote

Share this post


Link to post
Share on other sites

yyk419476391    0

yyk419476391

yyk419476391    0

  • Tree Puncher
  • yyk419476391
  • Members
  • 0
  • 16 posts
Posted April 17, 2018
7 hours ago, diesieben07 said:

Show your code.

if (mc.theWorld != null) {
	String text = "Hello!";
  	int width = mc.fontRendererObj.getStringWidth(text);
  	mc.fontRendererObj.drawStringWithShadow(text, mc.displayWidth/2-width/2, 0, 0xFFFFFF);
}

here's code

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6693

diesieben07

diesieben07    6693

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6693
  • 45741 posts
Posted April 18, 2018

You must use ScaledResolution::getScaledWidth.

  • Quote

Share this post


Link to post
Share on other sites

yyk419476391    0

yyk419476391

yyk419476391    0

  • Tree Puncher
  • yyk419476391
  • Members
  • 0
  • 16 posts
Posted April 18, 2018
25 minutes ago, diesieben07 said:

You must use ScaledResolution::getScaledWidth.

thank you very much

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • darkgreenminer
      [1.12.2] Multiple Structure Generation

      By darkgreenminer · Posted 23 minutes ago

      Someone else had that same problem of their mod only spawning the last structure added to WorldGenCustomStructures, and I remembered that the solution I found was what a commentor named Redstone Tim mentioned, that in WorldGenStructure you have to remove 'static'.  I'm happy to email my version of these two classes to you if you want to have a look.  It took me hours and hours to get them working.  I have no idea what might cause the cascading gen lag, but fixing the multiple structure problem might help.    
    • troyvs
      problems starting with modding

      By troyvs · Posted 1 hour ago

      what command did you run to set up?  
    • MightyAhmed
      Immediate Crash On Any Version Of Forge

      By MightyAhmed · Posted 1 hour ago

      ok so its been a while but it was workling fine before somehow but now minecraft still works it just freezes and lagspikes every 5 seconds please help me on this issue i cant find anything on the internet also ihave 4GB ram total in my computer and i have dedicated 2gb ram to minecraft in the JVM arguments section also i have 125 mods installed.
    • deanvangreunen
      Custom Armor Item - Help - MC/Forge 1.14.4/1.14.3

      By deanvangreunen · Posted 2 hours ago

      Hello, I'm in progress of making a Minecraft 1.14.4 Mod using Forge. Needing some help, Could you please look at the following Class File and Explain what I'm doing wrong or what I should be doing?.   The "OnArmorTick" and other ".....Tick" functions don't work.   My intent: - if water is below and near player by 1 block while the boots are on then turn the water into ice. I'm trying to implement "Frost Walking Boots"   Code: - FrostBootsItem.java <- File I need help with - My Project Repo  <- Repo, So if you want to see how my mod is setup. (includes my world saves, etc)   Dev Details: - Minecraft Version: 1.14.4 - Minecraft Snapshot: 20191020-1.14.3 - Forge Version: 1.14.4-28.1.61   Notes: - I've followed a tutorial for 1.14.4 modding by MCJty on youtube (The author of RFTools) - I'm new to minecraft modding. I have expeirenced as a software developer/engineer.   ❤️❤️❤️❤️❤️❤️❤️❤️❤️  ❤️  .Thanks in advance. ❤️  ❤️❤️❤️❤️❤️❤️❤️❤️❤️ 
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 2 hours ago

      please see the screenshoot above.
  • Topics

    • Merthew
      8
      [1.12.2] Multiple Structure Generation

      By Merthew
      Started November 7, 2018

    • coolian
      1
      problems starting with modding

      By coolian
      Started October 9

    • MightyAhmed
      83
      Immediate Crash On Any Version Of Forge

      By MightyAhmed
      Started November 10

    • deanvangreunen
      0
      Custom Armor Item - Help - MC/Forge 1.14.4/1.14.3

      By deanvangreunen
      Started 2 hours ago

    • DragonITA
      48
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA
      Started December 9

  • Who's Online (See full list)

    • Zero
    • A-Game
    • Guy123
    • bitman
    • LTNightshade
    • GttiqwT
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [SOLVED]How to draw a string in center
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community