Posted May 17, 201411 yr I've been trying to use ScaledResolution to center my gui, but it's not really working. My gui coide centers where I want with the default resolution, but when I go full screen (1920 by 1080), it gets shifted to the left. Here's my gui class: package flappyworld.gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.util.ResourceLocation; import tlhpoe.UtilT; import flappyworld.ReferenceFW; public class GuiGameFW extends GuiScreen { private double x = 298.5, y = 15; public static final ResourceLocation phoneTexture = new ResourceLocation(ReferenceFW.ID + ":textures/gui/phone.png"); @Override public void drawScreen(int par1, int par2, float par3) { this.drawDefaultBackground(); super.drawScreen(par1, par2, par3); UtilT.getMC().renderEngine.bindTexture(phoneTexture); ScaledResolution sr = UtilT.getScaledResolution(); this.drawTexturedModalRect((int) UtilT.getScaledX(x, sr), (int) UtilT.getScaledY(y, sr), 0, 0, 128, 224); } @Override public boolean doesGuiPauseGame() { return false; } } Here's the UtilT class: package tlhpoe; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.nbt.NBTTagCompound; public class UtilT { public static Minecraft getMC() { return Minecraft.getMinecraft(); } public static ScaledResolution getScaledResolution() { return new ScaledResolution(getMC().gameSettings, getMC().displayWidth, getMC().displayHeight); } public static double getScaledX(double x, ScaledResolution sr) { return (x / ReferenceT.DEFAULT_WIDTH) * sr.getScaledWidth_double(); } public static double getScaledX(double x) { return getScaledX(x, getScaledResolution()); } public static double getScaledY(double y, ScaledResolution sr) { return (y / ReferenceT.DEFAULT_HEIGHT) * sr.getScaledHeight_double(); } public static double getScaledY(double y) { return getScaledY(y, getScaledResolution()); } } Finally, here are the default width and height variables: public static final int DEFAULT_WIDTH = 854; public static final int DEFAULT_HEIGHT = 480; Kain
May 18, 201411 yr Author For some reason it only works in lower resolutions, and bugs out in higher resolutions. Minecraft mc = UtilT.getMC(); int width = 128; int height = 224; int x = (mc.displayWidth - width) / 2; int y = (mc.displayHeight - height) / 2; this.drawTexturedModalRect(x, y, 0, 0, width, height); Kain
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.