diff --git a/README.md b/README.md index de94b02..d3523f2 100644 --- a/README.md +++ b/README.md @@ -23,14 +23,14 @@ ### To compile the latest version of the client, on Windows: -1. Make sure you have at least Java 11 installed and added to your PATH, its is recommended to use Java 17 +1. Make sure you have at least Java 11 installed and added to your PATH, it is recommended to use Java 17 2. Download (clone) this repository to your computer 3. Double click `CompileLatestClient.bat`, a GUI resembling a classic windows installer should open 4. Follow the steps shown to you in the new window to finish compiling ### To compile the latest version of the client, on Linux/macOS: -1. Make sure you have at least Java 11 installed, its is recommended to use Java 17 +1. Make sure you have at least Java 11 installed, it is recommended to use Java 17 2. Download (clone) this repository to your computer 3. Open a terminal in the folder the repository was cloned to 4. Type `chmod +x CompileLatestClient.sh` and hit enter @@ -63,6 +63,12 @@ EaglercraftX 1.8 includes a deferred physically-based renderer modeled after the EaglercraftX 1.8 includes an integrated voice-chat service that can be used in shared worlds and also on multiplayer servers when it is enabled by the server owner. This feature also uses WebRTC like shared worlds, so be careful that you don't leak your IP address accidentally by using it on a public server. If you own a website and don't want people to use voice chat on it, edit the `eaglercraftXOpts` variable in your index.html and add `allowVoiceClient: false`. +## Resource Packs + +EaglercraftX 1.8 allows you to use any vanilla Minecraft 1.8 resource pack in your browser by importing it as a zip file, resource packs are saved to your browser's local storage and are saved between page refreshes. This can be used to add the original C418 soundtrack back into the game, download and import [this pack](https://bafybeiayojww5jfyzvlmtuk7l5ufkt7nlfto7mhwmzf2vs4bvsjd5ouiuq.ipfs.nftstorage.link/?filename=Music_For_Eaglercraft.zip) to add music back to Eaglercraft. A known bug with the debug desktop runtime is that sound files in resource packs do not play, this may be fixed in the future but is not a high priority issue. + +If you are creating a resource pack and want to disable the blur filter on the main menu panorama, create a file called `assets/minecraft/textures/gui/title/background/enable_blur.txt` in your pack and set it's contents to `enable_blur=0` + ## Making a Server To make a server for EaglercraftX 1.8 the recommended software to use is EaglercraftXBungee ("EaglerXBungee") which is included in this repository in the `gateway/EaglercraftXBungee` folder. This is a plugin designed to be used with BungeeCord to allow Eaglercraft players to join your BungeeCord server. It is assumed that the reader already knows what BungeeCord is and has a working server set up that is joinable via java edition. If you don't know what BungeeCord is, please research the topic yourself first before continuing. Waterfall and FlameCord have also been tested, but EaglerXBungee was natively compiled against BungeeCord. @@ -156,6 +162,7 @@ The default eaglercraftXOpts values is this: - `allowVoiceClient:` can be used to disable the voice chat feature - `allowFNAWSkins:` can be used to disable the high poly FNAW skins - `localStorageNamespace:` can be used to change the prefix of the local storage keys (Default: `"_eaglercraftX"`) +- `enableMinceraft:` can be used to disable the "Minceraft" title screen - `hooks:` can be used to define JavaScript callbacks for certain events * `localStorageSaved:` JavaScript callback to save local storage keys * `localStorageLoaded:` JavaScript callback to load local storage keys diff --git a/client_version b/client_version index 979e1e0..5e6a25e 100644 --- a/client_version +++ b/client_version @@ -1 +1 @@ -u34 \ No newline at end of file +u35 \ No newline at end of file diff --git a/patches/minecraft/net/minecraft/client/Minecraft.edit.java b/patches/minecraft/net/minecraft/client/Minecraft.edit.java index 34e1f62..f24b1b0 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.edit.java +++ b/patches/minecraft/net/minecraft/client/Minecraft.edit.java @@ -357,9 +357,10 @@ ~ logger.info("Caught error stitching, removing all assigned resourcepacks"); ~ logger.info(runtimeexception); -> INSERT 9 : 11 @ 9 +> INSERT 9 : 12 @ 9 + ShaderSource.clearCache(); ++ GuiMainMenu.doResourceReloadHack(); + > CHANGE 7 : 10 @ 7 : 19 diff --git a/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.edit.java b/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.edit.java index 2b669b3..09be208 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.edit.java +++ b/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.edit.java @@ -7,7 +7,9 @@ > DELETE 2 @ 2 : 3 -> DELETE 3 @ 3 : 4 +> CHANGE 3 : 4 @ 3 : 4 + +~ import java.nio.charset.StandardCharsets; > INSERT 1 : 2 @ 1 @@ -17,6 +19,7 @@ ~ ~ import net.lax1dude.eaglercraft.v1_8.EagRuntime; +~ import net.lax1dude.eaglercraft.v1_8.EagUtils; ~ import net.lax1dude.eaglercraft.v1_8.EaglerInputStream; ~ import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; ~ import net.lax1dude.eaglercraft.v1_8.EaglercraftVersion; @@ -25,7 +28,6 @@ ~ import com.google.common.base.Charsets; ~ import com.google.common.collect.Lists; ~ -~ import net.lax1dude.eaglercraft.v1_8.crypto.MD5Digest; ~ import net.lax1dude.eaglercraft.v1_8.crypto.SHA1Digest; ~ import net.lax1dude.eaglercraft.v1_8.internal.EnumCursorType; ~ import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; @@ -61,12 +63,10 @@ ~ private static final EaglercraftRandom RANDOM = new EaglercraftRandom(); -> INSERT 1 : 7 @ 1 +> INSERT 1 : 5 @ 1 + private boolean isDefault; + private static final int lendef = 5987; -+ private static final byte[] md5def = new byte[] { -61, -53, -36, 27, 24, 27, 103, -31, -58, -116, 113, -60, -67, -8, -+ -77, 30 }; + private static final byte[] sha1def = new byte[] { -107, 77, 108, 49, 11, -100, -8, -119, -1, -100, -85, -55, 18, + -69, -107, 113, -93, -101, -79, 32 }; @@ -78,58 +78,105 @@ > DELETE 2 @ 2 : 3 -> INSERT 3 : 4 @ 3 +> INSERT 3 : 6 @ 3 ++ private static final ResourceLocation minecraftTitleBlurFlag = new ResourceLocation( ++ "textures/gui/title/background/enable_blur.txt"); + private static final ResourceLocation eaglerGuiTextures = new ResourceLocation("eagler:gui/eagler_gui.png"); > DELETE 7 @ 7 : 9 -> CHANGE 6 : 9 @ 6 : 8 +> CHANGE 6 : 11 @ 6 : 8 ~ private static ResourceLocation backgroundTexture = null; ~ private GuiUpdateCheckerOverlay updateCheckerOverlay; ~ private GuiButton downloadOfflineButton; +~ private boolean enableBlur = true; +~ private boolean shouldReload = false; -> DELETE 2 @ 2 : 3 +> INSERT 1 : 3 @ 1 + ++ private static GuiMainMenu instance = null; ++ + +> CHANGE 1 : 2 @ 1 : 2 + +~ instance = this; > INSERT 1 : 2 @ 1 + updateCheckerOverlay = new GuiUpdateCheckerOverlay(false, this); -> DELETE 38 @ 38 : 44 +> CHANGE 38 : 65 @ 38 : 43 -> INSERT 1 : 25 @ 1 +~ +~ reloadResourceFlags(); +~ } +~ +~ private void reloadResourceFlags() { +~ if (Minecraft.getMinecraft().isDemo()) { +~ this.isDefault = false; +~ } else { +~ if (!EagRuntime.getConfiguration().isEnableMinceraft()) { +~ this.isDefault = false; +~ } else { +~ try { +~ byte[] bytes = EaglerInputStream.inputStreamToBytesQuiet(Minecraft.getMinecraft() +~ .getResourceManager().getResource(minecraftTitleTextures).getInputStream()); +~ if (bytes != null && bytes.length == lendef) { +~ SHA1Digest sha1 = new SHA1Digest(); +~ byte[] sha1out = new byte[20]; +~ sha1.update(bytes, 0, bytes.length); +~ sha1.doFinal(sha1out, 0); +~ this.isDefault = Arrays.equals(sha1out, sha1def); +~ } else { +~ this.isDefault = false; +~ } +~ } catch (IOException e) { +~ this.isDefault = false; +~ } +~ } -+ if (Minecraft.getMinecraft().isDemo()) { -+ this.isDefault = false; -+ } else { -+ MD5Digest md5 = new MD5Digest(); -+ SHA1Digest sha1 = new SHA1Digest(); -+ byte[] md5out = new byte[16]; -+ byte[] sha1out = new byte[20]; -+ try { -+ byte[] bytes = EaglerInputStream.inputStreamToBytesQuiet(Minecraft.getMinecraft().getResourceManager() -+ .getResource(minecraftTitleTextures).getInputStream()); -+ if (bytes != null) { -+ md5.update(bytes, 0, bytes.length); -+ sha1.update(bytes, 0, bytes.length); -+ md5.doFinal(md5out, 0); -+ sha1.doFinal(sha1out, 0); -+ this.isDefault = bytes.length == lendef && Arrays.equals(md5out, md5def) -+ && Arrays.equals(sha1out, sha1def); -+ } else { -+ this.isDefault = false; +> INSERT 2 : 21 @ 2 + ++ this.enableBlur = true; ++ ++ try { ++ byte[] bytes = EaglerInputStream.inputStreamToBytesQuiet( ++ Minecraft.getMinecraft().getResourceManager().getResource(minecraftTitleBlurFlag).getInputStream()); ++ if (bytes != null) { ++ String[] blurCfg = EagUtils.linesArray(new String(bytes, StandardCharsets.UTF_8)); ++ for (int i = 0; i < blurCfg.length; ++i) { ++ String s = blurCfg[i]; ++ if (s.startsWith("enable_blur=")) { ++ s = s.substring(12).trim(); ++ this.enableBlur = s.equals("1") || s.equals("true"); ++ break; ++ } + } -+ } catch (IOException e) { -+ this.isDefault = false; + } ++ } catch (IOException e) { ++ ; + } -> INSERT 4 : 7 @ 4 +> INSERT 2 : 8 @ 2 + ++ public static void doResourceReloadHack() { ++ if (instance != null) { ++ instance.shouldReload = true; ++ } ++ } ++ + +> INSERT 2 : 9 @ 2 + if (downloadOfflineButton != null) { + downloadOfflineButton.enabled = !UpdateService.shouldDisableDownloadButton(); + } ++ if (shouldReload) { ++ reloadResourceFlags(); ++ shouldReload = false; ++ } > CHANGE 6 : 7 @ 6 : 7 @@ -256,11 +303,25 @@ > DELETE 1 @ 1 : 2 -> CHANGE 8 : 9 @ 8 : 9 +> CHANGE 8 : 13 @ 8 : 9 -~ GlStateManager.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F); +~ if (enableBlur) { +~ GlStateManager.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F); +~ } else { +~ GlStateManager.gluPerspective(85.0F, (float) width / (float) height, 0.05F, 10.0F); +~ } -> CHANGE 73 : 77 @ 73 : 77 +> CHANGE 5 : 8 @ 5 : 6 + +~ if (enableBlur) { +~ GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F); +~ } + +> CHANGE 5 : 6 @ 5 : 6 + +~ byte b0 = enableBlur ? (byte) 8 : (byte) 1; + +> CHANGE 61 : 65 @ 61 : 65 ~ this.mc.getTextureManager().bindTexture(backgroundTexture); ~ EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -271,11 +332,23 @@ > DELETE 9 @ 9 : 10 -> DELETE 24 @ 24 : 26 +> CHANGE 22 : 27 @ 22 : 23 -> CHANGE 7 : 8 @ 7 : 8 +~ if (enableBlur) { +~ this.renderSkybox(i, j, f); +~ } else { +~ this.drawPanorama(i, j, f); +~ } -~ if (this.isDefault || (double) this.updateCounter < 1.0E-4D) { +> DELETE 1 @ 1 : 3 + +> CHANGE 7 : 12 @ 7 : 8 + +~ boolean minc = (double) this.updateCounter < 1.0E-4D; +~ if (this.isDefault) { +~ minc = !minc; +~ } +~ if (minc) { > CHANGE 4 : 5 @ 4 : 5 diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.edit.java b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.edit.java index 6eaa72f..2d8c84d 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.edit.java +++ b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.edit.java @@ -84,7 +84,7 @@ + public static final ServerResourceMode[] _VALUES = values(); + -> INSERT 10 : 76 @ 10 +> INSERT 10 : 81 @ 10 + + public void setMOTDFromQuery(QueryResponse pkt) { @@ -95,7 +95,12 @@ + this.serverMOTD = motd.length() > 0 + ? (motd.length() > 1 ? motd.getString(0) + "\n" + motd.getString(1) : motd.getString(0)) + : ""; -+ this.populationInfo = "" + motdData.getInt("online") + "/" + motdData.getInt("max"); ++ int max = motdData.getInt("max"); ++ if (max > 0) { ++ this.populationInfo = "" + motdData.getInt("online") + "/" + max; ++ } else { ++ this.populationInfo = "" + motdData.getInt("online"); ++ } + this.playerList = null; + JSONArray players = motdData.optJSONArray("players"); + if (players.length() > 0) { diff --git a/sources/lwjgl/java/net/lax1dude/eaglercraft/v1_8/internal/lwjgl/DesktopClientConfigAdapter.java b/sources/lwjgl/java/net/lax1dude/eaglercraft/v1_8/internal/lwjgl/DesktopClientConfigAdapter.java index 1380861..2709b2b 100644 --- a/sources/lwjgl/java/net/lax1dude/eaglercraft/v1_8/internal/lwjgl/DesktopClientConfigAdapter.java +++ b/sources/lwjgl/java/net/lax1dude/eaglercraft/v1_8/internal/lwjgl/DesktopClientConfigAdapter.java @@ -142,6 +142,11 @@ public class DesktopClientConfigAdapter implements IClientConfigAdapter { return EaglercraftVersion.localStorageNamespace; } + @Override + public boolean isEnableMinceraft() { + return true; + } + @Override public IClientConfigAdapterHooks getHooks() { return hooks; diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglerInputStream.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglerInputStream.java index d35b115..bf1466c 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglerInputStream.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglerInputStream.java @@ -121,20 +121,24 @@ public class EaglerInputStream extends InputStream { } public static byte[] inputStreamToBytes(InputStream is) throws IOException { - if (is instanceof EaglerInputStream) { - return ((EaglerInputStream) is).getAsArray(); - } else if (is instanceof ByteArrayInputStream) { - byte[] ret = new byte[is.available()]; - is.read(ret); - return ret; - } else { - EaglerOutputStream os = new EaglerOutputStream(1024); - byte[] buf = new byte[1024]; - int i; - while ((i = is.read(buf)) != -1) { - os.write(buf, 0, i); + try { + if (is instanceof EaglerInputStream) { + return ((EaglerInputStream) is).getAsArray(); + } else if (is instanceof ByteArrayInputStream) { + byte[] ret = new byte[is.available()]; + is.read(ret); + return ret; + } else { + EaglerOutputStream os = new EaglerOutputStream(1024); + byte[] buf = new byte[1024]; + int i; + while ((i = is.read(buf)) != -1) { + os.write(buf, 0, i); + } + return os.toByteArray(); } - return os.toByteArray(); + }finally { + is.close(); } } diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java index 05e7a77..32a245f 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java @@ -10,7 +10,7 @@ public class EaglercraftVersion { /// Customize these to fit your fork: public static final String projectForkName = "EaglercraftX"; - public static final String projectForkVersion = "u34"; + public static final String projectForkVersion = "u35"; public static final String projectForkVendor = "lax1dude"; public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; @@ -20,7 +20,7 @@ public class EaglercraftVersion { public static final String projectOriginName = "EaglercraftX"; public static final String projectOriginAuthor = "lax1dude"; public static final String projectOriginRevision = "1.8"; - public static final String projectOriginVersion = "u34"; + public static final String projectOriginVersion = "u35"; public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace @@ -31,7 +31,7 @@ public class EaglercraftVersion { public static final boolean enableUpdateService = true; public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client"; - public static final int updateBundlePackageVersionInt = 34; + public static final int updateBundlePackageVersionInt = 35; public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName; diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/internal/IClientConfigAdapter.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/internal/IClientConfigAdapter.java index d2e0492..f28f78a 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/internal/IClientConfigAdapter.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/internal/IClientConfigAdapter.java @@ -74,6 +74,8 @@ public interface IClientConfigAdapter { String getLocalStorageNamespace(); + boolean isEnableMinceraft(); + IClientConfigAdapterHooks getHooks(); } diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/EaglerDeferredPipeline.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/EaglerDeferredPipeline.java index 246a8c5..6e0fa7e 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/EaglerDeferredPipeline.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/EaglerDeferredPipeline.java @@ -66,7 +66,6 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.ExtGLEnums.*; import java.io.DataInputStream; import java.io.IOException; -import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; import java.util.List; diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/texture/EaglerBitwisePackedTexture.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/texture/EaglerBitwisePackedTexture.java index 5d37d21..72bcf5f 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/texture/EaglerBitwisePackedTexture.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/texture/EaglerBitwisePackedTexture.java @@ -3,6 +3,7 @@ package net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.texture; import java.io.IOException; import java.io.InputStream; +import net.lax1dude.eaglercraft.v1_8.IOUtils; import net.lax1dude.eaglercraft.v1_8.opengl.ImageData; /** @@ -75,4 +76,15 @@ public class EaglerBitwisePackedTexture { return img; } + public static ImageData loadTextureSafe(InputStream is, int alpha) throws IOException { + ImageData bufferedimage; + try { + bufferedimage = loadTexture(is, alpha); + } finally { + IOUtils.closeQuietly(is); + } + + return bufferedimage; + } + } diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/texture/PBRTextureMapUtils.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/texture/PBRTextureMapUtils.java index 2e4b77d..e29938f 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/texture/PBRTextureMapUtils.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/texture/PBRTextureMapUtils.java @@ -73,7 +73,7 @@ public class PBRTextureMapUtils { }catch(Throwable t) { } try { - return EaglerBitwisePackedTexture.loadTexture(resMgr.getResource(new ResourceLocation("eagler:glsl/deferred/assets_pbr/" + fname + ".ebp")).getInputStream(), 255); + return EaglerBitwisePackedTexture.loadTextureSafe(resMgr.getResource(new ResourceLocation("eagler:glsl/deferred/assets_pbr/" + fname + ".ebp")).getInputStream(), 255); }catch(Throwable t) { // dead code because teavm t.toString(); diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightBucketLoader.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightBucketLoader.java index ab8f3c5..8f06214 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightBucketLoader.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightBucketLoader.java @@ -4,7 +4,6 @@ import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*; import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*; import static net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.ExtGLEnums.*; -import java.util.ArrayList; import java.util.Comparator; import java.util.List; diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightInstance.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightInstance.java index 72ec488..e6b388a 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightInstance.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightInstance.java @@ -17,30 +17,21 @@ package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights; */ class DynamicLightInstance { - public final String lightName; - long lastCacheHit = 0l; - double posX; double posY; double posZ; float radius; - public DynamicLightInstance(String lightName) { - this.lightName = lightName; + public DynamicLightInstance() { } public void updateLight(double posX, double posY, double posZ, float radius) { - this.lastCacheHit = System.currentTimeMillis(); this.posX = posX; this.posY = posY; this.posZ = posZ; this.radius = radius; } - public void destroy() { - - } - public float getRadiusInWorld() { return radius; } diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightsPipelineCompiler.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightsPipelineCompiler.java index 23d6a30..bb501c0 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightsPipelineCompiler.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightsPipelineCompiler.java @@ -8,7 +8,6 @@ import net.lax1dude.eaglercraft.v1_8.opengl.FixedFunctionShader.FixedFunctionSta import net.lax1dude.eaglercraft.v1_8.opengl.IExtPipelineCompiler; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.ShaderSource; import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.program.DynamicLightsExtPipelineShader; -import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f; import net.minecraft.client.renderer.GLAllocation; /** diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightsStateManager.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightsStateManager.java index ad7bac9..0495c29 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightsStateManager.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/DynamicLightsStateManager.java @@ -1,10 +1,9 @@ package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights; -import java.util.HashMap; +import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import java.util.Map; import net.lax1dude.eaglercraft.v1_8.opengl.FixedFunctionPipeline; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; @@ -31,14 +30,15 @@ import net.minecraft.util.MathHelper; public class DynamicLightsStateManager { static final DynamicLightsPipelineCompiler deferredExtPipeline = new DynamicLightsPipelineCompiler(); - static final Map lightRenderers = new HashMap(); + private static List lightInstancePool = new ArrayList(); + private static int instancePoolIndex = 0; + private static int maxListLengthTracker = 0; static final List lightRenderList = new LinkedList(); static final Matrix4f inverseViewMatrix = new Matrix4f(); static int inverseViewMatrixSerial = 0; static DynamicLightBucketLoader bucketLoader = null; static DynamicLightsAcceleratedEffectRenderer accelParticleRenderer = null; static int lastTotal = 0; - static long renderTimeout = 5000l; private static long lastTick = 0l; public static final void enableDynamicLightsRender() { @@ -52,6 +52,9 @@ public class DynamicLightsStateManager { accelParticleRenderer = new DynamicLightsAcceleratedEffectRenderer(); accelParticleRenderer.initialize(); } + lightRenderList.clear(); + instancePoolIndex = 0; + maxListLengthTracker = 0; } public static final void bindAcceleratedEffectRenderer(EffectRenderer renderer) { @@ -72,6 +75,8 @@ public class DynamicLightsStateManager { } destroyAll(); lightRenderList.clear(); + instancePoolIndex = 0; + maxListLengthTracker = 0; } public static final boolean isDynamicLightsRender() { @@ -99,21 +104,27 @@ public class DynamicLightsStateManager { public static final void renderDynamicLight(String lightName, double posX, double posY, double posZ, float radius) { if(bucketLoader != null) { - DynamicLightInstance dl = lightRenderers.get(lightName); - if(dl == null) { - lightRenderers.put(lightName, dl = new DynamicLightInstance(lightName)); + DynamicLightInstance dl; + if(instancePoolIndex < lightInstancePool.size()) { + dl = lightInstancePool.get(instancePoolIndex); + }else { + lightInstancePool.add(dl = new DynamicLightInstance()); } + ++instancePoolIndex; dl.updateLight(posX, posY, posZ, radius); lightRenderList.add(dl); } } public static final void clearRenderList() { + if(instancePoolIndex > maxListLengthTracker) { + maxListLengthTracker = instancePoolIndex; + } lightRenderList.clear(); + instancePoolIndex = 0; } public static final void commitLightSourceBuckets(double renderPosX, double renderPosY, double renderPosZ) { - updateTimers(); lastTotal = lightRenderList.size(); if(bucketLoader != null) { bucketLoader.clearBuckets(); @@ -131,7 +142,8 @@ public class DynamicLightsStateManager { bucketLoader.setRenderPos(renderPosX, renderPosY, renderPosZ); bucketLoader.truncateOverflowingBuffers(); } - lightRenderList.clear(); + updateTimers(); + clearRenderList(); } public static final void setupInverseViewMatrix() { @@ -141,25 +153,21 @@ public class DynamicLightsStateManager { private static final void updateTimers() { long millis = System.currentTimeMillis(); - if(millis - lastTick > 1000l) { + if(millis - lastTick > 5000l) { lastTick = millis; - Iterator itr = lightRenderers.values().iterator(); - while(itr.hasNext()) { - DynamicLightInstance dl = itr.next(); - if(millis - dl.lastCacheHit > renderTimeout) { - dl.destroy(); - itr.remove(); + if(maxListLengthTracker < (lightInstancePool.size() >> 1)) { + List newPool = new ArrayList(Math.max(maxListLengthTracker, 16)); + for(int i = 0; i < maxListLengthTracker; ++i) { + newPool.add(lightInstancePool.get(i)); } + lightInstancePool = newPool; } + maxListLengthTracker = 0; } } public static final void destroyAll() { - Iterator itr = lightRenderers.values().iterator(); - while(itr.hasNext()) { - itr.next().destroy(); - } - lightRenderers.clear(); + lightInstancePool = new ArrayList(); } public static String getF3String() { diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/program/DynamicLightsAccelParticleShader.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/program/DynamicLightsAccelParticleShader.java index 3fc0346..ff16f55 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/program/DynamicLightsAccelParticleShader.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/dynamiclights/program/DynamicLightsAccelParticleShader.java @@ -1,11 +1,7 @@ package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.program; import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*; -import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.GL_FRAGMENT_SHADER; -import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.GL_VERTEX_SHADER; - -import java.util.ArrayList; -import java.util.List; +import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*; import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL; import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL; diff --git a/sources/resources/assets/eagler/glsl/core.fsh b/sources/resources/assets/eagler/glsl/core.fsh index eb9fcd1..5a01a79 100644 --- a/sources/resources/assets/eagler/glsl/core.fsh +++ b/sources/resources/assets/eagler/glsl/core.fsh @@ -170,7 +170,7 @@ void main() { #ifdef COMPILE_ENABLE_FOG vec3 fogPos = v_position4f.xyz / v_position4f.w; - float dist = sqrt(dot(fogPos, fogPos)); + float dist = length(fogPos); float fogDensity = u_fogParameters4f.y; float fogStart = u_fogParameters4f.z; float fogEnd = u_fogParameters4f.w; diff --git a/sources/resources/assets/eagler/glsl/deferred/deferred_fog.fsh b/sources/resources/assets/eagler/glsl/deferred/deferred_fog.fsh index b179645..8130c07 100644 --- a/sources/resources/assets/eagler/glsl/deferred/deferred_fog.fsh +++ b/sources/resources/assets/eagler/glsl/deferred/deferred_fog.fsh @@ -69,7 +69,7 @@ void main() { fragPos4f.xyz /= fragPos4f.w; fragPos4f.w = 1.0; - float l = sqrt(dot(fragPos4f.xyz, fragPos4f.xyz)); + float l = length(fragPos4f.xyz); #ifdef COMPILE_FOG_LINEAR float f = (l - u_linearFogParam2f.x) / (u_linearFogParam2f.y - u_linearFogParam2f.x); #else diff --git a/sources/resources/assets/eagler/glsl/deferred/forward_core.fsh b/sources/resources/assets/eagler/glsl/deferred/forward_core.fsh index 65f98d0..4e6a375 100644 --- a/sources/resources/assets/eagler/glsl/deferred/forward_core.fsh +++ b/sources/resources/assets/eagler/glsl/deferred/forward_core.fsh @@ -431,7 +431,7 @@ void main() { float type = u_fogParameters4f.x - atmos; fogBlend4f = mix(u_fogColorLight4f, u_fogColorDark4f, lightmapCoords2f.g); - float l = sqrt(dot(v_position4f.xyz, v_position4f.xyz)); + float l = length(v_position4f.xyz); if(type == 1.0) { f = (l - u_fogParameters4f.z) / (u_fogParameters4f.w - u_fogParameters4f.z); }else { diff --git a/sources/resources/assets/eagler/glsl/deferred/forward_glass_highlights.fsh b/sources/resources/assets/eagler/glsl/deferred/forward_glass_highlights.fsh index 72925fd..5f0100f 100644 --- a/sources/resources/assets/eagler/glsl/deferred/forward_glass_highlights.fsh +++ b/sources/resources/assets/eagler/glsl/deferred/forward_glass_highlights.fsh @@ -292,7 +292,7 @@ void main() { fogFade = mix(u_fogColorDark4f.a, u_fogColorLight4f.a, lightmapCoords2f.g); float f; - float l = sqrt(dot(v_position4f.xyz, v_position4f.xyz)); + float l = length(v_position4f.xyz); if(type == 1.0) { f = (l - u_fogParameters4f.z) / (u_fogParameters4f.w - u_fogParameters4f.z); }else { diff --git a/sources/resources/assets/eagler/glsl/deferred/realistic_water_render.fsh b/sources/resources/assets/eagler/glsl/deferred/realistic_water_render.fsh index f5f9869..5413ff5 100644 --- a/sources/resources/assets/eagler/glsl/deferred/realistic_water_render.fsh +++ b/sources/resources/assets/eagler/glsl/deferred/realistic_water_render.fsh @@ -397,7 +397,7 @@ void main() { float type = u_fogParameters4f.x - atmos; fogBlend4f = mix(u_fogColorLight4f, u_fogColorDark4f, lightmapCoords2f.g); - float f, l = sqrt(dot(v_position4f.xyz, v_position4f.xyz)); + float f, l = length(v_position4f.xyz); if(type == 1.0) { f = (l - u_fogParameters4f.z) / (u_fogParameters4f.w - u_fogParameters4f.z); }else { diff --git a/sources/resources/assets/eagler/glsl/deferred/shader_pack_info.json b/sources/resources/assets/eagler/glsl/deferred/shader_pack_info.json index 6b573da..af5f511 100644 --- a/sources/resources/assets/eagler/glsl/deferred/shader_pack_info.json +++ b/sources/resources/assets/eagler/glsl/deferred/shader_pack_info.json @@ -1,7 +1,7 @@ { "name": "§eHigh Performance PBR", "desc": "Pack made from scratch specifically for this client, designed to give what I call the best balance between quality and performance possible in a browser but obviously that's just my opinion", - "vers": "1.2.0", + "vers": "1.2.1", "author": "lax1dude", "api_vers": 1, "features": [ diff --git a/sources/resources/assets/eagler/glsl/dynamiclights/accel_particle_dynamiclights.fsh b/sources/resources/assets/eagler/glsl/dynamiclights/accel_particle_dynamiclights.fsh index 1492065..c8289e8 100644 --- a/sources/resources/assets/eagler/glsl/dynamiclights/accel_particle_dynamiclights.fsh +++ b/sources/resources/assets/eagler/glsl/dynamiclights/accel_particle_dynamiclights.fsh @@ -48,7 +48,9 @@ void main() { } vec4 light; + float blockLight = v_lightmap2f.x; float diffuse = 0.0; + float len; if(u_dynamicLightCount1i > 0) { vec4 worldPosition4f = u_inverseViewMatrix4f * v_position4f; worldPosition4f.xyz /= worldPosition4f.w; @@ -57,11 +59,13 @@ void main() { for(int i = 0; i < safeLightCount; ++i) { light = u_dynamicLightArray[i]; light.xyz = light.xyz - worldPosition4f.xyz; - diffuse += max(dot(normalize(light.xyz), normalVector3f) * 0.8 + 0.2, 0.0) * max(light.w - sqrt(dot(light.xyz, light.xyz)), 0.0); + len = length(light.xyz); + diffuse += max(dot(light.xyz / len, normalVector3f) * 0.8 + 0.2, 0.0) * max(light.w - len, 0.0); } + blockLight = min(blockLight + diffuse * 0.066667, 1.0); } - color *= texture(u_lightmapTexture, vec2(min(v_lightmap2f.x + diffuse * 0.066667, 1.0), v_lightmap2f.y)); + color *= texture(u_lightmapTexture, vec2(blockLight, v_lightmap2f.y)); output4f = color; } diff --git a/sources/resources/assets/eagler/glsl/dynamiclights/core_dynamiclights.fsh b/sources/resources/assets/eagler/glsl/dynamiclights/core_dynamiclights.fsh index aeaebf5..aa3bc51 100644 --- a/sources/resources/assets/eagler/glsl/dynamiclights/core_dynamiclights.fsh +++ b/sources/resources/assets/eagler/glsl/dynamiclights/core_dynamiclights.fsh @@ -152,6 +152,12 @@ void main() { #ifdef COMPILE_ENABLE_LIGHTMAP float diffuse = 0.0; +#ifdef COMPILE_LIGHTMAP_ATTRIB + float blockLight = v_lightmap2f.x; +#else + float blockLight = u_textureCoords02.x; +#endif + float len; vec4 light; if(u_dynamicLightCount1i > 0) { vec4 worldPosition4f = u_inverseViewMatrix4f * v_position4f; @@ -161,13 +167,15 @@ void main() { for(int i = 0; i < safeLightCount; ++i) { light = u_dynamicLightArray[i]; light.xyz = light.xyz - worldPosition4f.xyz; - diffuse += max(dot(normalize(light.xyz), normalVector3f) * 0.8 + 0.2, 0.0) * max(light.w - sqrt(dot(light.xyz, light.xyz)), 0.0); + len = length(light.xyz); + diffuse += max(dot(light.xyz / len, normalVector3f) * 0.8 + 0.2, 0.0) * max(light.w - len, 0.0); } + blockLight = min(blockLight + diffuse * 0.066667, 1.0); } #ifdef COMPILE_LIGHTMAP_ATTRIB - color *= texture(u_samplerLightmap, vec2(min(v_lightmap2f.x + diffuse * 0.066667, 1.0), v_lightmap2f.y)); + color *= texture(u_samplerLightmap, vec2(blockLight, v_lightmap2f.y)); #else - color *= texture(u_samplerLightmap, vec2(min(u_textureCoords02.x + diffuse * 0.066667, 1.0), u_textureCoords02.y)); + color *= texture(u_samplerLightmap, vec2(blockLight, u_textureCoords02.y)); #endif #endif diff --git a/sources/resources/assets/minecraft/textures/gui/title/background/enable_blur.txt b/sources/resources/assets/minecraft/textures/gui/title/background/enable_blur.txt new file mode 100644 index 0000000..3fd898d --- /dev/null +++ b/sources/resources/assets/minecraft/textures/gui/title/background/enable_blur.txt @@ -0,0 +1,2 @@ +# Change to 0 to disable blur +enable_blur=1 \ No newline at end of file diff --git a/sources/resources/plugin_download.zip b/sources/resources/plugin_download.zip index a1e55c8..391713a 100644 Binary files a/sources/resources/plugin_download.zip and b/sources/resources/plugin_download.zip differ diff --git a/sources/resources/plugin_version.json b/sources/resources/plugin_version.json index 94ea04e..fc71aa9 100644 --- a/sources/resources/plugin_version.json +++ b/sources/resources/plugin_version.json @@ -1 +1 @@ -{"pluginName":"EaglercraftXBungee","pluginVersion":"1.2.5","pluginButton":"Download \"EaglerXBungee-1.2.5.jar\"","pluginFilename":"EaglerXBungee.zip"} \ No newline at end of file +{"pluginName":"EaglercraftXBungee","pluginVersion":"1.2.6","pluginButton":"Download \"EaglerXBungee-1.2.6.jar\"","pluginFilename":"EaglerXBungee.zip"} \ No newline at end of file diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformApplication.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformApplication.java index 073fa6a..14da64d 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformApplication.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformApplication.java @@ -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() { diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformAssets.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformAssets.java index 0e2d783..678d99d 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformAssets.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformAssets.java @@ -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() { diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformAudio.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformAudio.java index c110a3a..4fcedd5 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformAudio.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformAudio.java @@ -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); diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformNetworking.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformNetworking.java index 17c32c3..3dccd21 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformNetworking.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformNetworking.java @@ -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)); } } diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformRuntime.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformRuntime.java index 8c1e5b8..a1f2a98 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformRuntime.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformRuntime.java @@ -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 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 cb) { diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformUpdateSvc.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformUpdateSvc.java index 7a1dcc0..c1b7a0e 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformUpdateSvc.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformUpdateSvc.java @@ -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() { diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformWebRTC.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformWebRTC.java index 234fc68..06624f1 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformWebRTC.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformWebRTC.java @@ -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) 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) 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 relayQueryLimited = new HashMap<>(); private static final Map 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) { diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMClientConfigAdapter.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMClientConfigAdapter.java index a679dde..7078eae 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMClientConfigAdapter.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMClientConfigAdapter.java @@ -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); diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMServerQuery.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMServerQuery.java index adeb7ab..550078c 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMServerQuery.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMServerQuery.java @@ -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)); } } diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMUpdateThread.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMUpdateThread.java index 1d071a5..862d068 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMUpdateThread.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMUpdateThread.java @@ -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); diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMUtils.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMUtils.java index 0a8edf7..a135a90 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMUtils.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMUtils.java @@ -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); diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRoot.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRoot.java index a2be173..467f9c6 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRoot.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRoot.java @@ -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); + } diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/sp/internal/ClientPlatformSingleplayer.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/sp/internal/ClientPlatformSingleplayer.java index d05992b..afbb05d 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/sp/internal/ClientPlatformSingleplayer.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/sp/internal/ClientPlatformSingleplayer.java @@ -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) { diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/sp/server/internal/ServerPlatformSingleplayer.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/sp/server/internal/ServerPlatformSingleplayer.java index 08fc37a..52dab9f 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/sp/server/internal/ServerPlatformSingleplayer.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/sp/server/internal/ServerPlatformSingleplayer.java @@ -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 recieveAllPacket() {