Update #35 - Fixes, improved dynamic lighting

This commit is contained in:
lax1dude 2024-06-16 16:47:12 -07:00
parent ad3579659d
commit 77c6c217f4
42 changed files with 385 additions and 172 deletions

View File

@ -23,14 +23,14 @@
### To compile the latest version of the client, on Windows: ### 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 2. Download (clone) this repository to your computer
3. Double click `CompileLatestClient.bat`, a GUI resembling a classic windows installer should open 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 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: ### 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 2. Download (clone) this repository to your computer
3. Open a terminal in the folder the repository was cloned to 3. Open a terminal in the folder the repository was cloned to
4. Type `chmod +x CompileLatestClient.sh` and hit enter 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`. 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 ## 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. 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 - `allowVoiceClient:` can be used to disable the voice chat feature
- `allowFNAWSkins:` can be used to disable the high poly FNAW skins - `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"`) - `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 - `hooks:` can be used to define JavaScript callbacks for certain events
* `localStorageSaved:` JavaScript callback to save local storage keys * `localStorageSaved:` JavaScript callback to save local storage keys
* `localStorageLoaded:` JavaScript callback to load local storage keys * `localStorageLoaded:` JavaScript callback to load local storage keys

View File

@ -1 +1 @@
u34 u35

View File

@ -357,9 +357,10 @@
~ logger.info("Caught error stitching, removing all assigned resourcepacks"); ~ logger.info("Caught error stitching, removing all assigned resourcepacks");
~ logger.info(runtimeexception); ~ logger.info(runtimeexception);
> INSERT 9 : 11 @ 9 > INSERT 9 : 12 @ 9
+ ShaderSource.clearCache(); + ShaderSource.clearCache();
+ GuiMainMenu.doResourceReloadHack();
+ +
> CHANGE 7 : 10 @ 7 : 19 > CHANGE 7 : 10 @ 7 : 19

View File

@ -7,7 +7,9 @@
> DELETE 2 @ 2 : 3 > DELETE 2 @ 2 : 3
> DELETE 3 @ 3 : 4 > CHANGE 3 : 4 @ 3 : 4
~ import java.nio.charset.StandardCharsets;
> INSERT 1 : 2 @ 1 > INSERT 1 : 2 @ 1
@ -17,6 +19,7 @@
~ ~
~ import net.lax1dude.eaglercraft.v1_8.EagRuntime; ~ 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.EaglerInputStream;
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; ~ import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftVersion; ~ import net.lax1dude.eaglercraft.v1_8.EaglercraftVersion;
@ -25,7 +28,6 @@
~ import com.google.common.base.Charsets; ~ import com.google.common.base.Charsets;
~ import com.google.common.collect.Lists; ~ 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.crypto.SHA1Digest;
~ import net.lax1dude.eaglercraft.v1_8.internal.EnumCursorType; ~ import net.lax1dude.eaglercraft.v1_8.internal.EnumCursorType;
~ import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; ~ import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
@ -61,12 +63,10 @@
~ private static final EaglercraftRandom RANDOM = new EaglercraftRandom(); ~ private static final EaglercraftRandom RANDOM = new EaglercraftRandom();
> INSERT 1 : 7 @ 1 > INSERT 1 : 5 @ 1
+ private boolean isDefault; + private boolean isDefault;
+ private static final int lendef = 5987; + 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, + 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 }; + -69, -107, 113, -93, -101, -79, 32 };
@ -78,58 +78,105 @@
> DELETE 2 @ 2 : 3 > 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"); + private static final ResourceLocation eaglerGuiTextures = new ResourceLocation("eagler:gui/eagler_gui.png");
> DELETE 7 @ 7 : 9 > DELETE 7 @ 7 : 9
> CHANGE 6 : 9 @ 6 : 8 > CHANGE 6 : 11 @ 6 : 8
~ private static ResourceLocation backgroundTexture = null; ~ private static ResourceLocation backgroundTexture = null;
~ private GuiUpdateCheckerOverlay updateCheckerOverlay; ~ private GuiUpdateCheckerOverlay updateCheckerOverlay;
~ private GuiButton downloadOfflineButton; ~ 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 > INSERT 1 : 2 @ 1
+ updateCheckerOverlay = new GuiUpdateCheckerOverlay(false, this); + 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()) { > INSERT 2 : 21 @ 2
+ this.isDefault = false;
+ } else { + this.enableBlur = true;
+ MD5Digest md5 = new MD5Digest(); +
+ SHA1Digest sha1 = new SHA1Digest();
+ byte[] md5out = new byte[16];
+ byte[] sha1out = new byte[20];
+ try { + try {
+ byte[] bytes = EaglerInputStream.inputStreamToBytesQuiet(Minecraft.getMinecraft().getResourceManager() + byte[] bytes = EaglerInputStream.inputStreamToBytesQuiet(
+ .getResource(minecraftTitleTextures).getInputStream()); + Minecraft.getMinecraft().getResourceManager().getResource(minecraftTitleBlurFlag).getInputStream());
+ if (bytes != null) { + if (bytes != null) {
+ md5.update(bytes, 0, bytes.length); + String[] blurCfg = EagUtils.linesArray(new String(bytes, StandardCharsets.UTF_8));
+ sha1.update(bytes, 0, bytes.length); + for (int i = 0; i < blurCfg.length; ++i) {
+ md5.doFinal(md5out, 0); + String s = blurCfg[i];
+ sha1.doFinal(sha1out, 0); + if (s.startsWith("enable_blur=")) {
+ this.isDefault = bytes.length == lendef && Arrays.equals(md5out, md5def) + s = s.substring(12).trim();
+ && Arrays.equals(sha1out, sha1def); + this.enableBlur = s.equals("1") || s.equals("true");
+ } else { + break;
+ this.isDefault = false; + }
+ }
+ } + }
+ } catch (IOException e) { + } catch (IOException e) {
+ this.isDefault = false; + ;
+ }
+ } + }
> 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) { + if (downloadOfflineButton != null) {
+ downloadOfflineButton.enabled = !UpdateService.shouldDisableDownloadButton(); + downloadOfflineButton.enabled = !UpdateService.shouldDisableDownloadButton();
+ } + }
+ if (shouldReload) {
+ reloadResourceFlags();
+ shouldReload = false;
+ }
> CHANGE 6 : 7 @ 6 : 7 > CHANGE 6 : 7 @ 6 : 7
@ -256,11 +303,25 @@
> DELETE 1 @ 1 : 2 > DELETE 1 @ 1 : 2
> CHANGE 8 : 9 @ 8 : 9 > CHANGE 8 : 13 @ 8 : 9
~ if (enableBlur) {
~ GlStateManager.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F); ~ 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); ~ this.mc.getTextureManager().bindTexture(backgroundTexture);
~ EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); ~ EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@ -271,11 +332,23 @@
> DELETE 9 @ 9 : 10 > 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 > CHANGE 4 : 5 @ 4 : 5

View File

@ -84,7 +84,7 @@
+ public static final ServerResourceMode[] _VALUES = values(); + public static final ServerResourceMode[] _VALUES = values();
+ +
> INSERT 10 : 76 @ 10 > INSERT 10 : 81 @ 10
+ +
+ public void setMOTDFromQuery(QueryResponse pkt) { + public void setMOTDFromQuery(QueryResponse pkt) {
@ -95,7 +95,12 @@
+ this.serverMOTD = motd.length() > 0 + this.serverMOTD = motd.length() > 0
+ ? (motd.length() > 1 ? motd.getString(0) + "\n" + motd.getString(1) : motd.getString(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; + this.playerList = null;
+ JSONArray players = motdData.optJSONArray("players"); + JSONArray players = motdData.optJSONArray("players");
+ if (players.length() > 0) { + if (players.length() > 0) {

View File

@ -142,6 +142,11 @@ public class DesktopClientConfigAdapter implements IClientConfigAdapter {
return EaglercraftVersion.localStorageNamespace; return EaglercraftVersion.localStorageNamespace;
} }
@Override
public boolean isEnableMinceraft() {
return true;
}
@Override @Override
public IClientConfigAdapterHooks getHooks() { public IClientConfigAdapterHooks getHooks() {
return hooks; return hooks;

View File

@ -121,6 +121,7 @@ public class EaglerInputStream extends InputStream {
} }
public static byte[] inputStreamToBytes(InputStream is) throws IOException { public static byte[] inputStreamToBytes(InputStream is) throws IOException {
try {
if (is instanceof EaglerInputStream) { if (is instanceof EaglerInputStream) {
return ((EaglerInputStream) is).getAsArray(); return ((EaglerInputStream) is).getAsArray();
} else if (is instanceof ByteArrayInputStream) { } else if (is instanceof ByteArrayInputStream) {
@ -136,6 +137,9 @@ public class EaglerInputStream extends InputStream {
} }
return os.toByteArray(); return os.toByteArray();
} }
}finally {
is.close();
}
} }
public byte[] getAsArray() { public byte[] getAsArray() {

View File

@ -10,7 +10,7 @@ public class EaglercraftVersion {
/// Customize these to fit your fork: /// Customize these to fit your fork:
public static final String projectForkName = "EaglercraftX"; 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 projectForkVendor = "lax1dude";
public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; 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 projectOriginName = "EaglercraftX";
public static final String projectOriginAuthor = "lax1dude"; public static final String projectOriginAuthor = "lax1dude";
public static final String projectOriginRevision = "1.8"; 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 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 boolean enableUpdateService = true;
public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client"; 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; public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName;

View File

@ -74,6 +74,8 @@ public interface IClientConfigAdapter {
String getLocalStorageNamespace(); String getLocalStorageNamespace();
boolean isEnableMinceraft();
IClientConfigAdapterHooks getHooks(); IClientConfigAdapterHooks getHooks();
} }

View File

@ -66,7 +66,6 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.ExtGLEnums.*;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;

View File

@ -3,6 +3,7 @@ package net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.texture;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import net.lax1dude.eaglercraft.v1_8.IOUtils;
import net.lax1dude.eaglercraft.v1_8.opengl.ImageData; import net.lax1dude.eaglercraft.v1_8.opengl.ImageData;
/** /**
@ -75,4 +76,15 @@ public class EaglerBitwisePackedTexture {
return img; 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;
}
} }

View File

@ -73,7 +73,7 @@ public class PBRTextureMapUtils {
}catch(Throwable t) { }catch(Throwable t) {
} }
try { 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) { }catch(Throwable t) {
// dead code because teavm // dead code because teavm
t.toString(); t.toString();

View File

@ -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.RealOpenGLEnums.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.ExtGLEnums.*; import static net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.ExtGLEnums.*;
import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;

View File

@ -17,30 +17,21 @@ package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights;
*/ */
class DynamicLightInstance { class DynamicLightInstance {
public final String lightName;
long lastCacheHit = 0l;
double posX; double posX;
double posY; double posY;
double posZ; double posZ;
float radius; float radius;
public DynamicLightInstance(String lightName) { public DynamicLightInstance() {
this.lightName = lightName;
} }
public void updateLight(double posX, double posY, double posZ, float radius) { public void updateLight(double posX, double posY, double posZ, float radius) {
this.lastCacheHit = System.currentTimeMillis();
this.posX = posX; this.posX = posX;
this.posY = posY; this.posY = posY;
this.posZ = posZ; this.posZ = posZ;
this.radius = radius; this.radius = radius;
} }
public void destroy() {
}
public float getRadiusInWorld() { public float getRadiusInWorld() {
return radius; return radius;
} }

View File

@ -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.IExtPipelineCompiler;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.ShaderSource; 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.opengl.ext.dynamiclights.program.DynamicLightsExtPipelineShader;
import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f;
import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.GLAllocation;
/** /**

View File

@ -1,10 +1,9 @@
package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights; package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights;
import java.util.HashMap; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
import net.lax1dude.eaglercraft.v1_8.opengl.FixedFunctionPipeline; import net.lax1dude.eaglercraft.v1_8.opengl.FixedFunctionPipeline;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
@ -31,14 +30,15 @@ import net.minecraft.util.MathHelper;
public class DynamicLightsStateManager { public class DynamicLightsStateManager {
static final DynamicLightsPipelineCompiler deferredExtPipeline = new DynamicLightsPipelineCompiler(); static final DynamicLightsPipelineCompiler deferredExtPipeline = new DynamicLightsPipelineCompiler();
static final Map<String, DynamicLightInstance> lightRenderers = new HashMap(); private static List<DynamicLightInstance> lightInstancePool = new ArrayList();
private static int instancePoolIndex = 0;
private static int maxListLengthTracker = 0;
static final List<DynamicLightInstance> lightRenderList = new LinkedList(); static final List<DynamicLightInstance> lightRenderList = new LinkedList();
static final Matrix4f inverseViewMatrix = new Matrix4f(); static final Matrix4f inverseViewMatrix = new Matrix4f();
static int inverseViewMatrixSerial = 0; static int inverseViewMatrixSerial = 0;
static DynamicLightBucketLoader bucketLoader = null; static DynamicLightBucketLoader bucketLoader = null;
static DynamicLightsAcceleratedEffectRenderer accelParticleRenderer = null; static DynamicLightsAcceleratedEffectRenderer accelParticleRenderer = null;
static int lastTotal = 0; static int lastTotal = 0;
static long renderTimeout = 5000l;
private static long lastTick = 0l; private static long lastTick = 0l;
public static final void enableDynamicLightsRender() { public static final void enableDynamicLightsRender() {
@ -52,6 +52,9 @@ public class DynamicLightsStateManager {
accelParticleRenderer = new DynamicLightsAcceleratedEffectRenderer(); accelParticleRenderer = new DynamicLightsAcceleratedEffectRenderer();
accelParticleRenderer.initialize(); accelParticleRenderer.initialize();
} }
lightRenderList.clear();
instancePoolIndex = 0;
maxListLengthTracker = 0;
} }
public static final void bindAcceleratedEffectRenderer(EffectRenderer renderer) { public static final void bindAcceleratedEffectRenderer(EffectRenderer renderer) {
@ -72,6 +75,8 @@ public class DynamicLightsStateManager {
} }
destroyAll(); destroyAll();
lightRenderList.clear(); lightRenderList.clear();
instancePoolIndex = 0;
maxListLengthTracker = 0;
} }
public static final boolean isDynamicLightsRender() { 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) { public static final void renderDynamicLight(String lightName, double posX, double posY, double posZ, float radius) {
if(bucketLoader != null) { if(bucketLoader != null) {
DynamicLightInstance dl = lightRenderers.get(lightName); DynamicLightInstance dl;
if(dl == null) { if(instancePoolIndex < lightInstancePool.size()) {
lightRenderers.put(lightName, dl = new DynamicLightInstance(lightName)); dl = lightInstancePool.get(instancePoolIndex);
}else {
lightInstancePool.add(dl = new DynamicLightInstance());
} }
++instancePoolIndex;
dl.updateLight(posX, posY, posZ, radius); dl.updateLight(posX, posY, posZ, radius);
lightRenderList.add(dl); lightRenderList.add(dl);
} }
} }
public static final void clearRenderList() { public static final void clearRenderList() {
if(instancePoolIndex > maxListLengthTracker) {
maxListLengthTracker = instancePoolIndex;
}
lightRenderList.clear(); lightRenderList.clear();
instancePoolIndex = 0;
} }
public static final void commitLightSourceBuckets(double renderPosX, double renderPosY, double renderPosZ) { public static final void commitLightSourceBuckets(double renderPosX, double renderPosY, double renderPosZ) {
updateTimers();
lastTotal = lightRenderList.size(); lastTotal = lightRenderList.size();
if(bucketLoader != null) { if(bucketLoader != null) {
bucketLoader.clearBuckets(); bucketLoader.clearBuckets();
@ -131,7 +142,8 @@ public class DynamicLightsStateManager {
bucketLoader.setRenderPos(renderPosX, renderPosY, renderPosZ); bucketLoader.setRenderPos(renderPosX, renderPosY, renderPosZ);
bucketLoader.truncateOverflowingBuffers(); bucketLoader.truncateOverflowingBuffers();
} }
lightRenderList.clear(); updateTimers();
clearRenderList();
} }
public static final void setupInverseViewMatrix() { public static final void setupInverseViewMatrix() {
@ -141,25 +153,21 @@ public class DynamicLightsStateManager {
private static final void updateTimers() { private static final void updateTimers() {
long millis = System.currentTimeMillis(); long millis = System.currentTimeMillis();
if(millis - lastTick > 1000l) { if(millis - lastTick > 5000l) {
lastTick = millis; lastTick = millis;
Iterator<DynamicLightInstance> itr = lightRenderers.values().iterator(); if(maxListLengthTracker < (lightInstancePool.size() >> 1)) {
while(itr.hasNext()) { List<DynamicLightInstance> newPool = new ArrayList(Math.max(maxListLengthTracker, 16));
DynamicLightInstance dl = itr.next(); for(int i = 0; i < maxListLengthTracker; ++i) {
if(millis - dl.lastCacheHit > renderTimeout) { newPool.add(lightInstancePool.get(i));
dl.destroy();
itr.remove();
} }
lightInstancePool = newPool;
} }
maxListLengthTracker = 0;
} }
} }
public static final void destroyAll() { public static final void destroyAll() {
Iterator<DynamicLightInstance> itr = lightRenderers.values().iterator(); lightInstancePool = new ArrayList();
while(itr.hasNext()) {
itr.next().destroy();
}
lightRenderers.clear();
} }
public static String getF3String() { public static String getF3String() {

View File

@ -1,11 +1,7 @@
package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.program; 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.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.GL_FRAGMENT_SHADER; import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.GL_VERTEX_SHADER;
import java.util.ArrayList;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL; import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL; import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL;

View File

@ -170,7 +170,7 @@ void main() {
#ifdef COMPILE_ENABLE_FOG #ifdef COMPILE_ENABLE_FOG
vec3 fogPos = v_position4f.xyz / v_position4f.w; vec3 fogPos = v_position4f.xyz / v_position4f.w;
float dist = sqrt(dot(fogPos, fogPos)); float dist = length(fogPos);
float fogDensity = u_fogParameters4f.y; float fogDensity = u_fogParameters4f.y;
float fogStart = u_fogParameters4f.z; float fogStart = u_fogParameters4f.z;
float fogEnd = u_fogParameters4f.w; float fogEnd = u_fogParameters4f.w;

View File

@ -69,7 +69,7 @@ void main() {
fragPos4f.xyz /= fragPos4f.w; fragPos4f.xyz /= fragPos4f.w;
fragPos4f.w = 1.0; fragPos4f.w = 1.0;
float l = sqrt(dot(fragPos4f.xyz, fragPos4f.xyz)); float l = length(fragPos4f.xyz);
#ifdef COMPILE_FOG_LINEAR #ifdef COMPILE_FOG_LINEAR
float f = (l - u_linearFogParam2f.x) / (u_linearFogParam2f.y - u_linearFogParam2f.x); float f = (l - u_linearFogParam2f.x) / (u_linearFogParam2f.y - u_linearFogParam2f.x);
#else #else

View File

@ -431,7 +431,7 @@ void main() {
float type = u_fogParameters4f.x - atmos; float type = u_fogParameters4f.x - atmos;
fogBlend4f = mix(u_fogColorLight4f, u_fogColorDark4f, lightmapCoords2f.g); 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) { if(type == 1.0) {
f = (l - u_fogParameters4f.z) / (u_fogParameters4f.w - u_fogParameters4f.z); f = (l - u_fogParameters4f.z) / (u_fogParameters4f.w - u_fogParameters4f.z);
}else { }else {

View File

@ -292,7 +292,7 @@ void main() {
fogFade = mix(u_fogColorDark4f.a, u_fogColorLight4f.a, lightmapCoords2f.g); fogFade = mix(u_fogColorDark4f.a, u_fogColorLight4f.a, lightmapCoords2f.g);
float f; float f;
float l = sqrt(dot(v_position4f.xyz, v_position4f.xyz)); float l = length(v_position4f.xyz);
if(type == 1.0) { if(type == 1.0) {
f = (l - u_fogParameters4f.z) / (u_fogParameters4f.w - u_fogParameters4f.z); f = (l - u_fogParameters4f.z) / (u_fogParameters4f.w - u_fogParameters4f.z);
}else { }else {

View File

@ -397,7 +397,7 @@ void main() {
float type = u_fogParameters4f.x - atmos; float type = u_fogParameters4f.x - atmos;
fogBlend4f = mix(u_fogColorLight4f, u_fogColorDark4f, lightmapCoords2f.g); 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) { if(type == 1.0) {
f = (l - u_fogParameters4f.z) / (u_fogParameters4f.w - u_fogParameters4f.z); f = (l - u_fogParameters4f.z) / (u_fogParameters4f.w - u_fogParameters4f.z);
}else { }else {

View File

@ -1,7 +1,7 @@
{ {
"name": "§eHigh Performance PBR", "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", "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", "author": "lax1dude",
"api_vers": 1, "api_vers": 1,
"features": [ "features": [

View File

@ -48,7 +48,9 @@ void main() {
} }
vec4 light; vec4 light;
float blockLight = v_lightmap2f.x;
float diffuse = 0.0; float diffuse = 0.0;
float len;
if(u_dynamicLightCount1i > 0) { if(u_dynamicLightCount1i > 0) {
vec4 worldPosition4f = u_inverseViewMatrix4f * v_position4f; vec4 worldPosition4f = u_inverseViewMatrix4f * v_position4f;
worldPosition4f.xyz /= worldPosition4f.w; worldPosition4f.xyz /= worldPosition4f.w;
@ -57,11 +59,13 @@ void main() {
for(int i = 0; i < safeLightCount; ++i) { for(int i = 0; i < safeLightCount; ++i) {
light = u_dynamicLightArray[i]; light = u_dynamicLightArray[i];
light.xyz = light.xyz - worldPosition4f.xyz; 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; output4f = color;
} }

View File

@ -152,6 +152,12 @@ void main() {
#ifdef COMPILE_ENABLE_LIGHTMAP #ifdef COMPILE_ENABLE_LIGHTMAP
float diffuse = 0.0; float diffuse = 0.0;
#ifdef COMPILE_LIGHTMAP_ATTRIB
float blockLight = v_lightmap2f.x;
#else
float blockLight = u_textureCoords02.x;
#endif
float len;
vec4 light; vec4 light;
if(u_dynamicLightCount1i > 0) { if(u_dynamicLightCount1i > 0) {
vec4 worldPosition4f = u_inverseViewMatrix4f * v_position4f; vec4 worldPosition4f = u_inverseViewMatrix4f * v_position4f;
@ -161,13 +167,15 @@ void main() {
for(int i = 0; i < safeLightCount; ++i) { for(int i = 0; i < safeLightCount; ++i) {
light = u_dynamicLightArray[i]; light = u_dynamicLightArray[i];
light.xyz = light.xyz - worldPosition4f.xyz; 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 #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 #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
#endif #endif

View File

@ -0,0 +1,2 @@
# Change to 0 to disable blur
enable_blur=1

View File

@ -1 +1 @@
{"pluginName":"EaglercraftXBungee","pluginVersion":"1.2.5","pluginButton":"Download \"EaglerXBungee-1.2.5.jar\"","pluginFilename":"EaglerXBungee.zip"} {"pluginName":"EaglercraftXBungee","pluginVersion":"1.2.6","pluginButton":"Download \"EaglerXBungee-1.2.6.jar\"","pluginFilename":"EaglerXBungee.zip"}

View File

@ -19,7 +19,6 @@ import org.teavm.jso.dom.html.HTMLCanvasElement;
import org.teavm.jso.dom.html.HTMLDocument; import org.teavm.jso.dom.html.HTMLDocument;
import org.teavm.jso.dom.html.HTMLInputElement; import org.teavm.jso.dom.html.HTMLInputElement;
import org.teavm.jso.typedarrays.ArrayBuffer; 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.Base64;
import net.lax1dude.eaglercraft.v1_8.EagRuntime; import net.lax1dude.eaglercraft.v1_8.EagRuntime;
@ -200,7 +199,7 @@ public class PlatformApplication {
if(name == null) { if(name == null) {
fileChooserResultObject = null; fileChooserResultObject = null;
}else { }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); private static final native void downloadBytesImpl(String str, ArrayBuffer buf);
public static final void downloadFileWithName(String str, byte[] dat) { public static final void downloadFileWithName(String str, byte[] dat) {
downloadBytesImpl(str, TeaVMUtils.unwrapUnsignedByteArray(dat).getBuffer()); downloadBytesImpl(str, TeaVMUtils.unwrapArrayBuffer(dat));
} }
public static void showDebugConsole() { public static void showDebugConsole() {

View File

@ -16,7 +16,6 @@ import org.teavm.jso.dom.html.HTMLCanvasElement;
import org.teavm.jso.dom.html.HTMLImageElement; import org.teavm.jso.dom.html.HTMLImageElement;
import org.teavm.jso.dom.xml.Document; import org.teavm.jso.dom.xml.Document;
import org.teavm.jso.typedarrays.ArrayBuffer; import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Int32Array;
import org.teavm.jso.typedarrays.Uint8ClampedArray; import org.teavm.jso.typedarrays.Uint8ClampedArray;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream; import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
@ -54,7 +53,7 @@ public class PlatformAssets {
ArrayBuffer file = PlatformRuntime.downloadRemoteURI( ArrayBuffer file = PlatformRuntime.downloadRemoteURI(
ClientMain.configLocalesFolder + "/" + path.substring(22)); ClientMain.configLocalesFolder + "/" + path.substring(22));
if(file != null && file.getByteLength() > 0) { if(file != null && file.getByteLength() > 0) {
data = TeaVMUtils.arrayBufferToBytes(file); data = TeaVMUtils.wrapByteArrayBuffer(file);
assets.put(path, data); assets.put(path, data);
return data; return data;
}else { }else {
@ -79,12 +78,15 @@ public class PlatformAssets {
private static CanvasRenderingContext2D imageLoadContext = null; private static CanvasRenderingContext2D imageLoadContext = null;
public static ImageData loadImageFile(byte[] data) { public static ImageData loadImageFile(byte[] data) {
return loadImageFile(TeaVMUtils.unwrapUnsignedByteArray(data).getBuffer()); return loadImageFile(TeaVMUtils.unwrapArrayBuffer(data));
} }
@JSBody(params = { }, script = "return { willReadFrequently: true };") @JSBody(params = { }, script = "return { willReadFrequently: true };")
public static native JSObject youEagler(); public static native JSObject youEagler();
@JSBody(params = { "ctx" }, script = "ctx.imageSmoothingEnabled = false;")
private static native void disableImageSmoothing(CanvasRenderingContext2D ctx);
@Async @Async
private static native ImageData loadImageFile(ArrayBuffer data); private static native ImageData loadImageFile(ArrayBuffer data);
@ -105,6 +107,7 @@ public class PlatformAssets {
} }
if(imageLoadContext == null) { if(imageLoadContext == null) {
imageLoadContext = (CanvasRenderingContext2D) imageLoadCanvas.getContext("2d", youEagler()); imageLoadContext = (CanvasRenderingContext2D) imageLoadCanvas.getContext("2d", youEagler());
disableImageSmoothing(imageLoadContext);
} }
imageLoadContext.clearRect(0, 0, toLoad.getWidth(), toLoad.getHeight()); imageLoadContext.clearRect(0, 0, toLoad.getWidth(), toLoad.getHeight());
imageLoadContext.drawImage(toLoad, 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); ret.complete(null);
return; 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>() { toLoad.addEventListener("error", new EventListener<Event>() {

View File

@ -214,7 +214,7 @@ public class PlatformAudio {
if(buffer == null) { if(buffer == null) {
byte[] file = PlatformAssets.getResourceBytes(filename); byte[] file = PlatformAssets.getResourceBytes(filename);
if(file == null) return null; if(file == null) return null;
buffer = new BrowserAudioResource(decodeAudioAsync(TeaVMUtils.unwrapUnsignedByteArray(file).getBuffer(), filename)); buffer = new BrowserAudioResource(decodeAudioAsync(TeaVMUtils.unwrapArrayBuffer(file), filename));
if(holdInCache) { if(holdInCache) {
synchronized(soundCache) { synchronized(soundCache) {
soundCache.put(filename, buffer); soundCache.put(filename, buffer);

View File

@ -12,7 +12,6 @@ import org.teavm.jso.dom.events.Event;
import org.teavm.jso.dom.events.EventListener; import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.dom.events.MessageEvent; import org.teavm.jso.dom.events.MessageEvent;
import org.teavm.jso.typedarrays.ArrayBuffer; import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import org.teavm.jso.websocket.WebSocket; import org.teavm.jso.websocket.WebSocket;
import net.lax1dude.eaglercraft.v1_8.internal.teavm.TeaVMServerQuery; import net.lax1dude.eaglercraft.v1_8.internal.teavm.TeaVMServerQuery;
@ -120,7 +119,7 @@ public class PlatformNetworking {
} }
}else { }else {
synchronized(readPackets) { 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) { public static void writePlayPacket(byte[] pkt) {
if(sock != null && !sockIsConnecting) { if(sock != null && !sockIsConnecting) {
nativeBinarySend(sock, TeaVMUtils.unwrapUnsignedByteArray(pkt).getBuffer()); nativeBinarySend(sock, TeaVMUtils.unwrapArrayBuffer(pkt));
} }
} }

View File

@ -29,7 +29,6 @@ import org.teavm.jso.dom.html.HTMLCanvasElement;
import org.teavm.jso.dom.html.HTMLDocument; import org.teavm.jso.dom.html.HTMLDocument;
import org.teavm.jso.dom.html.HTMLElement; import org.teavm.jso.dom.html.HTMLElement;
import org.teavm.jso.typedarrays.ArrayBuffer; import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import org.teavm.jso.webaudio.MediaStream; import org.teavm.jso.webaudio.MediaStream;
import org.teavm.jso.webgl.WebGLFramebuffer; import org.teavm.jso.webgl.WebGLFramebuffer;
@ -311,7 +310,7 @@ public class PlatformRuntime {
} }
public static void downloadRemoteURIByteArray(String assetPackageURI, final Consumer<byte[]> cb) { 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) { public static void downloadRemoteURI(String assetPackageURI, final Consumer<ArrayBuffer> cb) {

View File

@ -2,7 +2,6 @@ package net.lax1dude.eaglercraft.v1_8.internal;
import org.teavm.jso.JSBody; import org.teavm.jso.JSBody;
import org.teavm.jso.typedarrays.ArrayBuffer; 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.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.teavm.TeaVMUpdateThread; 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!"); logger.error("Failed to download client bundle or signature URL!");
return null; return null;
} }
return TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(buf)); return TeaVMUtils.wrapByteArrayBuffer(buf);
} }
public static byte[] getClientSignatureData() { public static byte[] getClientSignatureData() {

View File

@ -24,7 +24,6 @@ import org.teavm.jso.dom.events.Event;
import org.teavm.jso.dom.events.EventListener; import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.json.JSON; import org.teavm.jso.json.JSON;
import org.teavm.jso.typedarrays.ArrayBuffer; import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import org.teavm.jso.websocket.WebSocket; import org.teavm.jso.websocket.WebSocket;
import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.LinkedListMultimap;
@ -211,7 +210,7 @@ public class PlatformWebRTC {
TeaVMUtils.addEventListener(dataChannel, "message", (EventListener<Event>) evt -> { TeaVMUtils.addEventListener(dataChannel, "message", (EventListener<Event>) evt -> {
synchronized(clientLANPacketBuffer) { 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)); serverLANEventBuffer.put(peerId, new LANPeerEvent.LANPeerDataChannelEvent(peerId));
} }
TeaVMUtils.addEventListener(dataChannel, "message", (EventListener<Event>) evt2 -> { 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) { synchronized(serverLANEventBuffer) {
serverLANEventBuffer.put(peerId, e); serverLANEventBuffer.put(peerId, e);
} }
@ -538,10 +537,6 @@ public class PlatformWebRTC {
@JSBody(params = { "obj" }, script = "return typeof obj === \"string\";") @JSBody(params = { "obj" }, script = "return typeof obj === \"string\";")
private static native boolean isString(JSObject obj); 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> relayQueryLimited = new HashMap<>();
private static final Map<String,Long> relayQueryBlocked = new HashMap<>(); private static final Map<String,Long> relayQueryBlocked = new HashMap<>();
@ -587,7 +582,7 @@ public class PlatformWebRTC {
sock.onOpen(evt -> { sock.onOpen(evt -> {
try { try {
connectionPingStart = System.currentTimeMillis(); connectionPingStart = System.currentTimeMillis();
PlatformNetworking.nativeBinarySend(sock, convertToArrayBuffer( PlatformNetworking.nativeBinarySend(sock, TeaVMUtils.unwrapArrayBuffer(
IPacket.writePacket(new IPacket00Handshake(0x03, RelayManager.preferredRelayVersion, "")) IPacket.writePacket(new IPacket00Handshake(0x03, RelayManager.preferredRelayVersion, ""))
)); ));
} catch (IOException e) { } catch (IOException e) {
@ -599,7 +594,7 @@ public class PlatformWebRTC {
sock.onMessage(evt -> { sock.onMessage(evt -> {
if(evt.getData() != null && !isString(evt.getData())) { if(evt.getData() != null && !isString(evt.getData())) {
hasRecievedAnyData = true; hasRecievedAnyData = true;
byte[] arr = TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(evt.getDataAsArray())); byte[] arr = TeaVMUtils.wrapByteArrayBuffer(evt.getDataAsArray());
if(arr.length == 2 && arr[0] == (byte)0xFC) { if(arr.length == 2 && arr[0] == (byte)0xFC) {
long millis = System.currentTimeMillis(); long millis = System.currentTimeMillis();
if(arr[1] == (byte)0x00 || arr[1] == (byte)0x01) { if(arr[1] == (byte)0x00 || arr[1] == (byte)0x01) {
@ -842,7 +837,7 @@ public class PlatformWebRTC {
sock = s; sock = s;
sock.onOpen(evt -> { sock.onOpen(evt -> {
try { try {
PlatformNetworking.nativeBinarySend(sock, convertToArrayBuffer( PlatformNetworking.nativeBinarySend(sock, TeaVMUtils.unwrapArrayBuffer(
IPacket.writePacket(new IPacket00Handshake(0x04, RelayManager.preferredRelayVersion, "")) IPacket.writePacket(new IPacket00Handshake(0x04, RelayManager.preferredRelayVersion, ""))
)); ));
} catch (IOException e) { } catch (IOException e) {
@ -855,7 +850,7 @@ public class PlatformWebRTC {
sock.onMessage(evt -> { sock.onMessage(evt -> {
if(evt.getData() != null && !isString(evt.getData())) { if(evt.getData() != null && !isString(evt.getData())) {
hasRecievedAnyData = true; hasRecievedAnyData = true;
byte[] arr = TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(evt.getDataAsArray())); byte[] arr = TeaVMUtils.wrapByteArrayBuffer(evt.getDataAsArray());
if(arr.length == 2 && arr[0] == (byte)0xFC) { if(arr.length == 2 && arr[0] == (byte)0xFC) {
long millis = System.currentTimeMillis(); long millis = System.currentTimeMillis();
if(arr[1] == (byte)0x00 || arr[1] == (byte)0x01) { if(arr[1] == (byte)0x00 || arr[1] == (byte)0x01) {
@ -1065,7 +1060,7 @@ public class PlatformWebRTC {
if(evt.getData() != null && !isString(evt.getData())) { if(evt.getData() != null && !isString(evt.getData())) {
hasRecievedAnyData = true; hasRecievedAnyData = true;
try { 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) { if(pkt instanceof IPacket70SpecialUpdate) {
IPacket70SpecialUpdate ipkt = (IPacket70SpecialUpdate)pkt; IPacket70SpecialUpdate ipkt = (IPacket70SpecialUpdate)pkt;
if(ipkt.operation == IPacket70SpecialUpdate.OPERATION_UPDATE_CERTIFICATE) { if(ipkt.operation == IPacket70SpecialUpdate.OPERATION_UPDATE_CERTIFICATE) {
@ -1136,7 +1131,7 @@ public class PlatformWebRTC {
@Override @Override
public void writePacket(IPacket pkt) { public void writePacket(IPacket pkt) {
try { try {
PlatformNetworking.nativeBinarySend(sock, convertToArrayBuffer(IPacket.writePacket(pkt))); PlatformNetworking.nativeBinarySend(sock, TeaVMUtils.unwrapArrayBuffer(IPacket.writePacket(pkt)));
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Relay connection error: {}", e.toString()); logger.error("Relay connection error: {}", e.toString());
EagRuntime.debugPrintStackTrace(e); EagRuntime.debugPrintStackTrace(e);
@ -1283,7 +1278,7 @@ public class PlatformWebRTC {
// todo: ArrayBuffer version // todo: ArrayBuffer version
public static void clientLANSendPacket(byte[] pkt) { public static void clientLANSendPacket(byte[] pkt) {
rtcLANClient.sendPacketToServer(convertToArrayBuffer(pkt)); rtcLANClient.sendPacketToServer(TeaVMUtils.unwrapArrayBuffer(pkt));
} }
public static byte[] clientLANReadPacket() { public static byte[] clientLANReadPacket() {
@ -1409,7 +1404,7 @@ public class PlatformWebRTC {
} }
public static void serverLANWritePacket(String peer, byte[] data) { 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) { public static void serverLANCreatePeer(String peer) {

View File

@ -60,6 +60,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
private boolean allowFNAWSkins = true; private boolean allowFNAWSkins = true;
private String localStorageNamespace = "_eaglercraftX"; private String localStorageNamespace = "_eaglercraftX";
private final TeaVMClientConfigAdapterHooks hooks = new TeaVMClientConfigAdapterHooks(); private final TeaVMClientConfigAdapterHooks hooks = new TeaVMClientConfigAdapterHooks();
private boolean enableMinceraft = true;
public void loadNative(JSObject jsObject) { public void loadNative(JSObject jsObject) {
integratedServerOpts = new JSONObject(); integratedServerOpts = new JSONObject();
@ -81,6 +82,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
allowVoiceClient = eaglercraftXOpts.getAllowVoiceClient(true); allowVoiceClient = eaglercraftXOpts.getAllowVoiceClient(true);
allowFNAWSkins = !demoMode && eaglercraftXOpts.getAllowFNAWSkins(true); allowFNAWSkins = !demoMode && eaglercraftXOpts.getAllowFNAWSkins(true);
localStorageNamespace = eaglercraftXOpts.getLocalStorageNamespace(EaglercraftVersion.localStorageNamespace); localStorageNamespace = eaglercraftXOpts.getLocalStorageNamespace(EaglercraftVersion.localStorageNamespace);
enableMinceraft = eaglercraftXOpts.getEnableMinceraft(true);
JSEaglercraftXOptsHooks hooksObj = eaglercraftXOpts.getHooks(); JSEaglercraftXOptsHooks hooksObj = eaglercraftXOpts.getHooks();
if(hooksObj != null) { if(hooksObj != null) {
hooks.loadHooks(hooksObj); hooks.loadHooks(hooksObj);
@ -175,6 +177,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
allowVoiceClient = eaglercraftOpts.optBoolean("allowVoiceClient", true); allowVoiceClient = eaglercraftOpts.optBoolean("allowVoiceClient", true);
allowFNAWSkins = eaglercraftOpts.optBoolean("allowFNAWSkins", true); allowFNAWSkins = eaglercraftOpts.optBoolean("allowFNAWSkins", true);
localStorageNamespace = eaglercraftOpts.optString("localStorageNamespace", EaglercraftVersion.localStorageNamespace); localStorageNamespace = eaglercraftOpts.optString("localStorageNamespace", EaglercraftVersion.localStorageNamespace);
enableMinceraft = eaglercraftOpts.optBoolean("enableMinceraft", true);
JSONArray serversArray = eaglercraftOpts.optJSONArray("servers"); JSONArray serversArray = eaglercraftOpts.optJSONArray("servers");
if(serversArray != null) { if(serversArray != null) {
for(int i = 0, l = serversArray.length(); i < l; ++i) { for(int i = 0, l = serversArray.length(); i < l; ++i) {
@ -332,6 +335,11 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
return localStorageNamespace; return localStorageNamespace;
} }
@Override
public boolean isEnableMinceraft() {
return enableMinceraft;
}
@Override @Override
public IClientConfigAdapterHooks getHooks() { public IClientConfigAdapterHooks getHooks() {
return hooks; return hooks;
@ -357,6 +365,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
jsonObject.put("allowVoiceClient", allowVoiceClient); jsonObject.put("allowVoiceClient", allowVoiceClient);
jsonObject.put("allowFNAWSkins", allowFNAWSkins); jsonObject.put("allowFNAWSkins", allowFNAWSkins);
jsonObject.put("localStorageNamespace", localStorageNamespace); jsonObject.put("localStorageNamespace", localStorageNamespace);
jsonObject.put("enableMinceraft", enableMinceraft);
JSONArray serversArr = new JSONArray(); JSONArray serversArr = new JSONArray();
for(int i = 0, l = defaultServers.size(); i < l; ++i) { for(int i = 0, l = defaultServers.size(); i < l; ++i) {
DefaultServer srv = defaultServers.get(i); DefaultServer srv = defaultServers.get(i);

View File

@ -10,7 +10,6 @@ import org.teavm.jso.dom.events.Event;
import org.teavm.jso.dom.events.EventListener; import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.dom.events.MessageEvent; import org.teavm.jso.dom.events.MessageEvent;
import org.teavm.jso.typedarrays.ArrayBuffer; import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import org.teavm.jso.websocket.WebSocket; import org.teavm.jso.websocket.WebSocket;
import net.lax1dude.eaglercraft.v1_8.internal.EnumServerRateLimit; import net.lax1dude.eaglercraft.v1_8.internal.EnumServerRateLimit;
@ -116,7 +115,7 @@ public class TeaVMServerQuery implements IServerQuery {
} }
}else { }else {
synchronized(queryResponsesBytes) { 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 @Override
public void send(byte[] bytes) { public void send(byte[] bytes) {
if(open) { if(open) {
nativeBinarySend(sock, TeaVMUtils.unwrapByteArray(bytes).getBuffer()); nativeBinarySend(sock, TeaVMUtils.unwrapArrayBuffer(bytes));
} }
} }

View File

@ -16,7 +16,6 @@ import org.teavm.jso.browser.Window;
import org.teavm.jso.dom.events.Event; import org.teavm.jso.dom.events.Event;
import org.teavm.jso.dom.events.EventListener; import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.typedarrays.ArrayBuffer; import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
@ -220,7 +219,7 @@ public class TeaVMUpdateThread implements Runnable {
if(xhr.getStatus() == 200) { if(xhr.getStatus() == 200) {
ArrayBuffer data = (ArrayBuffer)xhr.getResponse(); ArrayBuffer data = (ArrayBuffer)xhr.getResponse();
if(data.getByteLength() == updateCert.bundleDataLength) { if(data.getByteLength() == updateCert.bundleDataLength) {
cb.complete(TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(data))); cb.complete(TeaVMUtils.wrapByteArrayBuffer(data));
}else { }else {
logger.error("Unexpected response length {} (expect: {}) from URL: {}", xhr.getStatus(), xhr.getStatusText(), url); logger.error("Unexpected response length {} (expect: {}) from URL: {}", xhr.getStatus(), xhr.getStatusText(), url);
cb.complete(null); cb.complete(null);

View File

@ -51,89 +51,199 @@ public class TeaVMUtils {
} }
public static Int8Array unwrapByteArray(byte[] buf) { public static Int8Array unwrapByteArray(byte[] buf) {
if(buf == null) {
return null;
}
return Int8Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer()); return Int8Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer());
} }
public static ArrayBuffer unwrapArrayBuffer(byte[] buf) { public static ArrayBuffer unwrapArrayBuffer(byte[] buf) {
if(buf == null) {
return null;
}
return ((TeaVMArrayObject)(Object)buf).getData().getBuffer(); return ((TeaVMArrayObject)(Object)buf).getData().getBuffer();
} }
public static ArrayBufferView unwrapArrayBufferView(byte[] buf) { public static ArrayBufferView unwrapArrayBufferView(byte[] buf) {
if(buf == null) {
return null;
}
return ((TeaVMArrayObject)(Object)buf).getData(); 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); private static native JSObject wrapByteArray0(JSObject buf);
public static byte[] wrapByteArray(Int8Array 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); 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) { public static Uint8Array unwrapUnsignedByteArray(byte[] buf) {
if(buf == null) {
return null;
}
return Uint8Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer()); return Uint8Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer());
} }
public static byte[] wrapUnsignedByteArray(Uint8Array buf) { 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) { public static Int32Array unwrapIntArray(int[] buf) {
if(buf == null) {
return null;
}
return Int32Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer()); return Int32Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer());
} }
public static ArrayBuffer unwrapArrayBuffer(int[] buf) { public static ArrayBuffer unwrapArrayBuffer(int[] buf) {
if(buf == null) {
return null;
}
return ((TeaVMArrayObject)(Object)buf).getData().getBuffer(); return ((TeaVMArrayObject)(Object)buf).getData().getBuffer();
} }
public static ArrayBufferView unwrapArrayBufferView(int[] buf) { public static ArrayBufferView unwrapArrayBufferView(int[] buf) {
if(buf == null) {
return null;
}
return ((TeaVMArrayObject)(Object)buf).getData(); 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); private static native JSObject wrapIntArray0(JSObject buf);
public static int[] wrapIntArray(Int32Array 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); 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) { public static Float32Array unwrapFloatArray(float[] buf) {
if(buf == null) {
return null;
}
return Float32Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer()); return Float32Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer());
} }
public static ArrayBuffer unwrapArrayBuffer(float[] buf) { public static ArrayBuffer unwrapArrayBuffer(float[] buf) {
if(buf == null) {
return null;
}
return ((TeaVMArrayObject)(Object)buf).getData().getBuffer(); return ((TeaVMArrayObject)(Object)buf).getData().getBuffer();
} }
public static ArrayBufferView unwrapArrayBufferView(float[] buf) { public static ArrayBufferView unwrapArrayBufferView(float[] buf) {
if(buf == null) {
return null;
}
return ((TeaVMArrayObject)(Object)buf).getData(); 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); private static native JSObject wrapFloatArray0(JSObject buf);
public static float[] wrapFloatArray(Float32Array 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); 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) { public static Int16Array unwrapShortArray(short[] buf) {
if(buf == null) {
return null;
}
return Int16Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer()); return Int16Array.create(((TeaVMArrayObject)(Object)buf).getData().getBuffer());
} }
public static ArrayBuffer unwrapArrayBuffer(short[] buf) { public static ArrayBuffer unwrapArrayBuffer(short[] buf) {
if(buf == null) {
return null;
}
return ((TeaVMArrayObject)(Object)buf).getData().getBuffer(); return ((TeaVMArrayObject)(Object)buf).getData().getBuffer();
} }
public static ArrayBufferView unwrapArrayBufferView(short[] buf) { public static ArrayBufferView unwrapArrayBufferView(short[] buf) {
if(buf == null) {
return null;
}
return ((TeaVMArrayObject)(Object)buf).getData(); 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); private static native JSObject wrapShortArray0(JSObject buf);
public static short[] wrapShortArray(Int16Array 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); return (short[])(Object)wrapShortArray0(buf);
} }
public static short[] wrapShortArrayBuffer(ArrayBufferView buf) {
if(buf == null) {
return null;
}
return (short[])(Object)wrapShortArray0(buf.getBuffer());
}
@Async @Async
public static native void sleepSetTimeout(int millis); public static native void sleepSetTimeout(int millis);
@ -141,14 +251,6 @@ public class TeaVMUtils {
Window.setTimeout(() -> cb.complete(null), millis); 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() { public static String tryResolveClassesSource() {
String str = dumpJSStackTrace(); String str = dumpJSStackTrace();
String[] frames = EagUtils.splitPattern.split(str); String[] frames = EagUtils.splitPattern.split(str);

View File

@ -93,4 +93,7 @@ public abstract class JSEaglercraftXOptsRoot implements JSObject {
@JSBody(params = { "def" }, script = "return (typeof this.localStorageNamespace === \"string\") ? this.localStorageNamespace : def;") @JSBody(params = { "def" }, script = "return (typeof this.localStorageNamespace === \"string\") ? this.localStorageNamespace : def;")
public native String getLocalStorageNamespace(String defaultValue); public native String getLocalStorageNamespace(String defaultValue);
@JSBody(params = { "def" }, script = "return (typeof this.enableMinceraft === \"boolean\") ? this.enableMinceraft : def;")
public native boolean getEnableMinceraft(boolean defaultValue);
} }

View File

@ -10,7 +10,6 @@ import org.teavm.jso.JSObject;
import org.teavm.jso.dom.events.ErrorEvent; import org.teavm.jso.dom.events.ErrorEvent;
import org.teavm.jso.dom.events.EventListener; import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.typedarrays.ArrayBuffer; import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import org.teavm.jso.workers.Worker; import org.teavm.jso.workers.Worker;
import net.lax1dude.eaglercraft.v1_8.internal.IPCPacketData; import net.lax1dude.eaglercraft.v1_8.internal.IPCPacketData;
@ -92,7 +91,7 @@ public class ClientPlatformSingleplayer {
} }
synchronized(messageQueue) { 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) { public static void sendPacket(IPCPacketData packet) {
ArrayBuffer arb = ArrayBuffer.create(packet.contents.length); sendPacketTeaVM(packet.channel, TeaVMUtils.unwrapArrayBuffer(packet.contents));
Uint8Array ar = Uint8Array.create(arb);
ar.set(packet.contents);
sendPacketTeaVM(packet.channel, TeaVMUtils.unwrapUnsignedByteArray(packet.contents).getBuffer());
} }
public static void sendPacketTeaVM(String channel, ArrayBuffer packet) { public static void sendPacketTeaVM(String channel, ArrayBuffer packet) {

View File

@ -8,7 +8,6 @@ import org.teavm.jso.JSBody;
import org.teavm.jso.JSFunctor; import org.teavm.jso.JSFunctor;
import org.teavm.jso.JSObject; import org.teavm.jso.JSObject;
import org.teavm.jso.typedarrays.ArrayBuffer; 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.IClientConfigAdapter;
import net.lax1dude.eaglercraft.v1_8.internal.IPCPacketData; import net.lax1dude.eaglercraft.v1_8.internal.IPCPacketData;
@ -58,7 +57,7 @@ public class ServerPlatformSingleplayer {
} }
synchronized(messageQueue) { 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 native void sendPacketTeaVM(String channel, ArrayBuffer arr);
public static void sendPacket(IPCPacketData packet) { public static void sendPacket(IPCPacketData packet) {
ArrayBuffer arb = ArrayBuffer.create(packet.contents.length); sendPacketTeaVM(packet.channel, TeaVMUtils.unwrapArrayBuffer(packet.contents));
Uint8Array ar = Uint8Array.create(arb);
ar.set(packet.contents);
sendPacketTeaVM(packet.channel, arb);
} }
public static List<IPCPacketData> recieveAllPacket() { public static List<IPCPacketData> recieveAllPacket() {