got it to compile to teavm

This commit is contained in:
LAX1DUDE 2022-04-30 23:06:29 -07:00
parent 5c1f65c894
commit a9881a5a73
55 changed files with 13468 additions and 299 deletions

18
.classpath Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/main" path="src/main/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/teavm/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>

7
.gitattributes vendored Normal file
View File

@ -0,0 +1,7 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
*.bat text eol=crlf
*.sh text eol=lf
gradlew text eol=lf

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>eaglercraft-beta</name>
<comment>Project eaglercraft-beta created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>

View File

@ -37,7 +37,7 @@ dependencies {
teavm { teavm {
compileScopes = null; compileScopes = null;
minifying = false; minifying = true;
maxTopLevelNames = 10000; maxTopLevelNames = 10000;
properties = null; properties = null;
debugInformationGenerated = false; debugInformationGenerated = false;

Binary file not shown.

12
epkcompiler/readme.txt Normal file
View File

@ -0,0 +1,12 @@
TO QUICKLY MAKE RESOURCE PACK:
1. make your changes to the files in '/lwjgl-rundir/resources'
2. double click 'run.bat' on windows, or run './run_unix.sh' in terminal on mac
3. copy 'assets.epk from '/javascript' to your web directory
To manually use the CompilePackage.jar on a custom directory, run the jar file like this:
java -jar CompilePackage.jar <source directory> <output file>
To recompile the assets.epk file found in /javascript, run:
java -jar CompilePackage.jar "../lwjgl-rundir/resources" "../javascript/assets.epk"

2
epkcompiler/run.bat Normal file
View File

@ -0,0 +1,2 @@
@echo off
java -jar CompilePackage.jar "../lwjgl-rundir/resources" "../javascript/assets.epk"

2
epkcompiler/run_unix.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/sh
java -jar CompilePackage.jar "../lwjgl-rundir/resources" "../javascript/assets.epk"

BIN
javascript/assets.epk Normal file

Binary file not shown.

9977
javascript/classes.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

26
javascript/index.html Normal file
View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>eagler</title>
<script type="text/javascript" src="classes.js"></script>
<script type="text/javascript">
if(document.location.href.startsWith("file:")) {
alert("You're not supposed to 'open' this file in your browser. Please upload this folder to your HTTP(s) server and access it via the internet. This is not a bug, please read the documentation");
}else {
window.addEventListener("load", function(){
window.minecraftOpts = ["game_frame","assets.epk"];
(function(){
var q = window.location.search;
if(typeof q === 'string' && q.startsWith("?")) {
q = new URLSearchParams(q);
var s = q.get("server");
if(s) window.minecraftOpts.push(s);
}
})();
main();
});}
</script>
</head>
<body style="margin:0px;width:100vw;height:100vh;" id="game_frame">
</body>
</html>

View File

@ -1,10 +0,0 @@
# This file NEEDS to be in UTF-8 format!
!"#$%&'()*+,-./
0123456789:;<=>?
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]^_
'abcdefghijklmno
pqrstuvwxyz{|}~⌂
ÇüéâäàåçêëèïîìÄÅ
ÉæÆôöòûùÿÖÜø£Ø׃
áíóúñѪº¿®¬½¼¡«»

View File

@ -12,6 +12,7 @@ menu.multiplayer=Multiplayer
menu.mods=Mods and Texture Packs menu.mods=Mods and Texture Packs
menu.options=Options... menu.options=Options...
menu.quit=Quit Game menu.quit=Quit Game
menu.editProfile=Edit Profile
selectWorld.title=Select World selectWorld.title=Select World
selectWorld.empty=empty selectWorld.empty=empty

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -947,6 +947,10 @@ public class EaglerAdapterImpl2 {
Mouse.setGrabbed(grabbed); Mouse.setGrabbed(grabbed);
} }
public static final boolean isPointerLocked() {
return Mouse.isGrabbed();
}
public static final int mouseGetDX() { public static final int mouseGetDX() {
return Mouse.getDX(); return Mouse.getDX();
} }
@ -1616,14 +1620,6 @@ public class EaglerAdapterImpl2 {
return (new File(filesystemBaseDirectory, stripPath(path))).lastModified(); return (new File(filesystemBaseDirectory, stripPath(path))).lastModified();
} }
public static final void setLastModified(String path, long t) {
(new File(filesystemBaseDirectory, stripPath(path))).setLastModified(t);
}
public static final void touchFile(String path) {
(new File(filesystemBaseDirectory, stripPath(path))).setLastModified(System.currentTimeMillis());
}
public static final int getFileSize(String path) { public static final int getFileSize(String path) {
return (int)(new File(filesystemBaseDirectory, stripPath(path))).length(); return (int)(new File(filesystemBaseDirectory, stripPath(path))).length();
} }
@ -1689,18 +1685,18 @@ public class EaglerAdapterImpl2 {
ArrayList<FileEntry> ret = new ArrayList<>(); ArrayList<FileEntry> ret = new ArrayList<>();
File f = new File(filesystemBaseDirectory, path); File f = new File(filesystemBaseDirectory, path);
if(f.isFile()) { if(f.isFile()) {
ret.add(new FileEntry(path, false, f.lastModified(), (int)f.length())); ret.add(new FileEntry(path, false, f.lastModified()));
}else if(f.isDirectory()) { }else if(f.isDirectory()) {
for(File ff : f.listFiles()) { for(File ff : f.listFiles()) {
if(ff.isDirectory()) { if(ff.isDirectory()) {
if(listDirs && !recursiveDirs) { if(listDirs && !recursiveDirs) {
ret.add(new FileEntry(path + "/" + ff.getName(), true, -1l, -1)); ret.add(new FileEntry(path + "/" + ff.getName(), true, -1l));
} }
if(recursiveDirs) { if(recursiveDirs) {
recursiveListing(path + "/" + ff.getName(), ff, ret, listDirs, recursiveDirs); recursiveListing(path + "/" + ff.getName(), ff, ret, listDirs, recursiveDirs);
} }
}else { }else {
ret.add(new FileEntry(path + "/" + ff.getName(), false, ff.lastModified(), (int)ff.length())); ret.add(new FileEntry(path + "/" + ff.getName(), false, ff.lastModified()));
} }
} }
} }
@ -1709,10 +1705,10 @@ public class EaglerAdapterImpl2 {
private static void recursiveListing(String path, File f, Collection<FileEntry> lst, boolean listDirs, boolean recursiveDirs) { private static void recursiveListing(String path, File f, Collection<FileEntry> lst, boolean listDirs, boolean recursiveDirs) {
if(f.isFile()) { if(f.isFile()) {
lst.add(new FileEntry(path, false, f.lastModified(), (int)f.length())); lst.add(new FileEntry(path, false, f.lastModified()));
}else if(f.isDirectory()) { }else if(f.isDirectory()) {
if(listDirs) { if(listDirs) {
lst.add(new FileEntry(path, true, -1l, -1)); lst.add(new FileEntry(path, true, -1l));
} }
if(recursiveDirs) { if(recursiveDirs) {
for(File ff : f.listFiles()) { for(File ff : f.listFiles()) {
@ -1735,13 +1731,11 @@ public class EaglerAdapterImpl2 {
public final String path; public final String path;
public final boolean isDirectory; public final boolean isDirectory;
public final long lastModified; public final long lastModified;
public final int fileSize;
protected FileEntry(String path, boolean isDirectory, long lastModified, int fileSize) { protected FileEntry(String path, boolean isDirectory, long lastModified) {
this.path = path; this.path = path;
this.isDirectory = isDirectory; this.isDirectory = isDirectory;
this.lastModified = lastModified; this.lastModified = lastModified;
this.fileSize = fileSize;
} }
public String getName() { public String getName() {

View File

@ -44,6 +44,7 @@ public abstract class Minecraft implements Runnable {
systemTime = System.currentTimeMillis(); systemTime = System.currentTimeMillis();
field_6300_ab = 0; field_6300_ab = 0;
hideQuitButton = false; hideQuitButton = false;
awaitPointerLock = false;
field_21900_a = this; field_21900_a = this;
} }
@ -62,7 +63,7 @@ public abstract class Minecraft implements Runnable {
field_22008_V = new EaglercraftSaveManager("saves"); field_22008_V = new EaglercraftSaveManager("saves");
} }
gameSettings = new GameSettings(); gameSettings = new GameSettings(this);
texturePackList = new TexturePackList(this); texturePackList = new TexturePackList(this);
renderEngine = new RenderEngine(texturePackList, gameSettings); renderEngine = new RenderEngine(texturePackList, gameSettings);
fontRenderer = new FontRenderer(gameSettings, "/font/default.png", renderEngine); fontRenderer = new FontRenderer(gameSettings, "/font/default.png", renderEngine);
@ -87,7 +88,7 @@ public abstract class Minecraft implements Runnable {
renderEngine.registerTextureFX(new TexturePortalFX()); renderEngine.registerTextureFX(new TexturePortalFX());
renderEngine.registerTextureFX(new TextureCompassFX(this)); renderEngine.registerTextureFX(new TextureCompassFX(this));
renderEngine.registerTextureFX(new TextureWatchFX(this)); renderEngine.registerTextureFX(new TextureWatchFX(this));
renderEngine.registerTextureFX(new TexureWaterFlowFX()); renderEngine.registerTextureFX(new TextureWaterFlowFX());
renderEngine.registerTextureFX(new TextureLavaFlowFX()); renderEngine.registerTextureFX(new TextureLavaFlowFX());
renderEngine.registerTextureFX(new TextureFlamesFX(0)); renderEngine.registerTextureFX(new TextureFlamesFX(0));
renderEngine.registerTextureFX(new TextureFlamesFX(1)); renderEngine.registerTextureFX(new TextureFlamesFX(1));
@ -95,6 +96,9 @@ public abstract class Minecraft implements Runnable {
EaglerAdapter.glViewport(0, 0, displayWidth, displayHeight); EaglerAdapter.glViewport(0, 0, displayWidth, displayHeight);
effectRenderer = new EffectRenderer(theWorld, renderEngine); effectRenderer = new EffectRenderer(theWorld, renderEngine);
checkGLError("Post startup"); checkGLError("Post startup");
while(EaglerAdapter.keysNext());
while(EaglerAdapter.mouseNext());
ingameGUI = new GuiIngame(this); ingameGUI = new GuiIngame(this);
if (serverName != null) { if (serverName != null) {
displayGuiScreen(new GuiConnecting(this, serverName, serverPort)); displayGuiScreen(new GuiConnecting(this, serverName, serverPort));
@ -104,13 +108,14 @@ public abstract class Minecraft implements Runnable {
} }
private void loadScreen() { private void loadScreen() {
ScaledResolution scaledresolution = new ScaledResolution(displayWidth, displayHeight); int xx = displayWidth;
int i = scaledresolution.getScaledWidth(); if(xx > displayHeight) {
int j = scaledresolution.getScaledHeight(); xx = displayHeight;
}
EaglerAdapter.glClear(16640); EaglerAdapter.glClear(16640);
EaglerAdapter.glMatrixMode(5889 /* GL_PROJECTION */); EaglerAdapter.glMatrixMode(5889 /* GL_PROJECTION */);
EaglerAdapter.glLoadIdentity(); EaglerAdapter.glLoadIdentity();
EaglerAdapter.glOrtho(0.0F, i, j, 0.0F, 1000F, 3000F); EaglerAdapter.glOrtho(0.0F, displayWidth, displayHeight, 0.0F, 1000F, 3000F);
EaglerAdapter.glMatrixMode(5888 /* GL_MODELVIEW0_ARB */); EaglerAdapter.glMatrixMode(5888 /* GL_MODELVIEW0_ARB */);
EaglerAdapter.glLoadIdentity(); EaglerAdapter.glLoadIdentity();
EaglerAdapter.glTranslatef(0.0F, 0.0F, -2000F); EaglerAdapter.glTranslatef(0.0F, 0.0F, -2000F);
@ -128,11 +133,16 @@ public abstract class Minecraft implements Runnable {
tessellator.addVertexWithUV(displayWidth, 0.0D, 0.0D, 0.0D, 0.0D); tessellator.addVertexWithUV(displayWidth, 0.0D, 0.0D, 0.0D, 0.0D);
tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D); tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
tessellator.draw(); tessellator.draw();
char c = '\u0100';
char c1 = '\u0100';
EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
tessellator.startDrawingQuads();
tessellator.setColorOpaque_I(0xffffff); tessellator.setColorOpaque_I(0xffffff);
func_6274_a((displayWidth / 2 - c) / 2, (displayHeight / 2 - c1) / 2, 0, 0, c, c1); int marginX = (displayWidth - xx) / 2;
int marginY = (displayHeight - xx) / 2;
tessellator.addVertexWithUV(marginX, displayHeight - marginY, 0.0D, 0.0D, 1.0D);
tessellator.addVertexWithUV(displayWidth - marginX, displayHeight - marginY, 0.0D, 1.0D, 1.0D);
tessellator.addVertexWithUV(displayWidth - marginX, marginY, 0.0D, 1.0D, 0.0D);
tessellator.addVertexWithUV(marginX, marginY, 0.0D, 0.0D, 0.0D);
tessellator.draw();
EaglerAdapter.glDisable(2896 /* GL_LIGHTING */); EaglerAdapter.glDisable(2896 /* GL_LIGHTING */);
EaglerAdapter.glDisable(2912 /* GL_FOG */); EaglerAdapter.glDisable(2912 /* GL_FOG */);
EaglerAdapter.glEnable(3008 /* GL_ALPHA_TEST */); EaglerAdapter.glEnable(3008 /* GL_ALPHA_TEST */);
@ -170,14 +180,14 @@ public abstract class Minecraft implements Runnable {
} }
currentScreen = guiscreen; currentScreen = guiscreen;
if (guiscreen != null) { if (guiscreen != null) {
func_6273_f(); ungrabMouseCursor();
ScaledResolution scaledresolution = new ScaledResolution(displayWidth, displayHeight); ScaledResolution scaledresolution = new ScaledResolution(displayWidth, displayHeight);
int i = scaledresolution.getScaledWidth(); int i = scaledresolution.getScaledWidth();
int j = scaledresolution.getScaledHeight(); int j = scaledresolution.getScaledHeight();
guiscreen.setWorldAndResolution(this, i, j); guiscreen.setWorldAndResolution(this, i, j);
field_6307_v = false; field_6307_v = false;
} else { } else {
func_6259_e(); grabMouseCursor();
} }
} }
@ -188,7 +198,6 @@ public abstract class Minecraft implements Runnable {
System.out.println("########## GL ERROR ##########"); System.out.println("########## GL ERROR ##########");
System.out.println((new StringBuilder()).append("@ ").append(s).toString()); System.out.println((new StringBuilder()).append("@ ").append(s).toString());
System.out.println((new StringBuilder()).append(i).append(": ").append(s1).toString()); System.out.println((new StringBuilder()).append(i).append(": ").append(s1).toString());
System.exit(0);
} }
} }
@ -203,7 +212,7 @@ public abstract class Minecraft implements Runnable {
} catch (Throwable throwable1) { } catch (Throwable throwable1) {
} }
EaglerAdapter.destroyContext(); EaglerAdapter.destroyContext();
System.exit(0); EaglerAdapter.exit();
} }
public void run() { public void run() {
@ -395,10 +404,11 @@ public abstract class Minecraft implements Runnable {
running = false; running = false;
} }
public void func_6259_e() { public void grabMouseCursor() {
if (!EaglerAdapter.isFocused()) { if (!EaglerAdapter.isFocused()) {
return; return;
} }
awaitPointerLock = true;
if (field_6289_L) { if (field_6289_L) {
return; return;
} else { } else {
@ -410,7 +420,7 @@ public abstract class Minecraft implements Runnable {
} }
} }
public void func_6273_f() { public void ungrabMouseCursor() {
if (!field_6289_L) { if (!field_6289_L) {
return; return;
} }
@ -422,11 +432,8 @@ public abstract class Minecraft implements Runnable {
} }
public void func_6252_g() { public void func_6252_g() {
if (currentScreen != null) { if (currentScreen == null) {
return;
} else {
displayGuiScreen(new GuiIngameMenu()); displayGuiScreen(new GuiIngameMenu());
return;
} }
} }
@ -601,7 +608,7 @@ public abstract class Minecraft implements Runnable {
} }
if (currentScreen == null) { if (currentScreen == null) {
if (!field_6289_L && EaglerAdapter.mouseGetEventButtonState()) { if (!field_6289_L && EaglerAdapter.mouseGetEventButtonState()) {
func_6259_e(); grabMouseCursor();
} else { } else {
if (EaglerAdapter.mouseGetEventButton() == 0 && EaglerAdapter.mouseGetEventButtonState()) { if (EaglerAdapter.mouseGetEventButton() == 0 && EaglerAdapter.mouseGetEventButtonState()) {
clickMouse(0); clickMouse(0);
@ -668,6 +675,8 @@ public abstract class Minecraft implements Runnable {
} }
} while (true); } while (true);
if (currentScreen == null) { if (currentScreen == null) {
if(EaglerAdapter.isPointerLocked()) {
awaitPointerLock = false;
if (EaglerAdapter.mouseIsButtonDown(0) && (float) (ticksRan - field_6302_aa) >= timer.ticksPerSecond / 4F if (EaglerAdapter.mouseIsButtonDown(0) && (float) (ticksRan - field_6302_aa) >= timer.ticksPerSecond / 4F
&& field_6289_L) { && field_6289_L) {
clickMouse(0); clickMouse(0);
@ -678,6 +687,10 @@ public abstract class Minecraft implements Runnable {
clickMouse(1); clickMouse(1);
field_6302_aa = ticksRan; field_6302_aa = ticksRan;
} }
}else if(!awaitPointerLock) {
field_6289_L = false;
func_6252_g();
}
} }
func_6254_a(0, currentScreen == null && EaglerAdapter.mouseIsButtonDown(0) && field_6289_L); func_6254_a(0, currentScreen == null && EaglerAdapter.mouseIsButtonDown(0) && field_6289_L);
} }
@ -1028,6 +1041,7 @@ public abstract class Minecraft implements Runnable {
public boolean isRaining; public boolean isRaining;
long systemTime; long systemTime;
private int field_6300_ab; private int field_6300_ab;
private boolean awaitPointerLock;
private static Minecraft instance = null; private static Minecraft instance = null;

View File

@ -309,8 +309,7 @@ public class Chunk {
int i = MathHelper.floor_double(entity.posX / 16D); int i = MathHelper.floor_double(entity.posX / 16D);
int j = MathHelper.floor_double(entity.posZ / 16D); int j = MathHelper.floor_double(entity.posZ / 16D);
if (i != xPosition || j != zPosition) { if (i != xPosition || j != zPosition) {
System.out.println((new StringBuilder()).append("Wrong location! ").append(entity).toString()); System.out.println((new StringBuilder()).append("Wrong entity location! ").append(entity).toString());
Thread.dumpStack();
} }
int k = MathHelper.floor_double(entity.posY / 16D); int k = MathHelper.floor_double(entity.posY / 16D);
if (k < 0) { if (k < 0) {

View File

@ -4,30 +4,28 @@ package net.minecraft.src;
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode // Decompiler options: packimports(3) braces deadcode
import java.io.PrintStream;
import java.lang.reflect.Constructor;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Function;
public class EntityList { public class EntityList {
public EntityList() { public EntityList() {
} }
private static void addMapping(Class class1, String s, int i) { private static void addMapping(Class class1, Function<World, Entity> construct, String s, int i) {
stringToClassMapping.put(s, class1); stringToConstructorMapping.put(s, construct);
classToStringMapping.put(class1, s); classToStringMapping.put(class1, s);
IDtoClassMapping.put(Integer.valueOf(i), class1); IDtoConstructorMapping.put(Integer.valueOf(i), construct);
classToIDMapping.put(class1, Integer.valueOf(i)); classToIDMapping.put(class1, Integer.valueOf(i));
} }
public static Entity createEntityInWorld(String s, World world) { public static Entity createEntityInWorld(String s, World world) {
Entity entity = null; Entity entity = null;
try { try {
Class class1 = (Class) stringToClassMapping.get(s); Function<World, Entity> class1 = (Function<World, Entity>) stringToConstructorMapping.get(s);
if (class1 != null) { if (class1 != null) {
entity = (Entity) class1.getConstructor(new Class[] { World.class }) entity = class1.apply(world);
.newInstance(new Object[] { world });
} }
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
@ -38,10 +36,9 @@ public class EntityList {
public static Entity createEntityFromNBT(NBTTagCompound nbttagcompound, World world) { public static Entity createEntityFromNBT(NBTTagCompound nbttagcompound, World world) {
Entity entity = null; Entity entity = null;
try { try {
Class class1 = (Class) stringToClassMapping.get(nbttagcompound.getString("id")); Function<World, Entity> class1 = (Function<World, Entity>) stringToConstructorMapping.get(nbttagcompound.getString("id"));
if (class1 != null) { if (class1 != null) {
entity = (Entity) class1.getConstructor(new Class[] { World.class }) entity = class1.apply(world);
.newInstance(new Object[] { world });
} }
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
@ -58,10 +55,9 @@ public class EntityList {
public static Entity createEntity(int i, World world) { public static Entity createEntity(int i, World world) {
Entity entity = null; Entity entity = null;
try { try {
Class class1 = (Class) IDtoClassMapping.get(Integer.valueOf(i)); Function<World, Entity> class1 = (Function<World, Entity>) IDtoConstructorMapping.get(Integer.valueOf(i));
if (class1 != null) { if (class1 != null) {
entity = (Entity) class1.getConstructor(new Class[] { World.class }) entity = class1.apply(world);
.newInstance(new Object[] { world });
} }
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
@ -80,34 +76,32 @@ public class EntityList {
return (String) classToStringMapping.get(entity.getClass()); return (String) classToStringMapping.get(entity.getClass());
} }
private static Map stringToClassMapping = new HashMap(); private static Map stringToConstructorMapping = new HashMap();
private static Map classToStringMapping = new HashMap(); private static Map classToStringMapping = new HashMap();
private static Map IDtoClassMapping = new HashMap(); private static Map IDtoConstructorMapping = new HashMap();
private static Map classToIDMapping = new HashMap(); private static Map classToIDMapping = new HashMap();
static { static {
addMapping(EntityArrow.class, "Arrow", 10); addMapping(EntityArrow.class, (w) -> new EntityArrow(w), "Arrow", 10);
addMapping(EntitySnowball.class, "Snowball", 11); addMapping(EntitySnowball.class, (w) -> new EntitySnowball(w), "Snowball", 11);
addMapping(EntityItem.class, "Item", 1); addMapping(EntityItem.class, (w) -> new EntityItem(w), "Item", 1);
addMapping(EntityPainting.class, "Painting", 9); addMapping(EntityPainting.class, (w) -> new EntityPainting(w), "Painting", 9);
addMapping(EntityLiving.class, "Mob", 48); addMapping(EntityCreeper.class, (w) -> new EntityCreeper(w), "Creeper", 50);
addMapping(EntityMobs.class, "Monster", 49); addMapping(EntitySkeleton.class, (w) -> new EntitySkeleton(w), "Skeleton", 51);
addMapping(EntityCreeper.class, "Creeper", 50); addMapping(EntitySpider.class, (w) -> new EntitySpider(w), "Spider", 52);
addMapping(EntitySkeleton.class, "Skeleton", 51); addMapping(EntityZombieSimple.class, (w) -> new EntityZombieSimple(w), "Giant", 53);
addMapping(EntitySpider.class, "Spider", 52); addMapping(EntityZombie.class, (w) -> new EntityZombie(w), "Zombie", 54);
addMapping(EntityZombieSimple.class, "Giant", 53); addMapping(EntitySlime.class, (w) -> new EntitySlime(w), "Slime", 55);
addMapping(EntityZombie.class, "Zombie", 54); addMapping(EntityGhast.class, (w) -> new EntityGhast(w), "Ghast", 56);
addMapping(EntitySlime.class, "Slime", 55); addMapping(EntityPigZombie.class, (w) -> new EntityPigZombie(w), "PigZombie", 57);
addMapping(EntityGhast.class, "Ghast", 56); addMapping(EntityPig.class, (w) -> new EntityPig(w), "Pig", 90);
addMapping(EntityPigZombie.class, "PigZombie", 57); addMapping(EntitySheep.class, (w) -> new EntitySheep(w), "Sheep", 91);
addMapping(EntityPig.class, "Pig", 90); addMapping(EntityCow.class, (w) -> new EntityCow(w), "Cow", 92);
addMapping(EntitySheep.class, "Sheep", 91); addMapping(EntityChicken.class, (w) -> new EntityChicken(w), "Chicken", 93);
addMapping(EntityCow.class, "Cow", 92); addMapping(EntitySquid.class, (w) -> new EntitySquid(w), "Squid", 94);
addMapping(EntityChicken.class, "Chicken", 93); addMapping(EntityTNTPrimed.class, (w) -> new EntityTNTPrimed(w), "PrimedTnt", 20);
addMapping(EntitySquid.class, "Squid", 94); addMapping(EntityFallingSand.class, (w) -> new EntityFallingSand(w), "FallingSand", 21);
addMapping(EntityTNTPrimed.class, "PrimedTnt", 20); addMapping(EntityMinecart.class, (w) -> new EntityMinecart(w), "Minecart", 40);
addMapping(EntityFallingSand.class, "FallingSand", 21); addMapping(EntityBoat.class, (w) -> new EntityBoat(w), "Boat", 41);
addMapping(EntityMinecart.class, "Minecart", 40);
addMapping(EntityBoat.class, "Boat", 41);
} }
} }

View File

@ -430,7 +430,13 @@ public class EntityRenderer {
EaglerAdapter.glEnable(2912 /* GL_FOG */); EaglerAdapter.glEnable(2912 /* GL_FOG */);
terrainTexture.bindTexture(); terrainTexture.bindTexture();
RenderHelper.disableStandardItemLighting(); RenderHelper.disableStandardItemLighting();
if(i == 0) {
EaglerAdapter.glAlphaFunc(516, 0.5F);
}
renderglobal.sortAndRender(entityliving, 0, f); renderglobal.sortAndRender(entityliving, 0, f);
if(i == 0) {
EaglerAdapter.glAlphaFunc(516, 0.1F);
}
EaglerAdapter.glShadeModel(7424 /* GL_FLAT */); EaglerAdapter.glShadeModel(7424 /* GL_FLAT */);
RenderHelper.enableStandardItemLighting(); RenderHelper.enableStandardItemLighting();
renderglobal.func_951_a(entityliving.getPosition(f), frustrum, f); renderglobal.func_951_a(entityliving.getPosition(f), frustrum, f);
@ -453,7 +459,7 @@ public class EntityRenderer {
EaglerAdapter.glEnable(3042 /* GL_BLEND */); EaglerAdapter.glEnable(3042 /* GL_BLEND */);
EaglerAdapter.glDisable(2884 /* GL_CULL_FACE */); EaglerAdapter.glDisable(2884 /* GL_CULL_FACE */);
terrainTexture.bindTexture(); terrainTexture.bindTexture();
if (mc.gameSettings.fancyGraphics) { //if (mc.gameSettings.fancyGraphics) {
EaglerAdapter.glColorMask(false, false, false, false); EaglerAdapter.glColorMask(false, false, false, false);
int l = renderglobal.sortAndRender(entityliving, 1, f); int l = renderglobal.sortAndRender(entityliving, 1, f);
EaglerAdapter.glColorMask(true, true, true, true); EaglerAdapter.glColorMask(true, true, true, true);
@ -467,9 +473,9 @@ public class EntityRenderer {
if (l > 0) { if (l > 0) {
renderglobal.sortAndRender(entityliving, 1, f); renderglobal.sortAndRender(entityliving, 1, f);
} }
} else { //} else {
renderglobal.sortAndRender(entityliving, 1, f); // renderglobal.sortAndRender(entityliving, 1, f);
} //}
EaglerAdapter.glDepthMask(true); EaglerAdapter.glDepthMask(true);
EaglerAdapter.glEnable(2884 /* GL_CULL_FACE */); EaglerAdapter.glEnable(2884 /* GL_CULL_FACE */);
EaglerAdapter.glDisable(3042 /* GL_BLEND */); EaglerAdapter.glDisable(3042 /* GL_BLEND */);

View File

@ -4,37 +4,28 @@ package net.minecraft.src;
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode // Decompiler options: packimports(3) braces deadcode
import java.io.BufferedReader;
import java.io.InputStreamReader;
import net.lax1dude.eaglercraft.EaglerAdapter;
public class FontAllowedCharacters { public class FontAllowedCharacters {
public FontAllowedCharacters() { public static int isAllowed(char c) {
int cc = (int) c;
for(int i = 0; i < allowedChars.length; ++i) {
if(cc == allowedChars[i]) {
return i;
}
}
return -1;
} }
private static String getAllowedCharacters() { public static final int[] allowedChars = new int[]{
String s = ""; 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,
try { 59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,
BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(EaglerAdapter.loadResource("/font.txt"), "UTF-8")); 86,87,88,89,90,91,92,93,94,95,39,97,98,99,100,101,102,103,104,105,106,107,108,109,
String s1 = ""; 110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,8962,199,252,
do { 233,226,228,224,229,231,234,235,232,239,238,236,196,197,201,230,198,244,246,242,
String s2; 251,249,255,214,220,248,163,216,215,402,225,237,243,250,241,209,170,186,191,174,
if ((s2 = bufferedreader.readLine()) == null) { 172,189,188,161,171,187
break; };
}
if (!s2.startsWith("#")) {
s = (new StringBuilder()).append(s).append(s2).toString();
}
} while (true);
bufferedreader.close();
} catch (Exception exception) {
}
return s;
}
public static final String allowedCharacters = getAllowedCharacters();
public static final char field_22286_b[] = { '/', '\n', '\r', '\t', '\0', '\f', '`', '?', '*', '\\', '<', '>', '|', '"', ':' }; public static final char field_22286_b[] = { '/', '\n', '\r', '\t', '\0', '\f', '`', '?', '*', '\\', '<', '>', '|', '"', ':' };
} }

View File

@ -138,7 +138,7 @@ public class FontRenderer {
} }
if (i1 < s.length()) { if (i1 < s.length()) {
int k1 = FontAllowedCharacters.allowedCharacters.indexOf(s.charAt(i1)); int k1 = FontAllowedCharacters.isAllowed(s.charAt(i1));
if (k1 >= 0) { if (k1 >= 0) {
EaglerAdapter.glCallList(fontDisplayLists + k1 + 32); EaglerAdapter.glCallList(fontDisplayLists + k1 + 32);
EaglerAdapter.glTranslatef(charWidth[k1 + 32], 0.0F, 0.0F); EaglerAdapter.glTranslatef(charWidth[k1 + 32], 0.0F, 0.0F);
@ -159,7 +159,7 @@ public class FontRenderer {
j++; j++;
continue; continue;
} }
int k = FontAllowedCharacters.allowedCharacters.indexOf(s.charAt(j)); int k = FontAllowedCharacters.isAllowed(s.charAt(j));
if (k >= 0) { if (k >= 0) {
i += charWidth[k + 32]; i += charWidth[k + 32];
} }

View File

@ -11,7 +11,7 @@ import net.minecraft.client.Minecraft;
public class GameSettings { public class GameSettings {
public GameSettings() { public GameSettings(Minecraft mcc) {
musicVolume = 1.0F; musicVolume = 1.0F;
soundVolume = 1.0F; soundVolume = 1.0F;
mouseSensitivity = 0.5F; mouseSensitivity = 0.5F;
@ -46,6 +46,7 @@ public class GameSettings {
field_22273_E = false; field_22273_E = false;
field_22272_F = 1.0F; field_22272_F = 1.0F;
field_22271_G = 1.0F; field_22271_G = 1.0F;
mc = mcc;
loadOptions(); loadOptions();
} }
@ -99,12 +100,16 @@ public class GameSettings {
} }
if (enumoptions == EnumOptions.GRAPHICS) { if (enumoptions == EnumOptions.GRAPHICS) {
fancyGraphics = !fancyGraphics; fancyGraphics = !fancyGraphics;
if(mc.renderGlobal != null) {
mc.renderGlobal.loadRenderers(); mc.renderGlobal.loadRenderers();
} }
}
if (enumoptions == EnumOptions.AMBIENT_OCCLUSION) { if (enumoptions == EnumOptions.AMBIENT_OCCLUSION) {
field_22278_j = !field_22278_j; field_22278_j = !field_22278_j;
if(mc.renderGlobal != null) {
mc.renderGlobal.loadRenderers(); mc.renderGlobal.loadRenderers();
} }
}
if (enumoptions == EnumOptions.ANTIALIASING) { if (enumoptions == EnumOptions.ANTIALIASING) {
antialiasing = (antialiasing + i) % 3; antialiasing = (antialiasing + i) % 3;
} }

View File

@ -7,7 +7,6 @@ import net.lax1dude.eaglercraft.EaglerAdapter;
public class GuiChat extends GuiScreen { public class GuiChat extends GuiScreen {
protected String field_985_a = ""; protected String field_985_a = "";
private int field_986_h = 0; private int field_986_h = 0;
private static final String field_20082_i = FontAllowedCharacters.allowedCharacters;
public void initGui() { public void initGui() {
EaglerAdapter.enableRepeatEvents(true); EaglerAdapter.enableRepeatEvents(true);
@ -42,7 +41,7 @@ public class GuiChat extends GuiScreen {
if (n == 14 && this.field_985_a.length() > 0) { if (n == 14 && this.field_985_a.length() > 0) {
this.field_985_a = this.field_985_a.substring(0, this.field_985_a.length() - 1); this.field_985_a = this.field_985_a.substring(0, this.field_985_a.length() - 1);
} }
if (field_20082_i.indexOf(c) >= 0 && this.field_985_a.length() < 100) { if (FontAllowedCharacters.isAllowed(c) >= 0 && this.field_985_a.length() < 100) {
this.field_985_a = this.field_985_a + c; this.field_985_a = this.field_985_a + c;
} }
} }

View File

@ -39,7 +39,8 @@ public class GuiDisableButton extends Gui {
if (!this.field_22081_b || !this.field_22082_a) { if (!this.field_22081_b || !this.field_22082_a) {
return; return;
} }
if (c == '') {
if ((int)c == 16) {
int n2; int n2;
String string = GuiScreen.getClipboardString(); String string = GuiScreen.getClipboardString();
if (string == null) { if (string == null) {
@ -55,7 +56,7 @@ public class GuiDisableButton extends Gui {
if (n == 14 && this.field_22075_h.length() > 0) { if (n == 14 && this.field_22075_h.length() > 0) {
this.field_22075_h = this.field_22075_h.substring(0, this.field_22075_h.length() - 1); this.field_22075_h = this.field_22075_h.substring(0, this.field_22075_h.length() - 1);
} }
if (FontAllowedCharacters.allowedCharacters.indexOf(c) >= 0 if (FontAllowedCharacters.isAllowed(c) >= 0
&& (this.field_22075_h.length() < this.field_22074_i || this.field_22074_i == 0)) { && (this.field_22075_h.length() < this.field_22074_i || this.field_22074_i == 0)) {
this.field_22075_h = this.field_22075_h + c; this.field_22075_h = this.field_22075_h + c;
} }

View File

@ -9,7 +9,6 @@ public class GuiEditSign extends GuiScreen {
private TileEntitySign field_1002_h; private TileEntitySign field_1002_h;
private int field_4189_i; private int field_4189_i;
private int field_1000_j = 0; private int field_1000_j = 0;
private static final String field_20083_l = FontAllowedCharacters.allowedCharacters;
public GuiEditSign(TileEntitySign tileEntitySign) { public GuiEditSign(TileEntitySign tileEntitySign) {
this.field_1002_h = tileEntitySign; this.field_1002_h = tileEntitySign;
@ -54,7 +53,7 @@ public class GuiEditSign extends GuiScreen {
this.field_1002_h.signText[this.field_1000_j] = this.field_1002_h.signText[this.field_1000_j].substring(0, this.field_1002_h.signText[this.field_1000_j] = this.field_1002_h.signText[this.field_1000_j].substring(0,
this.field_1002_h.signText[this.field_1000_j].length() - 1); this.field_1002_h.signText[this.field_1000_j].length() - 1);
} }
if (field_20083_l.indexOf(c) >= 0 && this.field_1002_h.signText[this.field_1000_j].length() < 15) { if (FontAllowedCharacters.isAllowed(c) >= 0 && this.field_1002_h.signText[this.field_1000_j].length() < 15) {
int n2 = this.field_1000_j; int n2 = this.field_1000_j;
this.field_1002_h.signText[n2] = this.field_1002_h.signText[n2] + c; this.field_1002_h.signText[n2] = this.field_1002_h.signText[n2] + c;
} }

View File

@ -162,12 +162,13 @@ public class GuiIngame extends Gui {
} }
if (mc.gameSettings.showDebugInfo) { if (mc.gameSettings.showDebugInfo) {
fontrenderer.drawStringWithShadow( fontrenderer.drawStringWithShadow(
(new StringBuilder()).append("Minecraft Beta 1.3_01 (").append(mc.debug).append(")").toString(), 2, (new StringBuilder()).append("Minecraft (Eaglercraft) Beta 1.3_01 (").append(mc.debug).append(")").toString(), 2,
2, 0xffffff); 2, 0xffffff);
fontrenderer.drawStringWithShadow(mc.func_6241_m(), 2, 12, 0xffffff); fontrenderer.drawStringWithShadow(mc.func_6241_m(), 2, 12, 0xffffff);
fontrenderer.drawStringWithShadow(mc.func_6262_n(), 2, 22, 0xffffff); fontrenderer.drawStringWithShadow(mc.func_6262_n(), 2, 22, 0xffffff);
fontrenderer.drawStringWithShadow(mc.func_6245_o(), 2, 32, 0xffffff); fontrenderer.drawStringWithShadow(mc.func_6245_o(), 2, 32, 0xffffff);
fontrenderer.drawStringWithShadow(mc.func_21002_o(), 2, 42, 0xffffff); fontrenderer.drawStringWithShadow(mc.func_21002_o(), 2, 42, 0xffffff);
/*
long l2 = Runtime.getRuntime().maxMemory(); long l2 = Runtime.getRuntime().maxMemory();
long l4 = Runtime.getRuntime().totalMemory(); long l4 = Runtime.getRuntime().totalMemory();
long l6 = Runtime.getRuntime().freeMemory(); long l6 = Runtime.getRuntime().freeMemory();
@ -178,6 +179,7 @@ public class GuiIngame extends Gui {
s = (new StringBuilder()).append("Allocated memory: ").append((l4 * 100L) / l2).append("% (") s = (new StringBuilder()).append("Allocated memory: ").append((l4 * 100L) / l2).append("% (")
.append(l4 / 1024L / 1024L).append("MB)").toString(); .append(l4 / 1024L / 1024L).append("MB)").toString();
drawString(fontrenderer, s, k - fontrenderer.getStringWidth(s) - 2, 12, 0xe0e0e0); drawString(fontrenderer, s, k - fontrenderer.getStringWidth(s) - 2, 12, 0xe0e0e0);
*/
drawString(fontrenderer, (new StringBuilder()).append("x: ").append(mc.thePlayer.posX).toString(), 2, 64, drawString(fontrenderer, (new StringBuilder()).append("x: ").append(mc.thePlayer.posX).toString(), 2, 64,
0xe0e0e0); 0xe0e0e0);
drawString(fontrenderer, (new StringBuilder()).append("y: ").append(mc.thePlayer.posY).toString(), 2, 72, drawString(fontrenderer, (new StringBuilder()).append("y: ").append(mc.thePlayer.posY).toString(), 2, 72,

View File

@ -38,7 +38,7 @@ public class GuiIngameMenu extends GuiScreen {
} }
if (guibutton.id == 4) { if (guibutton.id == 4) {
mc.displayGuiScreen(null); mc.displayGuiScreen(null);
mc.func_6259_e(); mc.grabMouseCursor();
} }
} }

View File

@ -4,8 +4,6 @@ package net.minecraft.src;
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode // Decompiler options: packimports(3) braces deadcode
import java.util.*;
import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.EaglercraftRandom; import net.lax1dude.eaglercraft.EaglercraftRandom;
import net.lax1dude.eaglercraft.TextureLocation; import net.lax1dude.eaglercraft.TextureLocation;
@ -60,11 +58,6 @@ public class GuiMainMenu extends GuiScreen {
} }
public void initGui() { public void initGui() {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
if (calendar.get(2) + 1 == 11 && calendar.get(5) == 19) {
splashText = "Happy birthday, lax1dude!";
}
StringTranslate stringtranslate = StringTranslate.getInstance(); StringTranslate stringtranslate = StringTranslate.getInstance();
int i = height / 4 + 48; int i = height / 4 + 48;
controlList.add(new GuiButton(1, width / 2 - 100, i, stringtranslate.translateKey("menu.singleplayer"))); controlList.add(new GuiButton(1, width / 2 - 100, i, stringtranslate.translateKey("menu.singleplayer")));
@ -74,7 +67,7 @@ public class GuiMainMenu extends GuiScreen {
controlList.add(new GuiButton(0, width / 2 - 100, i + 72, stringtranslate.translateKey("menu.options"))); controlList.add(new GuiButton(0, width / 2 - 100, i + 72, stringtranslate.translateKey("menu.options")));
} else { } else {
controlList.add(new GuiButton(0, width / 2 - 100, i + 72 + 12, 98, 20, stringtranslate.translateKey("menu.options"))); controlList.add(new GuiButton(0, width / 2 - 100, i + 72 + 12, 98, 20, stringtranslate.translateKey("menu.options")));
controlList.add(new GuiButton(4, width / 2 + 2, i + 72 + 12, 98, 20, stringtranslate.translateKey("menu.quit"))); controlList.add(new GuiButton(4, width / 2 + 2, i + 72 + 12, 98, 20, stringtranslate.translateKey("menu.editProfile")));
} }
if (mc.session == null) { if (mc.session == null) {
((GuiButton) controlList.get(1)).enabled = false; ((GuiButton) controlList.get(1)).enabled = false;
@ -95,7 +88,7 @@ public class GuiMainMenu extends GuiScreen {
// mc.displayGuiScreen(new GuiTexturePacks(this)); // mc.displayGuiScreen(new GuiTexturePacks(this));
//} //}
if (guibutton.id == 4) { if (guibutton.id == 4) {
mc.shutdown(); mc.displayGuiScreen(new GuiNoMultiplayer(this));
} }
} }

View File

@ -4,10 +4,6 @@ package net.minecraft.src;
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode // Decompiler options: packimports(3) braces deadcode
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.util.ArrayList; import java.util.ArrayList;
import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglerAdapter;
@ -36,20 +32,17 @@ public class GuiScreen extends Gui {
protected void keyTyped(char c, int i) { protected void keyTyped(char c, int i) {
if (i == 1) { if (i == 1) {
mc.displayGuiScreen(null); mc.displayGuiScreen(null);
mc.func_6259_e(); mc.grabMouseCursor();
} }
} }
public static String getClipboardString() { public static String getClipboardString() {
try { try {
Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); String s = EaglerAdapter.getClipboard();
if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { return s == null ? "" : s;
String s = (String) transferable.getTransferData(DataFlavor.stringFlavor); }catch(Throwable t) {
return s; return "";
} }
} catch (Exception exception) {
}
return null;
} }
protected void mouseClicked(int i, int j, int k) { protected void mouseClicked(int i, int j, int k) {

View File

@ -4,8 +4,7 @@ package net.minecraft.src;
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode // Decompiler options: packimports(3) braces deadcode
import java.util.List; import net.lax1dude.eaglercraft.EaglerAdapter;
import org.lwjgl.input.Keyboard;
public class GuiSleepMP extends GuiChat { public class GuiSleepMP extends GuiChat {
@ -13,14 +12,14 @@ public class GuiSleepMP extends GuiChat {
} }
public void initGui() { public void initGui() {
Keyboard.enableRepeatEvents(true); EaglerAdapter.enableRepeatEvents(true);
StringTranslate stringtranslate = StringTranslate.getInstance(); StringTranslate stringtranslate = StringTranslate.getInstance();
controlList.add(new GuiButton(1, width / 2 - 100, height - 40, controlList.add(new GuiButton(1, width / 2 - 100, height - 40,
stringtranslate.translateKey("multiplayer.stopSleeping"))); stringtranslate.translateKey("multiplayer.stopSleeping")));
} }
public void onGuiClosed() { public void onGuiClosed() {
Keyboard.enableRepeatEvents(false); EaglerAdapter.enableRepeatEvents(false);
} }
protected void keyTyped(char c, int i) { protected void keyTyped(char c, int i) {

View File

@ -1,5 +1,9 @@
package net.minecraft.src; package net.minecraft.src;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import net.lax1dude.eaglercraft.AWTColor; import net.lax1dude.eaglercraft.AWTColor;
import net.lax1dude.eaglercraft.EaglercraftRandom; import net.lax1dude.eaglercraft.EaglercraftRandom;
@ -15,10 +19,19 @@ public class MobSpawnerBase {
topBlock = (byte) Block.grass.blockID; topBlock = (byte) Block.grass.blockID;
fillerBlock = (byte) Block.dirt.blockID; fillerBlock = (byte) Block.dirt.blockID;
field_6502_q = 0x4ee031; field_6502_q = 0x4ee031;
biomeMonsters = (new Class[] { EntitySpider.class, EntityZombie.class, EntitySkeleton.class, biomeMonsters = new ArrayList();
EntityCreeper.class, EntitySlime.class }); biomeMonsters.add((w) -> new EntitySpider(w));
biomeCreatures = (new Class[] { EntitySheep.class, EntityPig.class, EntityChicken.class, EntityCow.class }); biomeMonsters.add((w) -> new EntityZombie(w));
biomeWaterCreatures = (new Class[] { EntitySquid.class }); biomeMonsters.add((w) -> new EntitySkeleton(w));
biomeMonsters.add((w) -> new EntityCreeper(w));
biomeMonsters.add((w) -> new EntitySlime(w));
biomeCreatures = new ArrayList();
biomeCreatures.add((w) -> new EntitySheep(w));
biomeCreatures.add((w) -> new EntityPig(w));
biomeCreatures.add((w) -> new EntityChicken(w));
biomeCreatures.add((w) -> new EntityCow(w));
biomeWaterCreatures = new ArrayList();
biomeWaterCreatures.add((w) -> new EntitySquid(w));
} }
public static void generateBiomeLookup() { public static void generateBiomeLookup() {
@ -115,7 +128,7 @@ public class MobSpawnerBase {
return AWTColor.HSBtoRGB(0.6222222F - f * 0.05F, 0.5F + f * 0.1F, 1.0F); return AWTColor.HSBtoRGB(0.6222222F - f * 0.05F, 0.5F + f * 0.1F, 1.0F);
} }
public Class[] getEntitiesForType(EnumCreatureType enumcreaturetype) { public List<Function<World, EntityLiving>> getEntitiesForType(EnumCreatureType enumcreaturetype) {
if (enumcreaturetype == EnumCreatureType.monster) { if (enumcreaturetype == EnumCreatureType.monster) {
return biomeMonsters; return biomeMonsters;
} }
@ -153,9 +166,9 @@ public class MobSpawnerBase {
public byte topBlock; public byte topBlock;
public byte fillerBlock; public byte fillerBlock;
public int field_6502_q; public int field_6502_q;
protected Class biomeMonsters[]; protected List<Function<World, EntityLiving>> biomeMonsters;
protected Class biomeCreatures[]; protected List<Function<World, EntityLiving>> biomeCreatures;
protected Class biomeWaterCreatures[]; protected List<Function<World, EntityLiving>> biomeWaterCreatures;
private static MobSpawnerBase biomeLookupTable[] = new MobSpawnerBase[4096]; private static MobSpawnerBase biomeLookupTable[] = new MobSpawnerBase[4096];
static { static {

View File

@ -1,4 +1,7 @@
package net.minecraft.src; package net.minecraft.src;
import java.util.ArrayList;
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
@ -7,7 +10,9 @@ package net.minecraft.src;
public class MobSpawnerHell extends MobSpawnerBase { public class MobSpawnerHell extends MobSpawnerBase {
public MobSpawnerHell() { public MobSpawnerHell() {
biomeMonsters = (new Class[] { EntityGhast.class, EntityPigZombie.class }); biomeMonsters = new ArrayList();
biomeCreatures = new Class[0]; biomeMonsters.add((w) -> new EntityGhast(w));
biomeMonsters.add((w) -> new EntityPigZombie(w));
biomeCreatures = new ArrayList();
} }
} }

View File

@ -4,20 +4,10 @@ package net.minecraft.src;
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode // Decompiler options: packimports(3) braces deadcode
import java.nio.IntBuffer;
import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglerAdapter;
public class MouseHelper { public class MouseHelper {
public MouseHelper() {
field_1115_e = 10;
IntBuffer intbuffer = GLAllocation.createDirectIntBuffer(1);
intbuffer.put(0);
intbuffer.flip();
IntBuffer intbuffer1 = GLAllocation.createDirectIntBuffer(1024);
}
public void func_774_a() { public void func_774_a() {
EaglerAdapter.mouseSetGrabbed(true); EaglerAdapter.mouseSetGrabbed(true);
deltaX = 0; deltaX = 0;
@ -36,5 +26,4 @@ public class MouseHelper {
public int deltaX; public int deltaX;
public int deltaY; public int deltaY;
private int field_1115_e;
} }

View File

@ -232,12 +232,19 @@ public class RenderEngine {
imageDataA.put(texturefx.imageData); imageDataA.put(texturefx.imageData);
imageDataA.position(0).limit(tileSize); imageDataA.position(0).limit(tileSize);
texturefx.bindImage(this); texturefx.bindImage(this);
for (int k = 0; k < texturefx.tileSize; k++) {
label0: for (int i1 = 0; i1 < texturefx.tileSize; i1++) {
int idx = texturefx.iconIndex + k + i1 * 16;
imageDataA.position(0).limit(tileSize); imageDataA.position(0).limit(tileSize);
for (int k = 0; k < texturefx.tileSize; k++) {
for (int i1 = 0; i1 < texturefx.tileSize; i1++) {
int idx = texturefx.iconIndex + k + i1 * 16;
imageDataA.mark();
EaglerAdapter.glTexSubImage2D(3553 /* GL_TEXTURE_2D */, 0, (idx % 16) * 16, (idx / 16) * 16, 16, 16, 6408 /* GL_RGBA */, EaglerAdapter.glTexSubImage2D(3553 /* GL_TEXTURE_2D */, 0, (idx % 16) * 16, (idx / 16) * 16, 16, 16, 6408 /* GL_RGBA */,
5121 /* GL_UNSIGNED_BYTE */, imageDataA); 5121 /* GL_UNSIGNED_BYTE */, imageDataA);
imageDataA.rewind();
}
}
if(texturefx.tileImage == 0) { if(texturefx.tileImage == 0) {
imageDataA.position(0).limit(tileSize); imageDataA.position(0).limit(tileSize);
imageDataB1.clear(); imageDataB1.clear();
@ -246,7 +253,7 @@ public class RenderEngine {
int k1 = 1; int k1 = 1;
do { do {
if (k1 > 4) { if (k1 > 4) {
continue label0; break;
} }
int i2 = 16 >> k1 - 1; int i2 = 16 >> k1 - 1;
int k2 = 16 >> k1; int k2 = 16 >> k1;
@ -261,60 +268,26 @@ public class RenderEngine {
imageDataB2.putInt((i3 + k3 * k2) * 4, l5); imageDataB2.putInt((i3 + k3 * k2) * 4, l5);
} }
} }
for (int k = 0; k < texturefx.tileSize; k++) {
for (int i1 = 0; i1 < texturefx.tileSize; i1++) {
int idx = texturefx.iconIndex + k + i1 * 16;
imageDataB2.mark();
EaglerAdapter.glTexSubImage2D(3553 /* GL_TEXTURE_2D */, k1, (idx % 16) * k2, (idx / 16) * k2, k2, k2, 6408 /* GL_RGBA */, EaglerAdapter.glTexSubImage2D(3553 /* GL_TEXTURE_2D */, k1, (idx % 16) * k2, (idx / 16) * k2, k2, k2, 6408 /* GL_RGBA */,
5121 /* GL_UNSIGNED_BYTE */, imageDataB2); 5121 /* GL_UNSIGNED_BYTE */, imageDataB2);
imageDataB2.rewind();
}
}
k1++; k1++;
ByteBuffer tmp = imageDataB1; ByteBuffer tmp = imageDataB1;
imageDataB1 = imageDataB2; imageDataB1 = imageDataB2;
imageDataB2 = tmp; imageDataB2 = tmp;
} while (true); } while (true);
} }
}
}
} }
// label1: for (int j = 0; j < textureList.size(); j++) {
// TextureFX texturefx1 = (TextureFX) textureList.get(j);
// if (texturefx1.field_1130_d <= 0) {
// continue;
// }
// imageDataA.clear();
// imageDataA.put(texturefx1.imageData);
// imageDataA.position(0).limit(texturefx1.imageData.length);
// EaglerAdapter.glBindTexture(3553 /* GL_TEXTURE_2D */, texturefx1.field_1130_d);
// EaglerAdapter.glTexSubImage2D(3553 /* GL_TEXTURE_2D */, 0, 0, 0, 16, 16, 6408 /* GL_RGBA */,
// 5121 /* GL_UNSIGNED_BYTE */, imageDataA);
// if(texturefx1.tileImage == 0) {
// int l = 1;
// do {
// if (l > 4) {
// continue label1;
// }
// int j1 = 16 >> l - 1;
// int l1 = 16 >> l;
// for (int j2 = 0; j2 < l1; j2++) {
// for (int l2 = 0; l2 < l1; l2++) {
// int j3 = imageDataA.getInt((j2 * 2 + 0 + (l2 * 2 + 0) * j1) * 4);
// int l3 = imageDataA.getInt((j2 * 2 + 1 + (l2 * 2 + 0) * j1) * 4);
// int j4 = imageDataA.getInt((j2 * 2 + 1 + (l2 * 2 + 1) * j1) * 4);
// int l4 = imageDataA.getInt((j2 * 2 + 0 + (l2 * 2 + 1) * j1) * 4);
// int j5 = averageColor(averageColor(j3, l3), averageColor(j4, l4));
// imageDataB.putInt((j2 + l2 * l1) * 4, j5);
// }
//
// }
//
// EaglerAdapter.glTexSubImage2D(3553 /* GL_TEXTURE_2D */, l, 0, 0, l1, l1, 6408 /* GL_RGBA */,
// 5121 /* GL_UNSIGNED_BYTE */, imageDataB);
// ByteBuffer tmp = imageDataA;
// imageDataA = imageDataB;
// imageDataB = tmp;
// l++;
// } while (true);
// }
// }
} }
private int averageColor(int i, int j) { private int averageColor(int i, int j) {

View File

@ -1,4 +1,4 @@
package net.lax1dude.eaglercraft.anvil; package net.minecraft.src;
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
@ -6,11 +6,6 @@ package net.lax1dude.eaglercraft.anvil;
import java.util.List; import java.util.List;
import net.minecraft.src.IChunkLoader;
import net.minecraft.src.ISaveHandler;
import net.minecraft.src.WorldInfo;
import net.minecraft.src.WorldProvider;
public class SaveHandlerMP implements ISaveHandler { public class SaveHandlerMP implements ISaveHandler {
public SaveHandlerMP() { public SaveHandlerMP() {

View File

@ -2,14 +2,21 @@
// Class Version: 5 // Class Version: 5
package net.minecraft.src; package net.minecraft.src;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.function.Function;
public final class SpawnerAnimals { public final class SpawnerAnimals {
private static Set<ChunkCoordIntPair> field_6544_a = new HashSet(); private static Set<ChunkCoordIntPair> field_6544_a = new HashSet();
protected static final Class[] field_22391_a = new Class[] { EntitySpider.class, EntityZombie.class, protected static final List<Function<World, EntityLiving>> field_22391_a = new ArrayList();
EntitySkeleton.class };
static {
field_22391_a.add((w) -> new EntitySpider(w));
field_22391_a.add((w) -> new EntityZombie(w));
field_22391_a.add((w) -> new EntitySkeleton(w));
}
protected static ChunkPosition func_4153_a(World world, int n, int n2) { protected static ChunkPosition func_4153_a(World world, int n, int n2) {
int n3 = n + world.rand.nextInt(16); int n3 = n + world.rand.nextInt(16);
@ -46,10 +53,10 @@ public final class SpawnerAnimals {
continue; continue;
block6: for (ChunkCoordIntPair chunkCoordIntPair : field_6544_a) { block6: for (ChunkCoordIntPair chunkCoordIntPair : field_6544_a) {
MobSpawnerBase mobSpawnerBase = world.getWorldChunkManager().func_4074_a(chunkCoordIntPair); MobSpawnerBase mobSpawnerBase = world.getWorldChunkManager().func_4074_a(chunkCoordIntPair);
Class[] classArray = mobSpawnerBase.getEntitiesForType(enumCreatureType); List<Function<World, EntityLiving>> classArray = mobSpawnerBase.getEntitiesForType(enumCreatureType);
if (classArray == null || classArray.length == 0) if (classArray == null || classArray.size() == 0)
continue; continue;
int n5 = world.rand.nextInt(classArray.length); int n5 = world.rand.nextInt(classArray.size());
ChunkPosition chunkPosition = SpawnerAnimals.func_4153_a(world, chunkCoordIntPair.chunkXPos * 16, ChunkPosition chunkPosition = SpawnerAnimals.func_4153_a(world, chunkCoordIntPair.chunkXPos * 16,
chunkCoordIntPair.chunkZPos * 16); chunkCoordIntPair.chunkZPos * 16);
int n6 = chunkPosition.x; int n6 = chunkPosition.x;
@ -84,7 +91,7 @@ public final class SpawnerAnimals {
+ (f = f5 - (float) ((ChunkCoordinates) object).field_22396_c) * f) < 576.0f) + (f = f5 - (float) ((ChunkCoordinates) object).field_22396_c) * f) < 576.0f)
continue; continue;
try { try {
entityLiving = (EntityLiving) classArray[n5].getConstructor(World.class).newInstance(world); entityLiving = classArray.get(n5).apply(world);
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
return n; return n;
@ -127,8 +134,8 @@ public final class SpawnerAnimals {
boolean bl = false; boolean bl = false;
Pathfinder pathfinder = new Pathfinder(world); Pathfinder pathfinder = new Pathfinder(world);
for (EntityPlayer entityPlayer : (List<EntityPlayer>) list) { for (EntityPlayer entityPlayer : (List<EntityPlayer>) list) {
Class[] classArray = field_22391_a; List<Function<World, EntityLiving>> classArray = field_22391_a;
if (classArray == null || classArray.length == 0) if (classArray == null || classArray.size() == 0)
continue; continue;
boolean bl2 = false; boolean bl2 = false;
for (int i = 0; i < 20 && !bl2; ++i) { for (int i = 0; i < 20 && !bl2; ++i) {
@ -143,7 +150,7 @@ public final class SpawnerAnimals {
} else if (n4 > 128) { } else if (n4 > 128) {
n4 = 128; n4 = 128;
} }
int n5 = world.rand.nextInt(classArray.length); int n5 = world.rand.nextInt(classArray.size());
for (n = n4; n > 2 && !world.isBlockOpaqueCube(n2, n - 1, n3); --n) { for (n = n4; n > 2 && !world.isBlockOpaqueCube(n2, n - 1, n3); --n) {
} }
while (!SpawnerAnimals.func_21203_a(EnumCreatureType.monster, world, n2, n, n3) && n < n4 + 16 while (!SpawnerAnimals.func_21203_a(EnumCreatureType.monster, world, n2, n, n3) && n < n4 + 16
@ -158,7 +165,7 @@ public final class SpawnerAnimals {
float f2 = n; float f2 = n;
float f3 = (float) n3 + 0.5f; float f3 = (float) n3 + 0.5f;
try { try {
entityLiving = (EntityLiving) classArray[n5].getConstructor(World.class).newInstance(world); entityLiving = (EntityLiving) classArray.get(n5).apply(world);
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
return bl; return bl;

View File

@ -4,9 +4,6 @@ package net.minecraft.src;
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode // Decompiler options: packimports(3) braces deadcode
import java.io.IOException;
import javax.imageio.ImageIO;
import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.EaglerImage; import net.lax1dude.eaglercraft.EaglerImage;

View File

@ -3,7 +3,6 @@ package net.minecraft.src;
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode // Decompiler options: packimports(3) braces deadcode
import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.TextureLocation; import net.lax1dude.eaglercraft.TextureLocation;
public class TextureFX { public class TextureFX {
@ -37,4 +36,5 @@ public class TextureFX {
public int field_1130_d; public int field_1130_d;
public int tileSize; public int tileSize;
public int tileImage; public int tileImage;
public int firstTick = 0;
} }

View File

@ -4,9 +4,9 @@ package net.minecraft.src;
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode // Decompiler options: packimports(3) braces deadcode
public class TexureWaterFlowFX extends TextureFX { public class TextureWaterFlowFX extends TextureFX {
public TexureWaterFlowFX() { public TextureWaterFlowFX() {
super(Block.waterStill.blockIndexInTexture + 1); super(Block.waterStill.blockIndexInTexture + 1);
field_1138_g = new float[256]; field_1138_g = new float[256];
field_1137_h = new float[256]; field_1137_h = new float[256];

View File

@ -7,17 +7,18 @@ package net.minecraft.src;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Supplier;
public class TileEntity { public class TileEntity {
public TileEntity() { public TileEntity() {
} }
private static void addMapping(Class class1, String s) { private static void addMapping(Class class1, Supplier<TileEntity> construct, String s) {
if (classToNameMap.containsKey(s)) { if (classToNameMap.containsKey(s)) {
throw new IllegalArgumentException((new StringBuilder()).append("Duplicate id: ").append(s).toString()); throw new IllegalArgumentException((new StringBuilder()).append("Duplicate id: ").append(s).toString());
} else { } else {
nameToClassMap.put(s, class1); nameToClassMap.put(s, construct);
classToNameMap.put(class1, s); classToNameMap.put(class1, s);
return; return;
} }
@ -49,9 +50,9 @@ public class TileEntity {
public static TileEntity createAndLoadEntity(NBTTagCompound nbttagcompound) { public static TileEntity createAndLoadEntity(NBTTagCompound nbttagcompound) {
TileEntity tileentity = null; TileEntity tileentity = null;
try { try {
Class class1 = (Class) nameToClassMap.get(nbttagcompound.getString("id")); Supplier<TileEntity> class1 = (Supplier<TileEntity>) nameToClassMap.get(nbttagcompound.getString("id"));
if (class1 != null) { if (class1 != null) {
tileentity = (TileEntity) class1.newInstance(); tileentity = class1.get();
} }
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
@ -102,11 +103,11 @@ public class TileEntity {
public int zCoord; public int zCoord;
static { static {
addMapping(TileEntityFurnace.class, "Furnace"); addMapping(TileEntityFurnace.class, () -> new TileEntityFurnace(), "Furnace");
addMapping(TileEntityChest.class, "Chest"); addMapping(TileEntityChest.class, () -> new TileEntityChest(), "Chest");
addMapping(TileEntityDispenser.class, "Trap"); addMapping(TileEntityDispenser.class, () -> new TileEntityDispenser(), "Trap");
addMapping(TileEntitySign.class, "Sign"); addMapping(TileEntitySign.class, () -> new TileEntitySign(), "Sign");
addMapping(TileEntityMobSpawner.class, "MobSpawner"); addMapping(TileEntityMobSpawner.class, () -> new TileEntityMobSpawner(), "MobSpawner");
addMapping(TileEntityNote.class, "Music"); addMapping(TileEntityNote.class, () -> new TileEntityNote(), "Music");
} }
} }

View File

@ -6,8 +6,6 @@ package net.minecraft.src;
import java.util.*; import java.util.*;
import net.lax1dude.eaglercraft.anvil.SaveHandlerMP;
public class WorldClient extends World { public class WorldClient extends World {
public WorldClient(NetClientHandler netclienthandler, long l, int i) { public WorldClient(NetClientHandler netclienthandler, long l, int i) {

View File

@ -60,10 +60,9 @@ public class WorldProvider {
public float[] func_4097_b(float f, float f1) { public float[] func_4097_b(float f, float f1) {
float f2 = 0.4F; float f2 = 0.4F;
float f3 = MathHelper.cos(f * 3.141593F * 2.0F) - 0.0F; float f3 = MathHelper.cos(f * 3.141593F * 2.0F);
float f4 = -0F; if (f3 >= -f2 && f3 <= f2) {
if (f3 >= f4 - f2 && f3 <= f4 + f2) { float f5 = (f3 / f2) * 0.5F + 0.5F;
float f5 = ((f3 - f4) / f2) * 0.5F + 0.5F;
float f6 = 1.0F - (1.0F - MathHelper.sin(f5 * 3.141593F)) * 0.99F; float f6 = 1.0F - (1.0F - MathHelper.sin(f5 * 3.141593F)) * 0.99F;
f6 *= f6; f6 *= f6;
field_4217_f[0] = f5 * 0.3F + 0.7F; field_4217_f[0] = f5 * 0.3F + 0.7F;

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,121 @@
package net.lax1dude.eaglercraft;
import java.util.Collection;
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FileEntry;
import net.lax1dude.eaglercraft.adapter.teavm.IndexedDBFilesystem;
import net.lax1dude.eaglercraft.adapter.teavm.IndexedDBFilesystem.OpenState;
public class TestFilesystem {
public static void main(String[] args) {
OpenState os = IndexedDBFilesystem.initialize();
if(os != OpenState.OPENED) {
System.out.println("Error: " + os);
System.out.println("Detail: " + IndexedDBFilesystem.errorDetail());
return;
}
IndexedDBFilesystem.writeFile("text.txt", "fuck fuck shit".getBytes());
IndexedDBFilesystem.writeFile("folder/text.txt", "fuck shit fuck".getBytes());
IndexedDBFilesystem.writeFile("folder/eee/text.txt", "shit shit fuck".getBytes());
System.out.println("exists text.txt:" + IndexedDBFilesystem.fileExists("text.txt"));
System.out.println("exists folder/text.txt:" + IndexedDBFilesystem.fileExists("folder/text.txt"));
System.out.println("exists folder/eee/text.txt:" + IndexedDBFilesystem.fileExists("folder/eee/text.txt"));
System.out.println("type file text.txt:" + IndexedDBFilesystem.fileExists("text.txt"));
System.out.println("type file folder:" + IndexedDBFilesystem.fileExists("folder"));
System.out.println("type file folder/text.txt:" + IndexedDBFilesystem.fileExists("folder/text.txt"));
System.out.println("type file folder/eee:" + IndexedDBFilesystem.fileExists("folder/eee"));
System.out.println("type file folder/eee/text.txt:" + IndexedDBFilesystem.fileExists("folder/eee/text.txt"));
System.out.println("type folder text.txt:" + IndexedDBFilesystem.directoryExists("text.txt"));
System.out.println("type folder folder:" + IndexedDBFilesystem.directoryExists("folder"));
System.out.println("type folder folder/text.txt:" + IndexedDBFilesystem.directoryExists("folder/text.txt"));
System.out.println("type folder folder/eee:" + IndexedDBFilesystem.directoryExists("folder/eee"));
System.out.println("type folder folder/eee/text.txt:" + IndexedDBFilesystem.directoryExists("folder/eee/text.txt"));
System.out.println("data file text.txt:" + new String(IndexedDBFilesystem.readFile("text.txt")));
System.out.println("data file folder/text.txt:" + new String(IndexedDBFilesystem.readFile("folder/text.txt")));
System.out.println("data file folder/eee/text.txt:" + new String(IndexedDBFilesystem.readFile("folder/eee/text.txt")));
System.out.println("copy file text.txt to text2.txt"); IndexedDBFilesystem.copyFile("text.txt", "text2.txt");
System.out.println("copy file text.txt to folder2/text2.txt"); IndexedDBFilesystem.copyFile("text.txt", "folder2/text2.txt");
System.out.println("copy file folder/text.txt to folder3/eee2/text2.txt:"); IndexedDBFilesystem.copyFile("folder/text.txt", "folder3/eee2/text2.txt");
System.out.println("copy file folder3/eee2/text2.txt to text2.txt:"); IndexedDBFilesystem.copyFile("folder3/eee2/text2.txt", "text2.txt");
System.out.println("type folder folder2:" + IndexedDBFilesystem.directoryExists("folder2"));
System.out.println("type folder folder3:" + IndexedDBFilesystem.directoryExists("folder3"));
System.out.println("type folder folder3/eee2:" + IndexedDBFilesystem.directoryExists("folder3/eee2"));
System.out.println("data file text.txt:" + new String(IndexedDBFilesystem.readFile("text.txt")));
System.out.println("data file folder/text.txt:" + new String(IndexedDBFilesystem.readFile("folder/text.txt")));
System.out.println("data file folder/eee/text.txt:" + new String(IndexedDBFilesystem.readFile("folder/eee/text.txt")));
System.out.println("data file text2.txt:" + new String(IndexedDBFilesystem.readFile("text2.txt")));
System.out.println("data file folder2/text2.txt:" + new String(IndexedDBFilesystem.readFile("folder2/text2.txt")));
System.out.println("data file folder3/eee2/text2.txt:" + new String(IndexedDBFilesystem.readFile("folder3/eee2/text2.txt")));
System.out.println("data file folder2/tefjfgj.txt:" + IndexedDBFilesystem.readFile("folder2/tefjfgj.txt"));
System.out.println("data file folder3/gjjg/text2.txt:" + IndexedDBFilesystem.readFile("folder3/eegjjge2/text2.txt"));
System.out.println("move file text.txt to text3.txt"); IndexedDBFilesystem.renameFile("text.txt", "text3.txt");
System.out.println("move file text.txt to folder4/text2.txt"); IndexedDBFilesystem.renameFile("text.txt", "folder4/text2.txt");
System.out.println("move file text3.txt to folder4/text2.txt"); IndexedDBFilesystem.renameFile("text.txt", "folder4/text3.txt");
System.out.println("move file folder22/text.txt to folder3/eee2/text3.txt:"); IndexedDBFilesystem.renameFile("folder22/text.txt", "folder3/eee2/text3.txt");
System.out.println("last modified text.txt:" + IndexedDBFilesystem.getLastModified("text.txt"));
System.out.println("last modified folder/text.txt:" + IndexedDBFilesystem.getLastModified("folder/text.txt"));
System.out.println("last modified folder/eee/text.txt:" + IndexedDBFilesystem.getLastModified("folder/eee/text.txt"));
System.out.println("last modified text2.txt:" + IndexedDBFilesystem.getLastModified("text2.txt"));
System.out.println("last modified folder2/text2.txt:" + IndexedDBFilesystem.getLastModified("folder2/text2.txt"));
System.out.println("last modified folder3/eee2/text2.txt:" + IndexedDBFilesystem.getLastModified("folder3/eee2/text2.txt"));
System.out.println("last modified folder2/tefjfgj.txt:" + IndexedDBFilesystem.getLastModified("folder2/tefjfgj.txt"));
System.out.println("last modified folder3/gjjg/text2.txt:" + IndexedDBFilesystem.getLastModified("folder3/eegjjge2/text2.txt"));
System.out.println("last modified text3.txt: " + IndexedDBFilesystem.getLastModified("text3.txt"));
System.out.println("last modified folder4/text2.txt: " + IndexedDBFilesystem.getLastModified("folder4/text2.txt"));
System.out.println("last modified folder4/text3.txt: " + IndexedDBFilesystem.getLastModified("folder4/text3.txt"));
System.out.println("last modified folder3/eee2/text3.txt:" + IndexedDBFilesystem.getLastModified("folder3/eee2/text3.txt"));
System.out.println("delete file text3.txt"); IndexedDBFilesystem.deleteFile("text3.txt");
System.out.println("delete file folder4/text2.txt"); IndexedDBFilesystem.deleteFile("folder4/text2.txt");
System.out.println("delete file folder4/text2.txt"); IndexedDBFilesystem.deleteFile("folder4/text3.txt");
System.out.println("delete file folder4"); IndexedDBFilesystem.deleteFile("folder4");
System.out.println("delete file folder3/eee2/text3.txt:"); IndexedDBFilesystem.deleteFile("folder3/eee2/text3.txt");
Collection<FileEntry> files = IndexedDBFilesystem.listFiles("", true, true);
System.out.println();
System.out.println("List all:");
listFileList(files);
files = IndexedDBFilesystem.listFiles("", false, true);
System.out.println();
System.out.println("List all files:");
listFileList(files);
files = IndexedDBFilesystem.listFiles("", false, false);
System.out.println();
System.out.println("List all files not recursive:");
listFileList(files);
files = IndexedDBFilesystem.listFiles("folder", true, true);
System.out.println();
System.out.println("List all files in 'folder':");
listFileList(files);
files = IndexedDBFilesystem.listFiles("folder", true, false);
System.out.println();
System.out.println("List all files in 'folder' no recursive:");
listFileList(files);
}
private static void listFileList(Collection<FileEntry> files) {
for(FileEntry f : files) {
System.out.println(" - " + f.path + " " + f.isDirectory + " " + f.lastModified + " " + f.getName());
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,351 @@
package net.lax1dude.eaglercraft.adapter;
import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Float32Array;
import org.teavm.jso.typedarrays.Int32Array;
import net.lax1dude.eaglercraft.EaglerAdapter;
public class Tessellator {
/** The byte buffer used for GL allocation. */
private Int32Array intBuffer;
private Float32Array floatBuffer;
/**
* The number of vertices to be drawn in the next draw call. Reset to 0 between
* draw calls.
*/
private int vertexCount = 0;
/** The first coordinate to be used for the texture. */
private float textureU;
/** The second coordinate to be used for the texture. */
private float textureV;
/** The color (RGBA) value to be used for the following draw call. */
private int color;
/**
* Whether the current draw object for this tessellator has color values.
*/
private boolean hasColor = false;
/**
* Whether the current draw object for this tessellator has texture coordinates.
*/
private boolean hasTexture = false;
/**
* Whether the current draw object for this tessellator has normal values.
*/
private boolean hasNormals = false;
/** The index into the raw buffer to be used for the next data. */
private int rawBufferIndex = 0;
/**
* The number of vertices manually added to the given draw call. This differs
* from vertexCount because it adds extra vertices when converting quads to
* triangles.
*/
private int addedVertices = 0;
/** Disables all color information for the following draw call. */
private boolean isColorDisabled = false;
/** The draw mode currently being used by the tessellator. */
private int drawMode;
/**
* An offset to be applied along the x-axis for all vertices in this draw call.
*/
private double xOffset;
/**
* An offset to be applied along the y-axis for all vertices in this draw call.
*/
private double yOffset;
/**
* An offset to be applied along the z-axis for all vertices in this draw call.
*/
private double zOffset;
/** The normal to be applied to the face being drawn. */
private int normal;
/** The static instance of the Tessellator. */
public static final Tessellator instance = new Tessellator(525000);
/** Whether this tessellator is currently in draw mode. */
private boolean isDrawing = false;
/** Whether we are currently using VBO or not. */
private boolean useVBO = false;
/** The size of the buffers used (in integers). */
private int bufferSize;
private Tessellator(int par1) {
this.bufferSize = par1;
ArrayBuffer a = ArrayBuffer.create(par1 * 4);
this.intBuffer = Int32Array.create(a);
this.floatBuffer = Float32Array.create(a);
}
/**
* Draws the data set up in this tessellator and resets the state to prepare for
* new drawing.
*/
public int draw() {
if (!this.isDrawing) {
return 0;
} else {
this.isDrawing = false;
if (this.vertexCount > 0) {
if (this.hasTexture) {
EaglerAdapter.glEnableVertexAttrib(EaglerAdapter.GL_TEXTURE_COORD_ARRAY);
}
if (this.hasColor) {
EaglerAdapter.glEnableVertexAttrib(EaglerAdapter.GL_COLOR_ARRAY);
}
if (this.hasNormals) {
EaglerAdapter.glEnableVertexAttrib(EaglerAdapter.GL_NORMAL_ARRAY);
}
EaglerAdapter.glDrawArrays(this.drawMode, 0, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 7));
if (this.hasTexture) {
EaglerAdapter.glDisableVertexAttrib(EaglerAdapter.GL_TEXTURE_COORD_ARRAY);
}
if (this.hasColor) {
EaglerAdapter.glDisableVertexAttrib(EaglerAdapter.GL_COLOR_ARRAY);
}
if (this.hasNormals) {
EaglerAdapter.glDisableVertexAttrib(EaglerAdapter.GL_NORMAL_ARRAY);
}
}
int var1 = this.rawBufferIndex * 4;
this.reset();
return var1;
}
}
/**
* Clears the tessellator state in preparation for new drawing.
*/
private void reset() {
this.vertexCount = 0;
//this.byteBuffer.clear();
this.rawBufferIndex = 0;
this.addedVertices = 0;
}
/**
* Sets draw mode in the tessellator to draw quads.
*/
public void startDrawingQuads() {
this.startDrawing(EaglerAdapter.GL_QUADS);
}
/**
* Resets tessellator state and prepares for drawing (with the specified draw
* mode).
*/
public void startDrawing(int par1) {
if (this.isDrawing) {
this.draw();
}
this.isDrawing = true;
this.reset();
this.drawMode = par1;
this.hasNormals = false;
this.hasColor = false;
this.hasTexture = false;
this.isColorDisabled = false;
}
/**
* Sets the texture coordinates.
*/
public void setTextureUV(double par1, double par3) {
this.hasTexture = true;
this.textureU = (float) par1;
this.textureV = (float) par3;
}
/**
* Sets the RGB values as specified, converting from floats between 0 and 1 to
* integers from 0-255.
*/
public void setColorOpaque_F(float par1, float par2, float par3) {
this.setColorOpaque((int) (par1 * 255.0F), (int) (par2 * 255.0F), (int) (par3 * 255.0F));
}
/**
* Sets the RGBA values for the color, converting from floats between 0 and 1 to
* integers from 0-255.
*/
public void setColorRGBA_F(float par1, float par2, float par3, float par4) {
this.setColorRGBA((int) (par1 * 255.0F), (int) (par2 * 255.0F), (int) (par3 * 255.0F), (int) (par4 * 255.0F));
}
/**
* Sets the RGB values as specified, and sets alpha to opaque.
*/
public void setColorOpaque(int par1, int par2, int par3) {
this.setColorRGBA(par1, par2, par3, 255);
}
/**
* Sets the RGBA values for the color. Also clamps them to 0-255.
*/
public void setColorRGBA(int par1, int par2, int par3, int par4) {
if (!this.isColorDisabled) {
if (par1 > 255) {
par1 = 255;
}
if (par2 > 255) {
par2 = 255;
}
if (par3 > 255) {
par3 = 255;
}
if (par4 > 255) {
par4 = 255;
}
if (par1 < 0) {
par1 = 0;
}
if (par2 < 0) {
par2 = 0;
}
if (par3 < 0) {
par3 = 0;
}
if (par4 < 0) {
par4 = 0;
}
this.hasColor = true;
this.color = par4 << 24 | par3 << 16 | par2 << 8 | par1;
}
}
/**
* Adds a vertex specifying both x,y,z and the texture u,v for it.
*/
public void addVertexWithUV(double par1, double par3, double par5, double par7, double par9) {
this.setTextureUV(par7, par9);
this.addVertex(par1, par3, par5);
}
/**
* Adds a vertex with the specified x,y,z to the current draw call. It will
* trigger a draw() if the buffer gets full.
*/
public void addVertex(double par1, double par3, double par5) {
if(this.addedVertices > 65534) return;
++this.addedVertices;
++this.vertexCount;
int bufferIndex = this.rawBufferIndex;
Int32Array intBuffer0 = intBuffer;
Float32Array floatBuffer0 = floatBuffer;
floatBuffer0.set(bufferIndex + 0, (float) (par1 + this.xOffset));
floatBuffer0.set(bufferIndex + 1, (float) (par3 + this.yOffset));
floatBuffer0.set(bufferIndex + 2, (float) (par5 + this.zOffset));
if (this.hasTexture) {
floatBuffer0.set(bufferIndex + 3, this.textureU);
floatBuffer0.set(bufferIndex + 4, this.textureV);
}
if (this.hasColor) {
intBuffer0.set(bufferIndex + 5, this.color);
}
if (this.hasNormals) {
intBuffer0.set(bufferIndex + 6, this.normal);
}
this.rawBufferIndex += 7;
}
/**
* Sets the color to the given opaque value (stored as byte values packed in an
* integer).
*/
public void setColorOpaque_I(int par1) {
int var2 = par1 >> 16 & 255;
int var3 = par1 >> 8 & 255;
int var4 = par1 & 255;
this.setColorOpaque(var2, var3, var4);
}
/**
* Sets the color to the given color (packed as bytes in integer) and alpha
* values.
*/
public void setColorRGBA_I(int par1, int par2) {
int var3 = par1 >> 16 & 255;
int var4 = par1 >> 8 & 255;
int var5 = par1 & 255;
this.setColorRGBA(var3, var4, var5, par2);
}
/**
* Disables colors for the current draw call.
*/
public void disableColor() {
this.isColorDisabled = true;
}
/**
* Sets the normal for the current draw call.
*/
public void setNormal(float par1, float par2, float par3) {
this.hasNormals = true;
float len = (float) Math.sqrt(par1 * par1 + par2 * par2 + par3 * par3);
int var4 = (int)((par1 / len) * 127.0F) + 127;
int var5 = (int)((par2 / len) * 127.0F) + 127;
int var6 = (int)((par3 / len) * 127.0F) + 127;
this.normal = var4 & 255 | (var5 & 255) << 8 | (var6 & 255) << 16;
}
/**
* Sets the translation for all vertices in the current draw call.
*/
public void setTranslationD(double par1, double par3, double par5) {
this.xOffset = par1;
this.yOffset = par3;
this.zOffset = par5;
}
/**
* Offsets the translation for all vertices in the current draw call.
*/
public void setTranslationF(float par1, float par2, float par3) {
this.xOffset += (float) par1;
this.yOffset += (float) par2;
this.zOffset += (float) par3;
}
}

View File

@ -0,0 +1,34 @@
package net.lax1dude.eaglercraft.adapter.teavm;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
public class BufferConverter {
public static final byte[] convertByteBuffer(ByteBuffer b) {
byte[] ret = new byte[b.limit() - b.position()];
b.get(ret);
return ret;
}
public static final short[] convertShortBuffer(ShortBuffer b) {
short[] ret = new short[b.limit() - b.position()];
b.get(ret);
return ret;
}
public static final int[] convertIntBuffer(IntBuffer b) {
int[] ret = new int[b.limit() - b.position()];
b.get(ret);
return ret;
}
public static final float[] convertFloatBuffer(FloatBuffer b) {
float[] ret = new float[b.limit() - b.position()];
b.get(ret);
return ret;
}
}

View File

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

View File

@ -0,0 +1,427 @@
package net.lax1dude.eaglercraft.adapter.teavm;
import java.util.Collection;
import java.util.LinkedList;
import org.teavm.interop.Async;
import org.teavm.interop.AsyncCallback;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.indexeddb.EventHandler;
import org.teavm.jso.indexeddb.IDBCountRequest;
import org.teavm.jso.indexeddb.IDBCursor;
import org.teavm.jso.indexeddb.IDBCursorRequest;
import org.teavm.jso.indexeddb.IDBDatabase;
import org.teavm.jso.indexeddb.IDBFactory;
import org.teavm.jso.indexeddb.IDBGetRequest;
import org.teavm.jso.indexeddb.IDBObjectStoreParameters;
import org.teavm.jso.indexeddb.IDBOpenDBRequest;
import org.teavm.jso.indexeddb.IDBRequest;
import org.teavm.jso.indexeddb.IDBTransaction;
import org.teavm.jso.indexeddb.IDBVersionChangeEvent;
import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2;
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FileEntry;
public class IndexedDBFilesystem {
public static enum OpenState {
OPENED, LOCKED, ERROR
}
private static String err = "";
private static IDBDatabase db = null;
public static final OpenState initialize() {
DatabaseOpen dbo = AsyncHandlers.openDB("_net_lax1dude_eaglercraft_beta_IndexedDBFilesystem_1_3");
if(dbo == null) {
err = "Unknown Error";
return OpenState.ERROR;
}
if(dbo.failedLocked) {
return OpenState.LOCKED;
}
if(dbo.failedInit || dbo.database == null) {
err = dbo.failedError == null ? "Initialization Failed" : dbo.failedError;
return OpenState.ERROR;
}
db = dbo.database;
return OpenState.OPENED;
}
public static final String errorDetail() {
return err;
}
public static final boolean fileExists(String path) {
return AsyncHandlers.fileGetType(db, path) == FileExists.FILE;
}
public static final boolean directoryExists(String path) {
return AsyncHandlers.fileGetType(db, path) == FileExists.DIRECTORY;
}
public static final boolean pathExists(String path) {
return AsyncHandlers.fileExists(db, path).bool;
}
private static final void mkdir(String dir) {
if(directoryExists(dir)) {
return;
}
int i = dir.lastIndexOf('/');
if(i > 0) {
mkdir(dir.substring(0, i));
}
AsyncHandlers.writeWholeFile(db, dir, true, ArrayBuffer.create(0));
}
public static final void writeFile(String path, byte[] data) {
int i = path.lastIndexOf('/');
if(i > 0) {
mkdir(path.substring(0, i));
}
Uint8Array arr = Uint8Array.create(data.length);
arr.set(data);
AsyncHandlers.writeWholeFile(db, path, false, arr.getBuffer());
}
public static final byte[] readFile(String path) {
ArrayBuffer arr = AsyncHandlers.readWholeFile(db, path);
if(arr == null) {
return null;
}
byte[] data = new byte[arr.getByteLength()];
Uint8Array arrr = Uint8Array.create(arr);
for(int i = 0; i < data.length; ++i) {
data[i] = (byte) arrr.get(i);
}
return data;
}
public static final long getLastModified(String path) {
int lm = AsyncHandlers.fileGetLastModified(db, path);
return lm == -1 ? -1l : AsyncHandlers.eaglercraftEpoch + lm;
}
public static final int getFileSize(String path) {
ArrayBuffer arr = AsyncHandlers.readWholeFile(db, path);
if(arr == null) {
return -1;
}else {
return arr.getByteLength();
}
}
public static final void renameFile(String oldPath, String newPath) {
copyFile(oldPath, newPath);
AsyncHandlers.deleteFile(db, oldPath);
}
public static final void copyFile(String oldPath, String newPath) {
ArrayBuffer arr = AsyncHandlers.readWholeFile(db, oldPath);
int i = newPath.lastIndexOf('/');
if(i > 0) {
mkdir(newPath.substring(0, i));
}
AsyncHandlers.writeWholeFile(db, newPath, false, arr);
}
public static final void deleteFile(String path) {
AsyncHandlers.deleteFile(db, path);
}
public static final Collection<FileEntry> listFiles(String path, boolean listDirs, boolean recursiveDirs) {
LinkedList<FileEntry> lst = new LinkedList<>();
AsyncHandlers.iterateFiles(db, path, listDirs, recursiveDirs, lst);
return lst;
}
protected static class BooleanResult {
protected static final BooleanResult TRUE = new BooleanResult(true);
protected static final BooleanResult FALSE = new BooleanResult(false);
protected final boolean bool;
private BooleanResult(boolean b) {
bool = b;
}
protected static BooleanResult _new(boolean b) {
return b ? TRUE : FALSE;
}
}
protected static class DatabaseOpen {
protected final boolean failedInit;
protected final boolean failedLocked;
protected final String failedError;
protected final IDBDatabase database;
protected DatabaseOpen(boolean init, boolean locked, String error, IDBDatabase db) {
failedInit = init;
failedLocked = locked;
failedError = error;
database = db;
}
}
protected static enum FileExists {
FILE, DIRECTORY, FALSE
}
@JSBody(script = "return ((typeof indexedDB) !== 'undefined') ? indexedDB : null;")
protected static native IDBFactory createIDBFactory();
protected static class AsyncHandlers {
protected static final long eaglercraftEpoch = 1645568542000l;
@Async
protected static native DatabaseOpen openDB(String name);
private static void openDB(String name, final AsyncCallback<DatabaseOpen> cb) {
IDBFactory i = createIDBFactory();
if(i == null) {
cb.complete(new DatabaseOpen(false, false, "window.indexedDB was null or undefined", null));
return;
}
final IDBOpenDBRequest f = i.open(name, 1);
f.setOnBlocked(new EventHandler() {
@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<EaglerAdapterImpl2.FileEntry> lst);
private static void iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection<EaglerAdapterImpl2.FileEntry> lst, final AsyncCallback<Integer> cb) {
IDBTransaction tx = db.transaction("filesystem", "readonly");
final IDBCursorRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").openCursor();
final int[] res = new int[1];
r.setOnSuccess(new EventHandler() {
@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 EaglerAdapterImpl2.FileEntry(k, true, -1));
}
}else {
lst.add(new EaglerAdapterImpl2.FileEntry(k, false, eaglercraftEpoch + 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() - eaglercraftEpoch), data));
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(BooleanResult._new(true));
}
});
r.setOnError(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(BooleanResult._new(false));
}
});
}
}
}

View File

@ -0,0 +1,42 @@
package net.lax1dude.eaglercraft.adapter.teavm;
import org.teavm.jso.webgl.WebGLRenderingContext;
public interface WebGL2RenderingContext extends WebGLRenderingContext {
int TEXTURE_MAX_LEVEL = 0x0000813D;
int TEXTURE_MAX_ANISOTROPY_EXT = 0x000084FE;
int UNSIGNED_INT_24_8 = 0x000084FA;
int ANY_SAMPLES_PASSED = 0x00008D6A;
int QUERY_RESULT = 0x00008866;
int QUERY_RESULT_AVAILABLE = 0x00008867;
int DEPTH24_STENCIL8 = 0x000088F0;
int DEPTH_COMPONENT32F = 0x00008CAC;
int READ_FRAMEBUFFER = 0x00008CA8;
int DRAW_FRAMEBUFFER = 0x00008CA9;
int RGB8 = 0x00008051;
int RGBA8 = 0x00008058;
WebGLQuery createQuery();
void beginQuery(int p1, WebGLQuery obj);
void endQuery(int p1);
void deleteQuery(WebGLQuery obj);
int getQueryParameter(WebGLQuery obj, int p2);
WebGLVertexArray createVertexArray();
void deleteVertexArray(WebGLVertexArray obj);
void bindVertexArray(WebGLVertexArray obj);
void renderbufferStorageMultisample(int p1, int p2, int p3, int p4, int p5);
void blitFramebuffer(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10);
void drawBuffers(int[] p1);
}

View File

@ -0,0 +1,6 @@
package net.lax1dude.eaglercraft.adapter.teavm;
import org.teavm.jso.JSObject;
public interface WebGLQuery extends JSObject {
}

View File

@ -0,0 +1,6 @@
package net.lax1dude.eaglercraft.adapter.teavm;
import org.teavm.jso.JSObject;
public interface WebGLVertexArray extends JSObject {
}