diff --git a/src/teavm/java/com/mojang/minecraft/GameSettings.java b/src/teavm/java/com/mojang/minecraft/GameSettings.java index 69def43..7bf6aa1 100644 --- a/src/teavm/java/com/mojang/minecraft/GameSettings.java +++ b/src/teavm/java/com/mojang/minecraft/GameSettings.java @@ -1,5 +1,7 @@ package com.mojang.minecraft; +import com.mojang.minecraft.gamemode.*; + import org.lwjgl.opengl.GL11; public final class GameSettings @@ -24,6 +26,7 @@ public final class GameSettings public boolean viewBobbing = true; public boolean anaglyph = false; public boolean limitFramerate = false; + public boolean gamemode = false; public KeyBinding forwardKey = new KeyBinding("Forward", 17); public KeyBinding leftKey = new KeyBinding("Left", 30); public KeyBinding backKey = new KeyBinding("Back", 31); @@ -93,6 +96,22 @@ public final class GameSettings { limitFramerate = !limitFramerate; } + + if(setting == 8) { + gamemode = !gamemode; + + if(gamemode) { + GameMode gamemode = new CreativeGameMode(minecraft); + gamemode.apply(minecraft.level); + gamemode.apply(minecraft.player); + minecraft.gamemode = gamemode; + } else { + GameMode gamemode = new SurvivalGameMode(minecraft); + gamemode.apply(minecraft.level); + gamemode.apply(minecraft.player); + minecraft.gamemode = gamemode; + } + } save(); } @@ -107,7 +126,8 @@ public final class GameSettings : (id == 5 ? "View bobbing: " + (viewBobbing ? "ON" : "OFF") : (id == 6 ? "3d anaglyph: " + (anaglyph ? "ON" : "OFF") : (id == 7 ? "Limit framerate: " + (limitFramerate ? "ON" : "OFF") - : ""))))))); + : (id == 8 ? "Game Mode: " + (gamemode ? "Creative" : "Survival") + : "")))))))); } private void load() diff --git a/src/teavm/java/com/mojang/minecraft/Minecraft.java b/src/teavm/java/com/mojang/minecraft/Minecraft.java index abe5c40..afd5d3e 100644 --- a/src/teavm/java/com/mojang/minecraft/Minecraft.java +++ b/src/teavm/java/com/mojang/minecraft/Minecraft.java @@ -982,7 +982,9 @@ public final class Minecraft implements Runnable { } private void tick() { - this.gamemode.spawnMob(); + if(!settings.gamemode) { + this.gamemode.spawnMob(); + } HUDScreen var17 = this.hud; ++this.hud.ticks; diff --git a/src/teavm/java/com/mojang/minecraft/gui/Screen.java b/src/teavm/java/com/mojang/minecraft/gui/Screen.java index 8019a41..379ef0d 100644 --- a/src/teavm/java/com/mojang/minecraft/gui/Screen.java +++ b/src/teavm/java/com/mojang/minecraft/gui/Screen.java @@ -31,30 +31,34 @@ public class Screen { GL11.glDisable(3042); } - protected static void drawFadingBox(int var0, int var1, int var2, int var3, int var4, int var5) { - float var6 = (float)(var4 >>> 24) / 255.0F; - float var7 = (float)(var4 >> 16 & 255) / 255.0F; - float var8 = (float)(var4 >> 8 & 255) / 255.0F; - float var12 = (float)(var4 & 255) / 255.0F; - float var9 = (float)(var5 >>> 24) / 255.0F; - float var10 = (float)(var5 >> 16 & 255) / 255.0F; - float var11 = (float)(var5 >> 8 & 255) / 255.0F; - float var13 = (float)(var5 & 255) / 255.0F; - GL11.glDisable(3553); - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - //TODO: Rewrite later... - - //GL11.glBegin(7); - GL11.glColor4f(var7, var8, var12, var6); - //GL11.glVertex2f((float)var2, (float)var1); - //GL11.glVertex2f((float)var0, (float)var1); - GL11.glColor4f(var10, var11, var13, var9); - //GL11.glVertex2f((float)var0, (float)var3); - //GL11.glVertex2f((float)var2, (float)var3); - //GL11.glEnd(); - GL11.glDisable(3042); - GL11.glEnable(3553); + protected static void drawFadingBox(int i, int j, int k, int l, int i1, int j1) { + float f = (float) (i1 >> 24 & 0xff) / 255F; + float f1 = (float) (i1 >> 16 & 0xff) / 255F; + float f2 = (float) (i1 >> 8 & 0xff) / 255F; + float f3 = (float) (i1 & 0xff) / 255F; + float f4 = (float) (j1 >> 24 & 0xff) / 255F; + float f5 = (float) (j1 >> 16 & 0xff) / 255F; + float f6 = (float) (j1 >> 8 & 0xff) / 255F; + float f7 = (float) (j1 & 0xff) / 255F; + GL11.glDisable(3553 /* GL_TEXTURE_2D */); + GL11.glEnable(3042 /* GL_BLEND */); + GL11.glDisable(3008 /* GL_ALPHA_TEST */); + GL11.glBlendFunc(770, 771); + GL11.glShadeModel(7425 /* GL_SMOOTH */); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(f1, f2, f3, f); + tessellator.addVertex(k, j, 0.0D); + tessellator.addVertex(i, j, 0.0D); + tessellator.setColorRGBA_F(f5, f6, f7, f4); + tessellator.addVertex(i, l, 0.0D); + tessellator.addVertex(k, l, 0.0D); + tessellator.draw(); + GL11.glShadeModel(7424 /* GL_FLAT */); + GL11.glDisable(3042 /* GL_BLEND */); + GL11.glEnable(3008 /* GL_ALPHA_TEST */); + GL11.glEnable(3553 /* GL_TEXTURE_2D */); + } public static void drawCenteredString(FontRenderer var0, String var1, int var2, int var3, int var4) {