Got it to compile with TeaVM!

This commit is contained in:
PeytonPlayz595 2024-02-09 08:34:16 -05:00
parent c03763f0be
commit f5f0880e99
14 changed files with 550 additions and 880 deletions

View File

@ -132,6 +132,6 @@ public class Client {
}
@JSBody(params = { "v" }, script = "try { return (typeof window[v] !== \"undefined\") ? JSON.stringify(window[v]) : \"[\\\"<error>\\\"]\"; } catch(e) { return \"[\\\"<error>\\\"]\"; }")
private static native String getArray(String var);
private static native String getArray(String v);
}

View File

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

View File

@ -1,79 +0,0 @@
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

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

View File

@ -41,7 +41,6 @@ import net.minecraft.src.TextureFlamesFX;
import net.minecraft.src.TextureLavaFX;
import net.minecraft.src.TextureLavaFlowFX;
import net.minecraft.src.TexturePortalFX;
import net.minecraft.src.TextureWatchFX;
import net.minecraft.src.TextureWaterFX;
import net.minecraft.src.TexureWaterFlowFX;
import net.minecraft.src.ThreadSleepForever;
@ -103,6 +102,7 @@ public class Minecraft implements Runnable {
public boolean field_6288_M = false;
long field_6287_N = System.currentTimeMillis();
private int field_6300_ab = 0;
private static Minecraft mc;
public Minecraft() {
this.field_9236_T = GL11.getCanvasWidth();
@ -110,6 +110,7 @@ public class Minecraft implements Runnable {
new ThreadSleepForever(this, "Timer hack thread");
this.displayWidth = GL11.getCanvasWidth();
this.displayHeight = GL11.getCanvasHeight();
mc = this;
}
public void func_6258_a(String var1, int var2) {
@ -141,13 +142,13 @@ public class Minecraft implements Runnable {
this.checkGLError("Startup");
this.renderEngine.registerTextureFX(this.field_9231_Y);
this.renderEngine.registerTextureFX(this.field_9232_X);
this.renderEngine.registerTextureFX(new TexturePortalFX());
//this.renderEngine.registerTextureFX(new TexturePortalFX());
this.renderEngine.registerTextureFX(new TextureCompassFX(this));
this.renderEngine.registerTextureFX(new TextureWatchFX(this));
this.renderEngine.registerTextureFX(new TexureWaterFlowFX());
this.renderEngine.registerTextureFX(new TextureLavaFlowFX());
this.renderEngine.registerTextureFX(new TextureFlamesFX(0));
this.renderEngine.registerTextureFX(new TextureFlamesFX(1));
// this.renderEngine.registerTextureFX(new TextureWatchFX(this));
// this.renderEngine.registerTextureFX(new TexureWaterFlowFX());
// this.renderEngine.registerTextureFX(new TextureLavaFlowFX());
// this.renderEngine.registerTextureFX(new TextureFlamesFX(0));
// this.renderEngine.registerTextureFX(new TextureFlamesFX(1));
this.field_6323_f = new RenderGlobal(this, this.renderEngine);
GL11.glViewport(0, 0, this.displayWidth, this.displayHeight);
this.field_6321_h = new EffectRenderer(this.theWorld, this.renderEngine);
@ -239,7 +240,6 @@ public class Minecraft implements Runnable {
System.out.println("########## GL ERROR ##########");
System.out.println("@ " + var1);
System.out.println(var2 + ": " + var3);
System.exit(0);
}
}
@ -935,4 +935,8 @@ public class Minecraft implements Runnable {
}
}
public static Minecraft getMinecraft() {
return mc;
}
}

View File

@ -376,8 +376,7 @@ public class Chunk {
int var2 = MathHelper.floor_double(var1.posX / 16.0D);
int var3 = MathHelper.floor_double(var1.posZ / 16.0D);
if(var2 != this.xPosition || var3 != this.zPosition) {
System.out.println("Wrong location! " + var1);
Thread.dumpStack();
System.err.println("Wrong location! " + var1);
}
int var4 = MathHelper.floor_double(var1.posY / 16.0D);

View File

@ -1,25 +1,17 @@
package net.minecraft.src;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import org.lwjgl.opengl.GL11;
public class ColorizerFoliage {
private static final int[] field_6529_a = new int[65536];
private static int field_6529_a[] = null;
public static int func_4146_a(double var0, double var2) {
var2 *= var0;
int var4 = (int)((1.0D - var0) * 255.0D);
int var5 = (int)((1.0D - var2) * 255.0D);
return field_6529_a[var5 << 8 | var4];
}
static {
try {
BufferedImage var0 = ImageIO.read(ColorizerFoliage.class.getResource("/misc/foliagecolor.png"));
var0.getRGB(0, 0, 256, 256, field_6529_a, 0, 256);
} catch (Exception var1) {
var1.printStackTrace();
if(field_6529_a == null) {
field_6529_a = GL11.loadPNG(GL11.loadResourceBytes("/misc/foliagecolor.png")).data;
}
var2 *= var0;
int i = (int) ((1.0D - var0) * 255D);
int j = (int) ((1.0D - var2) * 255D);
return field_6529_a[j << 8 | i];
}
}
}

View File

@ -1,25 +1,17 @@
package net.minecraft.src;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import org.lwjgl.opengl.GL11;
public class ColorizerGrass {
private static final int[] field_6540_a = new int[65536];
private static int[] field_6540_a = null;
public static int func_4147_a(double var0, double var2) {
if(field_6540_a == null) {
field_6540_a = GL11.loadPNG(GL11.loadResourceBytes("/misc/grasscolor.png")).data;
}
var2 *= var0;
int var4 = (int)((1.0D - var0) * 255.0D);
int var5 = (int)((1.0D - var2) * 255.0D);
return field_6540_a[var5 << 8 | var4];
}
static {
try {
BufferedImage var0 = ImageIO.read(ColorizerFoliage.class.getResource("/misc/grasscolor.png"));
var0.getRGB(0, 0, 256, 256, field_6540_a, 0, 256);
} catch (Exception var1) {
var1.printStackTrace();
}
}
}

View File

@ -1,6 +1,5 @@
package net.minecraft.src;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@ -154,9 +153,9 @@ public class GuiIngame extends Gui {
var8.drawStringWithShadow(this.mc.func_6241_m(), 2, 12, 16777215);
var8.drawStringWithShadow(this.mc.func_6262_n(), 2, 22, 16777215);
var8.drawStringWithShadow(this.mc.func_6245_o(), 2, 32, 16777215);
long var24 = Runtime.getRuntime().maxMemory();
long var29 = Runtime.getRuntime().totalMemory();
long var30 = Runtime.getRuntime().freeMemory();
long var24 = GL11.maxMemory();
long var29 = GL11.totalMemory();
long var30 = GL11.freeMemory();
long var21 = var29 - var30;
var23 = "Used memory: " + var21 * 100L / var24 + "% (" + var21 / 1024L / 1024L + "MB) of " + var24 / 1024L / 1024L + "MB";
this.drawString(var8, var23, var6 - var8.getStringWidth(var23) - 2, 2, 14737632);
@ -181,7 +180,7 @@ public class GuiIngame extends Gui {
GL11.glTranslatef((float)(var6 / 2), (float)(var7 - 48), 0.0F);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
var17 = Color.HSBtoRGB(var25 / 50.0F, 0.7F, 0.6F) & 16777215;
var17 = hsbToRgb(var25 / 50.0F, 0.7F, 0.6F) & 16777215;
var8.drawString(this.field_9420_i, -var8.getStringWidth(this.field_9420_i) / 2, -4, var17 + (var16 << 24));
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
@ -368,4 +367,46 @@ public class GuiIngame extends Gui {
this.field_9420_i = "Now playing: " + var1;
this.field_9419_j = 60;
}
public static int hsbToRgb(float hue, float saturation, float brightness) {
hue = (hue % 1f) + 1f;
saturation = Math.min(1f, Math.max(0f, saturation));
brightness = Math.min(1f, Math.max(0f, brightness));
float q = brightness < 0.5f ? brightness * (1f + saturation) : brightness + saturation - brightness * saturation;
float p = 2f * brightness - q;
float r, g, b;
if (hue < 1f/6f) {
r = q;
g = p + (q - p) * 6f * hue;
b = p;
} else if (hue < 2f/6f) {
r = p - (q - p) * 6f * (hue - 1f/6f);
g = q;
b = p;
} else if (hue < 3f/6f) {
r = p;
g = q - (q - p) * 6f * (hue - 2f/6f);
b = p - (q - p) * 6f * (hue - 2f/6f);
} else if (hue < 4f/6f) {
r = p;
g = p;
b = q - (q - p) * 6f * (hue - 3f/6f);
} else if (hue < 5f/6f) {
r = p + (q - p) * 6f * (hue - 4f/6f);
g = p;
b = q;
} else {
r = q;
g = p - (q - p) * 6f * (hue - 5f/6f);
b = p;
}
int red = (int) Math.max(0f, Math.min(255f, r * 255f));
int green = (int) Math.max(0f, Math.min(255f, g * 255f));
int blue = (int) Math.max(0f, Math.min(255f, b * 255f));
return (red << 16) | (green << 8) | blue;
}
}

View File

@ -1,8 +1,5 @@
package net.minecraft.src;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
@ -35,19 +32,6 @@ public class GuiScreen extends Gui {
}
public static String getClipboardString() {
try {
Transferable var0 = Toolkit.getDefaultToolkit().getSystemClipboard().getContents((Object)null);
if(var0 != null && var0.isDataFlavorSupported(DataFlavor.stringFlavor)) {
String var1 = (String)var0.getTransferData(DataFlavor.stringFlavor);
return var1;
}
} catch (Exception var2) {
}
return null;
}
protected void mouseClicked(int var1, int var2, int var3) {
if(var3 == 0) {
for(int var4 = 0; var4 < this.controlList.size(); ++var4) {

View File

@ -1,7 +1,5 @@
package net.minecraft.src;
import java.awt.Color;
public class MobSpawnerBase {
public static final MobSpawnerBase rainforest = (new MobSpawnerBase()).func_4123_b(588342).setBiomeName("Rainforest").func_4124_a(2094168);
public static final MobSpawnerBase swampland = (new MobSpawnerSwamp()).func_4123_b(522674).setBiomeName("Swampland").func_4124_a(9154376);
@ -75,7 +73,62 @@ public class MobSpawnerBase {
var1 = 1.0F;
}
return Color.getHSBColor(224.0F / 360.0F - var1 * 0.05F, 0.5F + var1 * 0.1F, 1.0F).getRGB();
return getHSBColor(224.0F / 360.0F - var1 * 0.05F, 0.5F + var1 * 0.1F, 1.0F);
}
public static int getHSBColor(float hue, float saturation, float brightness) {
float r, g, b;
if (saturation == 0) {
r = g = b = brightness;
} else {
float h = (hue - (float) Math.floor(hue)) * 6.0f;
float f = h - (float) Math.floor(h);
float p = brightness * (1.0f - saturation);
float q = brightness * (1.0f - saturation * f);
float t = brightness * (1.0f - (saturation * (1.0f - f)));
int hi = (int) h;
switch (hi) {
case 0:
r = brightness;
g = t;
b = p;
break;
case 1:
r = q;
g = brightness;
b = p;
break;
case 2:
r = p;
g = brightness;
b = t;
break;
case 3:
r = p;
g = q;
b = brightness;
break;
case 4:
r = t;
g = p;
b = brightness;
break;
case 5:
r = brightness;
g = p;
b = q;
break;
default:
r = g = b = brightness;
break;
}
}
int red = Math.round(r * 255);
int green = Math.round(g * 255);
int blue = Math.round(b * 255);
return (255 << 24) | (red << 16) | (green << 8) | blue;
}
public Class[] getEntitiesForType(EnumCreatureType var1) {

View File

@ -1,87 +1,87 @@
package net.minecraft.src;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Arrays;
import javax.imageio.ImageIO;
public class TerrainTextureManager {
private float[] field_1181_a = new float[768];
private int[] field_1180_b = new int[5120];
private int[] field_1186_c = new int[5120];
private int[] field_1185_d = new int[5120];
private int[] field_1184_e = new int[5120];
private int[] field_1183_f = new int[34];
private int[] field_1182_g = new int[768];
public TerrainTextureManager() {
try {
BufferedImage var1 = ImageIO.read(TerrainTextureManager.class.getResource("/terrain.png"));
int[] var2 = new int[65536];
var1.getRGB(0, 0, 256, 256, var2, 0, 256);
for(int var3 = 0; var3 < 256; ++var3) {
int var4 = 0;
int var5 = 0;
int var6 = 0;
int var7 = var3 % 16 * 16;
int var8 = var3 / 16 * 16;
int var9 = 0;
for(int var10 = 0; var10 < 16; ++var10) {
for(int var11 = 0; var11 < 16; ++var11) {
int var12 = var2[var11 + var7 + (var10 + var8) * 256];
int var13 = var12 >> 24 & 255;
if(var13 > 128) {
var4 += var12 >> 16 & 255;
var5 += var12 >> 8 & 255;
var6 += var12 & 255;
++var9;
}
}
if(var9 == 0) {
++var9;
}
this.field_1181_a[var3 * 3 + 0] = (float)(var4 / var9);
this.field_1181_a[var3 * 3 + 1] = (float)(var5 / var9);
this.field_1181_a[var3 * 3 + 2] = (float)(var6 / var9);
}
}
} catch (IOException var14) {
var14.printStackTrace();
}
for(int var15 = 0; var15 < 256; ++var15) {
if(Block.blocksList[var15] != null) {
this.field_1182_g[var15 * 3 + 0] = Block.blocksList[var15].getBlockTextureFromSide(1);
this.field_1182_g[var15 * 3 + 1] = Block.blocksList[var15].getBlockTextureFromSide(2);
this.field_1182_g[var15 * 3 + 2] = Block.blocksList[var15].getBlockTextureFromSide(3);
}
}
}
private void func_800_a() {
for(int var1 = 0; var1 < 32; ++var1) {
for(int var2 = 0; var2 < 160; ++var2) {
int var3 = var1 + var2 * 32;
if(this.field_1186_c[var3] == 0) {
this.field_1180_b[var3] = 0;
}
if(this.field_1185_d[var3] > this.field_1186_c[var3]) {
int var4 = this.field_1180_b[var3] >> 24 & 255;
this.field_1180_b[var3] = ((this.field_1180_b[var3] & 16711422) >> 1) + this.field_1184_e[var3];
if(var4 < 128) {
this.field_1180_b[var3] = Integer.MIN_VALUE + this.field_1184_e[var3] * 2;
} else {
this.field_1180_b[var3] |= -16777216;
}
}
}
}
}
}
//package net.minecraft.src;
//
//import java.awt.image.BufferedImage;
//import java.io.IOException;
//import java.util.Arrays;
//import javax.imageio.ImageIO;
//
//public class TerrainTextureManager {
// private float[] field_1181_a = new float[768];
// private int[] field_1180_b = new int[5120];
// private int[] field_1186_c = new int[5120];
// private int[] field_1185_d = new int[5120];
// private int[] field_1184_e = new int[5120];
// private int[] field_1183_f = new int[34];
// private int[] field_1182_g = new int[768];
//
// public TerrainTextureManager() {
// try {
// BufferedImage var1 = ImageIO.read(TerrainTextureManager.class.getResource("/terrain.png"));
// int[] var2 = new int[65536];
// var1.getRGB(0, 0, 256, 256, var2, 0, 256);
//
// for(int var3 = 0; var3 < 256; ++var3) {
// int var4 = 0;
// int var5 = 0;
// int var6 = 0;
// int var7 = var3 % 16 * 16;
// int var8 = var3 / 16 * 16;
// int var9 = 0;
//
// for(int var10 = 0; var10 < 16; ++var10) {
// for(int var11 = 0; var11 < 16; ++var11) {
// int var12 = var2[var11 + var7 + (var10 + var8) * 256];
// int var13 = var12 >> 24 & 255;
// if(var13 > 128) {
// var4 += var12 >> 16 & 255;
// var5 += var12 >> 8 & 255;
// var6 += var12 & 255;
// ++var9;
// }
// }
//
// if(var9 == 0) {
// ++var9;
// }
//
// this.field_1181_a[var3 * 3 + 0] = (float)(var4 / var9);
// this.field_1181_a[var3 * 3 + 1] = (float)(var5 / var9);
// this.field_1181_a[var3 * 3 + 2] = (float)(var6 / var9);
// }
// }
// } catch (IOException var14) {
// var14.printStackTrace();
// }
//
// for(int var15 = 0; var15 < 256; ++var15) {
// if(Block.blocksList[var15] != null) {
// this.field_1182_g[var15 * 3 + 0] = Block.blocksList[var15].getBlockTextureFromSide(1);
// this.field_1182_g[var15 * 3 + 1] = Block.blocksList[var15].getBlockTextureFromSide(2);
// this.field_1182_g[var15 * 3 + 2] = Block.blocksList[var15].getBlockTextureFromSide(3);
// }
// }
//
// }
//
// private void func_800_a() {
// for(int var1 = 0; var1 < 32; ++var1) {
// for(int var2 = 0; var2 < 160; ++var2) {
// int var3 = var1 + var2 * 32;
// if(this.field_1186_c[var3] == 0) {
// this.field_1180_b[var3] = 0;
// }
//
// if(this.field_1185_d[var3] > this.field_1186_c[var3]) {
// int var4 = this.field_1180_b[var3] >> 24 & 255;
// this.field_1180_b[var3] = ((this.field_1180_b[var3] & 16711422) >> 1) + this.field_1184_e[var3];
// if(var4 < 128) {
// this.field_1180_b[var3] = Integer.MIN_VALUE + this.field_1184_e[var3] * 2;
// } else {
// this.field_1180_b[var3] |= -16777216;
// }
// }
// }
// }
//
// }
//}

View File

@ -1,142 +1,229 @@
//package net.minecraft.src;
//
//import java.awt.image.BufferedImage;
//import java.io.IOException;
//import javax.imageio.ImageIO;
//import net.minecraft.client.Minecraft;
//
//public class TextureCompassFX extends TextureFX {
// private Minecraft mc;
// private int[] field_4230_h = new int[256];
// private double field_4229_i;
// private double field_4228_j;
//
// public TextureCompassFX(Minecraft var1) {
// super(Item.compass.getIconIndex((ItemStack)null));
// this.mc = var1;
// this.field_1128_f = 1;
//
// try {
// BufferedImage var2 = ImageIO.read(Minecraft.class.getResource("/gui/items.png"));
// int var3 = this.field_1126_b % 16 * 16;
// int var4 = this.field_1126_b / 16 * 16;
// var2.getRGB(var3, var4, 16, 16, this.field_4230_h, 0, 16);
// } catch (IOException var5) {
// var5.printStackTrace();
// }
//
// }
//
// public void func_783_a() {
// for(int var1 = 0; var1 < 256; ++var1) {
// int var2 = this.field_4230_h[var1] >> 24 & 255;
// int var3 = this.field_4230_h[var1] >> 16 & 255;
// int var4 = this.field_4230_h[var1] >> 8 & 255;
// int var5 = this.field_4230_h[var1] >> 0 & 255;
// if(this.field_1131_c) {
// int var6 = (var3 * 30 + var4 * 59 + var5 * 11) / 100;
// int var7 = (var3 * 30 + var4 * 70) / 100;
// int var8 = (var3 * 30 + var5 * 70) / 100;
// var3 = var6;
// var4 = var7;
// var5 = var8;
// }
//
// this.field_1127_a[var1 * 4 + 0] = (byte)var3;
// this.field_1127_a[var1 * 4 + 1] = (byte)var4;
// this.field_1127_a[var1 * 4 + 2] = (byte)var5;
// this.field_1127_a[var1 * 4 + 3] = (byte)var2;
// }
//
// double var20 = 0.0D;
// double var21;
// double var22;
// if(this.mc.theWorld != null && this.mc.thePlayer != null) {
// var21 = (double)this.mc.theWorld.spawnX - this.mc.thePlayer.posX;
// var22 = (double)this.mc.theWorld.spawnZ - this.mc.thePlayer.posZ;
// var20 = (double)(this.mc.thePlayer.rotationYaw - 90.0F) * Math.PI / 180.0D - Math.atan2(var22, var21);
// if(this.mc.theWorld.worldProvider.field_4220_c) {
// var20 = Math.random() * (double)((float)Math.PI) * 2.0D;
// }
// }
//
// for(var21 = var20 - this.field_4229_i; var21 < -Math.PI; var21 += Math.PI * 2.0D) {
// }
//
// while(var21 >= Math.PI) {
// var21 -= Math.PI * 2.0D;
// }
//
// if(var21 < -1.0D) {
// var21 = -1.0D;
// }
//
// if(var21 > 1.0D) {
// var21 = 1.0D;
// }
//
// this.field_4228_j += var21 * 0.1D;
// this.field_4228_j *= 0.8D;
// this.field_4229_i += this.field_4228_j;
// var22 = Math.sin(this.field_4229_i);
// double var23 = Math.cos(this.field_4229_i);
//
// int var9;
// int var10;
// int var11;
// int var12;
// int var13;
// int var14;
// int var15;
// short var16;
// int var17;
// int var18;
// int var19;
// for(var9 = -4; var9 <= 4; ++var9) {
// var10 = (int)(8.5D + var23 * (double)var9 * 0.3D);
// var11 = (int)(7.5D - var22 * (double)var9 * 0.3D * 0.5D);
// var12 = var11 * 16 + var10;
// var13 = 100;
// var14 = 100;
// var15 = 100;
// var16 = 255;
// if(this.field_1131_c) {
// var17 = (var13 * 30 + var14 * 59 + var15 * 11) / 100;
// var18 = (var13 * 30 + var14 * 70) / 100;
// var19 = (var13 * 30 + var15 * 70) / 100;
// var13 = var17;
// var14 = var18;
// var15 = var19;
// }
//
// this.field_1127_a[var12 * 4 + 0] = (byte)var13;
// this.field_1127_a[var12 * 4 + 1] = (byte)var14;
// this.field_1127_a[var12 * 4 + 2] = (byte)var15;
// this.field_1127_a[var12 * 4 + 3] = (byte)var16;
// }
//
// for(var9 = -8; var9 <= 16; ++var9) {
// var10 = (int)(8.5D + var22 * (double)var9 * 0.3D);
// var11 = (int)(7.5D + var23 * (double)var9 * 0.3D * 0.5D);
// var12 = var11 * 16 + var10;
// var13 = var9 >= 0 ? 255 : 100;
// var14 = var9 >= 0 ? 20 : 100;
// var15 = var9 >= 0 ? 20 : 100;
// var16 = 255;
// if(this.field_1131_c) {
// var17 = (var13 * 30 + var14 * 59 + var15 * 11) / 100;
// var18 = (var13 * 30 + var14 * 70) / 100;
// var19 = (var13 * 30 + var15 * 70) / 100;
// var13 = var17;
// var14 = var18;
// var15 = var19;
// }
//
// this.field_1127_a[var12 * 4 + 0] = (byte)var13;
// this.field_1127_a[var12 * 4 + 1] = (byte)var14;
// this.field_1127_a[var12 * 4 + 2] = (byte)var15;
// this.field_1127_a[var12 * 4 + 3] = (byte)var16;
// }
//
// }
//}
package net.minecraft.src;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
public class TextureCompassFX extends TextureFX {
private Minecraft mc;
private int[] field_4230_h = new int[256];
private double field_4229_i;
private double field_4228_j;
private final int[] compassSpriteSheet;
private final int compassSpriteSheetLength;
private float angleDelta = 0.0f;
private float currentAngle = 0.0f;
public TextureCompassFX(Minecraft var1) {
super(Item.compass.getIconIndex((ItemStack)null));
this.mc = var1;
this.field_1128_f = 1;
try {
BufferedImage var2 = ImageIO.read(Minecraft.class.getResource("/gui/items.png"));
int var3 = this.field_1126_b % 16 * 16;
int var4 = this.field_1126_b / 16 * 16;
var2.getRGB(var3, var4, 16, 16, this.field_4230_h, 0, 16);
} catch (IOException var5) {
var5.printStackTrace();
}
super(Item.compass.getIconIndex(null));
field_1128_f = 1;
this.compassSpriteSheet = GL11.loadPNG(GL11.loadResourceBytes("/gui/items.png")).data;
this.compassSpriteSheetLength = compassSpriteSheet.length / 256;
}
public void func_783_a() {
for(int var1 = 0; var1 < 256; ++var1) {
int var2 = this.field_4230_h[var1] >> 24 & 255;
int var3 = this.field_4230_h[var1] >> 16 & 255;
int var4 = this.field_4230_h[var1] >> 8 & 255;
int var5 = this.field_4230_h[var1] >> 0 & 255;
if(this.field_1131_c) {
int var6 = (var3 * 30 + var4 * 59 + var5 * 11) / 100;
int var7 = (var3 * 30 + var4 * 70) / 100;
int var8 = (var3 * 30 + var5 * 70) / 100;
var3 = var6;
var4 = var7;
var5 = var8;
}
this.field_1127_a[var1 * 4 + 0] = (byte)var3;
this.field_1127_a[var1 * 4 + 1] = (byte)var4;
this.field_1127_a[var1 * 4 + 2] = (byte)var5;
this.field_1127_a[var1 * 4 + 3] = (byte)var2;
Minecraft var1 = Minecraft.getMinecraft();
if (var1.theWorld != null && var1.thePlayer != null) {
this.updateCompass(var1.theWorld, var1.thePlayer.posX, var1.thePlayer.posZ, (double) var1.thePlayer.rotationYaw, false, false);
} else {
this.updateCompass((World) null, 0.0D, 0.0D, 0.0D, true, false);
}
}
public void updateCompass(World par1World, double par2, double par4, double par6, boolean par8, boolean par9) {
double var10 = 0.0D;
double var20 = 0.0D;
double var21;
double var22;
if(this.mc.theWorld != null && this.mc.thePlayer != null) {
var21 = (double)this.mc.theWorld.spawnX - this.mc.thePlayer.posX;
var22 = (double)this.mc.theWorld.spawnZ - this.mc.thePlayer.posZ;
var20 = (double)(this.mc.thePlayer.rotationYaw - 90.0F) * Math.PI / 180.0D - Math.atan2(var22, var21);
if(this.mc.theWorld.worldProvider.field_4220_c) {
var20 = Math.random() * (double)((float)Math.PI) * 2.0D;
if (par1World != null && !par8) {
double var13 = (double)par1World.spawnX - par2;
double var15 = (double)par1World.spawnZ - par4;
par6 %= 360.0D;
var10 = -((par6 - 90.0D) * Math.PI / 180.0D - Math.atan2(var15, var13));
if (!par1World.worldProvider.field_4220_c) {
var10 = Math.random() * Math.PI * 2.0D;
}
}
for(var21 = var20 - this.field_4229_i; var21 < -Math.PI; var21 += Math.PI * 2.0D) {
if (par9) {
this.currentAngle = (float) var10;
} else {
double var17;
for (var17 = var10 - this.currentAngle; var17 < -Math.PI; var17 += (Math.PI * 2D)) {
;
}
while (var17 >= Math.PI) {
var17 -= (Math.PI * 2D);
}
if (var17 < -1.0D) {
var17 = -1.0D;
}
if (var17 > 1.0D) {
var17 = 1.0D;
}
this.angleDelta += var17 * 0.1D;
this.angleDelta *= 0.8D;
this.currentAngle += this.angleDelta;
}
while(var21 >= Math.PI) {
var21 -= Math.PI * 2.0D;
}
if(var21 < -1.0D) {
var21 = -1.0D;
}
if(var21 > 1.0D) {
var21 = 1.0D;
}
this.field_4228_j += var21 * 0.1D;
this.field_4228_j *= 0.8D;
this.field_4229_i += this.field_4228_j;
var22 = Math.sin(this.field_4229_i);
double var23 = Math.cos(this.field_4229_i);
int var9;
int var10;
int var11;
int var12;
int var13;
int var14;
int var15;
short var16;
int var17;
int var18;
int var19;
for(var9 = -4; var9 <= 4; ++var9) {
var10 = (int)(8.5D + var23 * (double)var9 * 0.3D);
var11 = (int)(7.5D - var22 * (double)var9 * 0.3D * 0.5D);
var12 = var11 * 16 + var10;
var13 = 100;
var14 = 100;
var15 = 100;
var16 = 255;
if(this.field_1131_c) {
var17 = (var13 * 30 + var14 * 59 + var15 * 11) / 100;
var18 = (var13 * 30 + var14 * 70) / 100;
var19 = (var13 * 30 + var15 * 70) / 100;
var13 = var17;
var14 = var18;
var15 = var19;
}
this.field_1127_a[var12 * 4 + 0] = (byte)var13;
this.field_1127_a[var12 * 4 + 1] = (byte)var14;
this.field_1127_a[var12 * 4 + 2] = (byte)var15;
this.field_1127_a[var12 * 4 + 3] = (byte)var16;
for (var18 = (int) ((this.currentAngle / (Math.PI * 2D) + 1.0D) * (double) compassSpriteSheetLength) % compassSpriteSheetLength; var18 < 0; var18 = (var18 + compassSpriteSheetLength) % compassSpriteSheetLength) {
;
}
for(var9 = -8; var9 <= 16; ++var9) {
var10 = (int)(8.5D + var22 * (double)var9 * 0.3D);
var11 = (int)(7.5D + var23 * (double)var9 * 0.3D * 0.5D);
var12 = var11 * 16 + var10;
var13 = var9 >= 0 ? 255 : 100;
var14 = var9 >= 0 ? 20 : 100;
var15 = var9 >= 0 ? 20 : 100;
var16 = 255;
if(this.field_1131_c) {
var17 = (var13 * 30 + var14 * 59 + var15 * 11) / 100;
var18 = (var13 * 30 + var14 * 70) / 100;
var19 = (var13 * 30 + var15 * 70) / 100;
var13 = var17;
var14 = var18;
var15 = var19;
}
this.field_1127_a[var12 * 4 + 0] = (byte)var13;
this.field_1127_a[var12 * 4 + 1] = (byte)var14;
this.field_1127_a[var12 * 4 + 2] = (byte)var15;
this.field_1127_a[var12 * 4 + 3] = (byte)var16;
int offset = var18 * 256;
for(int i = 0; i < 256; ++i) {
this.field_1127_a[i * 4] = (byte)((compassSpriteSheet[offset + i] >> 16) & 0xFF);
this.field_1127_a[i * 4 + 1] = (byte)((compassSpriteSheet[offset + i] >> 8) & 0xFF);
this.field_1127_a[i * 4 + 2] = (byte)((compassSpriteSheet[offset + i]) & 0xFF);
this.field_1127_a[i * 4 + 3] = (byte)((compassSpriteSheet[offset + i] >> 24) & 0xFF);
}
}
}

View File

@ -1,99 +1,96 @@
package net.minecraft.src;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import net.minecraft.client.Minecraft;
public class TextureWatchFX extends TextureFX {
private Minecraft field_4225_g;
private int[] field_4224_h = new int[256];
private int[] field_4223_i = new int[256];
private double field_4222_j;
private double field_4221_k;
public TextureWatchFX(Minecraft var1) {
super(Item.pocketSundial.getIconIndex((ItemStack)null));
this.field_4225_g = var1;
this.field_1128_f = 1;
try {
BufferedImage var2 = ImageIO.read(Minecraft.class.getResource("/gui/items.png"));
int var3 = this.field_1126_b % 16 * 16;
int var4 = this.field_1126_b / 16 * 16;
var2.getRGB(var3, var4, 16, 16, this.field_4224_h, 0, 16);
var2 = ImageIO.read(Minecraft.class.getResource("/misc/dial.png"));
var2.getRGB(0, 0, 16, 16, this.field_4223_i, 0, 16);
} catch (IOException var5) {
var5.printStackTrace();
}
}
public void func_783_a() {
double var1 = 0.0D;
if(this.field_4225_g.theWorld != null && this.field_4225_g.thePlayer != null) {
float var3 = this.field_4225_g.theWorld.getCelestialAngle(1.0F);
var1 = (double)(-var3 * (float)Math.PI * 2.0F);
if(this.field_4225_g.theWorld.worldProvider.field_4220_c) {
var1 = Math.random() * (double)((float)Math.PI) * 2.0D;
}
}
double var22;
for(var22 = var1 - this.field_4222_j; var22 < -Math.PI; var22 += Math.PI * 2.0D) {
}
while(var22 >= Math.PI) {
var22 -= Math.PI * 2.0D;
}
if(var22 < -1.0D) {
var22 = -1.0D;
}
if(var22 > 1.0D) {
var22 = 1.0D;
}
this.field_4221_k += var22 * 0.1D;
this.field_4221_k *= 0.8D;
this.field_4222_j += this.field_4221_k;
double var5 = Math.sin(this.field_4222_j);
double var7 = Math.cos(this.field_4222_j);
for(int var9 = 0; var9 < 256; ++var9) {
int var10 = this.field_4224_h[var9] >> 24 & 255;
int var11 = this.field_4224_h[var9] >> 16 & 255;
int var12 = this.field_4224_h[var9] >> 8 & 255;
int var13 = this.field_4224_h[var9] >> 0 & 255;
if(var11 == var13 && var12 == 0 && var13 > 0) {
double var14 = -((double)(var9 % 16) / 15.0D - 0.5D);
double var16 = (double)(var9 / 16) / 15.0D - 0.5D;
int var18 = var11;
int var19 = (int)((var14 * var7 + var16 * var5 + 0.5D) * 16.0D);
int var20 = (int)((var16 * var7 - var14 * var5 + 0.5D) * 16.0D);
int var21 = (var19 & 15) + (var20 & 15) * 16;
var10 = this.field_4223_i[var21] >> 24 & 255;
var11 = (this.field_4223_i[var21] >> 16 & 255) * var11 / 255;
var12 = (this.field_4223_i[var21] >> 8 & 255) * var18 / 255;
var13 = (this.field_4223_i[var21] >> 0 & 255) * var18 / 255;
}
if(this.field_1131_c) {
int var23 = (var11 * 30 + var12 * 59 + var13 * 11) / 100;
int var15 = (var11 * 30 + var12 * 70) / 100;
int var24 = (var11 * 30 + var13 * 70) / 100;
var11 = var23;
var12 = var15;
var13 = var24;
}
this.field_1127_a[var9 * 4 + 0] = (byte)var11;
this.field_1127_a[var9 * 4 + 1] = (byte)var12;
this.field_1127_a[var9 * 4 + 2] = (byte)var13;
this.field_1127_a[var9 * 4 + 3] = (byte)var10;
}
}
}
//package net.minecraft.src;
//
//import net.minecraft.client.Minecraft;
//
//public class TextureWatchFX extends TextureFX {
// private Minecraft field_4225_g;
// private int[] field_4224_h = new int[256];
// private int[] field_4223_i = new int[256];
// private double field_4222_j;
// private double field_4221_k;
//
// public TextureWatchFX(Minecraft var1) {
// super(Item.pocketSundial.getIconIndex((ItemStack)null));
// this.field_4225_g = var1;
// this.field_1128_f = 1;
//
// try {
// BufferedImage var2 = ImageIO.read(Minecraft.class.getResource("/gui/items.png"));
// int var3 = this.field_1126_b % 16 * 16;
// int var4 = this.field_1126_b / 16 * 16;
// var2.getRGB(var3, var4, 16, 16, this.field_4224_h, 0, 16);
// var2 = ImageIO.read(Minecraft.class.getResource("/misc/dial.png"));
// var2.getRGB(0, 0, 16, 16, this.field_4223_i, 0, 16);
// } catch (IOException var5) {
// var5.printStackTrace();
// }
//
// }
//
// public void func_783_a() {
// double var1 = 0.0D;
// if(this.field_4225_g.theWorld != null && this.field_4225_g.thePlayer != null) {
// float var3 = this.field_4225_g.theWorld.getCelestialAngle(1.0F);
// var1 = (double)(-var3 * (float)Math.PI * 2.0F);
// if(this.field_4225_g.theWorld.worldProvider.field_4220_c) {
// var1 = Math.random() * (double)((float)Math.PI) * 2.0D;
// }
// }
//
// double var22;
// for(var22 = var1 - this.field_4222_j; var22 < -Math.PI; var22 += Math.PI * 2.0D) {
// }
//
// while(var22 >= Math.PI) {
// var22 -= Math.PI * 2.0D;
// }
//
// if(var22 < -1.0D) {
// var22 = -1.0D;
// }
//
// if(var22 > 1.0D) {
// var22 = 1.0D;
// }
//
// this.field_4221_k += var22 * 0.1D;
// this.field_4221_k *= 0.8D;
// this.field_4222_j += this.field_4221_k;
// double var5 = Math.sin(this.field_4222_j);
// double var7 = Math.cos(this.field_4222_j);
//
// for(int var9 = 0; var9 < 256; ++var9) {
// int var10 = this.field_4224_h[var9] >> 24 & 255;
// int var11 = this.field_4224_h[var9] >> 16 & 255;
// int var12 = this.field_4224_h[var9] >> 8 & 255;
// int var13 = this.field_4224_h[var9] >> 0 & 255;
// if(var11 == var13 && var12 == 0 && var13 > 0) {
// double var14 = -((double)(var9 % 16) / 15.0D - 0.5D);
// double var16 = (double)(var9 / 16) / 15.0D - 0.5D;
// int var18 = var11;
// int var19 = (int)((var14 * var7 + var16 * var5 + 0.5D) * 16.0D);
// int var20 = (int)((var16 * var7 - var14 * var5 + 0.5D) * 16.0D);
// int var21 = (var19 & 15) + (var20 & 15) * 16;
// var10 = this.field_4223_i[var21] >> 24 & 255;
// var11 = (this.field_4223_i[var21] >> 16 & 255) * var11 / 255;
// var12 = (this.field_4223_i[var21] >> 8 & 255) * var18 / 255;
// var13 = (this.field_4223_i[var21] >> 0 & 255) * var18 / 255;
// }
//
// if(this.field_1131_c) {
// int var23 = (var11 * 30 + var12 * 59 + var13 * 11) / 100;
// int var15 = (var11 * 30 + var12 * 70) / 100;
// int var24 = (var11 * 30 + var13 * 70) / 100;
// var11 = var23;
// var12 = var15;
// var13 = var24;
// }
//
// this.field_1127_a[var9 * 4 + 0] = (byte)var11;
// this.field_1127_a[var9 * 4 + 1] = (byte)var12;
// this.field_1127_a[var9 * 4 + 2] = (byte)var13;
// this.field_1127_a[var9 * 4 + 3] = (byte)var10;
// }
//
// }
//}