package com.example; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import java.io.IOException; public class MyGuiScreen extends GuiScreen { int lastClickedButton = 0; @Override public void initGui() { super.initGui(); this.buttonList.add(new GuiButton(0, width / 2 - 55, height / 2 - 10, 30, 20, "§cRED")); this.buttonList.add(new GuiButton(1, width / 2 - 15, height / 2 - 10, 30, 20, "§9BLUE")); this.buttonList.add(new GuiButton(2, width / 2 + 25, height / 2 - 10, 30, 20, "§2GREEN")); } @Override protected void actionPerformed(GuiButton button) throws IOException { lastClickedButton = button.id; } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { // Draw tinted background drawDefaultBackground(); Minecraft minecraft = Minecraft.getMinecraft(); // First we need to bind the texture minecraft.getTextureManager().bindTexture(new ResourceLocation("examplemod"/* or your modid */, "textures/gui/background.png")); // Render from your texture. drawModalRectWithCustomSizedTexture( // The first two arguments are the position on the screen width / 2 - 100, height / 2 - 20, // The next arguments are the starting u and v 0, 0, // The next arguments are the size on the screen 200, 40, // The last two arguments are the size of the texture 200, 40 ); FontRenderer fr = minecraft.fontRendererObj; String text = "Hello, World!"; int textWidth = fr.getStringWidth(text); // Draw a string left aligned fr.drawString(text, width / 2 - 95, height / 2 - 15, 0xFF000000); // Draw a string center aligned GlStateManager.pushMatrix(); GlStateManager.translate(width / 2, height / 2 - 5 + fr.FONT_HEIGHT / 2, 0); GlStateManager.rotate((float) ((System.currentTimeMillis() / 200.0) % (360)), 0, 0, 1); fr.drawString(text, -textWidth / 2, -fr.FONT_HEIGHT / 2, 0xFF000000); GlStateManager.popMatrix(); // Draw a string right aligned fr.drawString(text, width / 2 + 95 - textWidth, height / 2 + 5, 0xFF000000); } @Override protected void keyTyped(char typedChar, int keyCode) throws IOException { super.keyTyped(typedChar, keyCode); } int lastMouseButton = -1; @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); lastMouseButton = mouseButton; } }