Quality Update (Final Update) P1
This commit is contained in:
parent
8b15690879
commit
b401cf2d47
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,6 @@
|
|||
package net.PeytonPlayz585;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
|
@ -14,17 +15,16 @@ import org.teavm.jso.dom.html.HTMLElement;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Session;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.PeytonPlayz585.storage.LevelStorageManager;
|
||||
import net.PeytonPlayz585.storage.LocalStorageManager;
|
||||
|
||||
public class MinecraftMain {
|
||||
public static Thread thread = null;
|
||||
|
||||
public static class AbortedLaunchException extends RuntimeException {
|
||||
// yee
|
||||
}
|
||||
|
||||
public static HTMLElement rootElement = null;
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws IOException {
|
||||
registerErrorHandler();
|
||||
String[] e = getOpts();
|
||||
try {
|
||||
|
@ -41,18 +41,17 @@ public class MinecraftMain {
|
|||
run0();
|
||||
}
|
||||
|
||||
private static void run0() {
|
||||
private static void run0() throws IOException {
|
||||
System.out.println(" -------- starting minecraft -------- ");
|
||||
LocalStorageManager.loadStorage();
|
||||
LevelStorageManager.loadLevelData();
|
||||
run1();
|
||||
}
|
||||
|
||||
private static void run1() {
|
||||
Minecraft minecraft = new Minecraft(GL11.getCanvasWidth(), GL11.getCanvasHeight());
|
||||
//minecraft.minecraftUri = "127.0.0.1:25565";
|
||||
minecraft.session = new Session("PeytonPlayz595", "WebGL-Emulator");
|
||||
Thread thread = new Thread (minecraft, "Minecraft main Thread");
|
||||
thread.run();
|
||||
minecraft.session = new Session("PeytonPlayz595", "Indev-WebGL");
|
||||
minecraft.run();
|
||||
}
|
||||
|
||||
@JSBody(params = { }, script = "return window.classicConfig;")
|
||||
|
|
|
@ -39,11 +39,12 @@ public abstract class NBTBase {
|
|||
|
||||
public static void writeTag(NBTBase var0, DataOutput var1) throws IOException {
|
||||
var1.writeByte(var0.getType());
|
||||
if(var0.getType() != 0) {
|
||||
byte[] var2 = var0.getKey().getBytes("UTF-8");
|
||||
var1.writeShort(var2.length);
|
||||
var1.write(var2);
|
||||
if (var0.getType() == 0) {
|
||||
return;
|
||||
} else {
|
||||
var1.writeUTF(var0.getKey());
|
||||
var0.writeTagContents(var1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.Iterator;
|
|||
import java.util.Map;
|
||||
|
||||
public final class NBTTagCompound extends NBTBase {
|
||||
private Map tagMap = new HashMap();
|
||||
public Map tagMap = new HashMap();
|
||||
|
||||
final void writeTagContents(DataOutput var1) throws IOException {
|
||||
Iterator var2 = this.tagMap.values().iterator();
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package net.PeytonPlayz585.storage;
|
||||
|
||||
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);
|
||||
}
|
|
@ -0,0 +1,425 @@
|
|||
package net.PeytonPlayz585.storage;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.lwjgl.opengl.WebGL;
|
||||
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;
|
||||
|
||||
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_indev_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<WebGL.FileEntry> listFiles(String path, boolean listDirs, boolean recursiveDirs) {
|
||||
LinkedList<WebGL.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<WebGL.FileEntry> lst);
|
||||
|
||||
private static void iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection<WebGL.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 WebGL.FileEntry(k, true, -1));
|
||||
}
|
||||
}else {
|
||||
lst.add(new WebGL.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));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package net.PeytonPlayz585.storage;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.PeytonPlayz585.nbt.NBTBase;
|
||||
import net.PeytonPlayz585.nbt.NBTTagCompound;
|
||||
|
||||
public class LevelStorageManager {
|
||||
|
||||
public static NBTTagCompound levelStorage = null;
|
||||
|
||||
public static void loadLevelData() throws IOException {
|
||||
byte[] levelData = GL11.readFile("/saves/level1.dat");
|
||||
|
||||
if(levelData != null) {
|
||||
NBTBase nbtBase = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(levelData)));
|
||||
if(nbtBase != null && nbtBase instanceof NBTTagCompound) {
|
||||
levelStorage = (NBTTagCompound)nbtBase;
|
||||
}
|
||||
}
|
||||
|
||||
if(levelStorage.tagMap.size() == 0) {
|
||||
levelStorage = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveLevelData() throws IOException {
|
||||
ByteArrayOutputStream s = new ByteArrayOutputStream();
|
||||
NBTBase.writeTag(levelStorage, new DataOutputStream(s));
|
||||
GL11.writeFile("/saves/level1.dat", s.toByteArray());
|
||||
if(levelStorage.tagMap.size() == 0) {
|
||||
levelStorage = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import java.io.DataInputStream;
|
|||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.WebGL;
|
||||
|
||||
import net.PeytonPlayz585.minecraft.Base64;
|
||||
|
@ -48,24 +49,16 @@ public class LocalStorageManager {
|
|||
|
||||
}
|
||||
|
||||
public static void saveStorageG() {
|
||||
try {
|
||||
public static void saveStorageG() throws IOException {
|
||||
ByteArrayOutputStream s = new ByteArrayOutputStream();
|
||||
NBTBase.writeTag(gameSettingsStorage, new DataOutputStream(s));
|
||||
WebGL.saveLocalStorage("g", s.toByteArray());
|
||||
} catch (IOException e) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveStorageP() {
|
||||
try {
|
||||
public static void saveStorageP() throws IOException {
|
||||
ByteArrayOutputStream s = new ByteArrayOutputStream();
|
||||
NBTBase.writeTag(profileSettingsStorage, new DataOutputStream(s));
|
||||
WebGL.saveLocalStorage("p", s.toByteArray());
|
||||
} catch (IOException e) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public static String dumpConfiguration() {
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package net.minecraft.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.PeytonPlayz585.nbt.NBTTagCompound;
|
||||
import net.PeytonPlayz585.storage.LocalStorageManager;
|
||||
|
||||
public final class GameSettings {
|
||||
private static final String[] RENDER_DISTANCES = new String[]{"FAR", "NORMAL", "SHORT", "TINY"};
|
||||
private static final String[] DIFFICULTIES = new String[]{"Peaceful", "Easy", "Normal", "Hard"};
|
||||
|
@ -25,15 +30,11 @@ public final class GameSettings {
|
|||
public KeyBinding keyBindSave = new KeyBinding("Save location", 28);
|
||||
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};
|
||||
private Minecraft mc;
|
||||
// private File optionsFile;
|
||||
public int numberOfOptions = 9;
|
||||
public int difficulty = 2;
|
||||
public boolean thirdPersonView = false;
|
||||
|
||||
public GameSettings(Minecraft var1) {
|
||||
this.mc = var1;
|
||||
// this.optionsFile = new File(var2, "options.txt");
|
||||
public GameSettings() {
|
||||
this.loadOptions();
|
||||
}
|
||||
|
||||
|
@ -91,88 +92,73 @@ public final class GameSettings {
|
|||
}
|
||||
|
||||
private void loadOptions() {
|
||||
// try {
|
||||
// if(this.optionsFile.exists()) {
|
||||
// BufferedReader var1 = new BufferedReader(new FileReader(this.optionsFile));
|
||||
//
|
||||
// while(true) {
|
||||
// String var2 = var1.readLine();
|
||||
// if(var2 == null) {
|
||||
// var1.close();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// String[] var5 = var2.split(":");
|
||||
// if(var5[0].equals("music")) {
|
||||
// this.music = var5[1].equals("true");
|
||||
// }
|
||||
//
|
||||
// if(var5[0].equals("sound")) {
|
||||
// this.sound = var5[1].equals("true");
|
||||
// }
|
||||
//
|
||||
// if(var5[0].equals("invertYMouse")) {
|
||||
// this.invertMouse = var5[1].equals("true");
|
||||
// }
|
||||
//
|
||||
// if(var5[0].equals("showFrameRate")) {
|
||||
// this.showFPS = var5[1].equals("true");
|
||||
// }
|
||||
//
|
||||
// if(var5[0].equals("viewDistance")) {
|
||||
// this.renderDistance = Integer.parseInt(var5[1]);
|
||||
// }
|
||||
//
|
||||
// if(var5[0].equals("bobView")) {
|
||||
// this.fancyGraphics = var5[1].equals("true");
|
||||
// }
|
||||
//
|
||||
// if(var5[0].equals("anaglyph3d")) {
|
||||
// this.anaglyph = var5[1].equals("true");
|
||||
// }
|
||||
//
|
||||
// if(var5[0].equals("limitFramerate")) {
|
||||
// this.limitFramerate = var5[1].equals("true");
|
||||
// }
|
||||
//
|
||||
// if(var5[0].equals("difficulty")) {
|
||||
// this.difficulty = Integer.parseInt(var5[1]);
|
||||
// }
|
||||
//
|
||||
// for(int var3 = 0; var3 < this.keyBindings.length; ++var3) {
|
||||
// if(var5[0].equals("key_" + this.keyBindings[var3].keyDescription)) {
|
||||
// this.keyBindings[var3].keyCode = Integer.parseInt(var5[1]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception var4) {
|
||||
// System.out.println("Failed to load options");
|
||||
// var4.printStackTrace();
|
||||
// }
|
||||
NBTTagCompound settingsFile = LocalStorageManager.gameSettingsStorage;
|
||||
|
||||
if(settingsFile.tagMap.size() == 0) {
|
||||
return;
|
||||
} else {
|
||||
if(settingsFile.hasKey("music")) {
|
||||
this.music = settingsFile.getBoolean("music");
|
||||
}
|
||||
|
||||
if(settingsFile.hasKey("sound")) {
|
||||
this.sound = settingsFile.getBoolean("sound");
|
||||
}
|
||||
|
||||
if(settingsFile.hasKey("invertYMouse")) {
|
||||
this.invertMouse = settingsFile.getBoolean("invertYMouse");
|
||||
}
|
||||
|
||||
if(settingsFile.hasKey("showFrameRate")) {
|
||||
this.showFPS = settingsFile.getBoolean("showFrameRate");
|
||||
}
|
||||
|
||||
if(settingsFile.hasKey("viewDistance")) {
|
||||
this.renderDistance = settingsFile.getInteger("viewDistance");
|
||||
}
|
||||
|
||||
if(settingsFile.hasKey("bobView")) {
|
||||
this.fancyGraphics = settingsFile.getBoolean("bobView");
|
||||
}
|
||||
|
||||
if(settingsFile.hasKey("anaglyph3d")) {
|
||||
this.anaglyph = settingsFile.getBoolean("anaglyph3d");
|
||||
}
|
||||
|
||||
if(settingsFile.hasKey("limitFramerate")) {
|
||||
this.limitFramerate = settingsFile.getBoolean("music");
|
||||
}
|
||||
|
||||
if(settingsFile.hasKey("difficulty")) {
|
||||
this.difficulty = settingsFile.getInteger("difficulty");
|
||||
}
|
||||
|
||||
for(int i = 0; i < keyBindings.length; ++i) {
|
||||
String k = "key_" + keyBindings[i].keyDescription;
|
||||
if(settingsFile.hasKey(k)) keyBindings[i].keyCode = (int)settingsFile.getShort(k) & 0xFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void saveOptions() {
|
||||
// try {
|
||||
// PrintWriter var1 = new PrintWriter(new FileWriter(this.optionsFile));
|
||||
// var1.println("music:" + this.music);
|
||||
// var1.println("sound:" + this.sound);
|
||||
// var1.println("invertYMouse:" + this.invertMouse);
|
||||
// var1.println("showFrameRate:" + this.showFPS);
|
||||
// var1.println("viewDistance:" + this.renderDistance);
|
||||
// var1.println("bobView:" + this.fancyGraphics);
|
||||
// var1.println("anaglyph3d:" + this.anaglyph);
|
||||
// var1.println("limitFramerate:" + this.limitFramerate);
|
||||
// var1.println("difficulty:" + this.difficulty);
|
||||
//
|
||||
// for(int var2 = 0; var2 < this.keyBindings.length; ++var2) {
|
||||
// var1.println("key_" + this.keyBindings[var2].keyDescription + ":" + this.keyBindings[var2].keyCode);
|
||||
// }
|
||||
//
|
||||
// var1.close();
|
||||
// } catch (Exception var3) {
|
||||
// System.out.println("Failed to save options");
|
||||
// var3.printStackTrace();
|
||||
// }
|
||||
NBTTagCompound settingsFile = LocalStorageManager.gameSettingsStorage;
|
||||
settingsFile.setBoolean("music", this.music);
|
||||
settingsFile.setBoolean("sound", this.sound);
|
||||
settingsFile.setBoolean("invertYMouse", this.invertMouse);
|
||||
settingsFile.setBoolean("showFrameRate", this.showFPS);
|
||||
settingsFile.setInteger("viewDistance", this.renderDistance);
|
||||
settingsFile.setBoolean("bobView", this.fancyGraphics);
|
||||
settingsFile.setBoolean("anaglyph3d", this.anaglyph);
|
||||
settingsFile.setBoolean("limitFramerate", this.limitFramerate);
|
||||
settingsFile.setInteger("difficulty", this.difficulty);
|
||||
for(int i = 0; i < keyBindings.length; ++i) {
|
||||
String k = "key_" + keyBindings[i].keyDescription;
|
||||
settingsFile.setShort(k, (short)keyBindings[i].keyCode);
|
||||
}
|
||||
try {
|
||||
LocalStorageManager.saveStorageG();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,39 @@
|
|||
package net.minecraft.client;
|
||||
|
||||
import net.PeytonPlayz585.math.MathHelper;
|
||||
import net.PeytonPlayz585.storage.LevelStorageManager;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiLoadLevel;
|
||||
import net.minecraft.client.gui.GuiNewLevel;
|
||||
import net.minecraft.client.gui.GuiOptions;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.game.item.ItemStack;
|
||||
import net.minecraft.game.level.LevelLoader;
|
||||
import util.IProgressUpdate;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class GuiMainMenu extends GuiScreen {
|
||||
private float updateCounter = 0.0F;
|
||||
private String[] splashes = new String[]{"Pre-beta!", "As seen on TV!", "Awesome!", "100% pure!", "May contain nuts!", "Better than Prey!", "More polygons!", "Sexy!", "Limited edition!", "Flashing letters!", "Made by Notch!", "Coming soon!", "Best in class!", "When it\'s finished!", "Absolutely dragon free!", "Excitement!", "More than 5000 sold!", "One of a kind!", "700+ hits on YouTube!", "Indev!", "Spiders everywhere!", "Check it out!", "Holy cow, man!", "It\'s a game!", "Made in Sweden!", "Uses LWJGL!", "Reticulating splines!", "Minecraft!", "Yaaay!", "Alpha version!", "Singleplayer!", "Keyboard compatible!", "Undocumented!", "Ingots!", "Exploding creepers!", "That\'s not a moon!", "l33t!", "Create!", "Survive!", "Dungeon!", "Exclusive!", "The bee\'s knees!", "Down with O.P.P.!", "Closed source!", "Classy!", "Wow!", "Not on steam!", "9.95 euro!", "Half price!", "Oh man!", "Check it out!", "Awesome community!", "Pixels!", "Teetsuuuuoooo!", "Kaaneeeedaaaa!", "Now with difficulty!", "Enhanced!", "90% bug free!", "Pretty!", "12 herbs and spices!", "Fat free!", "Absolutely no memes!", "Free dental!", "Ask your doctor!", "Minors welcome!", "Cloud computing!", "Legal in Finland!", "Hard to label!", "Technically good!", "Bringing home the bacon!", "Indie!", "GOTY!", "Ceci n\'est pas une title screen!", "Euclidian!", "Now in 3D!", "Inspirational!", "Herregud!", "Complex cellular automata!", "Yes, sir!", "Played by cowboys!", "OpenGL 1.1!", "Thousands of colors!", "Try it!", "Age of Wonders is better!", "Try the mushroom stew!", "Sensational!", "Hot tamale, hot hot tamale!", "Play him off, keyboard cat!", "Guaranteed!", "Macroscopic!", "Bring it on!", "Random splash!", "Call your mother!", "Monster infighting!", "Loved by millions!", "Ultimate edition!", "Freaky!", "You\'ve got a brand new key!", "Water proof!", "Uninflammable!", "Whoa, dude!", "All inclusive!", "Tell your friends!", "NP is not in P!", "Notch <3 Ez!", "Music by C418!"};
|
||||
private String currentSplash = this.splashes[(int)(Math.random() * (double)this.splashes.length)];
|
||||
//private float updateCounter = 0.0F;
|
||||
//private String[] splashes = new String[]{"Pre-beta!", "As seen on TV!", "Awesome!", "100% pure!", "May contain nuts!", "Better than Prey!", "More polygons!", "Sexy!", "Limited edition!", "Flashing letters!", "Made by Notch!", "Coming soon!", "Best in class!", "When it\'s finished!", "Absolutely dragon free!", "Excitement!", "More than 5000 sold!", "One of a kind!", "700+ hits on YouTube!", "Indev!", "Spiders everywhere!", "Check it out!", "Holy cow, man!", "It\'s a game!", "Made in Sweden!", "Uses WebGL!", "Reticulating splines!", "Minecraft!", "Yaaay!", "Indev version!", "Singleplayer!", "Keyboard compatible!", "Undocumented!", "Ingots!", "Exploding creepers!", "That\'s not a moon!", "l33t!", "Create!", "Survive!", "Dungeon!", "Exclusive!", "The bee\'s knees!", "Down with O.P.P.!", "Open source!", "Classy!", "Wow!", "Not on steam!", "9.95 euro!", "Half price!", "Oh man!", "Check it out!", "Awesome community!", "Pixels!", "Teetsuuuuoooo!", "Kaaneeeedaaaa!", "Now with difficulty!", "Enhanced!", "90% bug free!", "Pretty!", "12 herbs and spices!", "Fat free!", "Absolutely no memes!", "Free dental!", "Ask your doctor!", "Minors welcome!", "Cloud computing!", "Legal in Finland!", "Hard to label!", "Technically good!", "Bringing home the bacon!", "Indie!", "GOTY!", "Ceci n\'est pas une title screen!", "Euclidian!", "Now in 3D!", "Inspirational!", "Herregud!", "Complex cellular automata!", "Yes, sir!", "Played by cowboys!", "WebGL 2.0!", "Thousands of colors!", "Try it!", "Age of Wonders is better!", "Try the mushroom stew!", "Sensational!", "Hot tamale, hot hot tamale!", "Play him off, keyboard cat!", "Guaranteed!", "Macroscopic!", "Bring it on!", "Random splash!", "Call your mother!", "Monster infighting!", "Loved by millions!", "Ultimate edition!", "Freaky!", "You\'ve got a brand new key!", "Water proof!", "Uninflammable!", "Whoa, dude!", "All inclusive!", "Tell your friends!", "NP is not in P!", "Notch <3 Ez!", "Music by C418!"};
|
||||
private String currentSplash = "Made by PeytonPlayz585!";
|
||||
|
||||
public final void updateScreen() {
|
||||
this.updateCounter += 0.01F;
|
||||
}
|
||||
//public final void updateScreen() {
|
||||
//this.updateCounter += 0.01F;
|
||||
//}
|
||||
|
||||
protected final void keyTyped(char var1, int var2) {
|
||||
}
|
||||
|
||||
public final void initGui() {
|
||||
this.controlList.clear();
|
||||
this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 48, "Generate new level..."));
|
||||
this.controlList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 72, "Load level.."));
|
||||
this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 72, "Generate new level..."));
|
||||
this.controlList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 48, "Load level.."));
|
||||
this.controlList.add(new GuiButton(3, this.width / 2 - 100, this.height / 4 + 96, "Play tutorial level"));
|
||||
this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, "Options..."));
|
||||
if(LevelStorageManager.levelStorage == null) {
|
||||
((GuiButton)this.controlList.get(1)).enabled = false;
|
||||
}
|
||||
((GuiButton)this.controlList.get(2)).enabled = false;
|
||||
}
|
||||
|
||||
|
@ -40,8 +46,10 @@ public final class GuiMainMenu extends GuiScreen {
|
|||
this.mc.displayGuiScreen(new GuiNewLevel(this));
|
||||
}
|
||||
|
||||
if(this.mc.session != null && var1.id == 2) {
|
||||
this.mc.displayGuiScreen(new GuiLoadLevel(this));
|
||||
if(var1.id == 2) {
|
||||
LevelLoader loader = new LevelLoader();
|
||||
Minecraft.getMinecraft().setLevel(loader.load());
|
||||
this.mc.displayGuiScreen((GuiScreen)null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -61,7 +69,7 @@ public final class GuiMainMenu extends GuiScreen {
|
|||
GL11.glScalef(var15, var15, var15);
|
||||
drawCenteredString(this.fontRenderer, this.currentSplash, 0, -8, 16776960);
|
||||
GL11.glPopMatrix();
|
||||
String var16 = "Copyright Mojang Specifications. Do not distribute.";
|
||||
String var16 = "Fuck Mojang, Distribute to everyone!";
|
||||
drawString(this.fontRenderer, var16, this.width - this.fontRenderer.getStringWidth(var16) - 2, this.height - 10, 16777215);
|
||||
long var7 = GL11.maxMemory();
|
||||
long var9 = GL11.totalMemory();
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package net.minecraft.client;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import net.PeytonPlayz585.storage.LevelStorageManager;
|
||||
import net.minecraft.client.controller.PlayerController;
|
||||
import net.minecraft.client.controller.PlayerControllerCreative;
|
||||
import net.minecraft.client.controller.PlayerControllerSP;
|
||||
|
@ -15,6 +14,7 @@ import net.minecraft.client.gui.GuiIngame;
|
|||
import net.minecraft.client.gui.GuiIngameMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.gui.container.GuiContainer;
|
||||
import net.minecraft.client.gui.container.GuiInventory;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.player.EntityPlayerSP;
|
||||
|
@ -30,10 +30,13 @@ import net.minecraft.game.entity.EntityLiving;
|
|||
import net.minecraft.game.entity.player.InventoryPlayer;
|
||||
import net.minecraft.game.item.Item;
|
||||
import net.minecraft.game.item.ItemStack;
|
||||
import net.minecraft.game.level.LevelLoader;
|
||||
import net.minecraft.game.level.World;
|
||||
import net.minecraft.game.level.block.Block;
|
||||
import net.minecraft.game.level.generator.LevelGenerator;
|
||||
import net.minecraft.game.physics.MovingObjectPosition;
|
||||
import util.IProgressUpdate;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -42,7 +45,7 @@ public final class Minecraft implements Runnable {
|
|||
private boolean fullscreen = false;
|
||||
public int displayWidth;
|
||||
public int displayHeight;
|
||||
private Timer timer = new Timer(20.0F);
|
||||
public Timer timer = new Timer(20.0F);
|
||||
public World theWorld;
|
||||
public RenderGlobal renderGlobal;
|
||||
public EntityPlayerSP thePlayer;
|
||||
|
@ -55,7 +58,7 @@ public final class Minecraft implements Runnable {
|
|||
public GuiScreen currentScreen = null;
|
||||
public LoadingScreenRenderer loadingScreen = new LoadingScreenRenderer(this);
|
||||
public EntityRenderer entityRenderer = new EntityRenderer(this);
|
||||
private int ticksRan = 0;
|
||||
public int ticksRan = 0;
|
||||
private int leftClickCounter = 0;
|
||||
private int tempDisplayWidth;
|
||||
private int tempDisplayHeight;
|
||||
|
@ -69,7 +72,7 @@ public final class Minecraft implements Runnable {
|
|||
private String server;
|
||||
private TextureWaterFX textureWaterFX;
|
||||
private TextureLavaFX textureLavaFX;
|
||||
volatile boolean running;
|
||||
public boolean running;
|
||||
public String debug;
|
||||
public boolean inventoryScreen;
|
||||
private int prevFrameTime;
|
||||
|
@ -149,7 +152,7 @@ public final class Minecraft implements Runnable {
|
|||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
this.options = new GameSettings(this);
|
||||
this.options = new GameSettings();
|
||||
this.renderEngine = new RenderEngine(this.options);
|
||||
this.fontRenderer = new FontRenderer(this.options, "/default.png", this.renderEngine);
|
||||
var24 = BufferUtils.createIntBuffer(256);
|
||||
|
@ -210,7 +213,7 @@ public final class Minecraft implements Runnable {
|
|||
this.isGamePaused = this.currentScreen != null && this.currentScreen.doesGuiPauseGame();
|
||||
|
||||
while(System.currentTimeMillis() >= var23 + 1000L) {
|
||||
this.debug = var28 + " fps, " + WorldRenderer.chunksUpdated + " chunk updates";
|
||||
this.debug = "FPS: " + var28 + ", Chunk Updates: " + WorldRenderer.chunksUpdated;
|
||||
WorldRenderer.chunksUpdated = 0;
|
||||
var23 += 1000L;
|
||||
var28 = 0;
|
||||
|
@ -358,6 +361,15 @@ public final class Minecraft implements Runnable {
|
|||
}
|
||||
|
||||
private void runTick() {
|
||||
mc = this;
|
||||
|
||||
this.levelSave();
|
||||
|
||||
if(this.playerController instanceof PlayerControllerCreative) {
|
||||
for(int var1 = 0; var1 < 9; var1++) {
|
||||
this.thePlayer.inventory.mainInventory[var1].stackSize = 64;
|
||||
}
|
||||
}
|
||||
|
||||
if(!this.inventoryScreen) {
|
||||
this.mouseHelper.ungrabMouse();
|
||||
|
@ -506,7 +518,7 @@ public final class Minecraft implements Runnable {
|
|||
this.options.thirdPersonView = !this.options.thirdPersonView;
|
||||
}
|
||||
|
||||
if(GL11.getEventKey() == this.options.keyBindInventory.keyCode) {
|
||||
if(GL11.getEventKey() == this.options.keyBindInventory.keyCode && !(this.playerController instanceof PlayerControllerCreative)) {
|
||||
this.displayGuiScreen(new GuiInventory(this.thePlayer.inventory));
|
||||
}
|
||||
|
||||
|
@ -579,6 +591,29 @@ public final class Minecraft implements Runnable {
|
|||
|
||||
}
|
||||
|
||||
public int ticksUntilSave = 6000;
|
||||
public int ticksUntilSave2 = 100;
|
||||
public static int inventoryTicks = 0;
|
||||
|
||||
private void levelSave() {
|
||||
if(this.theWorld == null) {
|
||||
ticksUntilSave = this.ticksRan + 6000;
|
||||
this.ticksUntilSave2 = this.ticksRan + 100;
|
||||
}
|
||||
|
||||
if(this.ticksRan >= this.ticksUntilSave2 && this.theWorld != null && this.currentScreen instanceof GuiContainer) {
|
||||
this.ticksUntilSave2 = this.ticksRan + 100;
|
||||
LevelLoader loader = new LevelLoader();
|
||||
loader.save();
|
||||
}
|
||||
|
||||
if(this.ticksRan >= this.ticksUntilSave) {
|
||||
LevelLoader loader = new LevelLoader();
|
||||
loader.save();
|
||||
ticksUntilSave = this.ticksRan + 6000;
|
||||
}
|
||||
}
|
||||
|
||||
public final void generateLevel(int var1, int var2, int var3, int var4) {
|
||||
this.setLevel((World)null);
|
||||
System.gc();
|
||||
|
@ -614,6 +649,9 @@ public final class Minecraft implements Runnable {
|
|||
|
||||
if(var1 != null) {
|
||||
var1.load();
|
||||
//PlayerControllerCreative creative = new PlayerControllerCreative(this);
|
||||
//creative.onWorldChange(var1);
|
||||
this.playerController = new PlayerControllerSP(this);
|
||||
this.playerController.onWorldChange(var1);
|
||||
this.thePlayer = (EntityPlayerSP)var1.findSubclassOf(EntityPlayerSP.class);
|
||||
var1.playerEntity = this.thePlayer;
|
||||
|
@ -649,6 +687,10 @@ public final class Minecraft implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
if(this.thePlayer != null && LevelStorageManager.levelStorage != null) {
|
||||
this.thePlayer.readEntityFromNBT(LevelStorageManager.levelStorage);
|
||||
}
|
||||
|
||||
System.gc();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ import util.IProgressUpdate;
|
|||
public final class PlayerLoader extends LevelLoader {
|
||||
private Minecraft mc;
|
||||
|
||||
public PlayerLoader(Minecraft var1, IProgressUpdate var2) {
|
||||
super(var2);
|
||||
public PlayerLoader(Minecraft var1) {
|
||||
super();
|
||||
this.mc = var1;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||
import net.minecraft.game.level.block.Block;
|
||||
|
||||
public final class Session {
|
||||
public static List registeredBlocksList;
|
||||
public static List<Block> registeredBlocksList;
|
||||
public String username;
|
||||
public String sessionId;
|
||||
|
||||
|
@ -15,7 +15,7 @@ public final class Session {
|
|||
}
|
||||
|
||||
static {
|
||||
(registeredBlocksList = new ArrayList()).add(Block.stone);
|
||||
(registeredBlocksList = new ArrayList<Block>()).add(Block.stone);
|
||||
registeredBlocksList.add(Block.cobblestone);
|
||||
registeredBlocksList.add(Block.brick);
|
||||
registeredBlocksList.add(Block.dirt);
|
||||
|
|
|
@ -11,7 +11,7 @@ import net.minecraft.game.level.block.Block;
|
|||
public final class PlayerControllerCreative extends PlayerController {
|
||||
private MobSpawner mobSpawner;
|
||||
|
||||
private PlayerControllerCreative(Minecraft var1) {
|
||||
public PlayerControllerCreative(Minecraft var1) {
|
||||
super(var1);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,24 @@
|
|||
package net.minecraft.client.gui;
|
||||
|
||||
import net.PeytonPlayz585.nbt.NBTTagCompound;
|
||||
import net.PeytonPlayz585.storage.LevelStorageManager;
|
||||
import net.minecraft.client.player.EntityPlayerSP;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class GuiGameOver extends GuiScreen {
|
||||
|
||||
public GuiGameOver() {
|
||||
LevelStorageManager.levelStorage = new NBTTagCompound();
|
||||
try {
|
||||
LevelStorageManager.saveLevelData();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public final void initGui() {
|
||||
this.controlList.clear();
|
||||
this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 72, "Generate new level..."));
|
||||
|
|
|
@ -151,13 +151,15 @@ public final class GuiIngame extends Gui {
|
|||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_NORMALIZE);
|
||||
if(this.mc.options.showFPS) {
|
||||
var4.drawStringWithShadow("Minecraft Indev (" + this.mc.debug + ")", 2, 2, 16777215);
|
||||
var4.drawStringWithShadow("Minecraft Indev (Made by PeytonPlayz585)", 2, 2, 16777215);
|
||||
Minecraft var23 = this.mc;
|
||||
var4.drawStringWithShadow(var23.renderGlobal.getDebugInfoRenders(), 2, 12, 16777215);
|
||||
var4.drawStringWithShadow(this.mc.debug, 2, 12, 16777215);
|
||||
var23 = this.mc;
|
||||
var4.drawStringWithShadow(var23.renderGlobal.getDebugInfoEntities(), 2, 22, 16777215);
|
||||
var4.drawStringWithShadow(var23.renderGlobal.getDebugInfoRenders(), 2, 22, 16777215);
|
||||
var23 = this.mc;
|
||||
var4.drawStringWithShadow("P: " + var23.effectRenderer.getStatistics() + ". T: " + var23.theWorld.debugSkylightUpdates(), 2, 32, 16777215);
|
||||
var4.drawStringWithShadow(var23.renderGlobal.getDebugInfoEntities(), 2, 32, 16777215);
|
||||
var23 = this.mc;
|
||||
var4.drawStringWithShadow("P: " + var23.effectRenderer.getStatistics() + ". T: " + var23.theWorld.debugSkylightUpdates(), 2, 42, 16777215);
|
||||
long var24 = GL11.maxMemory();
|
||||
long var27 = GL11.totalMemory();
|
||||
long var28 = GL11.freeMemory();
|
||||
|
@ -167,7 +169,7 @@ public final class GuiIngame extends Gui {
|
|||
var18 = "Allocated memory: " + var27 * 100L / var24 + "% (" + var27 / 1024L / 1024L + "MB)";
|
||||
drawString(var4, var18, var3 - var4.getStringWidth(var18) - 2, 12, 14737632);
|
||||
} else {
|
||||
var4.drawStringWithShadow("Minecraft Indev", 2, 2, 16777215);
|
||||
var4.drawStringWithShadow("Minecraft Indev (Made by PeytonPlayz585)", 2, 2, 16777215);
|
||||
}
|
||||
|
||||
for(var12 = 0; var12 < this.chatMessageList.size() && var12 < 10; ++var12) {
|
||||
|
|
|
@ -2,7 +2,15 @@ package net.minecraft.client.gui;
|
|||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.game.level.LevelLoader;
|
||||
|
||||
public final class GuiIngameMenu extends GuiScreen {
|
||||
|
||||
public GuiIngameMenu() {
|
||||
LevelLoader loader = new LevelLoader();
|
||||
loader.save();
|
||||
}
|
||||
|
||||
public final void initGui() {
|
||||
this.controlList.clear();
|
||||
this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4, "Options..."));
|
||||
|
|
|
@ -127,9 +127,9 @@ public class GuiLoadLevel extends GuiScreen implements Runnable {
|
|||
protected void openLevel(File var1) {
|
||||
try {
|
||||
FileInputStream var4 = new FileInputStream(var1);
|
||||
World var2 = (new PlayerLoader(this.mc, this.mc.loadingScreen)).load(var4);
|
||||
//World var2 = (new PlayerLoader(this.mc, this.mc.loadingScreen)).load(var4);
|
||||
var4.close();
|
||||
this.mc.setLevel(var2);
|
||||
//this.mc.setLevel(var2);
|
||||
} catch (IOException var3) {
|
||||
var3.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package net.minecraft.client.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.PeytonPlayz585.nbt.NBTTagCompound;
|
||||
import net.PeytonPlayz585.storage.LevelStorageManager;
|
||||
|
||||
public final class GuiNewLevel extends GuiScreen {
|
||||
private GuiScreen prevGui;
|
||||
private String[] worldType = new String[]{"Inland", "Island", "Floating", "Flat"};
|
||||
|
@ -37,6 +42,13 @@ public final class GuiNewLevel extends GuiScreen {
|
|||
if(var1.id == 5) {
|
||||
this.mc.displayGuiScreen(this.prevGui);
|
||||
} else if(var1.id == 4) {
|
||||
LevelStorageManager.levelStorage = new NBTTagCompound();
|
||||
try {
|
||||
LevelStorageManager.saveLevelData();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.mc.ticksUntilSave = this.mc.ticksRan + 6000;
|
||||
this.mc.generateLevel(this.selectedWorldSize, this.selectedWorldShape, this.selectedWorldType, this.selectedWorldTheme);
|
||||
this.mc.displayGuiScreen((GuiScreen)null);
|
||||
} else if(var1.id == 0) {
|
||||
|
|
|
@ -34,7 +34,7 @@ public final class GuiSaveLevel extends GuiLoadLevel {
|
|||
protected final void openLevel(File var1) {
|
||||
try {
|
||||
FileOutputStream var3 = new FileOutputStream(var1);
|
||||
(new PlayerLoader(this.mc, this.mc.loadingScreen)).save(this.mc.theWorld, var3);
|
||||
//(new PlayerLoader(this.mc, this.mc.loadingScreen)).save(this.mc.theWorld, var3);
|
||||
var3.close();
|
||||
} catch (IOException var2) {
|
||||
var2.printStackTrace();
|
||||
|
|
5
src/teavm/java/net/minecraft/client/gui/GuiYesNo.java
Normal file
5
src/teavm/java/net/minecraft/client/gui/GuiYesNo.java
Normal file
|
@ -0,0 +1,5 @@
|
|||
package net.minecraft.client.gui;
|
||||
|
||||
public class GuiYesNo extends GuiScreen {
|
||||
|
||||
}
|
|
@ -39,7 +39,7 @@ public class EntityPlayerSP extends EntityPlayer {
|
|||
super.onLivingUpdate();
|
||||
}
|
||||
|
||||
protected final void writeEntityToNBT(NBTTagCompound var1) {
|
||||
public final void writeEntityToNBT(NBTTagCompound var1) {
|
||||
super.writeEntityToNBT(var1);
|
||||
var1.setInteger("Score", this.getScore);
|
||||
InventoryPlayer var10002 = this.inventory;
|
||||
|
@ -69,7 +69,7 @@ public class EntityPlayerSP extends EntityPlayer {
|
|||
var1.setTag("Inventory", var2);
|
||||
}
|
||||
|
||||
protected final void readEntityFromNBT(NBTTagCompound var1) {
|
||||
public final void readEntityFromNBT(NBTTagCompound var1) {
|
||||
super.readEntityFromNBT(var1);
|
||||
this.getScore = var1.getInteger("Score");
|
||||
NBTTagList var6 = var1.getTagList("Inventory");
|
||||
|
|
|
@ -30,16 +30,16 @@ public final class EntityRenderer {
|
|||
private boolean anaglyphEnable = false;
|
||||
private float farPlaneDistance = 0.0F;
|
||||
public ItemRenderer itemRenderer;
|
||||
private int rendererUpdateCount;
|
||||
//private int rendererUpdateCount;
|
||||
private Entity pointedEntity = null;
|
||||
private int entityRendererInt1;
|
||||
private int entityRendererInt2;
|
||||
private DecimalFormat entityDecimalFormat = new DecimalFormat("0000");
|
||||
private ByteBuffer entityByteBuffer;
|
||||
private FloatBuffer entityFloatBuffer = BufferUtils.createFloatBuffer(16);
|
||||
private Random random = new Random();
|
||||
private volatile int unusedInt0 = 0;
|
||||
private volatile int unusedInt1 = 0;
|
||||
//private int entityRendererInt1;
|
||||
//private int entityRendererInt2;
|
||||
//private DecimalFormat entityDecimalFormat = new DecimalFormat("0000");
|
||||
//private ByteBuffer entityByteBuffer;
|
||||
//private FloatBuffer entityFloatBuffer = BufferUtils.createFloatBuffer(16);
|
||||
//private Random random = new Random();
|
||||
//private volatile int unusedInt0 = 0;
|
||||
//private volatile int unusedInt1 = 0;
|
||||
private FloatBuffer fogColorBuffer = BufferUtils.createFloatBuffer(16);
|
||||
private float fogColorRed;
|
||||
private float fogColorGreen;
|
||||
|
@ -58,7 +58,7 @@ public final class EntityRenderer {
|
|||
float var2 = (float)(3 - this.mc.options.renderDistance) / 3.0F;
|
||||
var1 = var1 * (1.0F - var2) + var2;
|
||||
this.fogColor += (var1 - this.fogColor) * 0.1F;
|
||||
++this.rendererUpdateCount;
|
||||
//++this.rendererUpdateCount;
|
||||
this.itemRenderer.updateEquippedItem();
|
||||
}
|
||||
|
||||
|
@ -376,12 +376,16 @@ public final class EntityRenderer {
|
|||
}
|
||||
|
||||
if(!this.mc.options.thirdPersonView) {
|
||||
GL11.flipLightMatrix();
|
||||
this.itemRenderer.renderItemInFirstPerson(var1);
|
||||
GL11.flipLightMatrix();
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
if(!this.mc.options.thirdPersonView) {
|
||||
GL11.flipLightMatrix();
|
||||
this.itemRenderer.renderOverlays(var1);
|
||||
GL11.flipLightMatrix();
|
||||
this.hurtCameraEffect(var1);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,9 @@ public final class ItemRenderer {
|
|||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(var3.prevRotationPitch + (var3.rotationPitch - var3.prevRotationPitch) * var1, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(var3.prevRotationYaw + (var3.rotationYaw - var3.prevRotationYaw) * var1, 0.0F, 1.0F, 0.0F);
|
||||
GL11.flipLightMatrix();
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.flipLightMatrix();
|
||||
GL11.glPopMatrix();
|
||||
float var9 = this.mc.theWorld.getLightBrightness((int)var3.posX, (int)var3.posY, (int)var3.posZ);
|
||||
GL11.glColor4f(var9, var9, var9, 1.0F);
|
||||
|
@ -155,7 +157,9 @@ public final class ItemRenderer {
|
|||
var11.addVertexWithUV(1.0F, var7, -(1.0F / 16.0F), var5, var8);
|
||||
}
|
||||
|
||||
GL11.flipLightMatrix();
|
||||
var11.draw();
|
||||
GL11.flipLightMatrix();
|
||||
GL11.glDisable(GL11.GL_NORMALIZE);
|
||||
}
|
||||
|
||||
|
@ -189,12 +193,16 @@ public final class ItemRenderer {
|
|||
GL11.glTranslatef(6.0F, 0.0F, 0.0F);
|
||||
Render var13 = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer);
|
||||
RenderPlayer var12 = (RenderPlayer)var13;
|
||||
GL11.flipLightMatrix();
|
||||
var12.drawFirstPersonHand();
|
||||
GL11.flipLightMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_NORMALIZE);
|
||||
GL11.flipLightMatrix();
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.flipLightMatrix();
|
||||
}
|
||||
|
||||
public final void renderOverlays(float var1) {
|
||||
|
@ -227,7 +235,9 @@ public final class ItemRenderer {
|
|||
var3.addVertexWithUV(0.5F, -0.5F, -0.5F, var6, var9);
|
||||
var3.addVertexWithUV(0.5F, 0.5F, -0.5F, var6, var7);
|
||||
var3.addVertexWithUV(-0.5F, 0.5F, -0.5F, var10, var7);
|
||||
GL11.flipLightMatrix();
|
||||
var3.draw();
|
||||
GL11.flipLightMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
@ -251,7 +261,9 @@ public final class ItemRenderer {
|
|||
var3.addVertexWithUV(1.0F, -1.0F, -0.5F, var7 + 0.0F, var9 + 4.0F);
|
||||
var3.addVertexWithUV(1.0F, 1.0F, -0.5F, var7 + 0.0F, var9 + 0.0F);
|
||||
var3.addVertexWithUV(-1.0F, 1.0F, -0.5F, var7 + 4.0F, var9 + 0.0F);
|
||||
GL11.flipLightMatrix();
|
||||
var3.draw();
|
||||
GL11.flipLightMatrix();
|
||||
GL11.glPopMatrix();
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
|
|
@ -18,7 +18,6 @@ public class RenderEngine {
|
|||
textureNameToImageMap = new HashMap<Integer, MinecraftImage>();
|
||||
singleIntBuffer = BufferUtils.createIntBuffer(1);
|
||||
imageDataB1 = BufferUtils.createByteBuffer(0x100000);
|
||||
imageDataB2 = BufferUtils.createByteBuffer(0x100000);
|
||||
clampTexture = false;
|
||||
blurTexture = false;
|
||||
options = gamesettings;
|
||||
|
@ -42,11 +41,7 @@ public class RenderEngine {
|
|||
setupTexture(readTextureImage(GL11.loadResourceBytes(s.substring(6))), i);
|
||||
blurTexture = false;
|
||||
} else {
|
||||
if(s.equals("/terrain.png")) {
|
||||
useMipmaps = true;
|
||||
}
|
||||
setupTexture(readTextureImage(GL11.loadResourceBytes(s)), i);
|
||||
useMipmaps = false;
|
||||
}
|
||||
textureMap.put(s, Integer.valueOf(i));
|
||||
return i;
|
||||
|
@ -81,14 +76,8 @@ public class RenderEngine {
|
|||
|
||||
public void setupTexture(MinecraftImage bufferedimage, int i) {
|
||||
bindTexture(i);
|
||||
if (useMipmaps) {
|
||||
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, GL11.GL_NEAREST_MIPMAP_LINEAR);
|
||||
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, GL11.GL_NEAREST /* GL_LINEAR */);
|
||||
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, GL11.GL_TEXTURE_MAX_LEVEL, 4);
|
||||
} else {
|
||||
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, 9728 /* GL_NEAREST */);
|
||||
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9728 /* GL_NEAREST */);
|
||||
}
|
||||
if (blurTexture) {
|
||||
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, 9729 /* GL_LINEAR */);
|
||||
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9729 /* GL_LINEAR */);
|
||||
|
@ -127,32 +116,6 @@ public class RenderEngine {
|
|||
imageDataB1.position(0).limit(abyte0.length);
|
||||
GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, 0, 6408 /* GL_RGBA */, j, k, 0, 6408 /* GL_RGBA */,
|
||||
5121 /* GL_UNSIGNED_BYTE */, imageDataB1);
|
||||
if (useMipmaps) {
|
||||
for (int i1 = 1; i1 <= 4; i1++) {
|
||||
int k1 = j >> i1 - 1;
|
||||
int i2 = j >> i1;
|
||||
int k2 = k >> i1;
|
||||
imageDataB2.clear();
|
||||
for (int i3 = 0; i3 < i2; i3++) {
|
||||
for (int k3 = 0; k3 < k2; k3++) {
|
||||
int i4 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 0) * k1) * 4);
|
||||
int k4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 0) * k1) * 4);
|
||||
int l4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 1) * k1) * 4);
|
||||
int i5 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 1) * k1) * 4);
|
||||
int j5 = averageColor(averageColor(i4, k4), averageColor(l4, i5));
|
||||
imageDataB2.putInt((i3 + k3 * i2) * 4, j5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, i1, 6408 /* GL_RGBA */, i2, k2, 0, 6408 /* GL_RGBA */,
|
||||
5121 /* GL_UNSIGNED_BYTE */, imageDataB2);
|
||||
ByteBuffer tmp = imageDataB1;
|
||||
imageDataB1 = imageDataB2;
|
||||
imageDataB2 = tmp;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteTexture(int i) {
|
||||
|
@ -160,23 +123,9 @@ public class RenderEngine {
|
|||
}
|
||||
|
||||
public int getTextureForDownloadableImage(String s) {
|
||||
// if(s.contains("creeper")) {
|
||||
// return getTexture("/mob/creeper.png");
|
||||
// } else if(s.contains("pig")) {
|
||||
// return getTexture("/mob/pig.png");
|
||||
// } else if(s.contains("sheep")) {
|
||||
// return getTexture("/mob/sheep.png");
|
||||
// }
|
||||
return getTexture(s);
|
||||
}
|
||||
|
||||
private int averageColor(int i, int j) {
|
||||
int k = (i & 0xff000000) >> 24 & 0xff;
|
||||
int l = (j & 0xff000000) >> 24 & 0xff;
|
||||
return ((k + l >> 1) << 24) + ((i & 0xfefefe) + (j & 0xfefefe) >> 1);
|
||||
|
||||
}
|
||||
|
||||
private MinecraftImage readTextureImage(byte[] inputstream) throws IOException {
|
||||
return GL11.loadPNG(inputstream);
|
||||
}
|
||||
|
@ -190,12 +139,10 @@ public class RenderEngine {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean useMipmaps = false;
|
||||
private HashMap<String, Integer> textureMap;
|
||||
private HashMap<Integer, MinecraftImage> textureNameToImageMap;
|
||||
private IntBuffer singleIntBuffer;
|
||||
private ByteBuffer imageDataB1;
|
||||
private ByteBuffer imageDataB2;
|
||||
private GameSettings options;
|
||||
private boolean clampTexture;
|
||||
private boolean blurTexture;
|
||||
|
|
|
@ -137,9 +137,9 @@ public final class RenderGlobal implements IWorldAccess {
|
|||
for(int var4 = 0; var4 < this.renderChunksTall; ++var4) {
|
||||
for(int var5 = 0; var5 < this.renderChunksDeep; ++var5) {
|
||||
this.worldRenderers[(var5 * this.renderChunksTall + var4) * this.renderChunksWide + var3] = new WorldRenderer(this.worldObj, var3 << 4, var4 << 4, var5 << 4, 16, this.glRenderListBase + var1);
|
||||
if(this.occlusionEnabled) {
|
||||
this.worldRenderers[(var5 * this.renderChunksTall + var4) * this.renderChunksWide + var3].glOcclusionQuery = this.glOcclusionQueryBase.get(var2);
|
||||
}
|
||||
//if(this.occlusionEnabled) {
|
||||
//this.worldRenderers[(var5 * this.renderChunksTall + var4) * this.renderChunksWide + var3].glOcclusionQuery = this.glOcclusionQueryBase.get(var2);
|
||||
//}
|
||||
|
||||
++var2;
|
||||
this.sortedWorldRenderers[(var5 * this.renderChunksTall + var4) * this.renderChunksWide + var3] = this.worldRenderers[(var5 * this.renderChunksTall + var4) * this.renderChunksWide + var3];
|
||||
|
@ -251,7 +251,7 @@ public final class RenderGlobal implements IWorldAccess {
|
|||
int var8;
|
||||
if(this.occlusionEnabled && var2 == 0) {
|
||||
int var10 = 8;
|
||||
this.checkOcclusionQueryResult(0, 8);
|
||||
//this.checkOcclusionQueryResult(0, 8);
|
||||
|
||||
int var6;
|
||||
for(var6 = 0; var6 < 8; ++var6) {
|
||||
|
@ -272,21 +272,21 @@ public final class RenderGlobal implements IWorldAccess {
|
|||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glColorMask(false, false, false, false);
|
||||
GL11.glDepthMask(false);
|
||||
this.checkOcclusionQueryResult(var9, var10);
|
||||
//this.checkOcclusionQueryResult(var9, var10);
|
||||
|
||||
for(var6 = var9; var6 < var10; ++var6) {
|
||||
if(!this.sortedWorldRenderers[var6].isInFrustrum) {
|
||||
this.sortedWorldRenderers[var6].isVisible = true;
|
||||
}
|
||||
|
||||
if(this.sortedWorldRenderers[var6].isInFrustrum && !this.sortedWorldRenderers[var6].isWaitingOnOcclusionQuery) {
|
||||
float var7 = MathHelper.sqrt_float(this.sortedWorldRenderers[var6].distanceToEntitySquared(var1));
|
||||
int var11 = (int)(1.0F + var7 / 64.0F);
|
||||
if(this.cloudOffsetX % var11 == var6 % var11) {
|
||||
this.sortedWorldRenderers[var6].callOcclusionQueryList();
|
||||
this.sortedWorldRenderers[var6].isWaitingOnOcclusionQuery = true;
|
||||
}
|
||||
}
|
||||
//if(this.sortedWorldRenderers[var6].isInFrustrum && !this.sortedWorldRenderers[var6].isWaitingOnOcclusionQuery) {
|
||||
//float var7 = MathHelper.sqrt_float(this.sortedWorldRenderers[var6].distanceToEntitySquared(var1));
|
||||
//int var11 = (int)(1.0F + var7 / 64.0F);
|
||||
//if(this.cloudOffsetX % var11 == var6 % var11) {
|
||||
//this.sortedWorldRenderers[var6].callOcclusionQueryList();
|
||||
//this.sortedWorldRenderers[var6].isWaitingOnOcclusionQuery = true;
|
||||
//}
|
||||
//}
|
||||
}
|
||||
|
||||
GL11.glColorMask(true, true, true, true);
|
||||
|
@ -302,19 +302,19 @@ public final class RenderGlobal implements IWorldAccess {
|
|||
return var8;
|
||||
}
|
||||
|
||||
private void checkOcclusionQueryResult(int var1, int var2) {
|
||||
for(var1 = var1; var1 < var2; ++var1) {
|
||||
if(this.sortedWorldRenderers[var1].isWaitingOnOcclusionQuery) {
|
||||
this.occlusionResult.clear();
|
||||
if(this.occlusionResult.get(0) != 0) {
|
||||
this.sortedWorldRenderers[var1].isWaitingOnOcclusionQuery = false;
|
||||
this.occlusionResult.clear();
|
||||
this.sortedWorldRenderers[var1].isVisible = this.occlusionResult.get(0) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// private void checkOcclusionQueryResult(int var1, int var2) {
|
||||
// for(var1 = var1; var1 < var2; ++var1) {
|
||||
// if(this.sortedWorldRenderers[var1].isWaitingOnOcclusionQuery) {
|
||||
// this.occlusionResult.clear();
|
||||
// if(this.occlusionResult.get(0) != 0) {
|
||||
// this.sortedWorldRenderers[var1].isWaitingOnOcclusionQuery = false;
|
||||
// this.occlusionResult.clear();
|
||||
// this.sortedWorldRenderers[var1].isVisible = this.occlusionResult.get(0) != 0;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
private int renderSortedRenderers(int var1, int var2, int var3) {
|
||||
int var4 = 0;
|
||||
|
@ -595,7 +595,9 @@ public final class RenderGlobal implements IWorldAccess {
|
|||
var6 = Block.stone;
|
||||
}
|
||||
|
||||
GL11.flipLightMatrix();
|
||||
this.globalRenderBlocks.renderBlockUsingTexture(var6, var1.blockX, var1.blockY, var1.blockZ, 240 + (int)(this.damagePartialTime * 10.0F));
|
||||
GL11.flipLightMatrix();
|
||||
var4.draw();
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDepthMask(true);
|
||||
|
|
|
@ -24,6 +24,8 @@ public class Tessellator {
|
|||
private double zOffset;
|
||||
public static final Tessellator instance = new Tessellator(285000);
|
||||
private boolean isDrawing = false;
|
||||
private boolean hasNormals = false;
|
||||
private int normal;
|
||||
|
||||
private Tessellator(int par1) {
|
||||
ArrayBuffer a = ArrayBuffer.create(par1 * 4);
|
||||
|
@ -51,6 +53,10 @@ public class Tessellator {
|
|||
GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
if (this.hasNormals) {
|
||||
GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY);
|
||||
}
|
||||
|
||||
GL11.glDrawArrays(this.drawMode, 0, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 7));
|
||||
|
||||
if (this.hasTexture) {
|
||||
|
@ -60,6 +66,10 @@ public class Tessellator {
|
|||
if (this.hasColor) {
|
||||
GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
if (this.hasNormals) {
|
||||
GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
int var1 = this.rawBufferIndex * 4;
|
||||
|
@ -95,6 +105,7 @@ public class Tessellator {
|
|||
this.isDrawing = true;
|
||||
this.reset();
|
||||
this.drawMode = par1;
|
||||
this.hasNormals = false;
|
||||
this.hasColor = false;
|
||||
this.hasTexture = false;
|
||||
this.isColorDisabled = false;
|
||||
|
@ -208,6 +219,10 @@ public class Tessellator {
|
|||
intBuffer0.set(bufferIndex + 5, this.color);
|
||||
}
|
||||
|
||||
if (this.hasNormals) {
|
||||
intBuffer0.set(bufferIndex + 6, this.normal);
|
||||
}
|
||||
|
||||
this.rawBufferIndex += 7;
|
||||
}
|
||||
|
||||
|
@ -244,6 +259,11 @@ public class Tessellator {
|
|||
* Sets the normal for the current draw call.
|
||||
*/
|
||||
public void setNormal(float par1, float par2, float par3) {
|
||||
GL11.glNormal3f(par1, par2, par3);
|
||||
this.hasNormals = true;
|
||||
float len = (float) Math.sqrt(par1 * par1 + par2 * par2 + par3 * par3);
|
||||
int var4 = (int)((par1 / len) * 125.0F) + 125;
|
||||
int var5 = (int)((par2 / len) * 125.0F) + 125;
|
||||
int var6 = (int)((par3 / len) * 125.0F) + 125;
|
||||
this.normal = var4 & 255 | (var5 & 255) << 8 | (var6 & 255) << 16;
|
||||
}
|
||||
}
|
|
@ -29,8 +29,6 @@ public final class WorldRenderer {
|
|||
private AxisAlignedBB rendererBoundingBox;
|
||||
private RenderBlocks renderBlocks;
|
||||
public boolean isVisible = true;
|
||||
public boolean isWaitingOnOcclusionQuery;
|
||||
public int glOcclusionQuery;
|
||||
|
||||
public WorldRenderer(World var1, int var2, int var3, int var4, int var5, int var6) {
|
||||
this.renderBlocks = new RenderBlocks(var1);
|
||||
|
@ -140,8 +138,4 @@ public final class WorldRenderer {
|
|||
public final void updateInFrustrum(ICamera var1) {
|
||||
this.isInFrustrum = var1.isBoundingBoxInFrustrum(this.rendererBoundingBox);
|
||||
}
|
||||
|
||||
public final void callOcclusionQueryList() {
|
||||
GL11.glCallList(this.glRenderList + 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public abstract class Render {
|
|||
float var7 = var3;
|
||||
float var6 = var2;
|
||||
Render var27 = this;
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glAlphaFunc(516, 0.1F);
|
||||
RenderEngine var10 = this.renderManager.renderEngine;
|
||||
RenderEngine.bindTexture(var10.getTexture("%clamp%/shadow.png"));
|
||||
World var11 = this.renderManager.worldObj;
|
||||
|
@ -172,7 +172,9 @@ public abstract class Render {
|
|||
}
|
||||
|
||||
var35.draw();
|
||||
GL11.flipLightMatrix();
|
||||
GL11.glPopMatrix();
|
||||
GL11.flipLightMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ public final class RenderArrow extends Render {
|
|||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_NORMALIZE);
|
||||
GL11.flipLightMatrix();
|
||||
GL11.glPopMatrix();
|
||||
GL11.flipLightMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ public final class RenderEntity extends Render {
|
|||
public final void doRender(Entity var1, float var2, float var3, float var4, float var5, float var6) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(var2 - var1.lastTickPosX, var3 - var1.lastTickPosY, var4 - var1.lastTickPosZ);
|
||||
GL11.flipLightMatrix();
|
||||
renderOffsetAABB(var1.boundingBox);
|
||||
GL11.flipLightMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,9 @@ public final class RenderItem extends Render {
|
|||
GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.flipLightMatrix();
|
||||
this.renderBlocks.renderBlockOnInventory(var8);
|
||||
GL11.flipLightMatrix();
|
||||
GL11.glPopMatrix();
|
||||
} else {
|
||||
if(var2.getItem().getIconIndex() >= 0) {
|
||||
|
@ -155,7 +157,9 @@ public final class RenderItem extends Render {
|
|||
GL11.glTranslatef(var4, var5, var6);
|
||||
}
|
||||
|
||||
GL11.flipLightMatrix();
|
||||
var12.renderBlocks.renderBlockOnInventory(Block.blocksList[var7.itemID]);
|
||||
GL11.flipLightMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
} else {
|
||||
|
@ -189,7 +193,9 @@ public final class RenderItem extends Render {
|
|||
var15.addVertexWithUV(0.5F, -0.25F, 0.0F, var5, var2);
|
||||
var15.addVertexWithUV(0.5F, 12.0F / 16.0F, 0.0F, var5, var6);
|
||||
var15.addVertexWithUV(-0.5F, 12.0F / 16.0F, 0.0F, var4, var6);
|
||||
GL11.flipLightMatrix();
|
||||
var15.draw();
|
||||
GL11.flipLightMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.PeytonPlayz585.math.MathHelper;
|
|||
import net.PeytonPlayz585.nbt.NBTTagCompound;
|
||||
import net.PeytonPlayz585.nbt.NBTTagFloat;
|
||||
import net.PeytonPlayz585.nbt.NBTTagList;
|
||||
import net.PeytonPlayz585.storage.LevelStorageManager;
|
||||
import net.minecraft.game.entity.misc.EntityItem;
|
||||
import net.minecraft.game.entity.player.EntityPlayer;
|
||||
import net.minecraft.game.item.ItemStack;
|
||||
|
@ -65,8 +66,12 @@ public abstract class Entity {
|
|||
|
||||
public Entity(World var1) {
|
||||
this.worldObj = var1;
|
||||
if(this instanceof EntityPlayer && LevelStorageManager.levelStorage != null) {
|
||||
this.setPosition(LevelStorageManager.levelStorage.getFloat("player-x"), LevelStorageManager.levelStorage.getFloat("player-y"), LevelStorageManager.levelStorage.getFloat("player-z"));
|
||||
} else {
|
||||
this.setPosition(0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
|
||||
protected void preparePlayerToSpawn() {
|
||||
if(this.worldObj != null) {
|
||||
|
@ -74,7 +79,11 @@ public abstract class Entity {
|
|||
float var2 = (float)this.worldObj.ySpawn;
|
||||
|
||||
for(float var3 = (float)this.worldObj.zSpawn + 0.5F; var2 > 0.0F; ++var2) {
|
||||
if(this instanceof EntityPlayer && LevelStorageManager.levelStorage != null) {
|
||||
this.setPosition(LevelStorageManager.levelStorage.getFloat("player-x"), LevelStorageManager.levelStorage.getFloat("player-y"), LevelStorageManager.levelStorage.getFloat("player-z"));
|
||||
} else {
|
||||
this.setPosition(var1, var2, var3);
|
||||
}
|
||||
if(this.worldObj.getCollidingBoundingBoxes(this.boundingBox).size() == 0) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
package net.minecraft.game.level;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Iterator;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import net.PeytonPlayz585.nbt.NBTBase;
|
||||
import net.PeytonPlayz585.nbt.NBTTagCompound;
|
||||
import net.PeytonPlayz585.nbt.NBTTagList;
|
||||
import net.PeytonPlayz585.nbt.NBTTagShort;
|
||||
import net.minecraft.client.LoadingScreenRenderer;
|
||||
import net.PeytonPlayz585.storage.LevelStorageManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.game.entity.Entity;
|
||||
import net.minecraft.game.entity.EntityPainting;
|
||||
import net.minecraft.game.entity.animal.EntityPig;
|
||||
|
@ -26,25 +23,31 @@ import net.minecraft.game.level.block.Block;
|
|||
import net.minecraft.game.level.block.tileentity.TileEntity;
|
||||
import net.minecraft.game.level.block.tileentity.TileEntityChest;
|
||||
import net.minecraft.game.level.block.tileentity.TileEntityFurnace;
|
||||
import util.IProgressUpdate;
|
||||
|
||||
public abstract class LevelLoader {
|
||||
private IProgressUpdate guiLoading;
|
||||
public class LevelLoader {
|
||||
|
||||
public LevelLoader(IProgressUpdate var1) {
|
||||
this.guiLoading = var1;
|
||||
public final World load() {
|
||||
String[] randomText = new String[]{"Hi from PeytonPlayz585", "You Eagler!", "Setting up World", ":)", "Isn't Indev the best version?", "I hate Microsoft!", "Notch is the best!", "PeytonPlayz585!", "Random text lol...", "Spam ping Winix!", "Ghost ping Winix!", "DM Winix for no reason!", "Spam ping Winix lol!", "Ghost ping Winix!", "DM Winix for no reason!", "PeytonPlayz585's Birthday is 10/11", "Yee!", "WebGL 2.0!", "ShadowCraft!"};
|
||||
Minecraft.getMinecraft().loadingScreen.displayProgressMessage("Loading level");
|
||||
Minecraft.getMinecraft().loadingScreen.displayLoadingString(randomText[(int)(Math.random() * (double)randomText.length)]);
|
||||
Minecraft.getMinecraft().loadingScreen.setLoadingProgress(25);
|
||||
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
public final World load(InputStream var1) throws IOException {
|
||||
if(this.guiLoading != null) {
|
||||
this.guiLoading.displayProgressMessage("Loading level");
|
||||
Minecraft.getMinecraft().loadingScreen.displayLoadingString("Reading..");
|
||||
Minecraft.getMinecraft().loadingScreen.setLoadingProgress(50);
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(this.guiLoading != null) {
|
||||
this.guiLoading.displayLoadingString("Reading..");
|
||||
}
|
||||
|
||||
NBTTagCompound var13 = LoadingScreenRenderer.writeLevelTags(var1);
|
||||
NBTTagCompound var13 = LevelStorageManager.levelStorage;
|
||||
NBTTagCompound var2 = var13.getCompoundTag("About");
|
||||
NBTTagCompound var3 = var13.getCompoundTag("Map");
|
||||
NBTTagCompound var4 = var13.getCompoundTag("Environment");
|
||||
|
@ -53,8 +56,13 @@ public abstract class LevelLoader {
|
|||
short var7 = var3.getShort("Length");
|
||||
short var8 = var3.getShort("Height");
|
||||
World var9 = new World();
|
||||
if(this.guiLoading != null) {
|
||||
this.guiLoading.displayLoadingString("Preparing level..");
|
||||
Minecraft.getMinecraft().loadingScreen.displayLoadingString("Preparing level..");
|
||||
Minecraft.getMinecraft().loadingScreen.setLoadingProgress(75);
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
NBTTagList var10 = var3.getTagList("Spawn");
|
||||
|
@ -83,8 +91,13 @@ public abstract class LevelLoader {
|
|||
var9.worldTime = var4.getShort("TimeOfDay");
|
||||
var9.skylightSubtracted = var9.getSkyBrightness();
|
||||
var9.generate(var6, var8, var7, var3.getByteArray("Blocks"), var3.getByteArray("Data"));
|
||||
if(this.guiLoading != null) {
|
||||
this.guiLoading.displayLoadingString("Preparing entities..");
|
||||
Minecraft.getMinecraft().loadingScreen.displayLoadingString("Preparing entities..");
|
||||
Minecraft.getMinecraft().loadingScreen.setLoadingProgress(100);
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for(int var16 = 0; var16 < var5.tagCount(); ++var16) {
|
||||
|
@ -134,14 +147,16 @@ public abstract class LevelLoader {
|
|||
return (Entity)(var2.equals("Pig") ? new EntityPig(var1) : (var2.equals("Sheep") ? new EntitySheep(var1) : (var2.equals("Creeper") ? new EntityCreeper(var1) : (var2.equals("Skeleton") ? new EntitySkeleton(var1) : (var2.equals("Spider") ? new EntitySpider(var1) : (var2.equals("Zombie") ? new EntityZombie(var1) : (var2.equals("Giant") ? new EntityGiantZombie(var1) : (var2.equals("Item") ? new EntityItem(var1) : (var2.equals("Painting") ? new EntityPainting(var1) : null)))))))));
|
||||
}
|
||||
|
||||
public final void save(World var1, OutputStream var2) throws IOException {
|
||||
if(this.guiLoading != null) {
|
||||
this.guiLoading.displayProgressMessage("Saving level");
|
||||
}
|
||||
public final void save() {
|
||||
// if(this.guiLoading != null) {
|
||||
// this.guiLoading.displayProgressMessage("Saving level");
|
||||
// }
|
||||
|
||||
if(this.guiLoading != null) {
|
||||
this.guiLoading.displayLoadingString("Preparing level..");
|
||||
}
|
||||
// if(this.guiLoading != null) {
|
||||
// this.guiLoading.displayLoadingString("Preparing level..");
|
||||
// }
|
||||
|
||||
World var1 = Minecraft.getMinecraft().theWorld;
|
||||
|
||||
NBTTagCompound var3 = new NBTTagCompound();
|
||||
var3.setInteger("CloudColor", var1.cloudColor);
|
||||
|
@ -169,12 +184,12 @@ public abstract class LevelLoader {
|
|||
var15.setString("Author", var1.authorName);
|
||||
var15.setString("Name", var1.name);
|
||||
var15.setLong("CreatedOn", var1.createTime);
|
||||
if(this.guiLoading != null) {
|
||||
this.guiLoading.displayLoadingString("Preparing entities..");
|
||||
}
|
||||
// if(this.guiLoading != null) {
|
||||
// this.guiLoading.displayLoadingString("Preparing entities..");
|
||||
// }
|
||||
|
||||
NBTTagList var6 = new NBTTagList();
|
||||
Iterator var7 = var1.entityMap.entities.iterator();
|
||||
Iterator<?> var7 = var1.entityMap.entities.iterator();
|
||||
|
||||
while(var7.hasNext()) {
|
||||
Entity var8 = (Entity)var7.next();
|
||||
|
@ -186,7 +201,7 @@ public abstract class LevelLoader {
|
|||
}
|
||||
|
||||
NBTTagList var16 = new NBTTagList();
|
||||
Iterator var17 = var1.map.keySet().iterator();
|
||||
Iterator<?> var17 = var1.map.keySet().iterator();
|
||||
|
||||
while(var17.hasNext()) {
|
||||
int var19 = ((Integer)var17.next()).intValue();
|
||||
|
@ -204,18 +219,27 @@ public abstract class LevelLoader {
|
|||
var18.setCompoundTag("Environment", var3);
|
||||
var18.setTag("Entities", var6);
|
||||
var18.setTag("TileEntities", var16);
|
||||
if(this.guiLoading != null) {
|
||||
this.guiLoading.displayLoadingString("Writing..");
|
||||
}
|
||||
|
||||
NBTTagCompound var13 = var18;
|
||||
DataOutputStream var14 = new DataOutputStream(new GZIPOutputStream(var2));
|
||||
var18.setFloat("player-x", Minecraft.getMinecraft().thePlayer.posX);
|
||||
var18.setFloat("player-y", Minecraft.getMinecraft().thePlayer.posY);
|
||||
var18.setFloat("player-z", Minecraft.getMinecraft().thePlayer.posZ);
|
||||
|
||||
Minecraft.getMinecraft().thePlayer.writeEntityToNBT(var18);
|
||||
|
||||
// if(this.guiLoading != null) {
|
||||
// this.guiLoading.displayLoadingString("Writing..");
|
||||
// }
|
||||
|
||||
LevelStorageManager.levelStorage = var18;
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
NBTBase.writeTag(var13, var14);
|
||||
} finally {
|
||||
var14.close();
|
||||
LevelStorageManager.saveLevelData();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}).run();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package net.minecraft.game.level.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.game.level.World;
|
||||
import net.minecraft.game.level.material.Material;
|
||||
import net.minecraft.game.physics.AxisAlignedBB;
|
||||
|
@ -94,18 +97,28 @@ public final class BlockFarmland extends Block {
|
|||
++var10;
|
||||
}
|
||||
|
||||
if(!var10000) {
|
||||
var1.setBlockWithNotify(var2, var3, var4, Block.dirt.blockID);
|
||||
}
|
||||
/*
|
||||
* There is no way to obtain water in this version
|
||||
* And it's really annoying to have to walk back and forth between your base and where you planted your crops
|
||||
* So I removed it :)
|
||||
*/
|
||||
|
||||
// if(!var10000) {
|
||||
// var1.setBlockWithNotify(var2, var3, var4, Block.dirt.blockID);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final void onEntityWalking(World var1, int var2, int var3, int var4) {
|
||||
if(var1.random.nextInt(4) == 0) {
|
||||
var1.setBlockWithNotify(var2, var3, var4, Block.dirt.blockID);
|
||||
}
|
||||
/*
|
||||
* This is bugged and really annoying
|
||||
* So I also removed this too :)
|
||||
*/
|
||||
|
||||
//if(var1.random.nextInt(4) == 0) {
|
||||
//var1.setBlockWithNotify(var2, var3, var4, Block.dirt.blockID);
|
||||
//}
|
||||
}
|
||||
|
||||
public final void onNeighborBlockChange(World var1, int var2, int var3, int var4, int var5) {
|
||||
|
|
|
@ -65,9 +65,8 @@ import net.PeytonPlayz585.math.MathHelper;
|
|||
import net.PeytonPlayz585.minecraft.AssetRepository;
|
||||
import net.PeytonPlayz585.minecraft.Base64;
|
||||
import net.PeytonPlayz585.minecraft.MinecraftImage;
|
||||
import net.PeytonPlayz585.storage.IndexedDBFilesystem;
|
||||
import net.PeytonPlayz585.storage.LocalStorageManager;
|
||||
//import net.PeytonPlayz585.teavm.IndexedDBFilesystem;
|
||||
//import net.PeytonPlayz585.teavm.IndexedDBFilesystem.OpenState;
|
||||
import net.PeytonPlayz585.teavm.WebGL2RenderingContext;
|
||||
import net.PeytonPlayz585.teavm.WebGLQuery;
|
||||
import net.PeytonPlayz585.teavm.WebGLVertexArray;
|
||||
|
@ -116,7 +115,7 @@ public class WebGL {
|
|||
}
|
||||
}
|
||||
|
||||
public static void onWindowUnload() {
|
||||
public static void onWindowUnload() throws IOException {
|
||||
LocalStorageManager.saveStorageG();
|
||||
LocalStorageManager.saveStorageP();
|
||||
}
|
||||
|
@ -319,15 +318,15 @@ public class WebGL {
|
|||
onBeforeCloseRegister();
|
||||
initFileChooser();
|
||||
|
||||
// OpenState st = IndexedDBFilesystem.initialize();
|
||||
// if(st != OpenState.OPENED) {
|
||||
// if(st == OpenState.LOCKED) {
|
||||
// MinecraftMain.showDatabaseLockedScreen("\nError: World folder is locked!\n\nYou are already playing Minecraft in a different Window.\nClose all other Minecraft instances and reload");
|
||||
// }else {
|
||||
// MinecraftMain.showDatabaseLockedScreen("\nError: World folder could not be loaded!\n\n" + IndexedDBFilesystem.errorDetail());
|
||||
// }
|
||||
// throw new MinecraftMain.AbortedLaunchException();
|
||||
// }
|
||||
IndexedDBFilesystem.OpenState st = IndexedDBFilesystem.initialize();
|
||||
if(st != IndexedDBFilesystem.OpenState.OPENED) {
|
||||
if(st == IndexedDBFilesystem.OpenState.LOCKED) {
|
||||
MinecraftMain.showDatabaseLockedScreen("\nError: World folder is locked!\n\nYou are already playing Minecraft in a different Window.\nClose all other Minecraft instances and reload");
|
||||
}else {
|
||||
MinecraftMain.showDatabaseLockedScreen("\nError: World folder could not be loaded!\n\n" + IndexedDBFilesystem.errorDetail());
|
||||
}
|
||||
throw new MinecraftMain.AbortedLaunchException();
|
||||
}
|
||||
|
||||
downloadAssetPack(assetPackageURI);
|
||||
|
||||
|
@ -1887,57 +1886,57 @@ public class WebGL {
|
|||
@JSBody(params = { "obj" }, script = "return typeof obj === \"string\";")
|
||||
private static native boolean isString(JSObject obj);
|
||||
|
||||
// public static final boolean fileExists(String 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 boolean fileExists(String path) {
|
||||
return IndexedDBFilesystem.fileExists(path);
|
||||
}
|
||||
|
||||
// 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 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 {
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user