From d2ed7b18959d7901bc8ed3d6ac0f7ecbc5ca6ac7 Mon Sep 17 00:00:00 2001 From: LAX1DUDE Date: Thu, 28 Apr 2022 19:02:46 -0700 Subject: [PATCH] ported more classes to eagleradapter --- lwjgl-rundir/resources/lang/en_US.lang | 2 +- .../lax1dude/eaglercraft/MinecraftMain.java | 27 +-- .../adapter/EaglerAdapterImpl2.java | 9 + .../eaglercraft/LocalStorageManager.java | 78 +++++++ .../beta/EaglercraftChunkLoader.java | 2 +- .../eaglercraft/beta/FilesystemUtils.java | 16 +- .../beta/SingleplayerCommands.java | 30 +++ .../java/net/minecraft/client/Minecraft.java | 123 ++++------- src/main/java/net/minecraft/src/EnumOS1.java | 38 ---- src/main/java/net/minecraft/src/EnumOS2.java | 39 ---- .../minecraft/src/EnumOSMappingHelper.java | 32 --- .../java/net/minecraft/src/GameSettings.java | 196 +++++------------- .../java/net/minecraft/src/GuiGameOver.java | 2 +- .../java/net/minecraft/src/GuiMainMenu.java | 8 +- .../net/minecraft/src/GuiRenameWorld.java | 1 - .../java/net/minecraft/src/GuiSleepMP.java | 1 - .../net/minecraft/src/GuiTexturePacks.java | 7 +- .../net/minecraft/src/NBTTagCompound.java | 4 + .../net/minecraft/src/OpenGlCapsChecker.java | 6 +- src/main/java/net/minecraft/src/OsMap.java | 30 --- .../net/minecraft/src/TexturePackList.java | 10 +- src/main/java/net/minecraft/src/World.java | 7 +- 22 files changed, 257 insertions(+), 411 deletions(-) create mode 100644 src/main/java/net/lax1dude/eaglercraft/LocalStorageManager.java delete mode 100644 src/main/java/net/minecraft/src/EnumOS1.java delete mode 100644 src/main/java/net/minecraft/src/EnumOS2.java delete mode 100644 src/main/java/net/minecraft/src/EnumOSMappingHelper.java delete mode 100644 src/main/java/net/minecraft/src/OsMap.java diff --git a/lwjgl-rundir/resources/lang/en_US.lang b/lwjgl-rundir/resources/lang/en_US.lang index fd09c05..620c72d 100644 --- a/lwjgl-rundir/resources/lang/en_US.lang +++ b/lwjgl-rundir/resources/lang/en_US.lang @@ -102,7 +102,7 @@ key.jump=Jump key.inventory=Inventory key.drop=Drop key.chat=Chat -key.fog=Toggle Fog +key.function=Function key.sneak=Sneak key.playerlist=List players diff --git a/src/lwjgl/java/net/lax1dude/eaglercraft/MinecraftMain.java b/src/lwjgl/java/net/lax1dude/eaglercraft/MinecraftMain.java index 95d727b..4e2ccae 100644 --- a/src/lwjgl/java/net/lax1dude/eaglercraft/MinecraftMain.java +++ b/src/lwjgl/java/net/lax1dude/eaglercraft/MinecraftMain.java @@ -8,12 +8,25 @@ import net.lax1dude.eaglercraft.anvil.SaveConverterMcRegion; import net.minecraft.client.Minecraft; public class MinecraftMain { + + private static class MinecraftImpl extends Minecraft { + + @Override + public void displayCrashScreen(Throwable t) { + System.err.println("GAME CRASHED! Crash screen was requested"); + t.printStackTrace(); + EaglerAdapter.destroyContext(); + EaglerAdapter.exit(); + } + + } public static void main(String[] par0ArrayOfStr) { - JOptionPane.showMessageDialog(null, "launch renderdoc (optionally) and press ok to continue", "eaglercraft", JOptionPane.PLAIN_MESSAGE); + EaglerAdapter.initializeContext(); + LocalStorageManager.loadStorage(); for(int i = 0; i < par0ArrayOfStr.length; ++i) { String arg = par0ArrayOfStr[i]; @@ -22,17 +35,7 @@ public class MinecraftMain { } } - /* - * LocalStorageManager.loadStorage(); byte[] b = - * EaglerAdapter.loadLocalStorage("forced"); if(b != null) { - * ServerList.loadDefaultServers(Base64.encodeBase64String(b)); } - * if(par0ArrayOfStr.length > 0) { - * EaglerAdapter.setServerToJoinOnLaunch(par0ArrayOfStr[0]); } - */ - - // Minecraft.startMainThread(null, null, null); - - Minecraft mc = new Minecraft(); + Minecraft mc = new MinecraftImpl(); mc.run(); } diff --git a/src/lwjgl/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java b/src/lwjgl/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java index 803518d..097c130 100644 --- a/src/lwjgl/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java +++ b/src/lwjgl/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java @@ -992,6 +992,15 @@ public class EaglerAdapterImpl2 { return Keyboard.isKeyDown(p1); } + public static final boolean isFunctionKeyDown(boolean mod, int p1) { + return Keyboard.isKeyDown(p1) || (mod && p1 >= Keyboard.KEY_F1 && p1 <= Keyboard.KEY_F9 && Keyboard.isKeyDown(Keyboard.KEY_1 + (p1 - Keyboard.KEY_F1))); + } + + public static final boolean isFunctionKeyDown(int mod, int p1) { + return Keyboard.isKeyDown(p1) || (Keyboard.isKeyDown(mod) && p1 >= Keyboard.KEY_F1 && p1 <= Keyboard.KEY_F9 & + Keyboard.isKeyDown(Keyboard.KEY_1 + (p1 - Keyboard.KEY_F1))); + } + public static final String getKeyName(int p1) { return Keyboard.getKeyName(p1); } diff --git a/src/main/java/net/lax1dude/eaglercraft/LocalStorageManager.java b/src/main/java/net/lax1dude/eaglercraft/LocalStorageManager.java new file mode 100644 index 0000000..0f45001 --- /dev/null +++ b/src/main/java/net/lax1dude/eaglercraft/LocalStorageManager.java @@ -0,0 +1,78 @@ +package net.lax1dude.eaglercraft; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import net.minecraft.src.NBTBase; +import net.minecraft.src.NBTTagCompound; + +public class LocalStorageManager { + + public static NBTTagCompound gameSettingsStorage = null; + public static NBTTagCompound profileSettingsStorage = null; + + public static void loadStorage() { + byte[] g = EaglerAdapter.loadLocalStorage("g"); + byte[] p = EaglerAdapter.loadLocalStorage("p"); + + if(g != null) { + try { + NBTBase t = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(g))); + if(t != null && t instanceof NBTTagCompound) { + gameSettingsStorage = (NBTTagCompound)t; + } + }catch(IOException e) { + ; + } + } + + if(p != null) { + try { + NBTBase t = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(p))); + if(t != null && t instanceof NBTTagCompound) { + profileSettingsStorage = (NBTTagCompound)t; + } + }catch(IOException e) { + ; + } + } + + if(gameSettingsStorage == null) gameSettingsStorage = new NBTTagCompound(); + if(profileSettingsStorage == null) profileSettingsStorage = new NBTTagCompound(); + + } + + public static void saveStorageG() { + try { + ByteArrayOutputStream s = new ByteArrayOutputStream(); + NBTBase.writeTag(gameSettingsStorage, new DataOutputStream(s)); + EaglerAdapter.saveLocalStorage("g", s.toByteArray()); + } catch (IOException e) { + ; + } + } + + public static void saveStorageP() { + try { + ByteArrayOutputStream s = new ByteArrayOutputStream(); + NBTBase.writeTag(profileSettingsStorage, new DataOutputStream(s)); + EaglerAdapter.saveLocalStorage("p", s.toByteArray()); + } catch (IOException e) { + ; + } + } + + public static String dumpConfiguration() { + try { + ByteArrayOutputStream s = new ByteArrayOutputStream(); + NBTBase.writeTag(gameSettingsStorage, new DataOutputStream(s)); + return Base64.encodeBase64String(s.toByteArray()); + } catch(Throwable e) { + return ""; + } + } + +} diff --git a/src/main/java/net/lax1dude/eaglercraft/beta/EaglercraftChunkLoader.java b/src/main/java/net/lax1dude/eaglercraft/beta/EaglercraftChunkLoader.java index ff0a274..c76f12c 100644 --- a/src/main/java/net/lax1dude/eaglercraft/beta/EaglercraftChunkLoader.java +++ b/src/main/java/net/lax1dude/eaglercraft/beta/EaglercraftChunkLoader.java @@ -62,7 +62,7 @@ public class EaglercraftChunkLoader implements IChunkLoader { public void saveChunk(World world, Chunk chunk) { NBTTagCompound toSave = new NBTTagCompound(); storeChunkInCompound(chunk, world, toSave); - ByteArrayOutputStream bao = new ByteArrayOutputStream(98304); + ByteArrayOutputStream bao = new ByteArrayOutputStream(131072); try { NBTBase.writeTag(toSave, new DataOutputStream(bao)); } catch (IOException e) { diff --git a/src/main/java/net/lax1dude/eaglercraft/beta/FilesystemUtils.java b/src/main/java/net/lax1dude/eaglercraft/beta/FilesystemUtils.java index 0d644d2..65914ff 100644 --- a/src/main/java/net/lax1dude/eaglercraft/beta/FilesystemUtils.java +++ b/src/main/java/net/lax1dude/eaglercraft/beta/FilesystemUtils.java @@ -1,5 +1,6 @@ package net.lax1dude.eaglercraft.beta; +import java.util.Collection; import java.util.function.Consumer; import net.lax1dude.eaglercraft.EaglerAdapter; @@ -8,10 +9,21 @@ import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FileEntry; public class FilesystemUtils { public static void recursiveDeleteDirectory(String dir) { - EaglerAdapter.listFiles(dir, true, true).forEach(new Consumer() { + Collection lst = EaglerAdapter.listFiles(dir, true, true); + lst.forEach(new Consumer() { @Override public void accept(FileEntry t) { - EaglerAdapter.deleteFile(t.path); + if(!t.isDirectory) { + EaglerAdapter.deleteFile(t.path); + } + } + }); + lst.forEach(new Consumer() { + @Override + public void accept(FileEntry t) { + if(t.isDirectory) { + EaglerAdapter.deleteFile(t.path); + } } }); EaglerAdapter.deleteFile(dir); diff --git a/src/main/java/net/lax1dude/eaglercraft/beta/SingleplayerCommands.java b/src/main/java/net/lax1dude/eaglercraft/beta/SingleplayerCommands.java index 8ee0620..b0e2968 100644 --- a/src/main/java/net/lax1dude/eaglercraft/beta/SingleplayerCommands.java +++ b/src/main/java/net/lax1dude/eaglercraft/beta/SingleplayerCommands.java @@ -11,6 +11,7 @@ import net.minecraft.src.FontRenderer; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; import net.minecraft.src.MathHelper; +import net.minecraft.src.WorldInfo; public class SingleplayerCommands { @@ -21,6 +22,7 @@ public class SingleplayerCommands { singleplayerCommands.put("help", new CommandHelp()); singleplayerCommands.put("give", new CommandGiveItem()); singleplayerCommands.put("summon", new CommandSummon()); + singleplayerCommands.put("time", new CommandTime()); } public static interface Command { @@ -143,4 +145,32 @@ public class SingleplayerCommands { } + public static class CommandTime implements Command { + + @Override + public void processCommand(Minecraft mc, String[] args) throws Throwable { + int i; + if(args.length != 1) { + throw new CommandException("arguments must be: "); + } + try { + i = Integer.parseInt(args[0]); + }catch(NumberFormatException ex) { + throw new CommandException("time argument must be an integer"); + } + WorldInfo inf = mc.theWorld.getInfo(); + long t = inf.getWorldTime(); + t = t / 24000l * 24000l; + t += i; + inf.setWorldTime(t); + mc.displayChat("Set world time to " + i + " ticks"); + } + + @Override + public String getDescription() { + return "set world time in "; + } + + } + } diff --git a/src/main/java/net/minecraft/client/Minecraft.java b/src/main/java/net/minecraft/client/Minecraft.java index bf06fcc..db05e82 100644 --- a/src/main/java/net/minecraft/client/Minecraft.java +++ b/src/main/java/net/minecraft/client/Minecraft.java @@ -4,8 +4,6 @@ package net.minecraft.client; -import java.io.*; - import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.TextureLocation; import net.lax1dude.eaglercraft.adapter.Tessellator; @@ -13,10 +11,7 @@ import net.lax1dude.eaglercraft.beta.EaglercraftSaveManager; import net.lax1dude.eaglercraft.beta.SingleplayerCommands; import net.minecraft.src.*; -// Referenced classes of package net.minecraft.client: -// MinecraftApplet - -public class Minecraft implements Runnable { +public abstract class Minecraft implements Runnable { public Minecraft() { instance = this; @@ -51,6 +46,8 @@ public class Minecraft implements Runnable { hideQuitButton = false; field_21900_a = this; } + + public abstract void displayCrashScreen(Throwable t); public void setServer(String s, int i) { serverName = s; @@ -59,14 +56,13 @@ public class Minecraft implements Runnable { public void startGame() { RenderManager.instance.itemRenderer = new ItemRenderer(this); - mcDataDir = getMinecraftDir(); field_22008_V = EaglerAdapter.getConfiguredSaveFormat(); if(field_22008_V == null) { field_22008_V = new EaglercraftSaveManager("saves"); } - gameSettings = new GameSettings(this, mcDataDir); + gameSettings = new GameSettings(); texturePackList = new TexturePackList(this); renderEngine = new RenderEngine(texturePackList, gameSettings); fontRenderer = new FontRenderer(gameSettings, "/font/default.png", renderEngine); @@ -156,17 +152,6 @@ public class Minecraft implements Runnable { tessellator.draw(); } - public static File getMinecraftDir() { - if (minecraftDir == null) { - minecraftDir = new File("."); - } - return minecraftDir; - } - - private static EnumOS2 getOs() { - return EnumOS2.windows; - } - public ISaveFormat func_22004_c() { return field_22008_V; } @@ -226,9 +211,7 @@ public class Minecraft implements Runnable { try { startGame(); } catch (Exception exception) { - exception.printStackTrace(); - // displayUnexpectedThrowable(new UnexpectedThrowable("Failed to start game", - // exception)); //TODO: crash screen + displayCrashScreen(exception); return; } try { @@ -319,34 +302,25 @@ public class Minecraft implements Runnable { } } catch (Throwable throwable) { theWorld = null; - throwable.printStackTrace(); - // displayUnexpectedThrowable(new UnexpectedThrowable("Unexpected error", - // throwable)); //TODO: crash screen - } finally { - shutdownMinecraftApplet(); + displayCrashScreen(throwable); + return; } + + EaglerAdapter.destroyContext(); + EaglerAdapter.exit(); } private void screenshotListener() { - if (EaglerAdapter.isKeyDown(60)) { + if (EaglerAdapter.isFunctionKeyDown(gameSettings.keyBindFunction.keyCode, 60)) { if (!isTakingScreenshot) { isTakingScreenshot = true; - if (EaglerAdapter.isKeyDown(42)) { - ingameGUI.addChatMessage(func_21001_a(minecraftDir, displayWidth, displayHeight, 36450, 17700)); - } else { - //ingameGUI - // .addChatMessage(ScreenShotHelper.saveScreenshot(minecraftDir, displayWidth, displayHeight)); - } + EaglerAdapter.saveScreenshot(); } } else { isTakingScreenshot = false; } } - private String func_21001_a(File file, int i, int j, int k, int l) { - return "Screenshot not implemented"; - } - private void displayDebugInfo(long l) { long l1 = 0xfe502aL; if (prevFrameTime == -1L) { @@ -655,49 +629,40 @@ public class Minecraft implements Runnable { } thePlayer.handleKeyPress(EaglerAdapter.getEventKey(), EaglerAdapter.getEventKeyState()); if (EaglerAdapter.getEventKeyState()) { - if (EaglerAdapter.getEventKey() == 87) { - toggleFullscreen(); + if (currentScreen != null) { + currentScreen.handleKeyboardInput(); } else { - if (currentScreen != null) { - currentScreen.handleKeyboardInput(); - } else { - if (EaglerAdapter.getEventKey() == 1) { - func_6252_g(); - } - if (EaglerAdapter.getEventKey() == 31 && EaglerAdapter.isKeyDown(61)) { - forceReload(); - } - if (EaglerAdapter.getEventKey() == 59) { - gameSettings.field_22277_y = !gameSettings.field_22277_y; - } - if (EaglerAdapter.getEventKey() == 61) { - gameSettings.showDebugInfo = !gameSettings.showDebugInfo; - } - if (EaglerAdapter.getEventKey() == 63) { - gameSettings.thirdPersonView = !gameSettings.thirdPersonView; - } - if (EaglerAdapter.getEventKey() == 66) { - gameSettings.field_22274_D = !gameSettings.field_22274_D; - } - if (EaglerAdapter.getEventKey() == gameSettings.keyBindInventory.keyCode) { - displayGuiScreen(new GuiInventory(thePlayer)); - } - if (EaglerAdapter.getEventKey() == gameSettings.keyBindDrop.keyCode) { - thePlayer.dropCurrentItem(); - } - if (EaglerAdapter.getEventKey() == gameSettings.keyBindChat.keyCode) { - displayGuiScreen(new GuiChat()); - } + if (EaglerAdapter.getEventKey() == 1) { + func_6252_g(); } - for (int i = 0; i < 9; i++) { - if (EaglerAdapter.getEventKey() == 2 + i) { - thePlayer.inventory.currentItem = i; - } + if (EaglerAdapter.getEventKey() == 31 && EaglerAdapter.isFunctionKeyDown(gameSettings.keyBindFunction.keyCode, 61)) { + forceReload(); } - - if (EaglerAdapter.getEventKey() == gameSettings.keyBindToggleFog.keyCode) { - gameSettings.setOptionValue(EnumOptions.RENDER_DISTANCE, - !EaglerAdapter.isKeyDown(42) && !EaglerAdapter.isKeyDown(54) ? 1 : -1); + if (EaglerAdapter.isFunctionKeyDown(gameSettings.keyBindFunction.keyCode, 59)) { + gameSettings.field_22277_y = !gameSettings.field_22277_y; + } + if (EaglerAdapter.isFunctionKeyDown(gameSettings.keyBindFunction.keyCode, 61)) { + gameSettings.showDebugInfo = !gameSettings.showDebugInfo; + } + if (EaglerAdapter.isFunctionKeyDown(gameSettings.keyBindFunction.keyCode, 63)) { + gameSettings.thirdPersonView = !gameSettings.thirdPersonView; + } + if (EaglerAdapter.isFunctionKeyDown(gameSettings.keyBindFunction.keyCode, 66)) { + gameSettings.field_22274_D = !gameSettings.field_22274_D; + } + if (EaglerAdapter.getEventKey() == gameSettings.keyBindInventory.keyCode) { + displayGuiScreen(new GuiInventory(thePlayer)); + } + if (EaglerAdapter.getEventKey() == gameSettings.keyBindDrop.keyCode) { + thePlayer.dropCurrentItem(); + } + if (EaglerAdapter.getEventKey() == gameSettings.keyBindChat.keyCode) { + displayGuiScreen(new GuiChat()); + } + } + for (int i = 0; i < 9; i++) { + if (EaglerAdapter.getEventKey() == 2 + i) { + thePlayer.inventory.currentItem = i; } } } @@ -1046,7 +1011,6 @@ public class Minecraft implements Runnable { public SoundManager sndManager; public MouseHelper mouseHelper; public TexturePackList texturePackList; - private File mcDataDir; private ISaveFormat field_22008_V; public static long frameTimes[] = new long[512]; public static long tickTimes[] = new long[512]; @@ -1055,7 +1019,6 @@ public class Minecraft implements Runnable { private int serverPort; private TextureWaterFX textureWaterFX; private TextureLavaFX textureLavaFX; - private static File minecraftDir = null; public volatile boolean running; public String debug; boolean isTakingScreenshot; diff --git a/src/main/java/net/minecraft/src/EnumOS1.java b/src/main/java/net/minecraft/src/EnumOS1.java deleted file mode 100644 index b903266..0000000 --- a/src/main/java/net/minecraft/src/EnumOS1.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.minecraft.src; - -import net.lax1dude.eaglercraft.compat.CompatEnum; - -// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) braces deadcode - -final class EnumOS1 extends CompatEnum { - - public static EnumOS1[] values() { - return (EnumOS1[]) field_6525_f.clone(); - } - - public static EnumOS1 valueOf(String s) { - return (EnumOS1) CompatEnum.valueOf(EnumOS1.class, s); - } - - private EnumOS1(String s, int i) { - super(s, i); - } - - public static final EnumOS1 linux; - public static final EnumOS1 solaris; - public static final EnumOS1 windows; - public static final EnumOS1 macos; - public static final EnumOS1 unknown; - private static final EnumOS1 field_6525_f[]; /* synthetic field */ - - static { - linux = new EnumOS1("linux", 0); - solaris = new EnumOS1("solaris", 1); - windows = new EnumOS1("windows", 2); - macos = new EnumOS1("macos", 3); - unknown = new EnumOS1("unknown", 4); - field_6525_f = (new EnumOS1[] { linux, solaris, windows, macos, unknown }); - } -} diff --git a/src/main/java/net/minecraft/src/EnumOS2.java b/src/main/java/net/minecraft/src/EnumOS2.java deleted file mode 100644 index 1064bab..0000000 --- a/src/main/java/net/minecraft/src/EnumOS2.java +++ /dev/null @@ -1,39 +0,0 @@ -package net.minecraft.src; -// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. - -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) braces deadcode - -import net.lax1dude.eaglercraft.compat.CompatEnum; -import net.minecraft.client.Minecraft; - -public final class EnumOS2 extends CompatEnum { - - public static EnumOS2[] values() { - return (EnumOS2[]) field_6511_f.clone(); - } - - public static EnumOS2 valueOf(String s) { - return (EnumOS2) CompatEnum.valueOf(EnumOS2.class, s); - } - - private EnumOS2(String s, int i) { - super(s, i); - } - - public static final EnumOS2 linux; - public static final EnumOS2 solaris; - public static final EnumOS2 windows; - public static final EnumOS2 macos; - public static final EnumOS2 unknown; - private static final EnumOS2 field_6511_f[]; /* synthetic field */ - - static { - linux = new EnumOS2("linux", 0); - solaris = new EnumOS2("solaris", 1); - windows = new EnumOS2("windows", 2); - macos = new EnumOS2("macos", 3); - unknown = new EnumOS2("unknown", 4); - field_6511_f = (new EnumOS2[] { linux, solaris, windows, macos, unknown }); - } -} diff --git a/src/main/java/net/minecraft/src/EnumOSMappingHelper.java b/src/main/java/net/minecraft/src/EnumOSMappingHelper.java deleted file mode 100644 index 674a80c..0000000 --- a/src/main/java/net/minecraft/src/EnumOSMappingHelper.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.minecraft.src; -// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. - -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) braces deadcode - -import net.minecraft.client.Minecraft; - -public class EnumOSMappingHelper { - - public static final int enumOSMappingArray[]; /* synthetic field */ - - static { - enumOSMappingArray = new int[EnumOS2.values().length]; - try { - enumOSMappingArray[EnumOS2.linux.ordinal()] = 1; - } catch (NoSuchFieldError nosuchfielderror) { - } - try { - enumOSMappingArray[EnumOS2.solaris.ordinal()] = 2; - } catch (NoSuchFieldError nosuchfielderror1) { - } - try { - enumOSMappingArray[EnumOS2.windows.ordinal()] = 3; - } catch (NoSuchFieldError nosuchfielderror2) { - } - try { - enumOSMappingArray[EnumOS2.macos.ordinal()] = 4; - } catch (NoSuchFieldError nosuchfielderror3) { - } - } -} diff --git a/src/main/java/net/minecraft/src/GameSettings.java b/src/main/java/net/minecraft/src/GameSettings.java index 4d679fb..1355858 100644 --- a/src/main/java/net/minecraft/src/GameSettings.java +++ b/src/main/java/net/minecraft/src/GameSettings.java @@ -4,88 +4,49 @@ package net.minecraft.src; // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) braces deadcode -import java.io.*; import net.lax1dude.eaglercraft.EaglerAdapter; +import net.lax1dude.eaglercraft.LocalStorageManager; import net.minecraft.client.Minecraft; public class GameSettings { - public GameSettings(Minecraft minecraft, File file) { - musicVolume = 1.0F; - soundVolume = 1.0F; - mouseSensitivity = 0.5F; - invertMouse = false; - renderDistance = 0; - viewBobbing = true; - anaglyph = false; - limitFramerate = false; - fancyGraphics = true; - field_22278_j = true; - antialiasing = 1; - skin = "Default"; - keyBindForward = new KeyBinding("key.forward", 17); - keyBindLeft = new KeyBinding("key.left", 30); - keyBindBack = new KeyBinding("key.back", 31); - keyBindRight = new KeyBinding("key.right", 32); - keyBindJump = new KeyBinding("key.jump", 57); - keyBindInventory = new KeyBinding("key.inventory", 8); - keyBindDrop = new KeyBinding("key.drop", 16); - keyBindChat = new KeyBinding("key.chat", 20); - keyBindToggleFog = new KeyBinding("key.fog", 33); - keyBindSneak = new KeyBinding("key.sneak", 42); - keyBindings = (new KeyBinding[] { keyBindForward, keyBindLeft, keyBindBack, keyBindRight, keyBindJump, - keyBindSneak, keyBindDrop, keyBindInventory, keyBindChat, keyBindToggleFog }); - difficulty = 2; - field_22277_y = false; - thirdPersonView = false; - showDebugInfo = false; - lastServer = ""; - field_22275_C = false; - field_22274_D = false; - field_22273_E = false; - field_22272_F = 1.0F; - field_22271_G = 1.0F; - mc = minecraft; - optionsFile = new File(file, "options.txt"); - loadOptions(); - } - public GameSettings() { musicVolume = 1.0F; soundVolume = 1.0F; mouseSensitivity = 0.5F; invertMouse = false; - renderDistance = 0; + renderDistance = 2; viewBobbing = true; anaglyph = false; limitFramerate = false; fancyGraphics = false; field_22278_j = false; antialiasing = 1; - skin = "Default"; keyBindForward = new KeyBinding("key.forward", 17); keyBindLeft = new KeyBinding("key.left", 30); keyBindBack = new KeyBinding("key.back", 31); keyBindRight = new KeyBinding("key.right", 32); keyBindJump = new KeyBinding("key.jump", 57); - keyBindInventory = new KeyBinding("key.inventory", 23); + keyBindInventory = new KeyBinding("key.inventory", 18); keyBindDrop = new KeyBinding("key.drop", 16); keyBindChat = new KeyBinding("key.chat", 20); - keyBindToggleFog = new KeyBinding("key.fog", 33); keyBindSneak = new KeyBinding("key.sneak", 42); + keyBindFunction = new KeyBinding("key.function", 33); keyBindings = (new KeyBinding[] { keyBindForward, keyBindLeft, keyBindBack, keyBindRight, keyBindJump, - keyBindSneak, keyBindDrop, keyBindInventory, keyBindChat, keyBindToggleFog }); - difficulty = 2; + keyBindSneak, keyBindDrop, keyBindInventory, keyBindChat, keyBindFunction }); + difficulty = 1; field_22277_y = false; thirdPersonView = false; showDebugInfo = false; lastServer = ""; + texturePack = "Default"; field_22275_C = false; field_22274_D = false; field_22273_E = false; field_22272_F = 1.0F; field_22271_G = 1.0F; + loadOptions(); } public String getKeyBindingDescription(int i) { @@ -242,110 +203,50 @@ public class GameSettings { } public void loadOptions() { - try { - if (!optionsFile.exists()) { - return; + NBTTagCompound yee = LocalStorageManager.gameSettingsStorage; + if(!yee.hasNoTags()) { + if(yee.hasKey("musicVolume")) musicVolume = yee.getFloat("musicVolume"); + if(yee.hasKey("soundVolume")) soundVolume = yee.getFloat("soundVolume"); + if(yee.hasKey("mouseSensitivity")) mouseSensitivity = yee.getFloat("mouseSensitivity"); + if(yee.hasKey("invertMouse")) invertMouse = yee.getBoolean("invertMouse"); + if(yee.hasKey("renderDistance")) renderDistance = (int)yee.getByte("renderDistance") & 0xFF; + if(yee.hasKey("viewBobbing")) viewBobbing = yee.getBoolean("viewBobbing"); + if(yee.hasKey("anaglyph")) anaglyph = yee.getBoolean("anaglyph"); + if(yee.hasKey("limitFramerate")) limitFramerate = yee.getBoolean("limitFramerate"); + if(yee.hasKey("difficulty")) difficulty = (int)yee.getByte("difficulty") & 0xFF; + if(yee.hasKey("fancyGraphics")) fancyGraphics = yee.getBoolean("fancyGraphics"); + if(yee.hasKey("ao")) field_22278_j = yee.getBoolean("ao"); + if(yee.hasKey("antialiasing")) antialiasing = (int)yee.getByte("antialiasing") & 0xFF; + if(yee.hasKey("lastServer")) lastServer = yee.getString("lastServer"); + if(yee.hasKey("texturePack")) texturePack = yee.getString("texturePack"); + for(int i = 0; i < keyBindings.length; ++i) { + String k = "key_" + keyBindings[i].keyDescription; + if(yee.hasKey(k)) keyBindings[i].keyCode = (int)yee.getShort(k) & 0xFFFF; } - BufferedReader bufferedreader = new BufferedReader(new FileReader(optionsFile)); - for (String s = ""; (s = bufferedreader.readLine()) != null;) { - String as[] = s.split(":"); - if (as[0].equals("music")) { - musicVolume = parseFloat(as[1]); - } - if (as[0].equals("sound")) { - soundVolume = parseFloat(as[1]); - } - if (as[0].equals("mouseSensitivity")) { - mouseSensitivity = parseFloat(as[1]); - } - if (as[0].equals("invertYMouse")) { - invertMouse = as[1].equals("true"); - } - if (as[0].equals("viewDistance")) { - renderDistance = Integer.parseInt(as[1]); - } - if (as[0].equals("bobView")) { - viewBobbing = as[1].equals("true"); - } - if (as[0].equals("anaglyph3d")) { - anaglyph = as[1].equals("true"); - } - if (as[0].equals("limitFramerate")) { - limitFramerate = as[1].equals("true"); - } - if (as[0].equals("difficulty")) { - difficulty = Integer.parseInt(as[1]); - } - if (as[0].equals("fancyGraphics")) { - fancyGraphics = as[1].equals("true"); - } - if (as[0].equals("ao")) { - field_22278_j = as[1].equals("true"); - } - if (as[0].equals("antialiasing")) { - antialiasing = Integer.parseInt(as[1]); - } - if (as[0].equals("skin")) { - skin = as[1]; - } - if (as[0].equals("lastServer") && as.length >= 2) { - lastServer = as[1]; - } - int i = 0; - while (i < keyBindings.length) { - if (as[0].equals( - (new StringBuilder()).append("key_").append(keyBindings[i].keyDescription).toString())) { - keyBindings[i].keyCode = Integer.parseInt(as[1]); - } - i++; - } - } - - bufferedreader.close(); - } catch (Exception exception) { - System.out.println("Failed to load options"); - exception.printStackTrace(); - } - } - - private float parseFloat(String s) { - if (s.equals("true")) { - return 1.0F; - } - if (s.equals("false")) { - return 0.0F; - } else { - return Float.parseFloat(s); } } public void saveOptions() { - try { - PrintWriter printwriter = new PrintWriter(new FileWriter(optionsFile)); - printwriter.println((new StringBuilder()).append("music:").append(musicVolume).toString()); - printwriter.println((new StringBuilder()).append("sound:").append(soundVolume).toString()); - printwriter.println((new StringBuilder()).append("invertYMouse:").append(invertMouse).toString()); - printwriter.println((new StringBuilder()).append("mouseSensitivity:").append(mouseSensitivity).toString()); - printwriter.println((new StringBuilder()).append("viewDistance:").append(renderDistance).toString()); - printwriter.println((new StringBuilder()).append("bobView:").append(viewBobbing).toString()); - printwriter.println((new StringBuilder()).append("anaglyph3d:").append(anaglyph).toString()); - printwriter.println((new StringBuilder()).append("limitFramerate:").append(limitFramerate).toString()); - printwriter.println((new StringBuilder()).append("difficulty:").append(difficulty).toString()); - printwriter.println((new StringBuilder()).append("fancyGraphics:").append(fancyGraphics).toString()); - printwriter.println((new StringBuilder()).append("ao:").append(field_22278_j).toString()); - printwriter.println((new StringBuilder()).append("antialiasing:").append(antialiasing).toString()); - printwriter.println((new StringBuilder()).append("skin:").append(skin).toString()); - printwriter.println((new StringBuilder()).append("lastServer:").append(lastServer).toString()); - for (int i = 0; i < keyBindings.length; i++) { - printwriter.println((new StringBuilder()).append("key_").append(keyBindings[i].keyDescription) - .append(":").append(keyBindings[i].keyCode).toString()); - } - - printwriter.close(); - } catch (Exception exception) { - System.out.println("Failed to save options"); - exception.printStackTrace(); + NBTTagCompound yee = LocalStorageManager.gameSettingsStorage; + yee.setFloat("musicVolume", musicVolume); + yee.setFloat("soundVolume", soundVolume); + yee.setFloat("mouseSensitivity", mouseSensitivity); + yee.setBoolean("invertMouse", invertMouse); + yee.setByte("renderDistance", (byte)renderDistance); + yee.setBoolean("viewBobbing", viewBobbing); + yee.setBoolean("anaglyph", anaglyph); + yee.setBoolean("limitFramerate", limitFramerate); + yee.setByte("difficulty", (byte)difficulty); + yee.setBoolean("fancyGraphics", fancyGraphics); + yee.setBoolean("ao", field_22278_j); + yee.setByte("antialiasing", (byte)antialiasing); + yee.setString("lastServer", lastServer); + yee.setString("texturePack", texturePack); + for(int i = 0; i < keyBindings.length; ++i) { + String k = "key_" + keyBindings[i].keyDescription; + yee.setShort(k, (short)keyBindings[i].keyCode); } + LocalStorageManager.saveStorageG(); } private static final String RENDER_DISTANCES[] = { "options.renderDistance.far", "options.renderDistance.normal", @@ -365,7 +266,6 @@ public class GameSettings { public boolean fancyGraphics; public boolean field_22278_j; public int antialiasing; - public String skin; public KeyBinding keyBindForward; public KeyBinding keyBindLeft; public KeyBinding keyBindBack; @@ -374,16 +274,16 @@ public class GameSettings { public KeyBinding keyBindInventory; public KeyBinding keyBindDrop; public KeyBinding keyBindChat; - public KeyBinding keyBindToggleFog; public KeyBinding keyBindSneak; + public KeyBinding keyBindFunction; public KeyBinding keyBindings[]; protected Minecraft mc; - private File optionsFile; public int difficulty; public boolean field_22277_y; public boolean thirdPersonView; public boolean showDebugInfo; public String lastServer; + public String texturePack; public boolean field_22275_C; public boolean field_22274_D; public boolean field_22273_E; diff --git a/src/main/java/net/minecraft/src/GuiGameOver.java b/src/main/java/net/minecraft/src/GuiGameOver.java index af32bd2..8a3658a 100644 --- a/src/main/java/net/minecraft/src/GuiGameOver.java +++ b/src/main/java/net/minecraft/src/GuiGameOver.java @@ -44,7 +44,7 @@ public class GuiGameOver extends GuiScreen { drawCenteredString(fontRenderer, "Game over!", width / 2 / 2, 30, 0xffffff); EaglerAdapter.glPopMatrix(); drawCenteredString(fontRenderer, - (new StringBuilder()).append("Score: &e").append(mc.thePlayer.getScore()).toString(), width / 2, 100, + (new StringBuilder()).append("Score: ").append(mc.thePlayer.getScore()).toString(), width / 2, 100, 0xffffff); super.drawScreen(i, j, f); } diff --git a/src/main/java/net/minecraft/src/GuiMainMenu.java b/src/main/java/net/minecraft/src/GuiMainMenu.java index f88f0fb..08a9c6d 100644 --- a/src/main/java/net/minecraft/src/GuiMainMenu.java +++ b/src/main/java/net/minecraft/src/GuiMainMenu.java @@ -70,7 +70,7 @@ public class GuiMainMenu extends GuiScreen { int i = height / 4 + 48; controlList.add(new GuiButton(1, width / 2 - 100, i, stringtranslate.translateKey("menu.singleplayer"))); controlList.add(new GuiButton(2, width / 2 - 100, i + 24, stringtranslate.translateKey("menu.multiplayer"))); - controlList.add(new GuiButton(3, width / 2 - 100, i + 48, stringtranslate.translateKey("menu.mods"))); + //controlList.add(new GuiButton(3, width / 2 - 100, i + 48, stringtranslate.translateKey("menu.mods"))); if (mc.hideQuitButton) { controlList.add(new GuiButton(0, width / 2 - 100, i + 72, stringtranslate.translateKey("menu.options"))); } else { @@ -92,9 +92,9 @@ public class GuiMainMenu extends GuiScreen { if (guibutton.id == 2) { mc.displayGuiScreen(new GuiMultiplayer(this)); } - if (guibutton.id == 3) { - mc.displayGuiScreen(new GuiTexturePacks(this)); - } + //if (guibutton.id == 3) { + // mc.displayGuiScreen(new GuiTexturePacks(this)); + //} if (guibutton.id == 4) { mc.shutdown(); } diff --git a/src/main/java/net/minecraft/src/GuiRenameWorld.java b/src/main/java/net/minecraft/src/GuiRenameWorld.java index 3dd982a..66241b0 100644 --- a/src/main/java/net/minecraft/src/GuiRenameWorld.java +++ b/src/main/java/net/minecraft/src/GuiRenameWorld.java @@ -5,7 +5,6 @@ package net.minecraft.src; // Decompiler options: packimports(3) braces deadcode import java.util.List; -import org.lwjgl.input.Keyboard; import net.lax1dude.eaglercraft.EaglerAdapter; diff --git a/src/main/java/net/minecraft/src/GuiSleepMP.java b/src/main/java/net/minecraft/src/GuiSleepMP.java index 7c3cb94..a652e7d 100644 --- a/src/main/java/net/minecraft/src/GuiSleepMP.java +++ b/src/main/java/net/minecraft/src/GuiSleepMP.java @@ -5,7 +5,6 @@ package net.minecraft.src; // Decompiler options: packimports(3) braces deadcode import java.util.List; -import net.minecraft.client.Minecraft; import org.lwjgl.input.Keyboard; public class GuiSleepMP extends GuiChat { diff --git a/src/main/java/net/minecraft/src/GuiTexturePacks.java b/src/main/java/net/minecraft/src/GuiTexturePacks.java index d8e1135..be42358 100644 --- a/src/main/java/net/minecraft/src/GuiTexturePacks.java +++ b/src/main/java/net/minecraft/src/GuiTexturePacks.java @@ -4,10 +4,7 @@ package net.minecraft.src; // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) braces deadcode -import java.io.File; -import java.util.List; import net.minecraft.client.Minecraft; -import org.lwjgl.Sys; public class GuiTexturePacks extends GuiScreen { @@ -23,7 +20,7 @@ public class GuiTexturePacks extends GuiScreen { stringtranslate.translateKey("texturePack.openFolder"))); controlList.add(new GuiSmallButton(6, width / 2 + 4, height - 48, stringtranslate.translateKey("gui.done"))); mc.texturePackList.func_6532_a(); - field_6453_p = (new File(Minecraft.getMinecraftDir(), "texturepacks")).getAbsolutePath(); + //field_6453_p = (new File(Minecraft.getMinecraftDir(), "texturepacks")).getAbsolutePath(); field_22128_k = new GuiTexturePackSlot(this); field_22128_k.func_22240_a(controlList, 7, 8); } @@ -33,7 +30,7 @@ public class GuiTexturePacks extends GuiScreen { return; } if (guibutton.id == 5) { - Sys.openURL((new StringBuilder()).append("file://").append(field_6453_p).toString()); + //Sys.openURL((new StringBuilder()).append("file://").append(field_6453_p).toString()); } else if (guibutton.id == 6) { mc.renderEngine.refreshTextures(); mc.displayGuiScreen(field_6461_a); diff --git a/src/main/java/net/minecraft/src/NBTTagCompound.java b/src/main/java/net/minecraft/src/NBTTagCompound.java index 10ab0bf..ea3321b 100644 --- a/src/main/java/net/minecraft/src/NBTTagCompound.java +++ b/src/main/java/net/minecraft/src/NBTTagCompound.java @@ -169,6 +169,10 @@ public class NBTTagCompound extends NBTBase { public String toString() { return (new StringBuilder()).append("").append(tagMap.size()).append(" entries").toString(); } + + public boolean hasNoTags() { + return tagMap.size() >= 0; + } private Map tagMap; } diff --git a/src/main/java/net/minecraft/src/OpenGlCapsChecker.java b/src/main/java/net/minecraft/src/OpenGlCapsChecker.java index 2a39b2b..1fb187a 100644 --- a/src/main/java/net/minecraft/src/OpenGlCapsChecker.java +++ b/src/main/java/net/minecraft/src/OpenGlCapsChecker.java @@ -4,8 +4,6 @@ package net.minecraft.src; // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) braces deadcode -import org.lwjgl.opengl.ContextCapabilities; -import org.lwjgl.opengl.GLContext; public class OpenGlCapsChecker { @@ -13,9 +11,7 @@ public class OpenGlCapsChecker { } public boolean checkARBOcclusion() { - return tryCheckOcclusionCapable && GLContext.getCapabilities().GL_ARB_occlusion_query; + return true; } - private static boolean tryCheckOcclusionCapable = false; - } diff --git a/src/main/java/net/minecraft/src/OsMap.java b/src/main/java/net/minecraft/src/OsMap.java deleted file mode 100644 index 582d1b2..0000000 --- a/src/main/java/net/minecraft/src/OsMap.java +++ /dev/null @@ -1,30 +0,0 @@ -package net.minecraft.src; -// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. - -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) braces deadcode - -class OsMap { - - static final int field_1193_a[]; /* synthetic field */ - - static { - field_1193_a = new int[EnumOS1.values().length]; - try { - field_1193_a[EnumOS1.linux.ordinal()] = 1; - } catch (NoSuchFieldError nosuchfielderror) { - } - try { - field_1193_a[EnumOS1.solaris.ordinal()] = 2; - } catch (NoSuchFieldError nosuchfielderror1) { - } - try { - field_1193_a[EnumOS1.windows.ordinal()] = 3; - } catch (NoSuchFieldError nosuchfielderror2) { - } - try { - field_1193_a[EnumOS1.macos.ordinal()] = 4; - } catch (NoSuchFieldError nosuchfielderror3) { - } - } -} diff --git a/src/main/java/net/minecraft/src/TexturePackList.java b/src/main/java/net/minecraft/src/TexturePackList.java index 1a3b7b8..083db9e 100644 --- a/src/main/java/net/minecraft/src/TexturePackList.java +++ b/src/main/java/net/minecraft/src/TexturePackList.java @@ -14,13 +14,7 @@ public class TexturePackList { defaultTexturePack = new TexturePackDefault(); field_6538_d = new HashMap(); mc = minecraft; - /* - texturePackDir = new File(file, "texturepacks"); - if (!texturePackDir.exists()) { - texturePackDir.mkdirs(); - } - */ - currentTexturePack = minecraft.gameSettings.skin; + currentTexturePack = minecraft.gameSettings.texturePack; func_6532_a(); selectedTexturePack.func_6482_a(); } @@ -32,7 +26,7 @@ public class TexturePackList { selectedTexturePack.closeTexturePackFile(); currentTexturePack = texturepackbase.texturePackFileName; selectedTexturePack = texturepackbase; - mc.gameSettings.skin = currentTexturePack; + mc.gameSettings.texturePack = currentTexturePack; mc.gameSettings.saveOptions(); selectedTexturePack.func_6482_a(); return true; diff --git a/src/main/java/net/minecraft/src/World.java b/src/main/java/net/minecraft/src/World.java index d798613..d381c83 100644 --- a/src/main/java/net/minecraft/src/World.java +++ b/src/main/java/net/minecraft/src/World.java @@ -83,6 +83,10 @@ public class World implements IBlockAccess { chunkProvider = getChunkProvider(); calculateInitialSkylight(); } + + public WorldInfo getInfo() { + return worldinfo; + } public World(ISaveHandler isavehandler, String s, long l) { this(isavehandler, s, l, ((WorldProvider) (null))); @@ -1452,9 +1456,6 @@ public class World implements IBlockAccess { if (l1 % (long) autosavePeriod == 0L) { saveWorld(false, null); } - if(l1 % 24000 > 12000) { - l1 += 12000; - } worldinfo.setWorldTime(l1); TickUpdates(false); func_4080_j();