Resources, glsl, VFS, fix mouse and compile

This commit is contained in:
PeytonPlayz595 2023-10-07 00:57:45 -04:00
parent 006ee708a2
commit 31d09f3c50
73 changed files with 8876 additions and 238 deletions

BIN
epkcompiler/CompilePackage.jar Executable file

Binary file not shown.

2
epkcompiler/run.bat Executable file
View File

@ -0,0 +1,2 @@
@echo off
java -jar CompilePackage.jar "../../resources" "../../js/resources.epk"

2
epkcompiler/run_unix.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
java -jar CompilePackage.jar "../resources" "../js/resources.epk"

5518
js/app.js Normal file

File diff suppressed because it is too large Load Diff

1
js/app.js.map Normal file

File diff suppressed because one or more lines are too long

16
js/index.html Normal file
View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Infdev</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script type="text/javascript" charset="utf-8" src="app.js"></script>
<script type = text/javascript>
window.addEventListener("load", function() {
window.minecraftOpts = ["game","resources.epk"];
main();
});
</script>
</head>
<body style="margin:0px;width:100vw;height:100vh;" id="game">
</body>
</html>

BIN
js/resources.epk Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
resources/armor/chain_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 964 B

BIN
resources/armor/chain_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

BIN
resources/armor/cloth_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
resources/armor/cloth_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

BIN
resources/armor/gold_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
resources/armor/gold_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 708 B

BIN
resources/armor/iron_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
resources/armor/iron_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

BIN
resources/art/kz.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

BIN
resources/char.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
resources/clouds.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
resources/default.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
resources/default.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
resources/dirt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1011 B

BIN
resources/fluff.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

144
resources/glsl/core.glsl Normal file
View File

@ -0,0 +1,144 @@
// eaglercraft opengl 1.3 emulation
// copyright (c) 2020 calder young
// creative commons BY-NC 4.0
#line 7
precision highp int;
precision highp sampler2D;
precision highp float;
uniform mat4 matrix_m;
uniform mat4 matrix_p;
uniform mat4 matrix_t;
#ifdef CC_VERT
in vec3 a_position;
#ifdef CC_a_texture0
in vec2 a_texture0;
#endif
#ifdef CC_a_color
in vec4 a_color;
#endif
#ifdef CC_a_normal
in vec4 a_normal;
#endif
#ifdef CC_fog
out vec4 v_position;
#endif
#ifdef CC_a_color
out vec4 v_color;
#endif
#ifdef CC_a_normal
out vec4 v_normal;
#endif
#ifdef CC_a_texture0
out vec2 v_texture0;
#endif
void main(){
vec4 pos = matrix_m * vec4(a_position, 1.0);
#ifdef CC_fog
v_position = pos;
#endif
#ifdef CC_a_color
v_color = a_color;
#endif
#ifdef CC_a_normal
v_normal = a_normal;
#endif
#ifdef CC_a_texture0
v_texture0 = a_texture0;
#endif
gl_Position = matrix_p * pos;
}
#endif
#ifdef CC_FRAG
#ifdef CC_unit0
uniform sampler2D tex0;
#ifndef CC_a_texture0
uniform vec2 texCoordV0;
#endif
#endif
#ifdef CC_lighting
uniform vec3 light0Pos;
uniform vec3 light1Pos;
uniform vec3 normalUniform;
#endif
#ifdef CC_fog
uniform vec4 fogColor;
uniform int fogMode;
uniform float fogStart;
uniform float fogEnd;
uniform float fogDensity;
uniform float fogPremultiply;
#endif
uniform vec4 colorUniform;
#ifdef CC_alphatest
uniform float alphaTestF;
#endif
#ifdef CC_fog
in vec4 v_position;
#endif
#ifdef CC_a_color
in vec4 v_color;
#endif
#ifdef CC_a_normal
in vec4 v_normal;
#endif
#ifdef CC_a_texture0
in vec2 v_texture0;
#endif
out vec4 fragColor;
void main(){
#ifdef CC_a_color
vec4 color = colorUniform * v_color;
#else
vec4 color = colorUniform;
#endif
#ifdef CC_unit0
#ifdef CC_a_texture0
color *= texture(tex0, (matrix_t * vec4(v_texture0, 0.0, 1.0)).xy).rgba;
#else
color *= texture(tex0, (matrix_t * vec4(texCoordV0, 0.0, 1.0)).xy).rgba;
#endif
#endif
#ifdef CC_alphatest
if(color.a < alphaTestF){
discard;
}
#endif
#ifdef CC_lighting
#ifdef CC_a_normal
vec3 normal = ((v_normal.xyz - 0.5) * 2.0);
#else
vec3 normal = normalUniform;
#endif
normal = normalize(mat3(matrix_m) * normal);
float ins = max(dot(normal, -light0Pos), 0.0) + max(dot(normal, -light1Pos), 0.0);
color.rgb *= min((0.4 + ins * 0.6), 1.0);
#endif
#ifdef CC_fog
float dist = sqrt(dot(v_position, v_position));
float i = (fogMode == 1) ? clamp((dist - fogStart) / (fogEnd - fogStart), 0.0, 1.0) : clamp(1.0 - pow(2.718, -(fogDensity * dist)), 0.0, 1.0);
color.rgb = mix(color.rgb, fogColor.xyz, i * fogColor.a);
#endif
fragColor = color;
}
#endif

BIN
resources/grass.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
resources/gui/container.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
resources/gui/crafting.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
resources/gui/furnace.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
resources/gui/gui.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
resources/gui/icons.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
resources/gui/inventory.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
resources/gui/items.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

BIN
resources/gui/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
resources/item/arrows.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

BIN
resources/item/cart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
resources/item/door.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
resources/item/sign.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
resources/misc/gear.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

BIN
resources/mob/creeper.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
resources/mob/pig.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
resources/mob/sheep.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
resources/mob/sheep_fur.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
resources/mob/skeleton.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 B

BIN
resources/mob/spider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

BIN
resources/mob/zombie.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
resources/particles.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 792 B

BIN
resources/rain.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
resources/rock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
resources/shadow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

BIN
resources/terrain.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
resources/terrain/moon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

BIN
resources/terrain/sun.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 799 B

BIN
resources/water.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

BIN
resources/waterterrain.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -6,6 +6,7 @@ import java.io.StringWriter;
import org.lwjgl.opengl.Display; import org.lwjgl.opengl.Display;
import org.teavm.jso.JSBody; import org.teavm.jso.JSBody;
import org.teavm.jso.browser.Window; import org.teavm.jso.browser.Window;
import org.teavm.jso.core.JSError;
import org.teavm.jso.dom.html.HTMLElement; import org.teavm.jso.dom.html.HTMLElement;
import net.PeytonPlayz585.opengl.LWJGLMain; import net.PeytonPlayz585.opengl.LWJGLMain;
@ -18,9 +19,31 @@ public class Client {
public static Minecraft instance = null; public static Minecraft instance = null;
private static Thread mcThread = null; private static Thread mcThread = null;
@JSBody(params = { }, script = "window.minecraftError = null; window.onerror = function(message, file, line, column, errorObj) { if(errorObj) { window.minecraftError = errorObj; window.minecraftErrorL = \"\"+line+\":\"+column; javaMethods.get(\"net.PeytonPlayz585.Client.handleNativeError()V\").invoke(); } else { alert(\"a native browser exception was thrown but your browser does not support fith argument in onerror\"); } };")
public static native void registerErrorHandler();
@JSBody(params = { }, script = "return window.minecraftError;")
public static native JSError getWindowError();
@JSBody(params = { }, script = "return window.minecraftErrorL;")
public static native String getWindowErrorL();
@JSBody(params = { }, script = "return window.minecraftOpts;") @JSBody(params = { }, script = "return window.minecraftOpts;")
public static native String[] getOpts(); public static native String[] getOpts();
public static void handleNativeError() {
JSError e = getWindowError();
StringBuilder str = new StringBuilder();
str.append("Native Browser Exception\n");
str.append("----------------------------------\n");
str.append(" Line: ").append(getWindowErrorL()).append('\n');
str.append(" Type: ").append(e.getName()).append('\n');
str.append(" Message: ").append(e.getMessage()).append('\n');
str.append("----------------------------------\n\n");
str.append(e.getStack()).append('\n');
System.err.println(str.toString());
}
public static void main(String args[]) { public static void main(String args[]) {
String[] e = getOpts(); String[] e = getOpts();
try { try {
@ -40,8 +63,8 @@ public class Client {
public static void run0() { public static void run0() {
instance = new Minecraft(Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight(), false); instance = new Minecraft(Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight(), false);
instance.session = new Session("Player", UUID.randomUUID()); instance.session = new Session("Player", "fuckmojang123");
instance.session.mpPassParameter = UUID.randomUUID(); instance.session.mpPassParameter = "randpasslol";
mcThread = new Thread(instance, "Minecraft main thread"); mcThread = new Thread(instance, "Minecraft main thread");
mcThread.start(); mcThread.start();
} }

View File

@ -1,22 +0,0 @@
package net.PeytonPlayz585;
import java.util.Random;
public class UUID {
private static final char[] HEX_CHARS = "0123456789abcdef".toCharArray();
private static final Random RANDOM = new Random();
public static String randomUUID() {
char[] uuidChars = new char[36];
for (int i = 0; i < 36; i++) {
if (i == 8 || i == 13 || i == 18 || i == 23) {
uuidChars[i] = '-';
} else {
uuidChars[i] = HEX_CHARS[RANDOM.nextInt(16)];
}
}
return new String(uuidChars);
}
}

View File

@ -0,0 +1,99 @@
package net.PeytonPlayz585.io;
import java.util.Collection;
import java.util.List;
import net.PeytonPlayz585.opengl.LWJGLMain;
public class File {
private String path;
public File(String path) {
this.path = path;
}
public File(String parent, String child) {
this.path = parent + "/" + child;
}
public File(File parent, String child) {
this.path = parent.getPath() + "/" + child;
}
public String getPath() {
return path;
}
public boolean exists() {
if(LWJGLMain.directoryExists(path) || LWJGLMain.fileExists(path)) {
return true;
} else {
return false;
}
}
public boolean mkdirs() {
String[] directories = path.split("/");
String currentPath = "";
for (String directory : directories) {
currentPath += directory + "/";
if (!LWJGLMain.directoryExists(currentPath) && !LWJGLMain.pathExists(currentPath)) {
LWJGLMain.writeFile(currentPath, new byte[0]);
if(LWJGLMain.readFile(currentPath) == null) {
return false;
}
}
}
return true;
}
public boolean mkdir() {
if (!LWJGLMain.listFiles(path, false, false).isEmpty()) {
return false;
}
LWJGLMain.writeFile(path, new byte[0]);
if(LWJGLMain.readFile(path) != null) {
return true;
} else {
return false;
}
}
public byte[] getBytes() {
return LWJGLMain.readFile(path);
}
public void writeBytes(byte[] data) {
LWJGLMain.writeFile(path, data);
}
public long length() {
return LWJGLMain.getFileSize(path);
}
public void delete() {
LWJGLMain.writeFile(path, null);
}
public File[] listFiles() {
Collection<LWJGLMain.FileEntry> fileEntries = LWJGLMain.listFiles(path, false, false);
File[] files = new File[fileEntries.size()];
int i = 0;
for (LWJGLMain.FileEntry fileEntry : fileEntries) {
files[i++] = new File(fileEntry.path);
}
return files;
}
public boolean isDirectory() {
return LWJGLMain.directoryExists(path);
}
public void renameTo(File var4) {
LWJGLMain.renameFile(path, var4.getPath());
}
}

View File

@ -0,0 +1,79 @@
package net.PeytonPlayz585.io;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
import org.teavm.jso.core.JSString;
import org.teavm.jso.indexeddb.IDBCountRequest;
import org.teavm.jso.indexeddb.IDBCursorRequest;
import org.teavm.jso.indexeddb.IDBCursorSource;
import org.teavm.jso.indexeddb.IDBDatabase;
import org.teavm.jso.indexeddb.IDBGetRequest;
import org.teavm.jso.indexeddb.IDBIndex;
import org.teavm.jso.indexeddb.IDBKeyRange;
import org.teavm.jso.indexeddb.IDBObjectStoreParameters;
import org.teavm.jso.indexeddb.IDBRequest;
import org.teavm.jso.indexeddb.IDBTransaction;
public abstract class IDBObjectStorePatched implements JSObject, IDBCursorSource {
@JSBody(params = { "db", "name", "optionalParameters" }, script = "return db.createObjectStore(name, optionalParameters);")
public static native IDBObjectStorePatched createObjectStorePatch(IDBDatabase db, String name, IDBObjectStoreParameters optionalParameters);
@JSBody(params = { "tx", "name" }, script = "return tx.objectStore(name);")
public static native IDBObjectStorePatched objectStorePatch(IDBTransaction tx, String name);
@JSProperty
public abstract String getName();
@JSProperty("keyPath")
abstract JSObject getKeyPathImpl();
public final String[] getKeyPath() {
JSObject result = getKeyPathImpl();
if (JSString.isInstance(result)) {
return new String[] { result.<JSString>cast().stringValue() };
} else {
return unwrapStringArray(result);
}
}
@JSBody(params = { "obj" }, script = "return this;")
private static native String[] unwrapStringArray(JSObject obj);
@JSProperty
public abstract String[] getIndexNames();
@JSProperty
public abstract boolean isAutoIncrement();
public abstract IDBRequest put(JSObject value, JSObject key);
public abstract IDBRequest put(JSObject value);
public abstract IDBRequest add(JSObject value, JSObject key);
public abstract IDBRequest add(JSObject value);
public abstract IDBRequest delete(JSObject key);
public abstract IDBGetRequest get(JSObject key);
public abstract IDBRequest clear();
public abstract IDBCursorRequest openCursor();
public abstract IDBCursorRequest openCursor(IDBKeyRange range);
public abstract IDBIndex createIndex(String name, String key);
public abstract IDBIndex createIndex(String name, String[] keys);
public abstract IDBIndex index(String name);
public abstract void deleteIndex(String name);
public abstract IDBCountRequest count();
public abstract IDBCountRequest count(JSObject key);
}

View File

@ -0,0 +1,426 @@
package net.PeytonPlayz585.io;
import java.util.Collection;
import java.util.LinkedList;
import org.teavm.interop.Async;
import org.teavm.interop.AsyncCallback;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.indexeddb.EventHandler;
import org.teavm.jso.indexeddb.IDBCountRequest;
import org.teavm.jso.indexeddb.IDBCursor;
import org.teavm.jso.indexeddb.IDBCursorRequest;
import org.teavm.jso.indexeddb.IDBDatabase;
import org.teavm.jso.indexeddb.IDBFactory;
import org.teavm.jso.indexeddb.IDBGetRequest;
import org.teavm.jso.indexeddb.IDBObjectStoreParameters;
import org.teavm.jso.indexeddb.IDBOpenDBRequest;
import org.teavm.jso.indexeddb.IDBRequest;
import org.teavm.jso.indexeddb.IDBTransaction;
import org.teavm.jso.indexeddb.IDBVersionChangeEvent;
import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import net.PeytonPlayz585.opengl.LWJGLMain;
public class IndexedDBFilesystem {
public static enum OpenState {
OPENED, LOCKED, ERROR
}
private static String err = "";
private static IDBDatabase db = null;
public static final OpenState initialize() {
DatabaseOpen dbo = AsyncHandlers.openDB("_net_peytonplayz585_minecraft_infdev_IndexedDBFilesystem");
if(dbo == null) {
err = "Unknown Error";
return OpenState.ERROR;
}
if(dbo.failedLocked) {
return OpenState.LOCKED;
}
if(dbo.failedInit || dbo.database == null) {
err = dbo.failedError == null ? "Initialization Failed" : dbo.failedError;
return OpenState.ERROR;
}
db = dbo.database;
return OpenState.OPENED;
}
public static final String errorDetail() {
return err;
}
public static final boolean fileExists(String path) {
return AsyncHandlers.fileGetType(db, path) == FileExists.FILE;
}
public static final boolean directoryExists(String path) {
return AsyncHandlers.fileGetType(db, path) == FileExists.DIRECTORY;
}
public static final boolean pathExists(String path) {
return AsyncHandlers.fileExists(db, path).bool;
}
private static final void mkdir(String dir) {
if(directoryExists(dir)) {
return;
}
int i = dir.lastIndexOf('/');
if(i > 0) {
mkdir(dir.substring(0, i));
}
AsyncHandlers.writeWholeFile(db, dir, true, ArrayBuffer.create(0));
}
public static final void writeFile(String path, byte[] data) {
int i = path.lastIndexOf('/');
if(i > 0) {
mkdir(path.substring(0, i));
}
Uint8Array arr = Uint8Array.create(data.length);
arr.set(data);
AsyncHandlers.writeWholeFile(db, path, false, arr.getBuffer());
}
public static final byte[] readFile(String path) {
ArrayBuffer arr = AsyncHandlers.readWholeFile(db, path);
if(arr == null) {
return null;
}
byte[] data = new byte[arr.getByteLength()];
Uint8Array arrr = Uint8Array.create(arr);
for(int i = 0; i < data.length; ++i) {
data[i] = (byte) arrr.get(i);
}
return data;
}
public static final long getLastModified(String path) {
int lm = AsyncHandlers.fileGetLastModified(db, path);
return lm == -1 ? -1l : AsyncHandlers.Epoch + lm;
}
public static final int getFileSize(String path) {
ArrayBuffer arr = AsyncHandlers.readWholeFile(db, path);
if(arr == null) {
return -1;
}else {
return arr.getByteLength();
}
}
public static final void renameFile(String oldPath, String newPath) {
copyFile(oldPath, newPath);
AsyncHandlers.deleteFile(db, oldPath);
}
public static final void copyFile(String oldPath, String newPath) {
ArrayBuffer arr = AsyncHandlers.readWholeFile(db, oldPath);
int i = newPath.lastIndexOf('/');
if(i > 0) {
mkdir(newPath.substring(0, i));
}
AsyncHandlers.writeWholeFile(db, newPath, false, arr);
}
public static final void deleteFile(String path) {
AsyncHandlers.deleteFile(db, path);
}
public static final Collection<LWJGLMain.FileEntry> listFiles(String path, boolean listDirs, boolean recursiveDirs) {
LinkedList<LWJGLMain.FileEntry> lst = new LinkedList<>();
AsyncHandlers.iterateFiles(db, path, listDirs, recursiveDirs, lst);
return lst;
}
protected static class BooleanResult {
protected static final BooleanResult TRUE = new BooleanResult(true);
protected static final BooleanResult FALSE = new BooleanResult(false);
protected final boolean bool;
private BooleanResult(boolean b) {
bool = b;
}
protected static BooleanResult _new(boolean b) {
return b ? TRUE : FALSE;
}
}
protected static class DatabaseOpen {
protected final boolean failedInit;
protected final boolean failedLocked;
protected final String failedError;
protected final IDBDatabase database;
protected DatabaseOpen(boolean init, boolean locked, String error, IDBDatabase db) {
failedInit = init;
failedLocked = locked;
failedError = error;
database = db;
}
}
protected static enum FileExists {
FILE, DIRECTORY, FALSE
}
@JSBody(script = "return ((typeof indexedDB) !== 'undefined') ? indexedDB : null;")
protected static native IDBFactory createIDBFactory();
protected static class AsyncHandlers {
protected static final long Epoch = 1645568542000l;
@Async
protected static native DatabaseOpen openDB(String name);
private static void openDB(String name, final AsyncCallback<DatabaseOpen> cb) {
IDBFactory i = createIDBFactory();
if(i == null) {
cb.complete(new DatabaseOpen(false, false, "window.indexedDB was null or undefined", null));
return;
}
final IDBOpenDBRequest f = i.open(name, 1);
f.setOnBlocked(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(new DatabaseOpen(false, true, null, null));
}
});
f.setOnSuccess(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(new DatabaseOpen(false, false, null, f.getResult()));
}
});
f.setOnError(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(new DatabaseOpen(true, false, "open error", null));
}
});
f.setOnUpgradeNeeded(new EventListener<IDBVersionChangeEvent>() {
@Override
public void handleEvent(IDBVersionChangeEvent evt) {
IDBObjectStorePatched.createObjectStorePatch(f.getResult(), "filesystem", IDBObjectStoreParameters.create().keyPath("path"));
}
});
}
@Async
protected static native BooleanResult deleteFile(IDBDatabase db, String name);
private static void deleteFile(IDBDatabase db, String name, final AsyncCallback<BooleanResult> cb) {
IDBTransaction tx = db.transaction("filesystem", "readwrite");
final IDBRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").delete(makeTheFuckingKeyWork(name));
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(BooleanResult._new(true));
}
});
r.setOnError(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(BooleanResult._new(false));
}
});
}
@JSBody(params = { "obj" }, script = "return (typeof obj === 'undefined') ? null : ((typeof obj.data === 'undefined') ? null : obj.data);")
protected static native ArrayBuffer readRow(JSObject obj);
@JSBody(params = { "obj" }, script = "return (typeof obj === 'undefined') ? false : ((typeof obj.directory === 'undefined') ? false : obj.directory);")
protected static native boolean isRowDirectory(JSObject obj);
@JSBody(params = { "obj" }, script = "return (typeof obj === 'undefined') ? -1 : ((typeof obj.lastModified === 'undefined') ? -1 : obj.lastModified);")
protected static native int readLastModified(JSObject obj);
@JSBody(params = { "obj" }, script = "return [obj];")
private static native JSObject makeTheFuckingKeyWork(String k);
@Async
protected static native ArrayBuffer readWholeFile(IDBDatabase db, String name);
private static void readWholeFile(IDBDatabase db, String name, final AsyncCallback<ArrayBuffer> cb) {
IDBTransaction tx = db.transaction("filesystem", "readonly");
final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name));
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(isRowDirectory(r.getResult()) ? null : readRow(r.getResult()));
}
});
r.setOnError(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(null);
}
});
}
@Async
protected static native Integer readLastModified(IDBDatabase db, String name);
private static void readLastModified(IDBDatabase db, String name, final AsyncCallback<Integer> cb) {
IDBTransaction tx = db.transaction("filesystem", "readonly");
final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name));
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(readLastModified(r.getResult()));
}
});
r.setOnError(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(-1);
}
});
}
@JSBody(params = { "k" }, script = "return ((typeof k) === \"string\") ? k : (((typeof k) === \"undefined\") ? null : (((typeof k[0]) === \"string\") ? k[0] : null));")
private static native String readKey(JSObject k);
@Async
protected static native Integer iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection<LWJGLMain.FileEntry> lst);
private static void iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection<LWJGLMain.FileEntry> lst, final AsyncCallback<Integer> cb) {
IDBTransaction tx = db.transaction("filesystem", "readonly");
final IDBCursorRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").openCursor();
final int[] res = new int[1];
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent() {
IDBCursor c = r.getResult();
if(c == null || c.getKey() == null || c.getValue() == null) {
cb.complete(res[0]);
return;
}
String k = readKey(c.getKey());
if(k != null) {
if(k.startsWith(prefix)) {
if(recursiveDirs || k.indexOf('/', prefix.length() + 1) == -1) {
boolean dir = isRowDirectory(c.getValue());
if(dir) {
if(listDirs) {
lst.add(new LWJGLMain.FileEntry(k, true, -1));
}
}else {
lst.add(new LWJGLMain.FileEntry(k, false, Epoch + readLastModified(c.getValue())));
}
}
}
}
c.doContinue();
}
});
r.setOnError(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(res[0] > 0 ? res[0] : -1);
}
});
}
@Async
protected static native BooleanResult fileExists(IDBDatabase db, String name);
private static void fileExists(IDBDatabase db, String name, final AsyncCallback<BooleanResult> cb) {
IDBTransaction tx = db.transaction("filesystem", "readonly");
final IDBCountRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").count(makeTheFuckingKeyWork(name));
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(BooleanResult._new(r.getResult() > 0));
}
});
r.setOnError(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(BooleanResult._new(false));
}
});
}
@Async
protected static native Integer fileGetLastModified(IDBDatabase db, String name);
private static void fileGetLastModified(IDBDatabase db, String name, final AsyncCallback<Integer> cb) {
IDBTransaction tx = db.transaction("filesystem", "readonly");
final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name));
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(readLastModified(r.getResult()));
}
});
r.setOnError(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(-1);
}
});
}
@Async
protected static native FileExists fileGetType(IDBDatabase db, String name);
private static void fileGetType(IDBDatabase db, String name, final AsyncCallback<FileExists> cb) {
IDBTransaction tx = db.transaction("filesystem", "readonly");
final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name));
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(r.getResult() == null ? FileExists.FALSE : (isRowDirectory(r.getResult()) ? FileExists.DIRECTORY : FileExists.FILE));
}
});
r.setOnError(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(FileExists.FALSE);
}
});
}
@JSBody(params = { "pat", "dir", "lm", "dat" }, script = "return { path: pat, directory: dir, lastModified: lm, data: dat };")
protected static native JSObject writeRow(String name, boolean directory, int lm, ArrayBuffer data);
@Async
protected static native BooleanResult writeWholeFile(IDBDatabase db, String name, boolean directory, ArrayBuffer data);
private static void writeWholeFile(IDBDatabase db, String name, boolean directory, ArrayBuffer data, final AsyncCallback<BooleanResult> cb) {
IDBTransaction tx = db.transaction("filesystem", "readwrite");
final IDBRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").put(writeRow(name, directory, (int)(System.currentTimeMillis() - Epoch), data));
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(BooleanResult._new(true));
}
});
r.setOnError(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(BooleanResult._new(false));
}
});
}
}
}

View File

@ -57,6 +57,7 @@ import org.teavm.jso.webgl.WebGLUniformLocation;
import org.teavm.jso.websocket.CloseEvent; import org.teavm.jso.websocket.CloseEvent;
import org.teavm.jso.websocket.WebSocket; import org.teavm.jso.websocket.WebSocket;
import net.PeytonPlayz585.io.IndexedDBFilesystem;
import net.PeytonPlayz585.minecraft.AssetRepository; import net.PeytonPlayz585.minecraft.AssetRepository;
import net.PeytonPlayz585.minecraft.Base64; import net.PeytonPlayz585.minecraft.Base64;
import net.minecraft.src.MathHelper; import net.minecraft.src.MathHelper;
@ -309,6 +310,8 @@ public class LWJGLMain {
//onBeforeCloseRegister(); //onBeforeCloseRegister();
initFileChooser(); initFileChooser();
IndexedDBFilesystem.OpenState st = IndexedDBFilesystem.initialize();
downloadAssetPack(assetPackageURI); downloadAssetPack(assetPackageURI);
try { try {
@ -1870,80 +1873,80 @@ public class LWJGLMain {
@JSBody(params = { "obj" }, script = "return typeof obj === \"string\";") @JSBody(params = { "obj" }, script = "return typeof obj === \"string\";")
private static native boolean isString(JSObject obj); private static native boolean isString(JSObject obj);
// public static final boolean fileExists(String path) { public static final boolean fileExists(String path) {
// return IndexedDBFilesystem.fileExists(path); return IndexedDBFilesystem.fileExists(path);
// } }
//
// public static final boolean directoryExists(String path) {
// return IndexedDBFilesystem.directoryExists(path);
// }
//
// public static final boolean pathExists(String path) {
// return IndexedDBFilesystem.pathExists(path);
// }
//
// public static final void writeFile(String path, byte[] data) {
// IndexedDBFilesystem.writeFile(path, data);
// }
//
// public static final byte[] readFile(String path) {
// return IndexedDBFilesystem.readFile(path);
// }
//
// public static final long getLastModified(String path) {
// return IndexedDBFilesystem.getLastModified(path);
// }
//
// public static final int getFileSize(String path) {
// return IndexedDBFilesystem.getFileSize(path);
// }
//
// public static final void renameFile(String oldPath, String newPath) {
// IndexedDBFilesystem.renameFile(oldPath, newPath);
// }
//
// public static final void copyFile(String oldPath, String newPath) {
// IndexedDBFilesystem.copyFile(oldPath, newPath);
// }
//
// public static final void deleteFile(String path) {
// IndexedDBFilesystem.deleteFile(path);
// }
//
// public static final Collection<FileEntry> listFiles(String path, boolean listDirs, boolean recursiveDirs) {
// return IndexedDBFilesystem.listFiles(path, listDirs, recursiveDirs);
// }
//
// public static final Collection<FileEntry> listFilesAndDirectories(String path) {
// return listFiles(path, true, false);
// }
//
// public static final Collection<FileEntry> listFilesRecursive(String path) {
// return listFiles(path, false, true);
// }
// public static class FileEntry { public static final boolean directoryExists(String path) {
// return IndexedDBFilesystem.directoryExists(path);
// public final String path; }
// public final boolean isDirectory;
// public final long lastModified; public static final boolean pathExists(String path) {
// return IndexedDBFilesystem.pathExists(path);
// public FileEntry(String path, boolean isDirectory, long lastModified) { }
// this.path = path;
// this.isDirectory = isDirectory; public static final void writeFile(String path, byte[] data) {
// this.lastModified = lastModified; IndexedDBFilesystem.writeFile(path, data);
// } }
//
// public String getName() { public static final byte[] readFile(String path) {
// int i = path.indexOf('/'); return IndexedDBFilesystem.readFile(path);
// if(i >= 0) { }
// return path.substring(i + 1);
// }else { public static final long getLastModified(String path) {
// return path; return IndexedDBFilesystem.getLastModified(path);
// } }
// }
// public static final int getFileSize(String path) {
// } return IndexedDBFilesystem.getFileSize(path);
}
public static final void renameFile(String oldPath, String newPath) {
IndexedDBFilesystem.renameFile(oldPath, newPath);
}
public static final void copyFile(String oldPath, String newPath) {
IndexedDBFilesystem.copyFile(oldPath, newPath);
}
public static final void deleteFile(String path) {
IndexedDBFilesystem.deleteFile(path);
}
public static final Collection<FileEntry> listFiles(String path, boolean listDirs, boolean recursiveDirs) {
return IndexedDBFilesystem.listFiles(path, listDirs, recursiveDirs);
}
public static final Collection<FileEntry> listFilesAndDirectories(String path) {
return listFiles(path, true, false);
}
public static final Collection<FileEntry> listFilesRecursive(String path) {
return listFiles(path, false, true);
}
public static class FileEntry {
public final String path;
public final boolean isDirectory;
public final long lastModified;
public FileEntry(String path, boolean isDirectory, long lastModified) {
this.path = path;
this.isDirectory = isDirectory;
this.lastModified = lastModified;
}
public String getName() {
int i = path.indexOf('/');
if(i >= 0) {
return path.substring(i + 1);
}else {
return path;
}
}
}
private static String stripPath(String str) { private static String stripPath(String str) {
if(str.startsWith("/")) { if(str.startsWith("/")) {
@ -1955,12 +1958,12 @@ public class LWJGLMain {
return str; return str;
} }
// @JSBody(params = { "name", "cvs" }, script = "var a=document.createElement(\"a\");a.href=URL.createObjectURL(new Blob([cvs],{type:\"application/octet-stream\"}));a.download=name;a.click();URL.revokeObjectURL(a.href);") @JSBody(params = { "name", "cvs" }, script = "var a=document.createElement(\"a\");a.href=URL.createObjectURL(new Blob([cvs],{type:\"application/octet-stream\"}));a.download=name;a.click();URL.revokeObjectURL(a.href);")
// private static native void downloadFile0(String name, ArrayBuffer cvs); private static native void downloadFile0(String name, ArrayBuffer cvs);
//
// public static final void downloadFile(String filename, byte[] data) { public static final void downloadFile(String filename, byte[] data) {
// Uint8Array b = Uint8Array.create(data.length); Uint8Array b = Uint8Array.create(data.length);
// b.set(data); b.set(data);
// downloadFile0(filename, b.getBuffer()); downloadFile0(filename, b.getBuffer());
// } }
} }

View File

@ -1,10 +1,10 @@
package net.minecraft.src; package net.minecraft.src;
import java.io.File; import java.io.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Iterator; import java.util.Iterator;
import net.PeytonPlayz585.io.File;
public class ChunkLoader implements IChunkLoader { public class ChunkLoader implements IChunkLoader {
private File saveDir; private File saveDir;
private boolean createIfNecessary; private boolean createIfNecessary;
@ -44,8 +44,7 @@ public class ChunkLoader implements IChunkLoader {
File var4 = this.chunkFileForXZ(var2, var3); File var4 = this.chunkFileForXZ(var2, var3);
if(var4 != null && var4.exists()) { if(var4 != null && var4.exists()) {
try { try {
FileInputStream var5 = new FileInputStream(var4); NBTTagCompound var6 = (NBTTagCompound) NBTBase.readNamedTag(new DataInputStream(new ByteArrayInputStream(var4.getBytes())));
NBTTagCompound var6 = CompressedStreamTools.readCompressed(var5);
return loadChunkIntoWorldFromCompound(var1, var6.getCompoundTag("Level")); return loadChunkIntoWorldFromCompound(var1, var6.getCompoundTag("Level"));
} catch (Exception var7) { } catch (Exception var7) {
var7.printStackTrace(); var7.printStackTrace();
@ -57,29 +56,17 @@ public class ChunkLoader implements IChunkLoader {
public void saveChunk(World var1, Chunk var2) { public void saveChunk(World var1, Chunk var2) {
File var3 = this.chunkFileForXZ(var2.xPosition, var2.zPosition); File var3 = this.chunkFileForXZ(var2.xPosition, var2.zPosition);
if(var3.exists()) { NBTTagCompound toSave = new NBTTagCompound();
var1.setSizeOnDisk -= var3.length(); storeChunkInCompound(var2, var1, toSave);
} ByteArrayOutputStream bao = new ByteArrayOutputStream(131072);
try { try {
File var4 = new File(this.saveDir, "tmp_chunk.dat"); NBTBase.writeNamedTag(toSave, new DataOutputStream(bao));
FileOutputStream var5 = new FileOutputStream(var4); } catch (IOException e) {
NBTTagCompound var6 = new NBTTagCompound(); System.err.println("Failed to serialize chunk at [" + var2.xPosition + ", " + var2.zPosition + "] to byte array");
NBTTagCompound var7 = new NBTTagCompound(); e.printStackTrace();
var6.setTag("Level", var7); return;
this.storeChunkInCompound(var2, var1, var7);
CompressedStreamTools.writeCompressed(var6, var5);
var5.close();
if(var3.exists()) {
var3.delete();
}
var4.renameTo(var3);
var1.setSizeOnDisk += var3.length();
} catch (Exception var8) {
var8.printStackTrace();
} }
var3.writeBytes(bao.toByteArray());
} }
public void storeChunkInCompound(Chunk var1, World var2, NBTTagCompound var3) { public void storeChunkInCompound(Chunk var1, World var2, NBTTagCompound var3) {

View File

@ -1,10 +1,5 @@
package net.minecraft.src; package net.minecraft.src;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
public class GameSettings { public class GameSettings {
@ -32,14 +27,14 @@ public class GameSettings {
public KeyBinding keyBindLoad = new KeyBinding("Load location", 19); public KeyBinding keyBindLoad = new KeyBinding("Load location", 19);
public KeyBinding[] keyBindings = new KeyBinding[]{this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindToggleFog, this.keyBindSave, this.keyBindLoad}; public KeyBinding[] keyBindings = new KeyBinding[]{this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindToggleFog, this.keyBindSave, this.keyBindLoad};
protected Minecraft mc; protected Minecraft mc;
private File optionsFile; //private File optionsFile;
public int numberOfOptions = 10; public int numberOfOptions = 10;
public int difficulty = 2; public int difficulty = 2;
public boolean thirdPersonView = false; public boolean thirdPersonView = false;
public GameSettings(Minecraft var1, File var2) { public GameSettings(Minecraft var1) {
this.mc = var1; this.mc = var1;
this.optionsFile = new File(var2, "options.txt"); //this.optionsFile = new File(mcDataDir, "options.txt");
this.loadOptions(); this.loadOptions();
} }
@ -104,98 +99,98 @@ public class GameSettings {
} }
public void loadOptions() { public void loadOptions() {
try { // try {
if(!this.optionsFile.exists()) { // if(!this.optionsFile.exists()) {
return; // return;
} // }
//
BufferedReader var1 = new BufferedReader(new FileReader(this.optionsFile)); // BufferedReader var1 = new BufferedReader(new FileReader(this.optionsFile));
String var2 = ""; // String var2 = "";
//
while(true) { // while(true) {
var2 = var1.readLine(); // var2 = var1.readLine();
if(var2 == null) { // if(var2 == null) {
var1.close(); // var1.close();
break; // break;
} // }
//
String[] var3 = var2.split(":"); // String[] var3 = var2.split(":");
if(var3[0].equals("music")) { // if(var3[0].equals("music")) {
this.music = var3[1].equals("true"); // this.music = var3[1].equals("true");
} // }
//
if(var3[0].equals("sound")) { // if(var3[0].equals("sound")) {
this.sound = var3[1].equals("true"); // this.sound = var3[1].equals("true");
} // }
//
if(var3[0].equals("invertYMouse")) { // if(var3[0].equals("invertYMouse")) {
this.invertMouse = var3[1].equals("true"); // this.invertMouse = var3[1].equals("true");
} // }
//
if(var3[0].equals("showFrameRate")) { // if(var3[0].equals("showFrameRate")) {
this.showFPS = var3[1].equals("true"); // this.showFPS = var3[1].equals("true");
} // }
//
if(var3[0].equals("viewDistance")) { // if(var3[0].equals("viewDistance")) {
this.renderDistance = Integer.parseInt(var3[1]); // this.renderDistance = Integer.parseInt(var3[1]);
} // }
//
if(var3[0].equals("bobView")) { // if(var3[0].equals("bobView")) {
this.viewBobbing = var3[1].equals("true"); // this.viewBobbing = var3[1].equals("true");
} // }
//
if(var3[0].equals("anaglyph3d")) { // if(var3[0].equals("anaglyph3d")) {
this.anaglyph = var3[1].equals("true"); // this.anaglyph = var3[1].equals("true");
} // }
//
if(var3[0].equals("limitFramerate")) { // if(var3[0].equals("limitFramerate")) {
this.limitFramerate = var3[1].equals("true"); // this.limitFramerate = var3[1].equals("true");
} // }
//
if(var3[0].equals("difficulty")) { // if(var3[0].equals("difficulty")) {
this.difficulty = Integer.parseInt(var3[1]); // this.difficulty = Integer.parseInt(var3[1]);
} // }
//
if(var3[0].equals("fancyGraphics")) { // if(var3[0].equals("fancyGraphics")) {
this.fancyGraphics = var3[1].equals("true"); // this.fancyGraphics = var3[1].equals("true");
} // }
//
for(int var4 = 0; var4 < this.keyBindings.length; ++var4) { // for(int var4 = 0; var4 < this.keyBindings.length; ++var4) {
if(var3[0].equals("key_" + this.keyBindings[var4].keyDescription)) { // if(var3[0].equals("key_" + this.keyBindings[var4].keyDescription)) {
this.keyBindings[var4].keyCode = Integer.parseInt(var3[1]); // this.keyBindings[var4].keyCode = Integer.parseInt(var3[1]);
} // }
} // }
} // }
} catch (Exception var5) { // } catch (Exception var5) {
System.out.println("Failed to load options"); // System.out.println("Failed to load options");
var5.printStackTrace(); // var5.printStackTrace();
} // }
} }
public void saveOptions() { public void saveOptions() {
try { // try {
PrintWriter var1 = new PrintWriter(new FileWriter(this.optionsFile)); // PrintWriter var1 = new PrintWriter(new FileWriter(this.optionsFile));
var1.println("music:" + this.music); // var1.println("music:" + this.music);
var1.println("sound:" + this.sound); // var1.println("sound:" + this.sound);
var1.println("invertYMouse:" + this.invertMouse); // var1.println("invertYMouse:" + this.invertMouse);
var1.println("showFrameRate:" + this.showFPS); // var1.println("showFrameRate:" + this.showFPS);
var1.println("viewDistance:" + this.renderDistance); // var1.println("viewDistance:" + this.renderDistance);
var1.println("bobView:" + this.viewBobbing); // var1.println("bobView:" + this.viewBobbing);
var1.println("anaglyph3d:" + this.anaglyph); // var1.println("anaglyph3d:" + this.anaglyph);
var1.println("limitFramerate:" + this.limitFramerate); // var1.println("limitFramerate:" + this.limitFramerate);
var1.println("difficulty:" + this.difficulty); // var1.println("difficulty:" + this.difficulty);
var1.println("fancyGraphics:" + this.fancyGraphics); // var1.println("fancyGraphics:" + this.fancyGraphics);
//
for(int var2 = 0; var2 < this.keyBindings.length; ++var2) { // for(int var2 = 0; var2 < this.keyBindings.length; ++var2) {
var1.println("key_" + this.keyBindings[var2].keyDescription + ":" + this.keyBindings[var2].keyCode); // var1.println("key_" + this.keyBindings[var2].keyDescription + ":" + this.keyBindings[var2].keyCode);
} // }
//
var1.close(); // var1.close();
} catch (Exception var3) { // } catch (Exception var3) {
System.out.println("Failed to save options"); // System.out.println("Failed to save options");
var3.printStackTrace(); // var3.printStackTrace();
} // }
} }
} }

View File

@ -1,6 +1,6 @@
package net.minecraft.src; package net.minecraft.src;
import java.io.File; import net.PeytonPlayz585.io.File;
public class GuiCreateWorld extends GuiScreen { public class GuiCreateWorld extends GuiScreen {
protected GuiScreen parentGuiScreen; protected GuiScreen parentGuiScreen;

View File

@ -1,6 +1,6 @@
package net.minecraft.src; package net.minecraft.src;
import java.io.File; import net.PeytonPlayz585.io.File;
public class GuiDeleteWorld extends GuiCreateWorld { public class GuiDeleteWorld extends GuiCreateWorld {
public GuiDeleteWorld(GuiScreen var1) { public GuiDeleteWorld(GuiScreen var1) {

View File

@ -1,12 +1,12 @@
package net.minecraft.src; package net.minecraft.src;
import java.io.File;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display; import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import net.PeytonPlayz585.io.File;
import net.PeytonPlayz585.opengl.LWJGLMain; import net.PeytonPlayz585.opengl.LWJGLMain;
public class Minecraft implements Runnable { public class Minecraft implements Runnable {
@ -69,7 +69,7 @@ public class Minecraft implements Runnable {
public void startGame() throws LWJGLException { public void startGame() throws LWJGLException {
this.mcDataDir = getMinecraftDir(); this.mcDataDir = getMinecraftDir();
this.gameSettings = new GameSettings(this, this.mcDataDir); this.gameSettings = new GameSettings(this);
this.renderEngine = new RenderEngine(this.gameSettings); this.renderEngine = new RenderEngine(this.gameSettings);
this.fontRenderer = new FontRenderer(this.gameSettings, "/default.png", this.renderEngine); this.fontRenderer = new FontRenderer(this.gameSettings, "/default.png", this.renderEngine);
this.loadScreen(); this.loadScreen();

View File

@ -1,8 +1,11 @@
package net.minecraft.src; package net.minecraft.src;
import java.io.File; import net.PeytonPlayz585.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -53,7 +56,7 @@ public class World implements IBlockAccess {
File var4 = new File(var3, "level.dat"); File var4 = new File(var3, "level.dat");
if(var4.exists()) { if(var4.exists()) {
try { try {
NBTTagCompound var5 = CompressedStreamTools.readCompressed(new FileInputStream(var4)); NBTTagCompound var5 = (NBTTagCompound) NBTBase.readNamedTag(new DataInputStream(new ByteArrayInputStream(var4.getBytes())));
NBTTagCompound var6 = var5.getCompoundTag("Data"); NBTTagCompound var6 = var5.getCompoundTag("Data");
return var6; return var6;
} catch (Exception var7) { } catch (Exception var7) {
@ -119,7 +122,7 @@ public class World implements IBlockAccess {
this.isNewWorld = !var5.exists(); this.isNewWorld = !var5.exists();
if(var5.exists()) { if(var5.exists()) {
try { try {
NBTTagCompound var6 = CompressedStreamTools.readCompressed(new FileInputStream(var5)); NBTTagCompound var6 = (NBTTagCompound) NBTBase.readNamedTag(new DataInputStream(new ByteArrayInputStream(var5.getBytes())));
NBTTagCompound var7 = var6.getCompoundTag("Data"); NBTTagCompound var7 = var6.getCompoundTag("Data");
this.randomSeed = var7.getLong("RandomSeed"); this.randomSeed = var7.getLong("RandomSeed");
this.spawnX = var7.getInteger("SpawnX"); this.spawnX = var7.getInteger("SpawnX");
@ -228,7 +231,9 @@ public class World implements IBlockAccess {
File var3 = new File(this.saveDirectory, "level.dat_new"); File var3 = new File(this.saveDirectory, "level.dat_new");
File var4 = new File(this.saveDirectory, "level.dat_old"); File var4 = new File(this.saveDirectory, "level.dat_old");
File var5 = new File(this.saveDirectory, "level.dat"); File var5 = new File(this.saveDirectory, "level.dat");
CompressedStreamTools.writeCompressed(var2, new FileOutputStream(var3)); ByteArrayOutputStream bao = new ByteArrayOutputStream(131072);
NBTBase.writeNamedTag(var2, new DataOutputStream(bao));
var3.writeBytes(bao.toByteArray());
if(var4.exists()) { if(var4.exists()) {
var4.delete(); var4.delete();
} }

View File

@ -13,7 +13,7 @@ public class Mouse {
} }
public static int getX() { public static int getX() {
return LWJGLMain.mouseGetY(); return LWJGLMain.mouseGetX();
} }
public static int getY() { public static int getY() {