Jump to content

Minecraft InGameHud scaling


Recommended Posts

I am trying to make an Scaling UI Hud Element, I want it so scale with the screen size but i haven't gotten an clue how to, ive looked online but all i found was code that would change the size of the picture but it would be black and would tile, this is the code i have

package com.callumcarmicheal.galacticfrontier.gui;

import java.awt.Color;

import org.lwjgl.opengl.GL11;

import com.callumcarmicheal.galacticfrontier.init.ModInfo;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiIngame;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderGameOverlayEvent;

public class Logo extends GuiScreen {

public ResourceLocation TEXTURE = new ResourceLocation(ModInfo.Mod_ID, "textures/gui/base.png");

TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
private static GuiIngame gig = new GuiIngame(Minecraft.getMinecraft());
FontRenderer fontRender;
ScaledResolution scale;

public void renderLogoText(RenderGameOverlayEvent event) {

	fontRender = Minecraft.getMinecraft().fontRenderer;
	scale = new ScaledResolution(

	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

	int width = scale.getScaledWidth();
	int height = scale.getScaledHeight();
	int posX = 1;
	int posY = 1;
	int sizeX = 176;
	int sizeY = 88;

	this.drawTexturedModalRect(posX, posY, 0,0, sizeX, sizeY);

	String Version = "Developer Edition";

	drawText("§fGlactical Frontier", 1, true);
	drawText("§b(§2"  + Version + "§b)", 2, true);
	drawText("§fPress §4Enter §fto §aContinue", 2, 7, true);



public void drawText(String text, int WidthOffset, int Line, boolean Shaddow) {
			10 * WidthOffset,
			10 * Line,

public void drawText(String text, int Line, boolean Shaddow) {
			10 * Line,


This is the image i have for the base.png: http://i.imgur.com/LxK33.png


Link to comment
Share on other sites

I forgot to add, i have it called in another class


package com.callumcarmicheal.galacticfrontier.render;

import com.callumcarmicheal.galacticfrontier.gui.Logo;
import com.callumcarmicheal.galacticfrontier.init.GalacticFrontier;

import net.minecraft.client.Minecraft;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent;

public class Init {

Logo logo = new Logo();

    public void onRenderTick(RenderTickEvent event) {

@SubscribeEvent(priority = EventPriority.NORMAL)
    public void overlayRender(RenderGameOverlayEvent event) {


also i had it extentending guiscreen because i was using an example code but i deleted it, it was the guiBuffBar on the wiki.

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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.

  • Create New...

Important Information

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