Posted March 30, 20205 yr Hello! I wanted to know how can I center text in 1.15.2, I searched ScaledResolution, but it doesn't seem to exist. Thanks!
March 30, 20205 yr It's very easy! Some geometry: In general it will be similar: String text = "something"; int objectWidth=fontRenderer.getStringWidth(text); int screenWidth=Minecraft.getInstance().mainWindow.getWidth(); fontRenderer.drawString(text, screenWidth/2-objectWidth/2, 10); //we can optimize division: fontRenderer.drawString(text, (screenWidth-objectWidth)/2, 10);
March 31, 20205 yr 3 hours ago, Nitoxym said: Hello! I wanted to know how can I center text in 1.15.2, I searched ScaledResolution, but it doesn't seem to exist. Thanks! First off where are you rendering at? Also what do you mean "center text"? In the exact middle of the screen? In the middle of the width, middle of the height. or even any other point on the screen? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
March 31, 20205 yr Author 9 hours ago, Animefan8888 said: First off where are you rendering at? Also what do you mean "center text"? In the exact middle of the screen? In the middle of the width, middle of the height. or even any other point on the screen? At the middle of the width and height, and I'm rendering in game And screenWidth is the width of the real screen, or the scaled one? Edited March 31, 20205 yr by Nitoxym
March 31, 20205 yr 5 minutes ago, Nitoxym said: and I'm rendering in game Not that kind of where, where is your code going to be located for this rendering operation? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
March 31, 20205 yr 6 minutes ago, Nitoxym said: What do you mean? An event, class? If so, it's in RenderGameOverlayEvent That's exactly what I meant. Inside the RenderGameOverlayEvent there is a getWIndow() function and that has a bunch of getters inside of it. There is one for getScaledWidth/Height and the normal getWidth/Height not sure which one you want to use though. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
March 31, 20205 yr Author 1 minute ago, Animefan8888 said: There is one for getScaledWidth/Height That's exactly what I needed, thanks! ?
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.