Got the world to render

This commit is contained in:
PeytonPlayz595 2024-02-09 15:38:46 -05:00
parent 4e1b162982
commit 727d0570d5
11 changed files with 53356 additions and 18288 deletions

59466
js/app.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -68,6 +68,8 @@ import net.lax1dude.eaglercraft.AssetRepository;
import net.lax1dude.eaglercraft.Base64; import net.lax1dude.eaglercraft.Base64;
import net.lax1dude.eaglercraft.Client; import net.lax1dude.eaglercraft.Client;
import net.lax1dude.eaglercraft.EaglerImage; import net.lax1dude.eaglercraft.EaglerImage;
import net.lax1dude.eaglercraft.adapter.teavm.IndexedDBFilesystem;
import net.lax1dude.eaglercraft.adapter.teavm.IndexedDBFilesystem.OpenState;
//import net.lax1dude.eaglercraft.adapter.teavm.IndexedDBFilesystem; //import net.lax1dude.eaglercraft.adapter.teavm.IndexedDBFilesystem;
//import net.lax1dude.eaglercraft.adapter.teavm.IndexedDBFilesystem.OpenState; //import net.lax1dude.eaglercraft.adapter.teavm.IndexedDBFilesystem.OpenState;
import net.lax1dude.eaglercraft.adapter.teavm.WebGL2RenderingContext; import net.lax1dude.eaglercraft.adapter.teavm.WebGL2RenderingContext;
@ -307,15 +309,15 @@ public class EaglerAdapterImpl2 {
onBeforeCloseRegister(); onBeforeCloseRegister();
initFileChooser(); initFileChooser();
// OpenState st = IndexedDBFilesystem.initialize(); OpenState st = IndexedDBFilesystem.initialize();
// if(st != OpenState.OPENED) { if(st != OpenState.OPENED) {
// if(st == OpenState.LOCKED) { if(st == OpenState.LOCKED) {
// Client.showDatabaseLockedScreen("\nError: World folder is locked!\n\nYou are already playing Eaglercraft in a different tab.\nClose all other Eaglercraft tabs and reload"); Client.showDatabaseLockedScreen("\nError: World folder is locked!\n\nYou are already playing Eaglercraft in a different tab.\nClose all other Eaglercraft tabs and reload");
// }else { }else {
// Client.showDatabaseLockedScreen("\nError: World folder could not be loaded!\n\n" + IndexedDBFilesystem.errorDetail()); Client.showDatabaseLockedScreen("\nError: World folder could not be loaded!\n\n" + IndexedDBFilesystem.errorDetail());
// } }
// throw new Client.AbortedLaunchException(); throw new Client.AbortedLaunchException();
// } }
downloadAssetPack(assetPackageURI); downloadAssetPack(assetPackageURI);
@ -1747,54 +1749,47 @@ public class EaglerAdapterImpl2 {
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);
return false;
} }
public static final boolean directoryExists(String path) { public static final boolean directoryExists(String path) {
//return IndexedDBFilesystem.directoryExists(path); return IndexedDBFilesystem.directoryExists(path);
return false;
} }
public static final boolean pathExists(String path) { public static final boolean pathExists(String path) {
//return IndexedDBFilesystem.pathExists(path); return IndexedDBFilesystem.pathExists(path);
return false;
} }
public static final void writeFile(String path, byte[] data) { public static final void writeFile(String path, byte[] data) {
//IndexedDBFilesystem.writeFile(path, data); IndexedDBFilesystem.writeFile(path, data);
} }
public static final byte[] readFile(String path) { public static final byte[] readFile(String path) {
//return IndexedDBFilesystem.readFile(path); return IndexedDBFilesystem.readFile(path);
return null;
} }
public static final long getLastModified(String path) { public static final long getLastModified(String path) {
//return IndexedDBFilesystem.getLastModified(path); return IndexedDBFilesystem.getLastModified(path);
return 0L;
} }
public static final int getFileSize(String path) { public static final int getFileSize(String path) {
//return IndexedDBFilesystem.getFileSize(path); return IndexedDBFilesystem.getFileSize(path);
return 0;
} }
public static final void renameFile(String oldPath, String newPath) { public static final void renameFile(String oldPath, String newPath) {
//IndexedDBFilesystem.renameFile(oldPath, newPath); IndexedDBFilesystem.renameFile(oldPath, newPath);
} }
public static final void copyFile(String oldPath, String newPath) { public static final void copyFile(String oldPath, String newPath) {
//IndexedDBFilesystem.copyFile(oldPath, newPath); IndexedDBFilesystem.copyFile(oldPath, newPath);
} }
public static final void deleteFile(String path) { public static final void deleteFile(String path) {
//IndexedDBFilesystem.deleteFile(path); IndexedDBFilesystem.deleteFile(path);
} }
public static final Collection<FileEntry> listFiles(String path, boolean listDirs, boolean recursiveDirs) { public static final Collection<FileEntry> listFiles(String path, boolean listDirs, boolean recursiveDirs) {
//return IndexedDBFilesystem.listFiles(path, listDirs, recursiveDirs); return IndexedDBFilesystem.listFiles(path, listDirs, recursiveDirs);
return null;
} }
public static final Collection<FileEntry> listFilesAndDirectories(String path) { public static final Collection<FileEntry> listFilesAndDirectories(String path) {

View File

@ -0,0 +1,79 @@
package net.lax1dude.eaglercraft.adapter.teavm;
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,407 @@
package net.lax1dude.eaglercraft.adapter.teavm;
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.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2;
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FileEntry;
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_lax1dude_eaglercraft_beta_IndexedDBFilesystem_1_3");
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.eaglercraftEpoch + 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<FileEntry> listFiles(String path, boolean listDirs, boolean recursiveDirs) {
LinkedList<FileEntry> lst = new LinkedList<FileEntry>();
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 eaglercraftEpoch = 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() {
public void handleEvent() {
cb.complete(new DatabaseOpen(false, true, null, null));
}
});
f.setOnSuccess(new EventHandler() {
public void handleEvent() {
cb.complete(new DatabaseOpen(false, false, null, f.getResult()));
}
});
f.setOnError(new EventHandler() {
public void handleEvent() {
cb.complete(new DatabaseOpen(true, false, "open error", null));
}
});
f.setOnUpgradeNeeded(new EventListener<IDBVersionChangeEvent>() {
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() {
public void handleEvent() {
cb.complete(BooleanResult._new(true));
}
});
r.setOnError(new EventHandler() {
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() {
public void handleEvent() {
cb.complete(isRowDirectory(r.getResult()) ? null : readRow(r.getResult()));
}
});
r.setOnError(new EventHandler() {
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() {
public void handleEvent() {
cb.complete(readLastModified(r.getResult()));
}
});
r.setOnError(new EventHandler() {
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<EaglerAdapterImpl2.FileEntry> lst);
private static void iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection<EaglerAdapterImpl2.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() {
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 EaglerAdapterImpl2.FileEntry(k, true, -1));
}
}else {
lst.add(new EaglerAdapterImpl2.FileEntry(k, false, eaglercraftEpoch + readLastModified(c.getValue())));
}
}
}
}
c.doContinue();
}
});
r.setOnError(new EventHandler() {
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() {
public void handleEvent() {
cb.complete(BooleanResult._new(r.getResult() > 0));
}
});
r.setOnError(new EventHandler() {
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() {
public void handleEvent() {
cb.complete(readLastModified(r.getResult()));
}
});
r.setOnError(new EventHandler() {
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() {
public void handleEvent() {
cb.complete(r.getResult() == null ? FileExists.FALSE : (isRowDirectory(r.getResult()) ? FileExists.DIRECTORY : FileExists.FILE));
}
});
r.setOnError(new EventHandler() {
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() - eaglercraftEpoch), data));
r.setOnSuccess(new EventHandler() {
public void handleEvent() {
cb.complete(BooleanResult._new(true));
}
});
r.setOnError(new EventHandler() {
public void handleEvent() {
cb.complete(BooleanResult._new(false));
}
});
}
}
}

View File

@ -261,17 +261,8 @@ public class Minecraft implements Runnable {
public void run() { public void run() {
this.running = true; this.running = true;
try {
this.startGame(); this.startGame();
} catch (Exception var15) {
var15.printStackTrace();
new UnexpectedThrowable("Failed to start game", var15);
return;
}
try {
try {
long var1 = System.currentTimeMillis(); long var1 = System.currentTimeMillis();
int var3 = 0; int var3 = 0;
@ -310,7 +301,11 @@ public class Minecraft implements Runnable {
} }
if(this.gameSettings.limitFramerate) { if(this.gameSettings.limitFramerate) {
try {
Thread.sleep(5L); Thread.sleep(5L);
} catch (InterruptedException e) {
e.printStackTrace();
}
} }
if(!(Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(8))) { if(!(Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(8))) {
@ -326,7 +321,11 @@ public class Minecraft implements Runnable {
} }
if(!GL11.isFocused()) { if(!GL11.isFocused()) {
try {
Thread.sleep(10L); Thread.sleep(10L);
} catch (InterruptedException e) {
e.printStackTrace();
}
} }
if(Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(4)) { if(Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(4)) {
@ -363,15 +362,6 @@ public class Minecraft implements Runnable {
var1 += 1000L; var1 += 1000L;
} }
} }
} catch (MinecraftError var16) {
} catch (Throwable var17) {
this.theWorld = null;
var17.printStackTrace();
new UnexpectedThrowable("Unexpected error", var17);
}
} finally {
}
} }
private void func_6238_a(long var1) { private void func_6238_a(long var1) {

View File

@ -1,8 +1,6 @@
package net.minecraft.src; package net.minecraft.src;
import java.io.ByteArrayInputStream; import java.io.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -30,7 +28,7 @@ public class ChunkLoader implements IChunkLoader {
try { try {
byte[] data = GL11.readFile(var4); byte[] data = GL11.readFile(var4);
ByteArrayInputStream var5 = new ByteArrayInputStream(data); ByteArrayInputStream var5 = new ByteArrayInputStream(data);
NBTTagCompound var6 = CompressedStreamTools.func_1138_a(var5); NBTTagCompound var6 = (NBTTagCompound) NBTBase.readTag(new DataInputStream(var5));
if(!var6.hasKey("Level")) { if(!var6.hasKey("Level")) {
System.out.println("Chunk file at " + var2 + "," + var3 + " is missing level data, skipping"); System.out.println("Chunk file at " + var2 + "," + var3 + " is missing level data, skipping");
return null; return null;
@ -72,10 +70,16 @@ public class ChunkLoader implements IChunkLoader {
NBTTagCompound var7 = new NBTTagCompound(); NBTTagCompound var7 = new NBTTagCompound();
var6.setTag("Level", var7); var6.setTag("Level", var7);
this.storeChunkInCompound(var2, var1, var7); this.storeChunkInCompound(var2, var1, var7);
CompressedStreamTools.writeGzippedCompoundToOutputStream(var6, var5); try (DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(var5))) {
NBTBase.writeTag(var6, dos);
dos.flush();
var5.flush(); var5.flush();
GL11.writeFile(var4, var5.toByteArray()); GL11.writeFile(var4, var5.toByteArray());
var5.close(); var5.close();
} catch(IOException e) {
e.printStackTrace();
}
if(GL11.readFile(var3) != null) { if(GL11.readFile(var3) != null) {
GL11.deleteFile(var3); GL11.deleteFile(var3);
} }

View File

@ -1,78 +1,78 @@
package net.minecraft.src; //package net.minecraft.src;
//
import java.io.ByteArrayInputStream; //import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; //import java.io.ByteArrayOutputStream;
import java.io.DataInput; //import java.io.DataInput;
import java.io.DataInputStream; //import java.io.DataInputStream;
import java.io.DataOutput; //import java.io.DataOutput;
import java.io.DataOutputStream; //import java.io.DataOutputStream;
import java.io.IOException; //import java.io.IOException;
import java.io.InputStream; //import java.io.InputStream;
import java.io.OutputStream; //import java.io.OutputStream;
import java.util.zip.GZIPInputStream; //import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream; //import java.util.zip.GZIPOutputStream;
//
public class CompressedStreamTools { //public class CompressedStreamTools {
public static NBTTagCompound func_1138_a(InputStream var0) throws IOException { // public static NBTTagCompound func_1138_a(InputStream var0) throws IOException {
DataInputStream var1 = new DataInputStream(new GZIPInputStream(var0)); // DataInputStream var1 = new DataInputStream(new GZIPInputStream(var0));
//
NBTTagCompound var2; // NBTTagCompound var2;
try { // try {
var2 = func_1141_a(var1); // var2 = func_1141_a(var1);
} finally { // } finally {
var1.close(); // var1.close();
} // }
//
return var2; // return var2;
} // }
//
public static void writeGzippedCompoundToOutputStream(NBTTagCompound var0, OutputStream var1) throws IOException { // public static void writeGzippedCompoundToOutputStream(NBTTagCompound var0, OutputStream var1) throws IOException {
DataOutputStream var2 = new DataOutputStream(new GZIPOutputStream(var1)); // DataOutputStream var2 = new DataOutputStream(new GZIPOutputStream(var1));
//
try { // try {
func_1139_a(var0, var2); // func_1139_a(var0, var2);
} finally { // } finally {
var2.close(); // var2.close();
} // }
//
} // }
//
public static NBTTagCompound func_1140_a(byte[] var0) throws IOException { // public static NBTTagCompound func_1140_a(byte[] var0) throws IOException {
DataInputStream var1 = new DataInputStream(new GZIPInputStream(new ByteArrayInputStream(var0))); // DataInputStream var1 = new DataInputStream(new GZIPInputStream(new ByteArrayInputStream(var0)));
//
NBTTagCompound var2; // NBTTagCompound var2;
try { // try {
var2 = func_1141_a(var1); // var2 = func_1141_a(var1);
} finally { // } finally {
var1.close(); // var1.close();
} // }
//
return var2; // return var2;
} // }
//
public static byte[] func_1142_a(NBTTagCompound var0) throws IOException { // public static byte[] func_1142_a(NBTTagCompound var0) throws IOException {
ByteArrayOutputStream var1 = new ByteArrayOutputStream(); // ByteArrayOutputStream var1 = new ByteArrayOutputStream();
DataOutputStream var2 = new DataOutputStream(new GZIPOutputStream(var1)); // DataOutputStream var2 = new DataOutputStream(new GZIPOutputStream(var1));
//
try { // try {
func_1139_a(var0, var2); // func_1139_a(var0, var2);
} finally { // } finally {
var2.close(); // var2.close();
} // }
//
return var1.toByteArray(); // return var1.toByteArray();
} // }
//
public static NBTTagCompound func_1141_a(DataInput var0) throws IOException { // public static NBTTagCompound func_1141_a(DataInput var0) throws IOException {
NBTBase var1 = NBTBase.readTag(var0); // NBTBase var1 = NBTBase.readTag(var0);
if(var1 instanceof NBTTagCompound) { // if(var1 instanceof NBTTagCompound) {
return (NBTTagCompound)var1; // return (NBTTagCompound)var1;
} else { // } else {
throw new IOException("Root tag must be a named compound tag"); // throw new IOException("Root tag must be a named compound tag");
} // }
} // }
//
public static void func_1139_a(NBTTagCompound var0, DataOutput var1) throws IOException { // public static void func_1139_a(NBTTagCompound var0, DataOutput var1) throws IOException {
NBTBase.writeTag(var0, var1); // NBTBase.writeTag(var0, var1);
} // }
} //}

View File

@ -31,9 +31,9 @@ public class GuiIngame extends Gui {
FontRenderer var8 = this.mc.fontRenderer; FontRenderer var8 = this.mc.fontRenderer;
this.mc.field_9243_r.func_905_b(); this.mc.field_9243_r.func_905_b();
GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_BLEND);
if(this.mc.gameSettings.fancyGraphics) { //if(this.mc.gameSettings.fancyGraphics) {
this.func_4064_a(this.mc.thePlayer.getEntityBrightness(var1), var6, var7); //this.func_4064_a(this.mc.thePlayer.getEntityBrightness(var1), var6, var7);
} //}
ItemStack var9 = this.mc.thePlayer.inventory.armorItemInSlot(3); ItemStack var9 = this.mc.thePlayer.inventory.armorItemInSlot(3);
if(!this.mc.gameSettings.thirdPersonView && var9 != null && var9.itemID == Block.pumpkin.blockID) { if(!this.mc.gameSettings.thirdPersonView && var9 != null && var9.itemID == Block.pumpkin.blockID) {
@ -255,34 +255,34 @@ public class GuiIngame extends Gui {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
} }
private void func_4064_a(float var1, int var2, int var3) { // private void func_4064_a(float var1, int var2, int var3) {
var1 = 1.0F - var1; // var1 = 1.0F - var1;
if(var1 < 0.0F) { // if(var1 < 0.0F) {
var1 = 0.0F; // var1 = 0.0F;
} // }
//
if(var1 > 1.0F) { // if(var1 > 1.0F) {
var1 = 1.0F; // var1 = 1.0F;
} // }
//
this.field_931_c = (float)((double)this.field_931_c + (double)(var1 - this.field_931_c) * 0.01D); // this.field_931_c = (float)((double)this.field_931_c + (double)(var1 - this.field_931_c) * 0.01D);
GL11.glDisable(GL11.GL_DEPTH_TEST); // GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(false); // GL11.glDepthMask(false);
GL11.glBlendFunc(GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_COLOR); // GL11.glBlendFunc(GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_COLOR);
GL11.glColor4f(this.field_931_c, this.field_931_c, this.field_931_c, 1.0F); // GL11.glColor4f(this.field_931_c, this.field_931_c, this.field_931_c, 1.0F);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("%blur%/misc/vignette.png")); // GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("%blur%/misc/vignette.png"));
Tessellator var4 = Tessellator.instance; // Tessellator var4 = Tessellator.instance;
var4.startDrawingQuads(); // var4.startDrawingQuads();
var4.addVertexWithUV(0.0D, (double)var3, -90.0D, 0.0D, 1.0D); // var4.addVertexWithUV(0.0D, (double)var3, -90.0D, 0.0D, 1.0D);
var4.addVertexWithUV((double)var2, (double)var3, -90.0D, 1.0D, 1.0D); // var4.addVertexWithUV((double)var2, (double)var3, -90.0D, 1.0D, 1.0D);
var4.addVertexWithUV((double)var2, 0.0D, -90.0D, 1.0D, 0.0D); // var4.addVertexWithUV((double)var2, 0.0D, -90.0D, 1.0D, 0.0D);
var4.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D); // var4.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
var4.draw(); // var4.draw();
GL11.glDepthMask(true); // GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_DEPTH_TEST); // GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); // GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
} // }
private void func_4065_b(float var1, int var2, int var3) { private void func_4065_b(float var1, int var2, int var3) {
var1 *= var1; var1 *= var1;

View File

@ -1,5 +1,6 @@
package net.minecraft.src; package net.minecraft.src;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataInputStream; import java.io.DataInputStream;
@ -63,7 +64,7 @@ public class World implements IBlockAccess {
byte[] data = GL11.readFile("saves/" + var1 + "/level.dat"); byte[] data = GL11.readFile("saves/" + var1 + "/level.dat");
if(!(data == null)) { if(!(data == null)) {
try { try {
NBTTagCompound var5 = CompressedStreamTools.func_1138_a(new ByteArrayInputStream(data)); NBTTagCompound var5 = (NBTTagCompound) NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(data)));
NBTTagCompound var6 = var5.getCompoundTag("Data"); NBTTagCompound var6 = var5.getCompoundTag("Data");
return var6; return var6;
} catch (Exception var7) { } catch (Exception var7) {
@ -233,7 +234,7 @@ public class World implements IBlockAccess {
byte[] data = GL11.readFile(var18); byte[] data = GL11.readFile(var18);
if(data != null) { if(data != null) {
try { try {
NBTTagCompound var8 = CompressedStreamTools.func_1138_a(new ByteArrayInputStream(data)); NBTTagCompound var8 = (NBTTagCompound) NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(data)));
NBTTagCompound var9 = var8.getCompoundTag("Data"); NBTTagCompound var9 = var8.getCompoundTag("Data");
this.randomSeed = var9.getLong("RandomSeed"); this.randomSeed = var9.getLong("RandomSeed");
this.spawnX = var9.getInteger("SpawnX"); this.spawnX = var9.getInteger("SpawnX");
@ -367,7 +368,15 @@ public class World implements IBlockAccess {
String var5 = field_9432_t + "/level.dat_old"; String var5 = field_9432_t + "/level.dat_old";
String var6 = field_9432_t + "/level.dat"; String var6 = field_9432_t + "/level.dat";
ByteArrayOutputStream data = new ByteArrayOutputStream(); ByteArrayOutputStream data = new ByteArrayOutputStream();
CompressedStreamTools.writeGzippedCompoundToOutputStream(var3, data); try (DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(data))) {
NBTBase.writeTag(var3, dos);
dos.flush();
byte[] file = data.toByteArray();
GL11.writeFile(var6, file);
} catch(IOException e) {
e.printStackTrace();
}
GL11.writeFile(var4, data.toByteArray()); GL11.writeFile(var4, data.toByteArray());
if(GL11.readFile(var5) != null) { if(GL11.readFile(var5) != null) {
@ -1953,6 +1962,9 @@ public class World implements IBlockAccess {
public void func_663_l() { public void func_663_l() {
try { try {
String var1 = this.field_9432_t + "/session.lock"; String var1 = this.field_9432_t + "/session.lock";
if(GL11.readFile(var1) == null) {
return;
}
DataInputStream var2 = new DataInputStream(new ByteArrayInputStream(GL11.readFile(var1))); DataInputStream var2 = new DataInputStream(new ByteArrayInputStream(GL11.readFile(var1)));
try { try {

View File

@ -74,10 +74,6 @@ public class WorldRenderer {
} }
} }
private void func_1203_g() {
GL11.glTranslatef((float)this.field_1752_l, (float)this.field_1751_m, (float)this.field_1750_n);
}
public void func_1198_a() { public void func_1198_a() {
if(this.needsUpdate) { if(this.needsUpdate) {
++field_1762_b; ++field_1762_b;
@ -113,14 +109,8 @@ public class WorldRenderer {
if(!var14) { if(!var14) {
var14 = true; var14 = true;
GL11.glNewList(this.field_1744_C + var11, GL11.GL_COMPILE); GL11.glNewList(this.field_1744_C + var11, GL11.GL_COMPILE);
GL11.glPushMatrix();
this.func_1203_g();
float var19 = 1.000001F;
GL11.glTranslatef((float)(-this.field_1756_h) / 2.0F, (float)(-this.field_1757_g) / 2.0F, (float)(-this.field_1756_h) / 2.0F);
GL11.glScalef(var19, var19, var19);
GL11.glTranslatef((float)this.field_1756_h / 2.0F, (float)this.field_1757_g / 2.0F, (float)this.field_1756_h / 2.0F);
field_1742_D.startDrawingQuads(); field_1742_D.startDrawingQuads();
field_1742_D.setTranslationD((double)(-this.field_1761_c), (double)(-this.field_1760_d), (double)(-this.field_1759_e)); field_1742_D.setTranslationD((double) (this.field_1752_l-this.field_1761_c), (double) (this.field_1751_m-this.field_1760_d), (double) (this.field_1750_n-this.field_1759_e));
} }
if(var11 == 0 && Block.isBlockContainer[var18]) { if(var11 == 0 && Block.isBlockContainer[var18]) {
@ -144,7 +134,6 @@ public class WorldRenderer {
if(var14) { if(var14) {
field_1742_D.draw(); field_1742_D.draw();
GL11.glPopMatrix();
GL11.glEndList(); GL11.glEndList();
field_1742_D.setTranslationD(0.0D, 0.0D, 0.0D); field_1742_D.setTranslationD(0.0D, 0.0D, 0.0D);
} else { } else {