ported more classes to eagleradapter

This commit is contained in:
LAX1DUDE 2022-04-28 19:02:46 -07:00
parent d39e81ff72
commit d2ed7b1895
22 changed files with 257 additions and 411 deletions

View File

@ -102,7 +102,7 @@ key.jump=Jump
key.inventory=Inventory key.inventory=Inventory
key.drop=Drop key.drop=Drop
key.chat=Chat key.chat=Chat
key.fog=Toggle Fog key.function=Function
key.sneak=Sneak key.sneak=Sneak
key.playerlist=List players key.playerlist=List players

View File

@ -8,12 +8,25 @@ import net.lax1dude.eaglercraft.anvil.SaveConverterMcRegion;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
public class MinecraftMain { 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) { public static void main(String[] par0ArrayOfStr) {
JOptionPane.showMessageDialog(null, "launch renderdoc (optionally) and press ok to continue", "eaglercraft", JOptionPane.showMessageDialog(null, "launch renderdoc (optionally) and press ok to continue", "eaglercraft",
JOptionPane.PLAIN_MESSAGE); JOptionPane.PLAIN_MESSAGE);
EaglerAdapter.initializeContext(); EaglerAdapter.initializeContext();
LocalStorageManager.loadStorage();
for(int i = 0; i < par0ArrayOfStr.length; ++i) { for(int i = 0; i < par0ArrayOfStr.length; ++i) {
String arg = par0ArrayOfStr[i]; String arg = par0ArrayOfStr[i];
@ -22,17 +35,7 @@ public class MinecraftMain {
} }
} }
/* Minecraft mc = new MinecraftImpl();
* 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();
mc.run(); mc.run();
} }

View File

@ -992,6 +992,15 @@ public class EaglerAdapterImpl2 {
return Keyboard.isKeyDown(p1); 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) { public static final String getKeyName(int p1) {
return Keyboard.getKeyName(p1); return Keyboard.getKeyName(p1);
} }

View File

@ -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 "<error>";
}
}
}

View File

@ -62,7 +62,7 @@ public class EaglercraftChunkLoader implements IChunkLoader {
public void saveChunk(World world, Chunk chunk) { public void saveChunk(World world, Chunk chunk) {
NBTTagCompound toSave = new NBTTagCompound(); NBTTagCompound toSave = new NBTTagCompound();
storeChunkInCompound(chunk, world, toSave); storeChunkInCompound(chunk, world, toSave);
ByteArrayOutputStream bao = new ByteArrayOutputStream(98304); ByteArrayOutputStream bao = new ByteArrayOutputStream(131072);
try { try {
NBTBase.writeTag(toSave, new DataOutputStream(bao)); NBTBase.writeTag(toSave, new DataOutputStream(bao));
} catch (IOException e) { } catch (IOException e) {

View File

@ -1,5 +1,6 @@
package net.lax1dude.eaglercraft.beta; package net.lax1dude.eaglercraft.beta;
import java.util.Collection;
import java.util.function.Consumer; import java.util.function.Consumer;
import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglerAdapter;
@ -8,10 +9,21 @@ import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FileEntry;
public class FilesystemUtils { public class FilesystemUtils {
public static void recursiveDeleteDirectory(String dir) { public static void recursiveDeleteDirectory(String dir) {
EaglerAdapter.listFiles(dir, true, true).forEach(new Consumer<FileEntry>() { Collection<FileEntry> lst = EaglerAdapter.listFiles(dir, true, true);
lst.forEach(new Consumer<FileEntry>() {
@Override @Override
public void accept(FileEntry t) { public void accept(FileEntry t) {
EaglerAdapter.deleteFile(t.path); if(!t.isDirectory) {
EaglerAdapter.deleteFile(t.path);
}
}
});
lst.forEach(new Consumer<FileEntry>() {
@Override
public void accept(FileEntry t) {
if(t.isDirectory) {
EaglerAdapter.deleteFile(t.path);
}
} }
}); });
EaglerAdapter.deleteFile(dir); EaglerAdapter.deleteFile(dir);

View File

@ -11,6 +11,7 @@ import net.minecraft.src.FontRenderer;
import net.minecraft.src.Item; import net.minecraft.src.Item;
import net.minecraft.src.ItemStack; import net.minecraft.src.ItemStack;
import net.minecraft.src.MathHelper; import net.minecraft.src.MathHelper;
import net.minecraft.src.WorldInfo;
public class SingleplayerCommands { public class SingleplayerCommands {
@ -21,6 +22,7 @@ public class SingleplayerCommands {
singleplayerCommands.put("help", new CommandHelp()); singleplayerCommands.put("help", new CommandHelp());
singleplayerCommands.put("give", new CommandGiveItem()); singleplayerCommands.put("give", new CommandGiveItem());
singleplayerCommands.put("summon", new CommandSummon()); singleplayerCommands.put("summon", new CommandSummon());
singleplayerCommands.put("time", new CommandTime());
} }
public static interface Command { 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: <ticks>");
}
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 <ticks>";
}
}
} }

View File

@ -4,8 +4,6 @@
package net.minecraft.client; package net.minecraft.client;
import java.io.*;
import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.TextureLocation; import net.lax1dude.eaglercraft.TextureLocation;
import net.lax1dude.eaglercraft.adapter.Tessellator; import net.lax1dude.eaglercraft.adapter.Tessellator;
@ -13,10 +11,7 @@ import net.lax1dude.eaglercraft.beta.EaglercraftSaveManager;
import net.lax1dude.eaglercraft.beta.SingleplayerCommands; import net.lax1dude.eaglercraft.beta.SingleplayerCommands;
import net.minecraft.src.*; import net.minecraft.src.*;
// Referenced classes of package net.minecraft.client: public abstract class Minecraft implements Runnable {
// MinecraftApplet
public class Minecraft implements Runnable {
public Minecraft() { public Minecraft() {
instance = this; instance = this;
@ -51,6 +46,8 @@ public class Minecraft implements Runnable {
hideQuitButton = false; hideQuitButton = false;
field_21900_a = this; field_21900_a = this;
} }
public abstract void displayCrashScreen(Throwable t);
public void setServer(String s, int i) { public void setServer(String s, int i) {
serverName = s; serverName = s;
@ -59,14 +56,13 @@ public class Minecraft implements Runnable {
public void startGame() { public void startGame() {
RenderManager.instance.itemRenderer = new ItemRenderer(this); RenderManager.instance.itemRenderer = new ItemRenderer(this);
mcDataDir = getMinecraftDir();
field_22008_V = EaglerAdapter.getConfiguredSaveFormat(); field_22008_V = EaglerAdapter.getConfiguredSaveFormat();
if(field_22008_V == null) { if(field_22008_V == null) {
field_22008_V = new EaglercraftSaveManager("saves"); field_22008_V = new EaglercraftSaveManager("saves");
} }
gameSettings = new GameSettings(this, mcDataDir); gameSettings = new GameSettings();
texturePackList = new TexturePackList(this); texturePackList = new TexturePackList(this);
renderEngine = new RenderEngine(texturePackList, gameSettings); renderEngine = new RenderEngine(texturePackList, gameSettings);
fontRenderer = new FontRenderer(gameSettings, "/font/default.png", renderEngine); fontRenderer = new FontRenderer(gameSettings, "/font/default.png", renderEngine);
@ -156,17 +152,6 @@ public class Minecraft implements Runnable {
tessellator.draw(); 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() { public ISaveFormat func_22004_c() {
return field_22008_V; return field_22008_V;
} }
@ -226,9 +211,7 @@ public class Minecraft implements Runnable {
try { try {
startGame(); startGame();
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); displayCrashScreen(exception);
// displayUnexpectedThrowable(new UnexpectedThrowable("Failed to start game",
// exception)); //TODO: crash screen
return; return;
} }
try { try {
@ -319,34 +302,25 @@ public class Minecraft implements Runnable {
} }
} catch (Throwable throwable) { } catch (Throwable throwable) {
theWorld = null; theWorld = null;
throwable.printStackTrace(); displayCrashScreen(throwable);
// displayUnexpectedThrowable(new UnexpectedThrowable("Unexpected error", return;
// throwable)); //TODO: crash screen
} finally {
shutdownMinecraftApplet();
} }
EaglerAdapter.destroyContext();
EaglerAdapter.exit();
} }
private void screenshotListener() { private void screenshotListener() {
if (EaglerAdapter.isKeyDown(60)) { if (EaglerAdapter.isFunctionKeyDown(gameSettings.keyBindFunction.keyCode, 60)) {
if (!isTakingScreenshot) { if (!isTakingScreenshot) {
isTakingScreenshot = true; isTakingScreenshot = true;
if (EaglerAdapter.isKeyDown(42)) { EaglerAdapter.saveScreenshot();
ingameGUI.addChatMessage(func_21001_a(minecraftDir, displayWidth, displayHeight, 36450, 17700));
} else {
//ingameGUI
// .addChatMessage(ScreenShotHelper.saveScreenshot(minecraftDir, displayWidth, displayHeight));
}
} }
} else { } else {
isTakingScreenshot = false; 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) { private void displayDebugInfo(long l) {
long l1 = 0xfe502aL; long l1 = 0xfe502aL;
if (prevFrameTime == -1L) { if (prevFrameTime == -1L) {
@ -655,49 +629,40 @@ public class Minecraft implements Runnable {
} }
thePlayer.handleKeyPress(EaglerAdapter.getEventKey(), EaglerAdapter.getEventKeyState()); thePlayer.handleKeyPress(EaglerAdapter.getEventKey(), EaglerAdapter.getEventKeyState());
if (EaglerAdapter.getEventKeyState()) { if (EaglerAdapter.getEventKeyState()) {
if (EaglerAdapter.getEventKey() == 87) { if (currentScreen != null) {
toggleFullscreen(); currentScreen.handleKeyboardInput();
} else { } else {
if (currentScreen != null) { if (EaglerAdapter.getEventKey() == 1) {
currentScreen.handleKeyboardInput(); func_6252_g();
} 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());
}
} }
for (int i = 0; i < 9; i++) { if (EaglerAdapter.getEventKey() == 31 && EaglerAdapter.isFunctionKeyDown(gameSettings.keyBindFunction.keyCode, 61)) {
if (EaglerAdapter.getEventKey() == 2 + i) { forceReload();
thePlayer.inventory.currentItem = i;
}
} }
if (EaglerAdapter.isFunctionKeyDown(gameSettings.keyBindFunction.keyCode, 59)) {
if (EaglerAdapter.getEventKey() == gameSettings.keyBindToggleFog.keyCode) { gameSettings.field_22277_y = !gameSettings.field_22277_y;
gameSettings.setOptionValue(EnumOptions.RENDER_DISTANCE, }
!EaglerAdapter.isKeyDown(42) && !EaglerAdapter.isKeyDown(54) ? 1 : -1); 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 SoundManager sndManager;
public MouseHelper mouseHelper; public MouseHelper mouseHelper;
public TexturePackList texturePackList; public TexturePackList texturePackList;
private File mcDataDir;
private ISaveFormat field_22008_V; private ISaveFormat field_22008_V;
public static long frameTimes[] = new long[512]; public static long frameTimes[] = new long[512];
public static long tickTimes[] = new long[512]; public static long tickTimes[] = new long[512];
@ -1055,7 +1019,6 @@ public class Minecraft implements Runnable {
private int serverPort; private int serverPort;
private TextureWaterFX textureWaterFX; private TextureWaterFX textureWaterFX;
private TextureLavaFX textureLavaFX; private TextureLavaFX textureLavaFX;
private static File minecraftDir = null;
public volatile boolean running; public volatile boolean running;
public String debug; public String debug;
boolean isTakingScreenshot; boolean isTakingScreenshot;

View File

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

View File

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

View File

@ -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) {
}
}
}

View File

@ -4,88 +4,49 @@ package net.minecraft.src;
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode // Decompiler options: packimports(3) braces deadcode
import java.io.*;
import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.LocalStorageManager;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
public class GameSettings { 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() { public GameSettings() {
musicVolume = 1.0F; musicVolume = 1.0F;
soundVolume = 1.0F; soundVolume = 1.0F;
mouseSensitivity = 0.5F; mouseSensitivity = 0.5F;
invertMouse = false; invertMouse = false;
renderDistance = 0; renderDistance = 2;
viewBobbing = true; viewBobbing = true;
anaglyph = false; anaglyph = false;
limitFramerate = false; limitFramerate = false;
fancyGraphics = false; fancyGraphics = false;
field_22278_j = false; field_22278_j = false;
antialiasing = 1; antialiasing = 1;
skin = "Default";
keyBindForward = new KeyBinding("key.forward", 17); keyBindForward = new KeyBinding("key.forward", 17);
keyBindLeft = new KeyBinding("key.left", 30); keyBindLeft = new KeyBinding("key.left", 30);
keyBindBack = new KeyBinding("key.back", 31); keyBindBack = new KeyBinding("key.back", 31);
keyBindRight = new KeyBinding("key.right", 32); keyBindRight = new KeyBinding("key.right", 32);
keyBindJump = new KeyBinding("key.jump", 57); keyBindJump = new KeyBinding("key.jump", 57);
keyBindInventory = new KeyBinding("key.inventory", 23); keyBindInventory = new KeyBinding("key.inventory", 18);
keyBindDrop = new KeyBinding("key.drop", 16); keyBindDrop = new KeyBinding("key.drop", 16);
keyBindChat = new KeyBinding("key.chat", 20); keyBindChat = new KeyBinding("key.chat", 20);
keyBindToggleFog = new KeyBinding("key.fog", 33);
keyBindSneak = new KeyBinding("key.sneak", 42); keyBindSneak = new KeyBinding("key.sneak", 42);
keyBindFunction = new KeyBinding("key.function", 33);
keyBindings = (new KeyBinding[] { keyBindForward, keyBindLeft, keyBindBack, keyBindRight, keyBindJump, keyBindings = (new KeyBinding[] { keyBindForward, keyBindLeft, keyBindBack, keyBindRight, keyBindJump,
keyBindSneak, keyBindDrop, keyBindInventory, keyBindChat, keyBindToggleFog }); keyBindSneak, keyBindDrop, keyBindInventory, keyBindChat, keyBindFunction });
difficulty = 2; difficulty = 1;
field_22277_y = false; field_22277_y = false;
thirdPersonView = false; thirdPersonView = false;
showDebugInfo = false; showDebugInfo = false;
lastServer = ""; lastServer = "";
texturePack = "Default";
field_22275_C = false; field_22275_C = false;
field_22274_D = false; field_22274_D = false;
field_22273_E = false; field_22273_E = false;
field_22272_F = 1.0F; field_22272_F = 1.0F;
field_22271_G = 1.0F; field_22271_G = 1.0F;
loadOptions();
} }
public String getKeyBindingDescription(int i) { public String getKeyBindingDescription(int i) {
@ -242,110 +203,50 @@ public class GameSettings {
} }
public void loadOptions() { public void loadOptions() {
try { NBTTagCompound yee = LocalStorageManager.gameSettingsStorage;
if (!optionsFile.exists()) { if(!yee.hasNoTags()) {
return; 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() { public void saveOptions() {
try { NBTTagCompound yee = LocalStorageManager.gameSettingsStorage;
PrintWriter printwriter = new PrintWriter(new FileWriter(optionsFile)); yee.setFloat("musicVolume", musicVolume);
printwriter.println((new StringBuilder()).append("music:").append(musicVolume).toString()); yee.setFloat("soundVolume", soundVolume);
printwriter.println((new StringBuilder()).append("sound:").append(soundVolume).toString()); yee.setFloat("mouseSensitivity", mouseSensitivity);
printwriter.println((new StringBuilder()).append("invertYMouse:").append(invertMouse).toString()); yee.setBoolean("invertMouse", invertMouse);
printwriter.println((new StringBuilder()).append("mouseSensitivity:").append(mouseSensitivity).toString()); yee.setByte("renderDistance", (byte)renderDistance);
printwriter.println((new StringBuilder()).append("viewDistance:").append(renderDistance).toString()); yee.setBoolean("viewBobbing", viewBobbing);
printwriter.println((new StringBuilder()).append("bobView:").append(viewBobbing).toString()); yee.setBoolean("anaglyph", anaglyph);
printwriter.println((new StringBuilder()).append("anaglyph3d:").append(anaglyph).toString()); yee.setBoolean("limitFramerate", limitFramerate);
printwriter.println((new StringBuilder()).append("limitFramerate:").append(limitFramerate).toString()); yee.setByte("difficulty", (byte)difficulty);
printwriter.println((new StringBuilder()).append("difficulty:").append(difficulty).toString()); yee.setBoolean("fancyGraphics", fancyGraphics);
printwriter.println((new StringBuilder()).append("fancyGraphics:").append(fancyGraphics).toString()); yee.setBoolean("ao", field_22278_j);
printwriter.println((new StringBuilder()).append("ao:").append(field_22278_j).toString()); yee.setByte("antialiasing", (byte)antialiasing);
printwriter.println((new StringBuilder()).append("antialiasing:").append(antialiasing).toString()); yee.setString("lastServer", lastServer);
printwriter.println((new StringBuilder()).append("skin:").append(skin).toString()); yee.setString("texturePack", texturePack);
printwriter.println((new StringBuilder()).append("lastServer:").append(lastServer).toString()); for(int i = 0; i < keyBindings.length; ++i) {
for (int i = 0; i < keyBindings.length; i++) { String k = "key_" + keyBindings[i].keyDescription;
printwriter.println((new StringBuilder()).append("key_").append(keyBindings[i].keyDescription) yee.setShort(k, (short)keyBindings[i].keyCode);
.append(":").append(keyBindings[i].keyCode).toString());
}
printwriter.close();
} catch (Exception exception) {
System.out.println("Failed to save options");
exception.printStackTrace();
} }
LocalStorageManager.saveStorageG();
} }
private static final String RENDER_DISTANCES[] = { "options.renderDistance.far", "options.renderDistance.normal", private static final String RENDER_DISTANCES[] = { "options.renderDistance.far", "options.renderDistance.normal",
@ -365,7 +266,6 @@ public class GameSettings {
public boolean fancyGraphics; public boolean fancyGraphics;
public boolean field_22278_j; public boolean field_22278_j;
public int antialiasing; public int antialiasing;
public String skin;
public KeyBinding keyBindForward; public KeyBinding keyBindForward;
public KeyBinding keyBindLeft; public KeyBinding keyBindLeft;
public KeyBinding keyBindBack; public KeyBinding keyBindBack;
@ -374,16 +274,16 @@ public class GameSettings {
public KeyBinding keyBindInventory; public KeyBinding keyBindInventory;
public KeyBinding keyBindDrop; public KeyBinding keyBindDrop;
public KeyBinding keyBindChat; public KeyBinding keyBindChat;
public KeyBinding keyBindToggleFog;
public KeyBinding keyBindSneak; public KeyBinding keyBindSneak;
public KeyBinding keyBindFunction;
public KeyBinding keyBindings[]; public KeyBinding keyBindings[];
protected Minecraft mc; protected Minecraft mc;
private File optionsFile;
public int difficulty; public int difficulty;
public boolean field_22277_y; public boolean field_22277_y;
public boolean thirdPersonView; public boolean thirdPersonView;
public boolean showDebugInfo; public boolean showDebugInfo;
public String lastServer; public String lastServer;
public String texturePack;
public boolean field_22275_C; public boolean field_22275_C;
public boolean field_22274_D; public boolean field_22274_D;
public boolean field_22273_E; public boolean field_22273_E;

View File

@ -44,7 +44,7 @@ public class GuiGameOver extends GuiScreen {
drawCenteredString(fontRenderer, "Game over!", width / 2 / 2, 30, 0xffffff); drawCenteredString(fontRenderer, "Game over!", width / 2 / 2, 30, 0xffffff);
EaglerAdapter.glPopMatrix(); EaglerAdapter.glPopMatrix();
drawCenteredString(fontRenderer, 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); 0xffffff);
super.drawScreen(i, j, f); super.drawScreen(i, j, f);
} }

View File

@ -70,7 +70,7 @@ public class GuiMainMenu extends GuiScreen {
int i = height / 4 + 48; int i = height / 4 + 48;
controlList.add(new GuiButton(1, width / 2 - 100, i, stringtranslate.translateKey("menu.singleplayer"))); 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(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) { if (mc.hideQuitButton) {
controlList.add(new GuiButton(0, width / 2 - 100, i + 72, stringtranslate.translateKey("menu.options"))); controlList.add(new GuiButton(0, width / 2 - 100, i + 72, stringtranslate.translateKey("menu.options")));
} else { } else {
@ -92,9 +92,9 @@ public class GuiMainMenu extends GuiScreen {
if (guibutton.id == 2) { if (guibutton.id == 2) {
mc.displayGuiScreen(new GuiMultiplayer(this)); mc.displayGuiScreen(new GuiMultiplayer(this));
} }
if (guibutton.id == 3) { //if (guibutton.id == 3) {
mc.displayGuiScreen(new GuiTexturePacks(this)); // mc.displayGuiScreen(new GuiTexturePacks(this));
} //}
if (guibutton.id == 4) { if (guibutton.id == 4) {
mc.shutdown(); mc.shutdown();
} }

View File

@ -5,7 +5,6 @@ package net.minecraft.src;
// Decompiler options: packimports(3) braces deadcode // Decompiler options: packimports(3) braces deadcode
import java.util.List; import java.util.List;
import org.lwjgl.input.Keyboard;
import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglerAdapter;

View File

@ -5,7 +5,6 @@ package net.minecraft.src;
// Decompiler options: packimports(3) braces deadcode // Decompiler options: packimports(3) braces deadcode
import java.util.List; import java.util.List;
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
public class GuiSleepMP extends GuiChat { public class GuiSleepMP extends GuiChat {

View File

@ -4,10 +4,7 @@ package net.minecraft.src;
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode // Decompiler options: packimports(3) braces deadcode
import java.io.File;
import java.util.List;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import org.lwjgl.Sys;
public class GuiTexturePacks extends GuiScreen { public class GuiTexturePacks extends GuiScreen {
@ -23,7 +20,7 @@ public class GuiTexturePacks extends GuiScreen {
stringtranslate.translateKey("texturePack.openFolder"))); stringtranslate.translateKey("texturePack.openFolder")));
controlList.add(new GuiSmallButton(6, width / 2 + 4, height - 48, stringtranslate.translateKey("gui.done"))); controlList.add(new GuiSmallButton(6, width / 2 + 4, height - 48, stringtranslate.translateKey("gui.done")));
mc.texturePackList.func_6532_a(); 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 = new GuiTexturePackSlot(this);
field_22128_k.func_22240_a(controlList, 7, 8); field_22128_k.func_22240_a(controlList, 7, 8);
} }
@ -33,7 +30,7 @@ public class GuiTexturePacks extends GuiScreen {
return; return;
} }
if (guibutton.id == 5) { 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) { } else if (guibutton.id == 6) {
mc.renderEngine.refreshTextures(); mc.renderEngine.refreshTextures();
mc.displayGuiScreen(field_6461_a); mc.displayGuiScreen(field_6461_a);

View File

@ -169,6 +169,10 @@ public class NBTTagCompound extends NBTBase {
public String toString() { public String toString() {
return (new StringBuilder()).append("").append(tagMap.size()).append(" entries").toString(); return (new StringBuilder()).append("").append(tagMap.size()).append(" entries").toString();
} }
public boolean hasNoTags() {
return tagMap.size() >= 0;
}
private Map tagMap; private Map tagMap;
} }

View File

@ -4,8 +4,6 @@ package net.minecraft.src;
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode // Decompiler options: packimports(3) braces deadcode
import org.lwjgl.opengl.ContextCapabilities;
import org.lwjgl.opengl.GLContext;
public class OpenGlCapsChecker { public class OpenGlCapsChecker {
@ -13,9 +11,7 @@ public class OpenGlCapsChecker {
} }
public boolean checkARBOcclusion() { public boolean checkARBOcclusion() {
return tryCheckOcclusionCapable && GLContext.getCapabilities().GL_ARB_occlusion_query; return true;
} }
private static boolean tryCheckOcclusionCapable = false;
} }

View File

@ -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) {
}
}
}

View File

@ -14,13 +14,7 @@ public class TexturePackList {
defaultTexturePack = new TexturePackDefault(); defaultTexturePack = new TexturePackDefault();
field_6538_d = new HashMap(); field_6538_d = new HashMap();
mc = minecraft; mc = minecraft;
/* currentTexturePack = minecraft.gameSettings.texturePack;
texturePackDir = new File(file, "texturepacks");
if (!texturePackDir.exists()) {
texturePackDir.mkdirs();
}
*/
currentTexturePack = minecraft.gameSettings.skin;
func_6532_a(); func_6532_a();
selectedTexturePack.func_6482_a(); selectedTexturePack.func_6482_a();
} }
@ -32,7 +26,7 @@ public class TexturePackList {
selectedTexturePack.closeTexturePackFile(); selectedTexturePack.closeTexturePackFile();
currentTexturePack = texturepackbase.texturePackFileName; currentTexturePack = texturepackbase.texturePackFileName;
selectedTexturePack = texturepackbase; selectedTexturePack = texturepackbase;
mc.gameSettings.skin = currentTexturePack; mc.gameSettings.texturePack = currentTexturePack;
mc.gameSettings.saveOptions(); mc.gameSettings.saveOptions();
selectedTexturePack.func_6482_a(); selectedTexturePack.func_6482_a();
return true; return true;

View File

@ -83,6 +83,10 @@ public class World implements IBlockAccess {
chunkProvider = getChunkProvider(); chunkProvider = getChunkProvider();
calculateInitialSkylight(); calculateInitialSkylight();
} }
public WorldInfo getInfo() {
return worldinfo;
}
public World(ISaveHandler isavehandler, String s, long l) { public World(ISaveHandler isavehandler, String s, long l) {
this(isavehandler, s, l, ((WorldProvider) (null))); this(isavehandler, s, l, ((WorldProvider) (null)));
@ -1452,9 +1456,6 @@ public class World implements IBlockAccess {
if (l1 % (long) autosavePeriod == 0L) { if (l1 % (long) autosavePeriod == 0L) {
saveWorld(false, null); saveWorld(false, null);
} }
if(l1 % 24000 > 12000) {
l1 += 12000;
}
worldinfo.setWorldTime(l1); worldinfo.setWorldTime(l1);
TickUpdates(false); TickUpdates(false);
func_4080_j(); func_4080_j();