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

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) {
	GL11.glDisable(GL11.GL_LIGHTING);


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

	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE);

	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);

	//GL11.glEnable(GL11.GL_LIGHTING);

}

public void drawText(String text, int WidthOffset, int Line, boolean Shaddow) {
	fontRender.drawString(
			text,
			10 * WidthOffset,
			10 * Line,
			Color.white.getRGB(),
			true);
}

public void drawText(String text, int Line, boolean Shaddow) {
	fontRender.drawString(
			text,
			10,
			10 * Line,
			Color.white.getRGB(),
			true);
}
}


 

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

 

  • Author

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();

    @SubscribeEvent
    public void onRenderTick(RenderTickEvent event) {
    	renderTick.tick(event);
    	GalacticFrontier.logger.info("renderTick");
    }


@SubscribeEvent(priority = EventPriority.NORMAL)
    public void overlayRender(RenderGameOverlayEvent event) {
	logo.renderLogoText(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.

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.