From 7d78af5b4c6290e2fcf92532955f7ec967e0bf4e Mon Sep 17 00:00:00 2001 From: PeytonPlayz595 <106421860+PeytonPlayz595@users.noreply.github.com> Date: Sat, 3 Feb 2024 20:28:41 -0500 Subject: [PATCH] Added warning message on startup --- .../java/net/minecraft/src/FontRenderer.java | 12 +++++ .../java/net/minecraft/src/GuiMessage.java | 45 +++++++++++++++++++ .../java/net/minecraft/src/GuiScreen.java | 2 +- .../java/net/minecraft/src/Minecraft.java | 24 +++++----- 4 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 src/main/java/net/minecraft/src/GuiMessage.java diff --git a/src/main/java/net/minecraft/src/FontRenderer.java b/src/main/java/net/minecraft/src/FontRenderer.java index 7e95723..bba8b88 100644 --- a/src/main/java/net/minecraft/src/FontRenderer.java +++ b/src/main/java/net/minecraft/src/FontRenderer.java @@ -1,6 +1,9 @@ package net.minecraft.src; import java.nio.IntBuffer; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; import org.lwjgl.opengl.GL11; @@ -169,4 +172,13 @@ public class FontRenderer { private IntBuffer buffer; public static final char formatChar = '\247'; + + public List listFormattedStringToWidth(String title2) { + java.util.ArrayList arraylist = new java.util.ArrayList(); + String[] string = title2.split("\n"); + for (String list : string) { + arraylist.add(list); + } + return arraylist; + } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/src/GuiMessage.java b/src/main/java/net/minecraft/src/GuiMessage.java new file mode 100644 index 0000000..261d701 --- /dev/null +++ b/src/main/java/net/minecraft/src/GuiMessage.java @@ -0,0 +1,45 @@ +package net.minecraft.src; + +import java.util.ArrayList; +import java.util.List; + +public class GuiMessage extends GuiScreen { + + private String title1; + private String title2; + private final List listLines2 = new ArrayList(); + private GuiScreen parent; + + public GuiMessage(GuiScreen var1, String var2, String var3) { + parent = var1; + title1 = var2; + title2 = var3; + } + + public void initGui() { + this.controlList.clear(); + this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 72, "I Understand!")); + this.listLines2.clear(); + this.listLines2.addAll(this.fontRenderer.listFormattedStringToWidth(this.title2)); + } + + protected void actionPerformed(GuiButton var1) { + if(var1.id == 0) { + this.mc.displayGuiScreen(parent); + } + } + + public void drawScreen(int var1, int var2, float var3) { + this.drawDefaultBackground(); + this.drawCenteredString(fontRenderer, title1, this.width / 2 - 5, 70, 16777215); + int i = 90; + + for (Object s : this.listLines2) { + this.drawCenteredString(this.fontRenderer, (String) s, this.width / 2 - 5, i, 16777215); + i += 9; + } + + super.drawScreen(var1, var2, var3); + } + +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/src/GuiScreen.java b/src/main/java/net/minecraft/src/GuiScreen.java index 252cb3f..4293ee6 100644 --- a/src/main/java/net/minecraft/src/GuiScreen.java +++ b/src/main/java/net/minecraft/src/GuiScreen.java @@ -10,7 +10,7 @@ public class GuiScreen extends Gui { protected Minecraft mc; public int width; public int height; - protected List controlList = new ArrayList(); + protected List controlList = new ArrayList(); public boolean allowUserInput = false; protected FontRenderer fontRenderer; diff --git a/src/main/java/net/minecraft/src/Minecraft.java b/src/main/java/net/minecraft/src/Minecraft.java index 13fda0e..b58b426 100644 --- a/src/main/java/net/minecraft/src/Minecraft.java +++ b/src/main/java/net/minecraft/src/Minecraft.java @@ -45,6 +45,7 @@ public class Minecraft implements Runnable { private int mouseTicksRan = 0; public boolean isRaining = false; long systemTime = System.currentTimeMillis(); + private static Minecraft mc; public Minecraft(int var4, int var5, boolean var6) { new ThreadSleepForever(this, "Timer hack thread"); @@ -55,7 +56,7 @@ public class Minecraft implements Runnable { public void setServer(String var1, int var2) { } - public void startGame() throws LWJGLException { + public void startGame() { this.gameSettings = new GameSettings(this); this.renderEngine = new RenderEngine(this.gameSettings); this.fontRenderer = new FontRenderer(this.gameSettings, "/default.png", this.renderEngine); @@ -75,7 +76,6 @@ public class Minecraft implements Runnable { GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); this.checkGLError("Startup"); - //this.sndManager.loadSoundSettings(this.gameSettings); this.renderEngine.registerTextureFX(this.textureLavaFX); this.renderEngine.registerTextureFX(this.textureWaterFX); this.renderEngine.registerTextureFX(new TextureWaterFlowFX()); @@ -84,7 +84,7 @@ public class Minecraft implements Runnable { this.renderEngine.registerTextureFX(new TextureFlamesFX(1)); this.renderGlobal = new RenderGlobal(this, this.renderEngine); GL11.glViewport(0, 0, this.displayWidth, this.displayHeight); - this.displayGuiScreen(new GuiMainMenu()); + Minecraft.getMinecraft().displayGuiMessage(new GuiMainMenu(), "EARLY BETA TESTING!", "THIS PROJECT IS STILL IN TESTING!\nTHERE WILL BE BUGS!"); this.effectRenderer = new EffectRenderer(this.theWorld, this.renderEngine); this.checkGLError("Post startup"); this.ingameGUI = new GuiIngame(this); @@ -150,6 +150,11 @@ public class Minecraft implements Runnable { } } + public void displayGuiMessage(GuiScreen var1, String var2, String var3) { + GuiMessage guimessage = new GuiMessage(var1, var2, var3); + this.displayGuiScreen(guimessage); + } + private void checkGLError(String var1) { int var2 = GL11.glGetError(); if(var2 != 0) { @@ -172,14 +177,7 @@ public class Minecraft implements Runnable { public void run() { this.running = true; - - try { - this.startGame(); - } catch (Exception var10) { - var10.printStackTrace(); - new UnexpectedThrowable("Failed to start game", var10); - return; - } + this.startGame(); long var1 = System.currentTimeMillis(); int var3 = 0; @@ -777,4 +775,8 @@ public class Minecraft implements Runnable { this.playerController.onRespawn(this.thePlayer); this.preloadWorld("Respawning"); } + + public static Minecraft getMinecraft() { + return mc; + } }