TeaVM 0.6.1, No Fucking Lag!

This commit is contained in:
LAX1DUDE 2022-07-29 16:48:06 -07:00
parent 8d31000bd1
commit aa02e00ca3
59 changed files with 34195 additions and 283696 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,30 +1,4 @@
buildscript {
repositories {
flatDir {
dirs "deps"
}
}
dependencies {
classpath name: "gson-2.2.4"
classpath name: "joda-time-2.7"
classpath name: "jzlib-1.1.3"
classpath name: "teavm-classlib-0.7.0-SNAPSHOT"
classpath name: "teavm-interop-0.7.0-SNAPSHOT"
classpath name: "teavm-jso-0.7.0-SNAPSHOT"
classpath name: "teavm-jso-apis-0.7.0-SNAPSHOT"
classpath name: "teavm-jso-impl-0.7.0-SNAPSHOT"
classpath name: "teavm-platform-0.7.0-SNAPSHOT"
classpath name: "teavm-metaprogramming-api-0.7.0-SNAPSHOT"
classpath name: "teavm-metaprogramming-impl-0.7.0-SNAPSHOT"
classpath name: "teavm-core-0.7.0-SNAPSHOT"
classpath name: "teavm-tooling-0.7.0-SNAPSHOT"
classpath name: "teavm-cli-0.6.1"
classpath name: "teavm-gradle-plugin-1.0.0-patched"
}
}
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "io.github.zebalu.teavm-gradle-plugin"
@ -47,18 +21,39 @@ repositories {
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'io.github.zebalu:teavm-gradle-plugin:1.0.0'
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'io.github.zebalu.teavm-gradle-plugin'
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
main {
java {
srcDir "src/main/java"
srcDir "src/ipc/java"
}
}
}
repositories {
jcenter()
}
dependencies {
implementation name: "gson-2.2.4"
implementation name: "joda-time-2.7"
implementation name: "jzlib-1.1.3"
implementation name: "teavm-classlib-0.7.0-SNAPSHOT"
implementation name: "teavm-interop-0.7.0-SNAPSHOT"
implementation name: "teavm-jso-0.7.0-SNAPSHOT"
implementation name: "teavm-jso-apis-0.7.0-SNAPSHOT"
implementation name: "teavm-jso-impl-0.7.0-SNAPSHOT"
implementation name: "teavm-platform-0.7.0-SNAPSHOT"
implementation name: "teavm-metaprogramming-api-0.7.0-SNAPSHOT"
implementation name: "teavm-metaprogramming-impl-0.7.0-SNAPSHOT"
implementation 'org.teavm:teavm-platform:0.6.1'
implementation 'org.teavm:teavm-classlib:0.6.1'
}
teavm {
@ -90,7 +85,7 @@ teavm {
classesToPreserve = null;
stopOnErrors = false;
optimizationLevel = "FULL"; //org.teavm.vm.TeaVMOptimizationLevel.SIMPLE;
optimizationLevel = "ADVANCED"; //org.teavm.vm.TeaVMOptimizationLevel.SIMPLE;
fastGlobalAnalysis = false;
targetType = "JAVASCRIPT"; //org.teavm.tooling.TeaVMTargetType.JAVASCRIPT;
cacheDirectory = null;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,79 @@
package net.lax1dude.eaglercraft.sp;
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

@ -304,43 +304,48 @@ public class IntegratedServer {
break;
case IPCPacket07ImportWorld.ID: {
IPCPacket07ImportWorld pkt = (IPCPacket07ImportWorld)packet;
if(pkt.worldFormat == IPCPacket07ImportWorld.WORLD_FORMAT_EAG) {
try {
String folder = VFSSaveHandler.worldNameToFolderName(pkt.worldName);
VFile dir = new VFile("worlds", folder);
EPKDecompiler dc = new EPKDecompiler(pkt.worldData);
EPKDecompiler.FileEntry f = null;
int lastProgUpdate = 0;
int prog = 0;
while((f = dc.readFile()) != null) {
byte[] b = f.data;
if(f.name.equals("level.dat")) {
NBTTagCompound worldDatNBT = CompressedStreamTools.decompress(b);
worldDatNBT.getCompoundTag("Data").setString("LevelName", pkt.worldName);
worldDatNBT.getCompoundTag("Data").setLong("LastPlayed", System.currentTimeMillis());
b = CompressedStreamTools.compress(worldDatNBT);
if(isServerStopped()) {
if(pkt.worldFormat == IPCPacket07ImportWorld.WORLD_FORMAT_EAG) {
try {
String folder = VFSSaveHandler.worldNameToFolderName(pkt.worldName);
VFile dir = new VFile("worlds", folder);
EPKDecompiler dc = new EPKDecompiler(pkt.worldData);
EPKDecompiler.FileEntry f = null;
int lastProgUpdate = 0;
int prog = 0;
while((f = dc.readFile()) != null) {
byte[] b = f.data;
if(f.name.equals("level.dat")) {
NBTTagCompound worldDatNBT = CompressedStreamTools.decompress(b);
worldDatNBT.getCompoundTag("Data").setString("LevelName", pkt.worldName);
worldDatNBT.getCompoundTag("Data").setLong("LastPlayed", System.currentTimeMillis());
b = CompressedStreamTools.compress(worldDatNBT);
}
VFile ff = new VFile(dir, f.name);
ff.setAllBytes(b);
prog += b.length;
if(prog - lastProgUpdate > 10000) {
lastProgUpdate = prog;
updateStatusString("selectWorld.progress.importing." + pkt.worldFormat, prog);
}
}
VFile ff = new VFile(dir, f.name);
ff.setAllBytes(b);
prog += b.length;
if(prog - lastProgUpdate > 10000) {
lastProgUpdate = prog;
updateStatusString("selectWorld.progress.importing." + pkt.worldFormat, prog);
String[] worldsTxt = SYS.VFS.getFile("worlds.txt").getAllLines();
if(worldsTxt == null || worldsTxt.length <= 0) {
worldsTxt = new String[] { folder };
}else {
String[] tmp = worldsTxt;
worldsTxt = new String[worldsTxt.length + 1];
System.arraycopy(tmp, 0, worldsTxt, 0, tmp.length);
worldsTxt[worldsTxt.length - 1] = folder;
}
SYS.VFS.getFile("worlds.txt").setAllChars(String.join("\n", worldsTxt));
sendIPCPacket(new IPCPacketFFProcessKeepAlive(IPCPacket07ImportWorld.ID));
}catch(Throwable t) {
throwExceptionToClient("Failed to import world '" + pkt.worldName + "' as EPK", t);
sendTaskFailed();
}
String[] worldsTxt = SYS.VFS.getFile("worlds.txt").getAllLines();
if(worldsTxt == null || worldsTxt.length <= 0) {
worldsTxt = new String[] { folder };
}else {
String[] tmp = worldsTxt;
worldsTxt = new String[worldsTxt.length + 1];
System.arraycopy(tmp, 0, worldsTxt, 0, tmp.length);
worldsTxt[worldsTxt.length - 1] = folder;
}
SYS.VFS.getFile("worlds.txt").setAllChars(String.join("\n", worldsTxt));
sendIPCPacket(new IPCPacketFFProcessKeepAlive(IPCPacket07ImportWorld.ID));
}catch(Throwable t) {
throwExceptionToClient("Failed to import world '" + pkt.worldName + "' as EPK", t);
}else {
System.err.println("Client tried to import a world in an unknown format: 0x" + Integer.toHexString(pkt.worldFormat));
sendTaskFailed();
}
}else {
@ -496,7 +501,7 @@ public class IntegratedServer {
continue;
}
if(!msg.channel.startsWith("NET|") || currentProcess == null) {
System.err.println("Unknown ICP channel: '" + msg.channel + "' passed " + msg.data.length + " bytes");
//System.err.println("Unknown ICP channel: '" + msg.channel + "' passed " + msg.data.length + " bytes");
continue;
}
String u = msg.channel.substring(4);
@ -553,18 +558,8 @@ public class IntegratedServer {
@JSBody(params = { "wb" }, script = "onmessage = function(o) { wb(o.data.ch, o.data.dat); };")
private static native void registerPacketHandler(WorkerBinaryPacketHandler wb);
@JSBody(script = "return (((typeof window) !== \"undefined\") && ((typeof window.testScript) !== \"undefined\")) ? window.testScript : null;")
private static native String shouldLaunchTest();
public static void main(String[] args) {
String test = shouldLaunchTest();
if(test != null) {
WorkerTest.init(test);
return;
}
registerPacketHandler(new WorkerBinaryPacketHandlerImpl());
isRunning = true;

View File

@ -24,7 +24,6 @@ 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.IDBObjectStore;
import org.teavm.jso.indexeddb.IDBObjectStoreParameters;
import org.teavm.jso.indexeddb.IDBOpenDBRequest;
import org.teavm.jso.indexeddb.IDBRequest;
@ -489,7 +488,7 @@ public class VirtualFilesystem {
f.setOnUpgradeNeeded(new EventListener<IDBVersionChangeEvent>() {
@Override
public void handleEvent(IDBVersionChangeEvent evt) {
f.getResult().createObjectStore("filesystem", IDBObjectStoreParameters.create().keyPath("path"));
IDBObjectStorePatched.createObjectStorePatch(f.getResult(), "filesystem", IDBObjectStoreParameters.create().keyPath("path"));
}
});
}
@ -499,7 +498,7 @@ public class VirtualFilesystem {
private static void deleteFile(IDBDatabase db, String name, final AsyncCallback<BooleanResult> cb) {
IDBTransaction tx = db.transaction("filesystem", "readwrite");
final IDBRequest r = tx.objectStore("filesystem").delete(makeTheFuckingKeyWork(name));
final IDBRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").delete(makeTheFuckingKeyWork(name));
r.setOnSuccess(new EventHandler() {
@Override
@ -526,7 +525,7 @@ public class VirtualFilesystem {
private static void readWholeFile(IDBDatabase db, String name, final AsyncCallback<ArrayBuffer> cb) {
IDBTransaction tx = db.transaction("filesystem", "readonly");
final IDBGetRequest r = tx.objectStore("filesystem").get(makeTheFuckingKeyWork(name));
final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name));
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent() {
@ -553,7 +552,7 @@ public class VirtualFilesystem {
private static void iterateFiles(IDBDatabase db, final VirtualFilesystem vfs, final String prefix, boolean rw, final VFSIterator itr, final AsyncCallback<Integer> cb) {
IDBTransaction tx = db.transaction("filesystem", rw ? "readwrite" : "readonly");
final IDBCursorRequest r = tx.objectStore("filesystem").openCursor();
final IDBCursorRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").openCursor();
final int[] res = new int[1];
r.setOnSuccess(new EventHandler() {
@Override
@ -591,7 +590,7 @@ public class VirtualFilesystem {
private static void deleteFiles(IDBDatabase db, final String prefix, final AsyncCallback<Integer> cb) {
IDBTransaction tx = db.transaction("filesystem", "readwrite");
final IDBCursorRequest r = tx.objectStore("filesystem").openCursor();
final IDBCursorRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").openCursor();
final int[] res = new int[1];
r.setOnSuccess(new EventHandler() {
@Override
@ -624,7 +623,7 @@ public class VirtualFilesystem {
private static void fileExists(IDBDatabase db, String name, final AsyncCallback<BooleanResult> cb) {
IDBTransaction tx = db.transaction("filesystem", "readonly");
final IDBCountRequest r = tx.objectStore("filesystem").count(makeTheFuckingKeyWork(name));
final IDBCountRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").count(makeTheFuckingKeyWork(name));
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent() {
@ -647,7 +646,7 @@ public class VirtualFilesystem {
private static void writeWholeFile(IDBDatabase db, String name, ArrayBuffer data, final AsyncCallback<BooleanResult> cb) {
IDBTransaction tx = db.transaction("filesystem", "readwrite");
final IDBRequest r = tx.objectStore("filesystem").put(writeRow(name, data));
final IDBRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").put(writeRow(name, data));
r.setOnSuccess(new EventHandler() {
@Override

View File

@ -1,169 +0,0 @@
package net.lax1dude.eaglercraft.sp;
import java.io.IOException;
import java.util.LinkedList;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSFunctor;
import org.teavm.jso.JSObject;
import org.teavm.jso.browser.Window;
import org.teavm.jso.dom.events.ErrorEvent;
import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.dom.html.HTMLDocument;
import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import org.teavm.jso.workers.Worker;
import net.lax1dude.eaglercraft.sp.ipc.*;
public class WorkerTest {
private static final LinkedList<PKT> messageQueue = new LinkedList();
private static boolean isAlive = false;
private static boolean isLoading = false;
protected static class PKT {
protected final String channel;
protected final byte[] data;
protected PKT(String channel, byte[] data) {
this.channel = channel;
this.data = data;
}
}
public static Worker server = null;
@JSFunctor
private static interface WorkerBinaryPacketHandler extends JSObject {
public void onMessage(String channel, ArrayBuffer buf);
}
private static class WorkerBinaryPacketHandlerImpl implements WorkerBinaryPacketHandler {
public void onMessage(String channel, ArrayBuffer buf) {
if(channel == null) {
System.err.println("Recieved IPC packet with null channel");
return;
}
if(buf == null) {
System.err.println("Recieved IPC packet with null buffer");
return;
}
Uint8Array a = Uint8Array.create(buf);
byte[] pkt = new byte[a.getLength()];
for(int i = 0; i < pkt.length; ++i) {
pkt[i] = (byte) a.get(i);
}
messageQueue.add(new PKT(channel, pkt));
}
}
@JSBody(params = { "w", "wb" }, script = "w.onmessage = function(o) { wb(o.data.ch, o.data.dat); };")
private static native void registerPacketHandler(Worker w, WorkerBinaryPacketHandler wb);
@JSBody(params = { "w", "ch", "dat" }, script = "w.postMessage({ ch: ch, dat : dat });")
private static native void sendWorkerPacket(Worker w, String channel, ArrayBuffer arr);
public static void sendIPCPacket(IPCPacketBase pkt) {
byte[] serialized;
try {
serialized = IPCPacketManager.IPCSerialize(pkt);
} catch (IOException e) {
System.err.println("Could not serialize IPC packet 0x" + Integer.toHexString(pkt.id()) + " class '" + pkt.getClass().getSimpleName() + "'");
e.printStackTrace();
return;
}
ArrayBuffer arb = ArrayBuffer.create(serialized.length);
Uint8Array ar = Uint8Array.create(arb);
ar.set(serialized);
sendWorkerPacket(server, "IPC", arb);
}
public static void init(String path) {
server = Worker.create(path);
server.onError(new EventListener<ErrorEvent>() {
@Override
public void handleEvent(ErrorEvent evt) {
System.err.println("Worker Error: " + evt.getError());
}
});
registerPacketHandler(server, new WorkerBinaryPacketHandlerImpl());
while(true) {
while(messageQueue.size() > 0) {
PKT p = messageQueue.remove(0);
if(p.channel.equals("IPC")) {
IPCPacketBase packet;
try {
packet = IPCPacketManager.IPCDeserialize(p.data);
}catch(IOException e) {
System.err.print("Failed to deserialize IPC packet: ");
e.printStackTrace();
return;
}
int id = packet.id();
try {
switch(id) {
case IPCPacketFFProcessKeepAlive.ID: {
isAlive = true;
}
break;
case IPCPacket15ThrowException.ID: {
IPCPacket15ThrowException pkt = (IPCPacket15ThrowException)packet;
System.err.println("Server Exception: " + pkt.errorMessage);
for(String s : pkt.stackTrace) {
System.err.println(" " + s);
}
}
break;
case IPCPacket0DProgressUpdate.ID: {
IPCPacket0DProgressUpdate pkt = (IPCPacket0DProgressUpdate)packet;
System.out.println("Progress: " + pkt.updateMessage + " (" + (int)(100 * pkt.updateProgress) + "/100)");
}
break;
default:
System.err.println("IPC packet type 0x" + Integer.toHexString(id) + " class '" + packet.getClass().getSimpleName() + "' was not handled");
break;
}
}catch(Throwable t) {
System.err.println("fuck");
t.printStackTrace();
}
}
}
if(isAlive && !isLoading) {
isLoading = true;
HTMLDocument doc = Window.current().getDocument();
String[] stat = doc.getElementById("str_STAT_GUID").getInnerText().split("\n");
String[] lang = doc.getElementById("str_LOCALE").getInnerText().split("\n");
sendIPCPacket(new IPCPacket14StringList(IPCPacket14StringList.STAT_GUID, stat));
sendIPCPacket(new IPCPacket14StringList(IPCPacket14StringList.LOCALE, lang));
sendIPCPacket(new IPCPacket02InitWorld("eagler", 1, 0, "", 6969696969696969l, true, true, true));
sendIPCPacket(new IPCPacket00StartServer("eagler", "LAX1DUDE", 0));
}
try {
Thread.sleep(1l); // allow some async to occur
}catch(InterruptedException e) {
System.err.println("you eagler");
}
}
}
}

View File

@ -20,119 +20,168 @@ public class AchievementList {
public static List achievementList = new ArrayList();
/** Is the 'open inventory' achievement. */
public static Achievement openInventory = (new Achievement(0, "openInventory", 0, 0, Item.book, (Achievement) null))
.setIndependent().registerAchievement();
public static Achievement openInventory = null;
/** Is the 'getting wood' achievement. */
public static Achievement mineWood = (new Achievement(1, "mineWood", 2, 1, Block.wood, openInventory))
.registerAchievement();
public static Achievement mineWood = null;
/** Is the 'benchmarking' achievement. */
public static Achievement buildWorkBench = (new Achievement(2, "buildWorkBench", 4, -1, Block.workbench, mineWood))
.registerAchievement();
public static Achievement buildWorkBench = null;
/** Is the 'time to mine' achievement. */
public static Achievement buildPickaxe = (new Achievement(3, "buildPickaxe", 4, 2, Item.pickaxeWood,
buildWorkBench)).registerAchievement();
public static Achievement buildPickaxe = null;
/** Is the 'hot topic' achievement. */
public static Achievement buildFurnace = (new Achievement(4, "buildFurnace", 3, 4, Block.furnaceIdle, buildPickaxe))
.registerAchievement();
public static Achievement buildFurnace = null;
/** Is the 'acquire hardware' achievement. */
public static Achievement acquireIron = (new Achievement(5, "acquireIron", 1, 4, Item.ingotIron, buildFurnace))
.registerAchievement();
public static Achievement acquireIron = null;
/** Is the 'time to farm' achievement. */
public static Achievement buildHoe = (new Achievement(6, "buildHoe", 2, -3, Item.hoeWood, buildWorkBench))
.registerAchievement();
public static Achievement buildHoe = null;
/** Is the 'bake bread' achievement. */
public static Achievement makeBread = (new Achievement(7, "makeBread", -1, -3, Item.bread, buildHoe))
.registerAchievement();
public static Achievement makeBread = null;
/** Is the 'the lie' achievement. */
public static Achievement bakeCake = (new Achievement(8, "bakeCake", 0, -5, Item.cake, buildHoe))
.registerAchievement();
public static Achievement bakeCake = null;
/** Is the 'getting a upgrade' achievement. */
public static Achievement buildBetterPickaxe = (new Achievement(9, "buildBetterPickaxe", 6, 2, Item.pickaxeStone,
buildPickaxe)).registerAchievement();
public static Achievement buildBetterPickaxe = null;
/** Is the 'delicious fish' achievement. */
public static Achievement cookFish = (new Achievement(10, "cookFish", 2, 6, Item.fishCooked, buildFurnace))
.registerAchievement();
public static Achievement cookFish = null;
/** Is the 'on a rail' achievement */
public static Achievement onARail = (new Achievement(11, "onARail", 2, 3, Block.rail, acquireIron)).setSpecial()
.registerAchievement();
public static Achievement onARail = null;
/** Is the 'time to strike' achievement. */
public static Achievement buildSword = (new Achievement(12, "buildSword", 6, -1, Item.swordWood, buildWorkBench))
.registerAchievement();
public static Achievement buildSword = null;
/** Is the 'monster hunter' achievement. */
public static Achievement killEnemy = (new Achievement(13, "killEnemy", 8, -1, Item.bone, buildSword))
.registerAchievement();
public static Achievement killEnemy = null;
/** is the 'cow tipper' achievement. */
public static Achievement killCow = (new Achievement(14, "killCow", 7, -3, Item.leather, buildSword))
.registerAchievement();
public static Achievement killCow = null;
/** Is the 'when pig fly' achievement. */
public static Achievement flyPig = (new Achievement(15, "flyPig", 8, -4, Item.saddle, killCow)).setSpecial()
.registerAchievement();
public static Achievement flyPig = null;
/** The achievement for killing a Skeleton from 50 meters aways. */
public static Achievement snipeSkeleton = (new Achievement(16, "snipeSkeleton", 7, 0, Item.bow, killEnemy))
.setSpecial().registerAchievement();
public static Achievement snipeSkeleton = null;
/** Is the 'DIAMONDS!' achievement */
public static Achievement diamonds = (new Achievement(17, "diamonds", -1, 5, Item.diamond, acquireIron))
.registerAchievement();
public static Achievement diamonds = null;
/** Is the 'We Need to Go Deeper' achievement */
public static Achievement portal = (new Achievement(18, "portal", -1, 7, Block.obsidian, diamonds))
.registerAchievement();
public static Achievement portal = null;
/** Is the 'Return to Sender' achievement */
public static Achievement ghast = (new Achievement(19, "ghast", -4, 8, Item.ghastTear, portal)).setSpecial()
.registerAchievement();
public static Achievement ghast = null;
/** Is the 'Into Fire' achievement */
public static Achievement blazeRod = (new Achievement(20, "blazeRod", 0, 9, Item.blazeRod, portal))
.registerAchievement();
public static Achievement blazeRod = null;
/** Is the 'Local Brewery' achievement */
public static Achievement potion = (new Achievement(21, "potion", 2, 8, Item.potion, blazeRod))
.registerAchievement();
public static Achievement potion = null;
/** Is the 'The End?' achievement */
public static Achievement theEnd = (new Achievement(22, "theEnd", 3, 10, Item.eyeOfEnder, blazeRod)).setSpecial()
.registerAchievement();
public static Achievement theEnd = null;
/** Is the 'The End.' achievement */
public static Achievement theEnd2 = (new Achievement(23, "theEnd2", 4, 13, Block.dragonEgg, theEnd)).setSpecial()
.registerAchievement();
public static Achievement theEnd2 = null;
/** Is the 'Enchanter' achievement */
public static Achievement enchantments = (new Achievement(24, "enchantments", -4, 4, Block.enchantmentTable,
diamonds)).registerAchievement();
public static Achievement overkill = (new Achievement(25, "overkill", -4, 1, Item.swordDiamond, enchantments))
.setSpecial().registerAchievement();
public static Achievement enchantments = null;
public static Achievement overkill = null;
/** Is the 'Librarian' achievement */
public static Achievement bookcase = (new Achievement(26, "bookcase", -3, 6, Block.bookShelf, enchantments))
.registerAchievement();
public static Achievement bookcase = null;
/**
* A stub functions called to make the static initializer for this class run.
*/
public static void init() {
System.out.println("yee");
achievementList = new ArrayList();
openInventory = (new Achievement(0, "openInventory", 0, 0, Item.book, (Achievement) null))
.setIndependent().registerAchievement();
mineWood = (new Achievement(1, "mineWood", 2, 1, Block.wood, openInventory))
.registerAchievement();
buildWorkBench = (new Achievement(2, "buildWorkBench", 4, -1, Block.workbench, mineWood))
.registerAchievement();
buildPickaxe = (new Achievement(3, "buildPickaxe", 4, 2, Item.pickaxeWood,
buildWorkBench)).registerAchievement();
buildFurnace = (new Achievement(4, "buildFurnace", 3, 4, Block.furnaceIdle, buildPickaxe))
.registerAchievement();
acquireIron = (new Achievement(5, "acquireIron", 1, 4, Item.ingotIron, buildFurnace))
.registerAchievement();
buildHoe = (new Achievement(6, "buildHoe", 2, -3, Item.hoeWood, buildWorkBench))
.registerAchievement();
makeBread = (new Achievement(7, "makeBread", -1, -3, Item.bread, buildHoe))
.registerAchievement();
bakeCake = (new Achievement(8, "bakeCake", 0, -5, Item.cake, buildHoe))
.registerAchievement();
buildBetterPickaxe = (new Achievement(9, "buildBetterPickaxe", 6, 2, Item.pickaxeStone,
buildPickaxe)).registerAchievement();
cookFish = (new Achievement(10, "cookFish", 2, 6, Item.fishCooked, buildFurnace))
.registerAchievement();
onARail = (new Achievement(11, "onARail", 2, 3, Block.rail, acquireIron)).setSpecial()
.registerAchievement();
buildSword = (new Achievement(12, "buildSword", 6, -1, Item.swordWood, buildWorkBench))
.registerAchievement();
killEnemy = (new Achievement(13, "killEnemy", 8, -1, Item.bone, buildSword))
.registerAchievement();
killCow = (new Achievement(14, "killCow", 7, -3, Item.leather, buildSword))
.registerAchievement();
flyPig = (new Achievement(15, "flyPig", 8, -4, Item.saddle, killCow)).setSpecial()
.registerAchievement();
snipeSkeleton = (new Achievement(16, "snipeSkeleton", 7, 0, Item.bow, killEnemy))
.setSpecial().registerAchievement();
diamonds = (new Achievement(17, "diamonds", -1, 5, Item.diamond, acquireIron))
.registerAchievement();
portal = (new Achievement(18, "portal", -1, 7, Block.obsidian, diamonds))
.registerAchievement();
ghast = (new Achievement(19, "ghast", -4, 8, Item.ghastTear, portal)).setSpecial()
.registerAchievement();
blazeRod = (new Achievement(20, "blazeRod", 0, 9, Item.blazeRod, portal))
.registerAchievement();
potion = (new Achievement(21, "potion", 2, 8, Item.potion, blazeRod))
.registerAchievement();
theEnd = (new Achievement(22, "theEnd", 3, 10, Item.eyeOfEnder, blazeRod)).setSpecial()
.registerAchievement();
theEnd2 = (new Achievement(23, "theEnd2", 4, 13, Block.dragonEgg, theEnd)).setSpecial()
.registerAchievement();
enchantments = (new Achievement(24, "enchantments", -4, 4, Block.enchantmentTable,
diamonds)).registerAchievement();
overkill = (new Achievement(25, "overkill", -4, 1, Item.swordDiamond, enchantments))
.setSpecial().registerAchievement();
bookcase = (new Achievement(26, "bookcase", -3, 6, Block.bookShelf, enchantments))
.registerAchievement();
}
static {
System.out.println(achievementList.size() + " achievements");
}
}

View File

@ -10,6 +10,7 @@ public class AchievementMap {
public static void init(List<String> guid) {
instance = new AchievementMap(guid);
StatList.initAll();
}
/** Maps a achievement id with it's unique GUID. */

View File

@ -1341,6 +1341,5 @@ public class Block {
}
canBlockGrass[0] = true;
StatList.initBreakableStats();
}
}

View File

@ -617,7 +617,4 @@ public class Item {
return false;
}
static {
StatList.initStats();
}
}

View File

@ -54,19 +54,19 @@ public class Packet51MapChunk extends Packet {
this.zCh = par1Chunk.zPosition;
this.includeInitialize = par2;
Packet51MapChunkData var4 = getMapChunkData(par1Chunk, par2, par3);
Deflater var5 = new Deflater(-1);
//Deflater var5 = new Deflater(-1);
this.yChMax = var4.chunkHasAddSectionFlag;
this.yChMin = var4.chunkExistFlag;
try {
this.compressedChunkData = var4.compressedData;
var5.setInput(var4.compressedData, 0, var4.compressedData.length);
var5.finish();
this.chunkData = new byte[var4.compressedData.length];
this.tempLength = var5.deflate(this.chunkData);
} finally {
var5.end();
}
//try {
//this.compressedChunkData = var4.compressedData;
//var5.setInput(var4.compressedData, 0, var4.compressedData.length);
//var5.finish();
this.chunkData = var4.compressedData;
this.tempLength = var4.compressedData.length;
//} finally {
// var5.end();
//}
}
/**
@ -79,7 +79,9 @@ public class Packet51MapChunk extends Packet {
this.yChMin = par1DataInputStream.readShort();
this.yChMax = par1DataInputStream.readShort();
this.tempLength = par1DataInputStream.readInt();
this.compressedChunkData = new byte[this.tempLength];
par1DataInputStream.readFully(this.compressedChunkData, 0, this.tempLength);
/*
if (temp.length < this.tempLength) {
temp = new byte[this.tempLength];
}
@ -109,6 +111,7 @@ public class Packet51MapChunk extends Packet {
} finally {
var4.end();
}
*/
}
/**
@ -120,7 +123,7 @@ public class Packet51MapChunk extends Packet {
par1DataOutputStream.writeBoolean(this.includeInitialize);
par1DataOutputStream.writeShort((short) (this.yChMin & 65535));
par1DataOutputStream.writeShort((short) (this.yChMax & 65535));
par1DataOutputStream.writeInt(this.tempLength);
par1DataOutputStream.writeInt(this.tempLength | 0x10000000);
par1DataOutputStream.write(this.chunkData, 0, this.tempLength);
}

View File

@ -4,9 +4,6 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.zip.DataFormatException;
import java.util.zip.Deflater;
import java.util.zip.Inflater;
public class Packet56MapChunks extends Packet {
private int[] chunkPostX;
@ -60,75 +57,17 @@ public class Packet56MapChunks extends Packet {
this.field_73584_f[var4] = var6.compressedData;
}
Deflater var11 = new Deflater(-1);
this.chunkDataBuffer = new byte[var3];
System.arraycopy(chunkDataNotCompressed, 0, this.chunkDataBuffer, 0, var3);
this.dataLength = this.chunkDataBuffer.length;
try {
var11.setInput(chunkDataNotCompressed, 0, var3);
var11.finish();
this.chunkDataBuffer = new byte[var3];
this.dataLength = var11.deflate(this.chunkDataBuffer);
} finally {
var11.end();
}
}
/**
* Abstract. Reads the raw packet data from the data stream.
*/
public void readPacketData(DataInputStream par1DataInputStream) throws IOException {
short var2 = par1DataInputStream.readShort();
this.dataLength = par1DataInputStream.readInt();
this.skyLightSent = par1DataInputStream.readBoolean();
this.chunkPostX = new int[var2];
this.chunkPosZ = new int[var2];
this.field_73590_a = new int[var2];
this.field_73588_b = new int[var2];
this.field_73584_f = new byte[var2][];
if (chunkDataNotCompressed.length < this.dataLength) {
chunkDataNotCompressed = new byte[this.dataLength];
}
par1DataInputStream.readFully(chunkDataNotCompressed, 0, this.dataLength);
byte[] var3 = new byte[196864 * var2];
Inflater var4 = new Inflater();
var4.setInput(chunkDataNotCompressed, 0, this.dataLength);
try {
var4.inflate(var3);
} catch (DataFormatException var12) {
throw new IOException("Bad compressed data format");
} finally {
var4.end();
}
int var5 = 0;
for (int var6 = 0; var6 < var2; ++var6) {
this.chunkPostX[var6] = par1DataInputStream.readInt();
this.chunkPosZ[var6] = par1DataInputStream.readInt();
this.field_73590_a[var6] = par1DataInputStream.readShort();
this.field_73588_b[var6] = par1DataInputStream.readShort();
int var7 = 0;
int var8 = 0;
int var9;
for (var9 = 0; var9 < 16; ++var9) {
var7 += this.field_73590_a[var6] >> var9 & 1;
var8 += this.field_73588_b[var6] >> var9 & 1;
}
var9 = 2048 * 4 * var7 + 256;
var9 += 2048 * var8;
if (this.skyLightSent) {
var9 += 2048 * var7;
}
this.field_73584_f[var6] = new byte[var9];
System.arraycopy(var3, var5, this.field_73584_f[var6], 0, var9);
var5 += var9;
}
// not used in server
}
/**

View File

@ -105,15 +105,9 @@ public class StatList {
/** Tracks the number of times a given block or item has been broken. */
public static StatBase[] objectBreakStats;
private static boolean blockStatsInitialized;
private static boolean itemStatsInitialized;
private static boolean blockStatsInitialized = false;
private static boolean itemStatsInitialized = false;
/**
* This method simply NOPs. It is presumably used to call the static
* constructors on server start.
*/
public static void nopInit() {
}
/**
* Initializes statistic fields related to breakable items and blocks.
@ -132,6 +126,11 @@ public class StatList {
initCraftableStats();
}
public static void initAll() {
initStats();
initBreakableStats();
}
/**
* Initializes statistics related to craftable items. Is only called after both
* block and item stats have been initialized.
@ -271,9 +270,4 @@ public class StatList {
}
}
static {
AchievementList.init();
blockStatsInitialized = false;
itemStatsInitialized = false;
}
}

View File

@ -481,7 +481,7 @@ public class GuiIngame extends Gui {
var8.drawStringWithShadow(info.get(i), (int)(var6 / 0.75f) - var8.getStringWidth(info.get(i)) - 2, 12 + i * 10, 14737632);
}
}
/*
if(mc.currentScreen == null || !(mc.currentScreen instanceof GuiIngameMenu)) {
int offset = this.mc.isChatOpen() ? 135 : 0;
int offset2 = this.mc.isChatOpen() ? 4 : 0;
@ -490,6 +490,7 @@ public class GuiIngame extends Gui {
str = "eaglercraft: " + ConfigConstants.version;
var8.drawStringWithShadow(str, (var6 * 4 / 3) - 2 - var8.getStringWidth(str) - offset, 12 + offset2, 14737632);
}
*/
EaglerAdapter.glPopMatrix();
}

View File

@ -61,25 +61,34 @@ public class Packet51MapChunk extends Packet {
this.yChMax = par1DataInputStream.readShort();
this.tempLength = par1DataInputStream.readInt();
if (temp.length < this.tempLength) {
temp = new byte[this.tempLength];
boolean compress = (this.tempLength & 0x10000000) != 0x10000000; // stupid
if(compress) {
if (temp.length < this.tempLength) {
temp = new byte[this.tempLength];
}
par1DataInputStream.readFully(temp, 0, this.tempLength);
int var2 = 0;
int var3;
for (var3 = 0; var3 < 16; ++var3) {
var2 += this.yChMin >> var3 & 1;
}
var3 = 12288 * var2;
if (this.includeInitialize) {
var3 += 256;
}
this.compressedChunkData = EaglerInflater.uncompress(temp);
}else {
this.tempLength &= 0xFFFFFFF;
this.compressedChunkData = new byte[this.tempLength];
par1DataInputStream.readFully(this.compressedChunkData, 0, this.tempLength);
}
par1DataInputStream.readFully(temp, 0, this.tempLength);
int var2 = 0;
int var3;
for (var3 = 0; var3 < 16; ++var3) {
var2 += this.yChMin >> var3 & 1;
}
var3 = 12288 * var2;
if (this.includeInitialize) {
var3 += 256;
}
this.compressedChunkData = EaglerInflater.uncompress(temp);
}
/**
@ -113,84 +122,4 @@ public class Packet51MapChunk extends Packet {
return this.compressedChunkData;
}
public static Packet51MapChunkData getMapChunkData(Chunk par0Chunk, boolean par1, int par2) {
int var3 = 0;
ExtendedBlockStorage[] var4 = par0Chunk.getBlockStorageArray();
int var5 = 0;
Packet51MapChunkData var6 = new Packet51MapChunkData();
byte[] var7 = temp;
if (par1) {
par0Chunk.sendUpdates = true;
}
int var8;
for (var8 = 0; var8 < var4.length; ++var8) {
if (var4[var8] != null && (!par1 || !var4[var8].isEmpty()) && (par2 & 1 << var8) != 0) {
var6.chunkExistFlag |= 1 << var8;
if (var4[var8].getBlockMSBArray() != null) {
var6.chunkHasAddSectionFlag |= 1 << var8;
++var5;
}
}
}
for (var8 = 0; var8 < var4.length; ++var8) {
if (var4[var8] != null && (!par1 || !var4[var8].isEmpty()) && (par2 & 1 << var8) != 0) {
byte[] var9 = var4[var8].getBlockLSBArray();
System.arraycopy(var9, 0, var7, var3, var9.length);
var3 += var9.length;
}
}
NibbleArray var10;
for (var8 = 0; var8 < var4.length; ++var8) {
if (var4[var8] != null && (!par1 || !var4[var8].isEmpty()) && (par2 & 1 << var8) != 0) {
var10 = var4[var8].getMetadataArray();
System.arraycopy(var10.data, 0, var7, var3, var10.data.length);
var3 += var10.data.length;
}
}
for (var8 = 0; var8 < var4.length; ++var8) {
if (var4[var8] != null && (!par1 || !var4[var8].isEmpty()) && (par2 & 1 << var8) != 0) {
var10 = var4[var8].getBlocklightArray();
System.arraycopy(var10.data, 0, var7, var3, var10.data.length);
var3 += var10.data.length;
}
}
if (!par0Chunk.worldObj.provider.hasNoSky) {
for (var8 = 0; var8 < var4.length; ++var8) {
if (var4[var8] != null && (!par1 || !var4[var8].isEmpty()) && (par2 & 1 << var8) != 0) {
var10 = var4[var8].getSkylightArray();
System.arraycopy(var10.data, 0, var7, var3, var10.data.length);
var3 += var10.data.length;
}
}
}
if (var5 > 0) {
for (var8 = 0; var8 < var4.length; ++var8) {
if (var4[var8] != null && (!par1 || !var4[var8].isEmpty()) && var4[var8].getBlockMSBArray() != null && (par2 & 1 << var8) != 0) {
var10 = var4[var8].getBlockMSBArray();
System.arraycopy(var10.data, 0, var7, var3, var10.data.length);
var3 += var10.data.length;
}
}
}
if (par1) {
byte[] var11 = par0Chunk.getBiomeArray();
System.arraycopy(var11, 0, var7, var3, var11.length);
var3 += var11.length;
}
var6.compressedData = new byte[var3];
System.arraycopy(var7, 0, var6.compressedData, 0, var3);
return var6;
}
}

View File

@ -5,8 +5,6 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.util.List;
import net.lax1dude.eaglercraft.EaglerInflater;
public class Packet56MapChunks extends Packet {
private int[] chunkPostX;
private int[] chunkPosZ;
@ -46,12 +44,8 @@ public class Packet56MapChunks extends Packet {
this.field_73588_b = new int[var2];
this.field_73584_f = new byte[var2][];
if (chunkDataNotCompressed.length < this.dataLength) {
chunkDataNotCompressed = new byte[this.dataLength];
}
par1DataInputStream.readFully(chunkDataNotCompressed, 0, this.dataLength);
byte[] var3 = EaglerInflater.uncompress(chunkDataNotCompressed);
byte[] var3 = new byte[this.dataLength];
par1DataInputStream.readFully(var3, 0, this.dataLength);
int var5 = 0;

View File

@ -83,8 +83,10 @@ import org.teavm.jso.workers.Worker;
import net.lax1dude.eaglercraft.AssetRepository;
import net.lax1dude.eaglercraft.Base64;
import net.lax1dude.eaglercraft.EaglerImage;
import net.lax1dude.eaglercraft.EaglerProfile;
import net.lax1dude.eaglercraft.EarlyLoadScreen;
import net.lax1dude.eaglercraft.ExpiringSet;
import net.lax1dude.eaglercraft.IntegratedServer;
import net.lax1dude.eaglercraft.LocalStorageManager;
import net.lax1dude.eaglercraft.PKT;
import net.lax1dude.eaglercraft.ServerQuery;
@ -94,6 +96,7 @@ import net.lax1dude.eaglercraft.adapter.teavm.SelfDefence;
import net.lax1dude.eaglercraft.adapter.teavm.WebGL2RenderingContext;
import net.lax1dude.eaglercraft.adapter.teavm.WebGLQuery;
import net.lax1dude.eaglercraft.adapter.teavm.WebGLVertexArray;
import net.minecraft.client.Minecraft;
import net.minecraft.src.MathHelper;
public class EaglerAdapterImpl2 {
@ -1833,6 +1836,9 @@ public class EaglerAdapterImpl2 {
enableVoice(Voice.VoiceChannel.NONE);
}
public static final boolean connectionOpen() {
if(IntegratedServer.doesChannelExist(EaglerProfile.username)) {
return true;
}
if(sock == null || sock.getReadyState() == 3) {
sockIsConnecting = false;
}
@ -1857,7 +1863,7 @@ public class EaglerAdapterImpl2 {
public static final byte[] loadLocalStorage(String key) {
Storage strg = win.getLocalStorage();
if(strg != null) {
String s =strg.getItem("_eaglercraft."+key);
String s = strg.getItem("_eaglercraft."+key);
if(s != null) {
return Base64.decodeBase64(s);
}else {