mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-27 18:38:14 -05:00
Update #35 - Fixes, improved dynamic lighting
This commit is contained in:
@ -19,7 +19,6 @@ import org.teavm.jso.dom.html.HTMLCanvasElement;
|
||||
import org.teavm.jso.dom.html.HTMLDocument;
|
||||
import org.teavm.jso.dom.html.HTMLInputElement;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.Base64;
|
||||
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
||||
@ -200,7 +199,7 @@ public class PlatformApplication {
|
||||
if(name == null) {
|
||||
fileChooserResultObject = null;
|
||||
}else {
|
||||
fileChooserResultObject = new FileChooserResult(name, TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(buffer)));
|
||||
fileChooserResultObject = new FileChooserResult(name, TeaVMUtils.wrapByteArrayBuffer(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,7 +295,7 @@ public class PlatformApplication {
|
||||
private static final native void downloadBytesImpl(String str, ArrayBuffer buf);
|
||||
|
||||
public static final void downloadFileWithName(String str, byte[] dat) {
|
||||
downloadBytesImpl(str, TeaVMUtils.unwrapUnsignedByteArray(dat).getBuffer());
|
||||
downloadBytesImpl(str, TeaVMUtils.unwrapArrayBuffer(dat));
|
||||
}
|
||||
|
||||
public static void showDebugConsole() {
|
||||
|
@ -16,7 +16,6 @@ import org.teavm.jso.dom.html.HTMLCanvasElement;
|
||||
import org.teavm.jso.dom.html.HTMLImageElement;
|
||||
import org.teavm.jso.dom.xml.Document;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Int32Array;
|
||||
import org.teavm.jso.typedarrays.Uint8ClampedArray;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
|
||||
@ -54,7 +53,7 @@ public class PlatformAssets {
|
||||
ArrayBuffer file = PlatformRuntime.downloadRemoteURI(
|
||||
ClientMain.configLocalesFolder + "/" + path.substring(22));
|
||||
if(file != null && file.getByteLength() > 0) {
|
||||
data = TeaVMUtils.arrayBufferToBytes(file);
|
||||
data = TeaVMUtils.wrapByteArrayBuffer(file);
|
||||
assets.put(path, data);
|
||||
return data;
|
||||
}else {
|
||||
@ -79,12 +78,15 @@ public class PlatformAssets {
|
||||
private static CanvasRenderingContext2D imageLoadContext = null;
|
||||
|
||||
public static ImageData loadImageFile(byte[] data) {
|
||||
return loadImageFile(TeaVMUtils.unwrapUnsignedByteArray(data).getBuffer());
|
||||
return loadImageFile(TeaVMUtils.unwrapArrayBuffer(data));
|
||||
}
|
||||
|
||||
@JSBody(params = { }, script = "return { willReadFrequently: true };")
|
||||
public static native JSObject youEagler();
|
||||
|
||||
@JSBody(params = { "ctx" }, script = "ctx.imageSmoothingEnabled = false;")
|
||||
private static native void disableImageSmoothing(CanvasRenderingContext2D ctx);
|
||||
|
||||
@Async
|
||||
private static native ImageData loadImageFile(ArrayBuffer data);
|
||||
|
||||
@ -105,6 +107,7 @@ public class PlatformAssets {
|
||||
}
|
||||
if(imageLoadContext == null) {
|
||||
imageLoadContext = (CanvasRenderingContext2D) imageLoadCanvas.getContext("2d", youEagler());
|
||||
disableImageSmoothing(imageLoadContext);
|
||||
}
|
||||
imageLoadContext.clearRect(0, 0, toLoad.getWidth(), toLoad.getHeight());
|
||||
imageLoadContext.drawImage(toLoad, 0, 0, toLoad.getWidth(), toLoad.getHeight());
|
||||
@ -116,7 +119,7 @@ public class PlatformAssets {
|
||||
ret.complete(null);
|
||||
return;
|
||||
}
|
||||
ret.complete(new ImageData(pxlsDat.getWidth(), pxlsDat.getHeight(), TeaVMUtils.wrapIntArray(Int32Array.create(pxls.getBuffer())), true));
|
||||
ret.complete(new ImageData(pxlsDat.getWidth(), pxlsDat.getHeight(), TeaVMUtils.wrapIntArrayBuffer(pxls.getBuffer()), true));
|
||||
}
|
||||
});
|
||||
toLoad.addEventListener("error", new EventListener<Event>() {
|
||||
|
@ -214,7 +214,7 @@ public class PlatformAudio {
|
||||
if(buffer == null) {
|
||||
byte[] file = PlatformAssets.getResourceBytes(filename);
|
||||
if(file == null) return null;
|
||||
buffer = new BrowserAudioResource(decodeAudioAsync(TeaVMUtils.unwrapUnsignedByteArray(file).getBuffer(), filename));
|
||||
buffer = new BrowserAudioResource(decodeAudioAsync(TeaVMUtils.unwrapArrayBuffer(file), filename));
|
||||
if(holdInCache) {
|
||||
synchronized(soundCache) {
|
||||
soundCache.put(filename, buffer);
|
||||
|
@ -12,7 +12,6 @@ import org.teavm.jso.dom.events.Event;
|
||||
import org.teavm.jso.dom.events.EventListener;
|
||||
import org.teavm.jso.dom.events.MessageEvent;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
import org.teavm.jso.websocket.WebSocket;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.teavm.TeaVMServerQuery;
|
||||
@ -120,7 +119,7 @@ public class PlatformNetworking {
|
||||
}
|
||||
}else {
|
||||
synchronized(readPackets) {
|
||||
readPackets.add(TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(evt.getDataAsArray())));
|
||||
readPackets.add(TeaVMUtils.wrapByteArrayBuffer(evt.getDataAsArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -181,7 +180,7 @@ public class PlatformNetworking {
|
||||
|
||||
public static void writePlayPacket(byte[] pkt) {
|
||||
if(sock != null && !sockIsConnecting) {
|
||||
nativeBinarySend(sock, TeaVMUtils.unwrapUnsignedByteArray(pkt).getBuffer());
|
||||
nativeBinarySend(sock, TeaVMUtils.unwrapArrayBuffer(pkt));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@ import org.teavm.jso.dom.html.HTMLCanvasElement;
|
||||
import org.teavm.jso.dom.html.HTMLDocument;
|
||||
import org.teavm.jso.dom.html.HTMLElement;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
import org.teavm.jso.webaudio.MediaStream;
|
||||
import org.teavm.jso.webgl.WebGLFramebuffer;
|
||||
|
||||
@ -311,7 +310,7 @@ public class PlatformRuntime {
|
||||
}
|
||||
|
||||
public static void downloadRemoteURIByteArray(String assetPackageURI, final Consumer<byte[]> cb) {
|
||||
downloadRemoteURI(assetPackageURI, arr -> cb.accept(TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(arr))));
|
||||
downloadRemoteURI(assetPackageURI, arr -> cb.accept(TeaVMUtils.wrapByteArrayBuffer(arr)));
|
||||
}
|
||||
|
||||
public static void downloadRemoteURI(String assetPackageURI, final Consumer<ArrayBuffer> cb) {
|
||||
|
@ -2,7 +2,6 @@ package net.lax1dude.eaglercraft.v1_8.internal;
|
||||
|
||||
import org.teavm.jso.JSBody;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.teavm.TeaVMUpdateThread;
|
||||
@ -62,7 +61,7 @@ public class PlatformUpdateSvc {
|
||||
logger.error("Failed to download client bundle or signature URL!");
|
||||
return null;
|
||||
}
|
||||
return TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(buf));
|
||||
return TeaVMUtils.wrapByteArrayBuffer(buf);
|
||||
}
|
||||
|
||||
public static byte[] getClientSignatureData() {
|
||||
|
@ -24,7 +24,6 @@ import org.teavm.jso.dom.events.Event;
|
||||
import org.teavm.jso.dom.events.EventListener;
|
||||
import org.teavm.jso.json.JSON;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
import org.teavm.jso.websocket.WebSocket;
|
||||
|
||||
import com.google.common.collect.LinkedListMultimap;
|
||||
@ -211,7 +210,7 @@ public class PlatformWebRTC {
|
||||
|
||||
TeaVMUtils.addEventListener(dataChannel, "message", (EventListener<Event>) evt -> {
|
||||
synchronized(clientLANPacketBuffer) {
|
||||
clientLANPacketBuffer.add(TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(getData(evt))));
|
||||
clientLANPacketBuffer.add(TeaVMUtils.wrapByteArrayBuffer(getData(evt)));
|
||||
}
|
||||
});
|
||||
|
||||
@ -326,7 +325,7 @@ public class PlatformWebRTC {
|
||||
serverLANEventBuffer.put(peerId, new LANPeerEvent.LANPeerDataChannelEvent(peerId));
|
||||
}
|
||||
TeaVMUtils.addEventListener(dataChannel, "message", (EventListener<Event>) evt2 -> {
|
||||
LANPeerEvent.LANPeerPacketEvent e = new LANPeerEvent.LANPeerPacketEvent(peerId, TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(getData(evt2))));
|
||||
LANPeerEvent.LANPeerPacketEvent e = new LANPeerEvent.LANPeerPacketEvent(peerId, TeaVMUtils.wrapByteArrayBuffer(getData(evt2)));
|
||||
synchronized(serverLANEventBuffer) {
|
||||
serverLANEventBuffer.put(peerId, e);
|
||||
}
|
||||
@ -538,10 +537,6 @@ public class PlatformWebRTC {
|
||||
@JSBody(params = { "obj" }, script = "return typeof obj === \"string\";")
|
||||
private static native boolean isString(JSObject obj);
|
||||
|
||||
private static ArrayBuffer convertToArrayBuffer(byte[] arr) {
|
||||
return TeaVMUtils.unwrapUnsignedByteArray(arr).getBuffer();
|
||||
}
|
||||
|
||||
private static final Map<String,Long> relayQueryLimited = new HashMap<>();
|
||||
private static final Map<String,Long> relayQueryBlocked = new HashMap<>();
|
||||
|
||||
@ -587,7 +582,7 @@ public class PlatformWebRTC {
|
||||
sock.onOpen(evt -> {
|
||||
try {
|
||||
connectionPingStart = System.currentTimeMillis();
|
||||
PlatformNetworking.nativeBinarySend(sock, convertToArrayBuffer(
|
||||
PlatformNetworking.nativeBinarySend(sock, TeaVMUtils.unwrapArrayBuffer(
|
||||
IPacket.writePacket(new IPacket00Handshake(0x03, RelayManager.preferredRelayVersion, ""))
|
||||
));
|
||||
} catch (IOException e) {
|
||||
@ -599,7 +594,7 @@ public class PlatformWebRTC {
|
||||
sock.onMessage(evt -> {
|
||||
if(evt.getData() != null && !isString(evt.getData())) {
|
||||
hasRecievedAnyData = true;
|
||||
byte[] arr = TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(evt.getDataAsArray()));
|
||||
byte[] arr = TeaVMUtils.wrapByteArrayBuffer(evt.getDataAsArray());
|
||||
if(arr.length == 2 && arr[0] == (byte)0xFC) {
|
||||
long millis = System.currentTimeMillis();
|
||||
if(arr[1] == (byte)0x00 || arr[1] == (byte)0x01) {
|
||||
@ -842,7 +837,7 @@ public class PlatformWebRTC {
|
||||
sock = s;
|
||||
sock.onOpen(evt -> {
|
||||
try {
|
||||
PlatformNetworking.nativeBinarySend(sock, convertToArrayBuffer(
|
||||
PlatformNetworking.nativeBinarySend(sock, TeaVMUtils.unwrapArrayBuffer(
|
||||
IPacket.writePacket(new IPacket00Handshake(0x04, RelayManager.preferredRelayVersion, ""))
|
||||
));
|
||||
} catch (IOException e) {
|
||||
@ -855,7 +850,7 @@ public class PlatformWebRTC {
|
||||
sock.onMessage(evt -> {
|
||||
if(evt.getData() != null && !isString(evt.getData())) {
|
||||
hasRecievedAnyData = true;
|
||||
byte[] arr = TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(evt.getDataAsArray()));
|
||||
byte[] arr = TeaVMUtils.wrapByteArrayBuffer(evt.getDataAsArray());
|
||||
if(arr.length == 2 && arr[0] == (byte)0xFC) {
|
||||
long millis = System.currentTimeMillis();
|
||||
if(arr[1] == (byte)0x00 || arr[1] == (byte)0x01) {
|
||||
@ -1065,7 +1060,7 @@ public class PlatformWebRTC {
|
||||
if(evt.getData() != null && !isString(evt.getData())) {
|
||||
hasRecievedAnyData = true;
|
||||
try {
|
||||
IPacket pkt = IPacket.readPacket(new DataInputStream(new EaglerInputStream(TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(evt.getDataAsArray())))));
|
||||
IPacket pkt = IPacket.readPacket(new DataInputStream(new EaglerInputStream(TeaVMUtils.wrapByteArrayBuffer(evt.getDataAsArray()))));
|
||||
if(pkt instanceof IPacket70SpecialUpdate) {
|
||||
IPacket70SpecialUpdate ipkt = (IPacket70SpecialUpdate)pkt;
|
||||
if(ipkt.operation == IPacket70SpecialUpdate.OPERATION_UPDATE_CERTIFICATE) {
|
||||
@ -1136,7 +1131,7 @@ public class PlatformWebRTC {
|
||||
@Override
|
||||
public void writePacket(IPacket pkt) {
|
||||
try {
|
||||
PlatformNetworking.nativeBinarySend(sock, convertToArrayBuffer(IPacket.writePacket(pkt)));
|
||||
PlatformNetworking.nativeBinarySend(sock, TeaVMUtils.unwrapArrayBuffer(IPacket.writePacket(pkt)));
|
||||
} catch (Throwable e) {
|
||||
logger.error("Relay connection error: {}", e.toString());
|
||||
EagRuntime.debugPrintStackTrace(e);
|
||||
@ -1283,7 +1278,7 @@ public class PlatformWebRTC {
|
||||
|
||||
// todo: ArrayBuffer version
|
||||
public static void clientLANSendPacket(byte[] pkt) {
|
||||
rtcLANClient.sendPacketToServer(convertToArrayBuffer(pkt));
|
||||
rtcLANClient.sendPacketToServer(TeaVMUtils.unwrapArrayBuffer(pkt));
|
||||
}
|
||||
|
||||
public static byte[] clientLANReadPacket() {
|
||||
@ -1409,7 +1404,7 @@ public class PlatformWebRTC {
|
||||
}
|
||||
|
||||
public static void serverLANWritePacket(String peer, byte[] data) {
|
||||
rtcLANServer.sendPacketToRemoteClient(peer, TeaVMUtils.unwrapUnsignedByteArray(data).getBuffer());
|
||||
rtcLANServer.sendPacketToRemoteClient(peer, TeaVMUtils.unwrapArrayBuffer(data));
|
||||
}
|
||||
|
||||
public static void serverLANCreatePeer(String peer) {
|
||||
|
@ -60,6 +60,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
|
||||
private boolean allowFNAWSkins = true;
|
||||
private String localStorageNamespace = "_eaglercraftX";
|
||||
private final TeaVMClientConfigAdapterHooks hooks = new TeaVMClientConfigAdapterHooks();
|
||||
private boolean enableMinceraft = true;
|
||||
|
||||
public void loadNative(JSObject jsObject) {
|
||||
integratedServerOpts = new JSONObject();
|
||||
@ -81,6 +82,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
|
||||
allowVoiceClient = eaglercraftXOpts.getAllowVoiceClient(true);
|
||||
allowFNAWSkins = !demoMode && eaglercraftXOpts.getAllowFNAWSkins(true);
|
||||
localStorageNamespace = eaglercraftXOpts.getLocalStorageNamespace(EaglercraftVersion.localStorageNamespace);
|
||||
enableMinceraft = eaglercraftXOpts.getEnableMinceraft(true);
|
||||
JSEaglercraftXOptsHooks hooksObj = eaglercraftXOpts.getHooks();
|
||||
if(hooksObj != null) {
|
||||
hooks.loadHooks(hooksObj);
|
||||
@ -175,6 +177,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
|
||||
allowVoiceClient = eaglercraftOpts.optBoolean("allowVoiceClient", true);
|
||||
allowFNAWSkins = eaglercraftOpts.optBoolean("allowFNAWSkins", true);
|
||||
localStorageNamespace = eaglercraftOpts.optString("localStorageNamespace", EaglercraftVersion.localStorageNamespace);
|
||||
enableMinceraft = eaglercraftOpts.optBoolean("enableMinceraft", true);
|
||||
JSONArray serversArray = eaglercraftOpts.optJSONArray("servers");
|
||||
if(serversArray != null) {
|
||||
for(int i = 0, l = serversArray.length(); i < l; ++i) {
|
||||
@ -332,6 +335,11 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
|
||||
return localStorageNamespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnableMinceraft() {
|
||||
return enableMinceraft;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClientConfigAdapterHooks getHooks() {
|
||||
return hooks;
|
||||
@ -357,6 +365,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
|
||||
jsonObject.put("allowVoiceClient", allowVoiceClient);
|
||||
jsonObject.put("allowFNAWSkins", allowFNAWSkins);
|
||||
jsonObject.put("localStorageNamespace", localStorageNamespace);
|
||||
jsonObject.put("enableMinceraft", enableMinceraft);
|
||||
JSONArray serversArr = new JSONArray();
|
||||
for(int i = 0, l = defaultServers.size(); i < l; ++i) {
|
||||
DefaultServer srv = defaultServers.get(i);
|
||||
|
@ -10,7 +10,6 @@ import org.teavm.jso.dom.events.Event;
|
||||
import org.teavm.jso.dom.events.EventListener;
|
||||
import org.teavm.jso.dom.events.MessageEvent;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
import org.teavm.jso.websocket.WebSocket;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.EnumServerRateLimit;
|
||||
@ -116,7 +115,7 @@ public class TeaVMServerQuery implements IServerQuery {
|
||||
}
|
||||
}else {
|
||||
synchronized(queryResponsesBytes) {
|
||||
queryResponsesBytes.add(TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(evt.getDataAsArray())));
|
||||
queryResponsesBytes.add(TeaVMUtils.wrapByteArrayBuffer(evt.getDataAsArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -143,7 +142,7 @@ public class TeaVMServerQuery implements IServerQuery {
|
||||
@Override
|
||||
public void send(byte[] bytes) {
|
||||
if(open) {
|
||||
nativeBinarySend(sock, TeaVMUtils.unwrapByteArray(bytes).getBuffer());
|
||||
nativeBinarySend(sock, TeaVMUtils.unwrapArrayBuffer(bytes));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ import org.teavm.jso.browser.Window;
|
||||
import org.teavm.jso.dom.events.Event;
|
||||
import org.teavm.jso.dom.events.EventListener;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
|
||||
import com.google.common.collect.ListMultimap;
|
||||
|
||||
@ -220,7 +219,7 @@ public class TeaVMUpdateThread implements Runnable {
|
||||
if(xhr.getStatus() == 200) {
|
||||
ArrayBuffer data = (ArrayBuffer)xhr.getResponse();
|
||||
if(data.getByteLength() == updateCert.bundleDataLength) {
|
||||
cb.complete(TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(data)));
|
||||
cb.complete(TeaVMUtils.wrapByteArrayBuffer(data));
|
||||
}else {
|
||||
logger.error("Unexpected response length {} (expect: {}) from URL: {}", xhr.getStatus(), xhr.getStatusText(), url);
|
||||
cb.complete(null);
|
||||
|
@ -51,89 +51,199 @@ public class TeaVMUtils {
|
||||
}
|
||||
|
||||
public static Int8Array unwrapByteArray(byte[] buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return Int8Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer());
|
||||
}
|
||||
|
||||
public static ArrayBuffer unwrapArrayBuffer(byte[] buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return ((TeaVMArrayObject)(Object)buf).getData().getBuffer();
|
||||
}
|
||||
|
||||
public static ArrayBufferView unwrapArrayBufferView(byte[] buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return ((TeaVMArrayObject)(Object)buf).getData();
|
||||
}
|
||||
|
||||
@JSBody(params = { "buf" }, script = "return $rt_createByteArray(buf.buffer)")
|
||||
@JSBody(params = { "buf" }, script = "return $rt_createByteArray(buf)")
|
||||
private static native JSObject wrapByteArray0(JSObject buf);
|
||||
|
||||
public static byte[] wrapByteArray(Int8Array buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return (byte[])(Object)wrapByteArray0(buf.getBuffer());
|
||||
}
|
||||
|
||||
public static byte[] wrapByteArrayBuffer(ArrayBuffer buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return (byte[])(Object)wrapByteArray0(buf);
|
||||
}
|
||||
|
||||
public static byte[] wrapByteArrayBufferView(ArrayBufferView buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return (byte[])(Object)wrapByteArray0(buf.getBuffer());
|
||||
}
|
||||
|
||||
public static Uint8Array unwrapUnsignedByteArray(byte[] buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return Uint8Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer());
|
||||
}
|
||||
|
||||
public static byte[] wrapUnsignedByteArray(Uint8Array buf) {
|
||||
return (byte[])(Object)wrapByteArray0(buf);
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return (byte[])(Object)wrapByteArray0(buf.getBuffer());
|
||||
}
|
||||
|
||||
public static Int32Array unwrapIntArray(int[] buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return Int32Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer());
|
||||
}
|
||||
|
||||
public static ArrayBuffer unwrapArrayBuffer(int[] buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return ((TeaVMArrayObject)(Object)buf).getData().getBuffer();
|
||||
}
|
||||
|
||||
public static ArrayBufferView unwrapArrayBufferView(int[] buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return ((TeaVMArrayObject)(Object)buf).getData();
|
||||
}
|
||||
|
||||
@JSBody(params = { "buf" }, script = "return $rt_createIntArray(buf.buffer)")
|
||||
@JSBody(params = { "buf" }, script = "return $rt_createIntArray(buf)")
|
||||
private static native JSObject wrapIntArray0(JSObject buf);
|
||||
|
||||
public static int[] wrapIntArray(Int32Array buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return (int[])(Object)wrapIntArray0(buf.getBuffer());
|
||||
}
|
||||
|
||||
public static int[] wrapIntArrayBuffer(ArrayBuffer buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return (int[])(Object)wrapIntArray0(buf);
|
||||
}
|
||||
|
||||
public static int[] wrapIntArrayBufferView(ArrayBufferView buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return (int[])(Object)wrapIntArray0(buf.getBuffer());
|
||||
}
|
||||
|
||||
public static Float32Array unwrapFloatArray(float[] buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return Float32Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer());
|
||||
}
|
||||
|
||||
public static ArrayBuffer unwrapArrayBuffer(float[] buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return ((TeaVMArrayObject)(Object)buf).getData().getBuffer();
|
||||
}
|
||||
|
||||
public static ArrayBufferView unwrapArrayBufferView(float[] buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return ((TeaVMArrayObject)(Object)buf).getData();
|
||||
}
|
||||
|
||||
@JSBody(params = { "buf" }, script = "return $rt_createFloatArray(buf.buffer)")
|
||||
@JSBody(params = { "buf" }, script = "return $rt_createFloatArray(buf)")
|
||||
private static native JSObject wrapFloatArray0(JSObject buf);
|
||||
|
||||
public static float[] wrapFloatArray(Float32Array buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return (float[])(Object)wrapFloatArray0(buf.getBuffer());
|
||||
}
|
||||
|
||||
public static float[] wrapFloatArrayBuffer(ArrayBuffer buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return (float[])(Object)wrapFloatArray0(buf);
|
||||
}
|
||||
|
||||
public static float[] wrapFloatArrayBufferView(ArrayBufferView buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return (float[])(Object)wrapFloatArray0(buf.getBuffer());
|
||||
}
|
||||
|
||||
public static Int16Array unwrapShortArray(short[] buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return Int16Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer());
|
||||
}
|
||||
|
||||
public static ArrayBuffer unwrapArrayBuffer(short[] buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return ((TeaVMArrayObject)(Object)buf).getData().getBuffer();
|
||||
}
|
||||
|
||||
public static ArrayBufferView unwrapArrayBufferView(short[] buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return ((TeaVMArrayObject)(Object)buf).getData();
|
||||
}
|
||||
|
||||
@JSBody(params = { "buf" }, script = "return $rt_createShortArray(buf.buffer)")
|
||||
@JSBody(params = { "buf" }, script = "return $rt_createShortArray(buf)")
|
||||
private static native JSObject wrapShortArray0(JSObject buf);
|
||||
|
||||
public static short[] wrapShortArray(Int16Array buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return (short[])(Object)wrapShortArray0(buf.getBuffer());
|
||||
}
|
||||
|
||||
public static short[] wrapShortArrayBuffer(ArrayBuffer buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return (short[])(Object)wrapShortArray0(buf);
|
||||
}
|
||||
|
||||
public static short[] wrapShortArrayBuffer(ArrayBufferView buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
return (short[])(Object)wrapShortArray0(buf.getBuffer());
|
||||
}
|
||||
|
||||
@Async
|
||||
public static native void sleepSetTimeout(int millis);
|
||||
|
||||
@ -141,14 +251,6 @@ public class TeaVMUtils {
|
||||
Window.setTimeout(() -> cb.complete(null), millis);
|
||||
}
|
||||
|
||||
public static final byte[] arrayBufferToBytes(ArrayBuffer buf) {
|
||||
if(buf == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return wrapUnsignedByteArray(Uint8Array.create(buf));
|
||||
}
|
||||
|
||||
public static String tryResolveClassesSource() {
|
||||
String str = dumpJSStackTrace();
|
||||
String[] frames = EagUtils.splitPattern.split(str);
|
||||
|
@ -93,4 +93,7 @@ public abstract class JSEaglercraftXOptsRoot implements JSObject {
|
||||
@JSBody(params = { "def" }, script = "return (typeof this.localStorageNamespace === \"string\") ? this.localStorageNamespace : def;")
|
||||
public native String getLocalStorageNamespace(String defaultValue);
|
||||
|
||||
@JSBody(params = { "def" }, script = "return (typeof this.enableMinceraft === \"boolean\") ? this.enableMinceraft : def;")
|
||||
public native boolean getEnableMinceraft(boolean defaultValue);
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import org.teavm.jso.JSObject;
|
||||
import org.teavm.jso.dom.events.ErrorEvent;
|
||||
import org.teavm.jso.dom.events.EventListener;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
import org.teavm.jso.workers.Worker;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IPCPacketData;
|
||||
@ -92,7 +91,7 @@ public class ClientPlatformSingleplayer {
|
||||
}
|
||||
|
||||
synchronized(messageQueue) {
|
||||
messageQueue.add(new IPCPacketData(channel, TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(buf))));
|
||||
messageQueue.add(new IPCPacketData(channel, TeaVMUtils.wrapByteArrayBuffer(buf)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,10 +195,7 @@ public class ClientPlatformSingleplayer {
|
||||
}
|
||||
|
||||
public static void sendPacket(IPCPacketData packet) {
|
||||
ArrayBuffer arb = ArrayBuffer.create(packet.contents.length);
|
||||
Uint8Array ar = Uint8Array.create(arb);
|
||||
ar.set(packet.contents);
|
||||
sendPacketTeaVM(packet.channel, TeaVMUtils.unwrapUnsignedByteArray(packet.contents).getBuffer());
|
||||
sendPacketTeaVM(packet.channel, TeaVMUtils.unwrapArrayBuffer(packet.contents));
|
||||
}
|
||||
|
||||
public static void sendPacketTeaVM(String channel, ArrayBuffer packet) {
|
||||
|
@ -8,7 +8,6 @@ import org.teavm.jso.JSBody;
|
||||
import org.teavm.jso.JSFunctor;
|
||||
import org.teavm.jso.JSObject;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IClientConfigAdapter;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IPCPacketData;
|
||||
@ -58,7 +57,7 @@ public class ServerPlatformSingleplayer {
|
||||
}
|
||||
|
||||
synchronized(messageQueue) {
|
||||
messageQueue.add(new IPCPacketData(channel, TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(buf))));
|
||||
messageQueue.add(new IPCPacketData(channel, TeaVMUtils.wrapByteArrayBuffer(buf)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,10 +78,7 @@ public class ServerPlatformSingleplayer {
|
||||
public static native void sendPacketTeaVM(String channel, ArrayBuffer arr);
|
||||
|
||||
public static void sendPacket(IPCPacketData packet) {
|
||||
ArrayBuffer arb = ArrayBuffer.create(packet.contents.length);
|
||||
Uint8Array ar = Uint8Array.create(arb);
|
||||
ar.set(packet.contents);
|
||||
sendPacketTeaVM(packet.channel, arb);
|
||||
sendPacketTeaVM(packet.channel, TeaVMUtils.unwrapArrayBuffer(packet.contents));
|
||||
}
|
||||
|
||||
public static List<IPCPacketData> recieveAllPacket() {
|
||||
|
Reference in New Issue
Block a user