update to u35
This commit is contained in:
parent
e13914a54f
commit
3409da13de
|
@ -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;
|
||||
|
|
|
@ -112,4 +112,5 @@ void main() {
|
|||
#endif
|
||||
|
||||
gl_Position = u_projectionMat4f * pos;
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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": [
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 942 B After Width: | Height: | Size: 315 B |
|
@ -0,0 +1,2 @@
|
|||
# Change to 0 to disable blur
|
||||
enable_blur=1
|
|
@ -9,14 +9,21 @@ import java.util.Arrays;
|
|||
/**
|
||||
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
|
@ -121,6 +128,7 @@ public class EaglerInputStream extends InputStream {
|
|||
}
|
||||
|
||||
public static byte[] inputStreamToBytes(InputStream is) throws IOException {
|
||||
try {
|
||||
if (is instanceof EaglerInputStream) {
|
||||
return ((EaglerInputStream) is).getAsArray();
|
||||
} else if (is instanceof ByteArrayInputStream) {
|
||||
|
@ -136,6 +144,9 @@ public class EaglerInputStream extends InputStream {
|
|||
}
|
||||
return os.toByteArray();
|
||||
}
|
||||
} finally {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getAsArray() {
|
||||
|
|
|
@ -9,7 +9,7 @@ public class EaglercraftVersion {
|
|||
/// Customize these to fit your fork:
|
||||
|
||||
public static final String projectForkName = "Eaglercraft Lambda";
|
||||
public static final String projectForkVersion = "0.5.0";
|
||||
public static final String projectForkVersion = "0.5.1";
|
||||
public static final String projectForkVendor = "HoosierTransfer";
|
||||
|
||||
public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";
|
||||
|
@ -19,7 +19,7 @@ public class EaglercraftVersion {
|
|||
public static final String projectOriginName = "EaglercraftX";
|
||||
public static final String projectOriginAuthor = "lax1dude";
|
||||
public static final String projectOriginRevision = "1.9.4";
|
||||
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
|
||||
|
||||
|
@ -28,7 +28,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;
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@ package net.lax1dude.eaglercraft.v1_8;
|
|||
import net.lax1dude.eaglercraft.v1_8.internal.EnumCursorType;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformInput;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.RenderResolution;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2022-2024 lax1dude, hoosiertransfer, ayunami2000. All Rights
|
||||
* Reserved.
|
||||
|
|
|
@ -81,5 +81,7 @@ public interface IClientConfigAdapter {
|
|||
|
||||
String getLocalStorageNamespace();
|
||||
|
||||
boolean isEnableMinceraft();
|
||||
|
||||
IClientConfigAdapterHooks getHooks();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -3,19 +3,27 @@ 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;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2023 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
|
@ -28,7 +36,8 @@ public class EaglerBitwisePackedTexture {
|
|||
if (startByte == endByte) {
|
||||
return (((int) bytes[startByte] & 0xff) >> (8 - (idxx & 7) - bits)) & ((1 << bits) - 1);
|
||||
} else {
|
||||
return (((((int)bytes[startByte] & 0xff) << 8) | ((int)bytes[endByte] & 0xff)) >> (16 - (idxx & 7) - bits)) & ((1 << bits) - 1);
|
||||
return (((((int) bytes[startByte] & 0xff) << 8) | ((int) bytes[endByte] & 0xff)) >> (16 - (idxx & 7)
|
||||
- bits)) & ((1 << bits) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,4 +84,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,14 +13,21 @@ import net.minecraft.util.ResourceLocation;
|
|||
/**
|
||||
* Copyright (c) 2023 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
|
@ -29,7 +36,8 @@ public class PBRTextureMapUtils {
|
|||
|
||||
public static final ImageData defaultNormalsTexture = new ImageData(1, 1, new int[] { 0 }, true);
|
||||
|
||||
public static final PBRMaterialConstants blockMaterialConstants = new PBRMaterialConstants(new ResourceLocation("eagler:glsl/deferred/material_block_constants.csv"));
|
||||
public static final PBRMaterialConstants blockMaterialConstants = new PBRMaterialConstants(
|
||||
new ResourceLocation("eagler:glsl/deferred/material_block_constants.csv"));
|
||||
|
||||
public static final Logger logger = LogManager.getLogger("PBRTextureMap");
|
||||
|
||||
|
@ -54,7 +62,8 @@ public class PBRTextureMapUtils {
|
|||
for (int i = 0, j; i < toRet.pixels.length; ++i) {
|
||||
// swap B and A, because labPBR support
|
||||
int a = (toRet.pixels[i] >>> 24) & 0xFF;
|
||||
if(a == 0xFF) a = 0;
|
||||
if (a == 0xFF)
|
||||
a = 0;
|
||||
toRet.pixels[i] = (toRet.pixels[i] & 0x0000FFFF) | Math.min(a << 18, 0xFF0000) | 0xFF000000;
|
||||
}
|
||||
}
|
||||
|
@ -69,11 +78,17 @@ public class PBRTextureMapUtils {
|
|||
fname = fname.substring(0, idx);
|
||||
}
|
||||
try {
|
||||
return TextureUtil.readBufferedImage(resMgr.getResource(new ResourceLocation("eagler:glsl/deferred/assets_pbr/" + fname + ".png")).getInputStream());
|
||||
return TextureUtil.readBufferedImage(
|
||||
resMgr.getResource(new ResourceLocation("eagler:glsl/deferred/assets_pbr/" + fname + ".png"))
|
||||
.getInputStream());
|
||||
} 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();
|
||||
|
@ -114,7 +129,8 @@ public class PBRTextureMapUtils {
|
|||
} else {
|
||||
for (int y = 0; y < resY; ++y) {
|
||||
for (int x = 0; x < resX; ++x) {
|
||||
out.pixels[y * resX + x] = in.pixels[((y * in.height / resY)) * in.width + (x * in.width / resX)];
|
||||
out.pixels[y * resX + x] = in.pixels[((y * in.height / resY)) * in.width
|
||||
+ (x * in.width / resX)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -24,30 +24,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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
@ -38,14 +37,15 @@ import net.minecraft.util.MathHelper;
|
|||
public class DynamicLightsStateManager {
|
||||
|
||||
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 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() {
|
||||
|
@ -59,6 +59,9 @@ public class DynamicLightsStateManager {
|
|||
accelParticleRenderer = new DynamicLightsAcceleratedEffectRenderer();
|
||||
accelParticleRenderer.initialize();
|
||||
}
|
||||
lightRenderList.clear();
|
||||
instancePoolIndex = 0;
|
||||
maxListLengthTracker = 0;
|
||||
}
|
||||
|
||||
public static final void bindAcceleratedEffectRenderer(EffectRenderer renderer) {
|
||||
|
@ -79,6 +82,8 @@ public class DynamicLightsStateManager {
|
|||
}
|
||||
destroyAll();
|
||||
lightRenderList.clear();
|
||||
instancePoolIndex = 0;
|
||||
maxListLengthTracker = 0;
|
||||
}
|
||||
|
||||
public static final boolean isDynamicLightsRender() {
|
||||
|
@ -109,21 +114,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();
|
||||
|
@ -141,7 +152,8 @@ public class DynamicLightsStateManager {
|
|||
bucketLoader.setRenderPos(renderPosX, renderPosY, renderPosZ);
|
||||
bucketLoader.truncateOverflowingBuffers();
|
||||
}
|
||||
lightRenderList.clear();
|
||||
updateTimers();
|
||||
clearRenderList();
|
||||
}
|
||||
|
||||
public static final void setupInverseViewMatrix() {
|
||||
|
@ -151,25 +163,21 @@ public class DynamicLightsStateManager {
|
|||
|
||||
private static final void updateTimers() {
|
||||
long millis = System.currentTimeMillis();
|
||||
if (millis - lastTick > 1000l) {
|
||||
if (millis - lastTick > 5000l) {
|
||||
lastTick = millis;
|
||||
Iterator<DynamicLightInstance> 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<DynamicLightInstance> 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<DynamicLightInstance> itr = lightRenderers.values().iterator();
|
||||
while (itr.hasNext()) {
|
||||
itr.next().destroy();
|
||||
}
|
||||
lightRenderers.clear();
|
||||
lightInstancePool = new ArrayList();
|
||||
}
|
||||
|
||||
public static String getF3String() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -613,6 +613,7 @@ public class Minecraft implements IThreadListener {
|
|||
}
|
||||
|
||||
ShaderSource.clearCache();
|
||||
GuiMainMenu.doResourceReloadHack();
|
||||
|
||||
this.mcLanguageManager.parseLanguageMetadata(arraylist);
|
||||
if (this.renderGlobal != null) {
|
||||
|
|
|
@ -5,23 +5,23 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
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;
|
||||
import net.lax1dude.eaglercraft.v1_8.Mouse;
|
||||
|
||||
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;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
|
||||
|
@ -38,7 +38,6 @@ import net.lax1dude.eaglercraft.v1_8.update.UpdateCertificate;
|
|||
import net.lax1dude.eaglercraft.v1_8.update.UpdateService;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
|
@ -82,8 +81,6 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
|
|||
private float updateCounter;
|
||||
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 };
|
||||
private String splashText;
|
||||
|
@ -101,6 +98,8 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
|
|||
private static final ResourceLocation splashTexts = new ResourceLocation("texts/splashes.txt");
|
||||
private static final ResourceLocation minecraftTitleTextures = new ResourceLocation(
|
||||
"textures/gui/title/minecraft.png");
|
||||
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");
|
||||
/**
|
||||
* +
|
||||
|
@ -122,8 +121,13 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
|
|||
private static ResourceLocation backgroundTexture = null;
|
||||
private GuiUpdateCheckerOverlay updateCheckerOverlay;
|
||||
private GuiButton downloadOfflineButton;
|
||||
private boolean enableBlur = true;
|
||||
private boolean shouldReload = false;
|
||||
|
||||
private static GuiMainMenu instance = null;
|
||||
|
||||
public GuiMainMenu() {
|
||||
instance = this;
|
||||
this.splashText = "missingno";
|
||||
updateCheckerOverlay = new GuiUpdateCheckerOverlay(false, this);
|
||||
BufferedReader bufferedreader = null;
|
||||
|
@ -164,24 +168,25 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
|
|||
}
|
||||
|
||||
this.updateCounter = RANDOM.nextFloat();
|
||||
reloadResourceFlags();
|
||||
}
|
||||
|
||||
private void reloadResourceFlags() {
|
||||
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];
|
||||
if (!EagRuntime.getConfiguration().isEnableMinceraft()) {
|
||||
this.isDefault = false;
|
||||
} else {
|
||||
try {
|
||||
byte[] bytes = EaglerInputStream.inputStreamToBytesQuiet(Minecraft.getMinecraft().getResourceManager()
|
||||
.getResource(minecraftTitleTextures).getInputStream());
|
||||
if (bytes != null) {
|
||||
md5.update(bytes, 0, bytes.length);
|
||||
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);
|
||||
md5.doFinal(md5out, 0);
|
||||
sha1.doFinal(sha1out, 0);
|
||||
this.isDefault = bytes.length == lendef && Arrays.equals(md5out, md5def)
|
||||
&& Arrays.equals(sha1out, sha1def);
|
||||
this.isDefault = Arrays.equals(sha1out, sha1def);
|
||||
} else {
|
||||
this.isDefault = false;
|
||||
}
|
||||
|
@ -191,6 +196,33 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
|
|||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public static void doResourceReloadHack() {
|
||||
if (instance != null) {
|
||||
instance.shouldReload = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* +
|
||||
* Called from the main game loop to update the screen.
|
||||
|
@ -200,6 +232,10 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
|
|||
if (downloadOfflineButton != null) {
|
||||
downloadOfflineButton.enabled = !UpdateService.shouldDisableDownloadButton();
|
||||
}
|
||||
if (shouldReload) {
|
||||
reloadResourceFlags();
|
||||
shouldReload = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -393,19 +429,25 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
|
|||
GlStateManager.matrixMode(GL_PROJECTION);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.loadIdentity();
|
||||
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);
|
||||
}
|
||||
GlStateManager.matrixMode(GL_MODELVIEW);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.loadIdentity();
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
|
||||
if (enableBlur) {
|
||||
GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.disableCull();
|
||||
GlStateManager.depthMask(false);
|
||||
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
byte b0 = 8;
|
||||
byte b0 = enableBlur ? (byte) 8 : (byte) 1;
|
||||
|
||||
for (int i = 0; i < b0 * b0; ++i) {
|
||||
GlStateManager.pushMatrix();
|
||||
|
@ -545,7 +587,11 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
|
|||
*/
|
||||
public void drawScreen(int i, int j, float f) {
|
||||
GlStateManager.disableAlpha();
|
||||
if (enableBlur) {
|
||||
this.renderSkybox(i, j, f);
|
||||
} else {
|
||||
this.drawPanorama(i, j, f);
|
||||
}
|
||||
GlStateManager.enableAlpha();
|
||||
short short1 = 274;
|
||||
int k = this.width / 2 - short1 / 2;
|
||||
|
@ -554,7 +600,11 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
|
|||
this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE);
|
||||
this.mc.getTextureManager().bindTexture(minecraftTitleTextures);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
if (this.isDefault || (double) this.updateCounter < 1.0E-4D) {
|
||||
boolean minc = (double) this.updateCounter < 1.0E-4D;
|
||||
if (this.isDefault) {
|
||||
minc = !minc;
|
||||
}
|
||||
if (minc) {
|
||||
this.drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 99, 44);
|
||||
this.drawTexturedModalRect(k + 99, b0 + 0, 129, 0, 27, 44);
|
||||
this.drawTexturedModalRect(k + 99 + 26, b0 + 0, 126, 0, 3, 44);
|
||||
|
|
|
@ -189,7 +189,12 @@ public class ServerData {
|
|||
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) {
|
||||
|
|
|
@ -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;
|
||||
|
@ -210,8 +209,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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,7 +306,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() {
|
||||
|
|
|
@ -27,14 +27,21 @@ import net.lax1dude.eaglercraft.v1_8.opengl.ImageData;
|
|||
/**
|
||||
* Copyright (c) 2022-2023 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
|
@ -54,7 +61,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 +86,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,10 +115,12 @@ 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());
|
||||
org.teavm.jso.canvas.ImageData pxlsDat = imageLoadContext.getImageData(0, 0, toLoad.getWidth(), toLoad.getHeight());
|
||||
org.teavm.jso.canvas.ImageData pxlsDat = imageLoadContext.getImageData(0, 0, toLoad.getWidth(),
|
||||
toLoad.getHeight());
|
||||
Uint8ClampedArray pxls = pxlsDat.getData();
|
||||
int totalPixels = pxlsDat.getWidth() * pxlsDat.getHeight();
|
||||
TeaVMUtils.freeDataURL(toLoad.getSrc());
|
||||
|
@ -116,7 +128,8 @@ public class PlatformAssets {
|
|||
ret.complete(null);
|
||||
return;
|
||||
}
|
||||
ret.complete(new ImageData(pxlsDat.getWidth(), pxlsDat.getHeight(), TeaVMUtils.wrapIntArray(Int32Array.create(pxls.getBuffer())), true));
|
||||
ret.complete(new ImageData(pxlsDat.getWidth(), pxlsDat.getHeight(),
|
||||
TeaVMUtils.wrapIntArrayBuffer(pxls.getBuffer()), true));
|
||||
}
|
||||
});
|
||||
toLoad.addEventListener("error", new EventListener<Event>() {
|
||||
|
|
|
@ -225,8 +225,7 @@ public class PlatformAudio {
|
|||
byte[] file = PlatformAssets.getResourceBytes(filename);
|
||||
if (file == null)
|
||||
return null;
|
||||
buffer = new BrowserAudioResource(
|
||||
decodeAudioAsync(TeaVMUtils.unwrapUnsignedByteArray(file).getBuffer(), filename));
|
||||
buffer = new BrowserAudioResource(decodeAudioAsync(TeaVMUtils.unwrapArrayBuffer(file), filename));
|
||||
if (holdInCache) {
|
||||
synchronized (soundCache) {
|
||||
soundCache.put(filename, buffer);
|
||||
|
|
|
@ -12,7 +12,6 @@ import org.teavm.jso.dom.events.Event;
|
|||
import org.teavm.jso.dom.events.EventListener;
|
||||
import org.teavm.jso.dom.events.MessageEvent;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
import org.teavm.jso.websocket.WebSocket;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.teavm.TeaVMServerQuery;
|
||||
|
@ -132,7 +131,7 @@ public class PlatformNetworking {
|
|||
}
|
||||
} else {
|
||||
synchronized (readPackets) {
|
||||
readPackets.add(TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(evt.getDataAsArray())));
|
||||
readPackets.add(TeaVMUtils.wrapByteArrayBuffer(evt.getDataAsArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +194,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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,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;
|
||||
|
||||
|
@ -56,19 +55,25 @@ import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
|||
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerFolderResourcePack;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.RenderResolution;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2022-2024 lax1dude, hoosiertransfer, ayunami2000. All Rights Reserved.
|
||||
* Copyright (c) 2022-2024 lax1dude, hoosiertransfer, ayunami2000. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
|
@ -94,7 +99,8 @@ public class PlatformRuntime {
|
|||
|
||||
parent = doc.getElementById(ClientMain.configRootElementId);
|
||||
if (parent == null) {
|
||||
throw new RuntimeInitializationFailureException("Root element \"" + ClientMain.configRootElementId + "\" was not found in this document!");
|
||||
throw new RuntimeInitializationFailureException(
|
||||
"Root element \"" + ClientMain.configRootElementId + "\" was not found in this document!");
|
||||
}
|
||||
|
||||
CSSStyleDeclaration style = parent.getStyle();
|
||||
|
@ -312,7 +318,7 @@ public class PlatformRuntime {
|
|||
}
|
||||
|
||||
public static void downloadRemoteURIByteArray(String assetPackageURI, final Consumer<byte[]> cb) {
|
||||
downloadRemoteURI(assetPackageURI, arr -> cb.accept(TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(arr))));
|
||||
downloadRemoteURI(assetPackageURI, arr -> cb.accept(TeaVMUtils.wrapByteArrayBuffer(arr)));
|
||||
}
|
||||
|
||||
public static void downloadRemoteURI(String assetPackageURI, final Consumer<ArrayBuffer> cb) {
|
||||
|
@ -381,7 +387,8 @@ public class PlatformRuntime {
|
|||
@Async
|
||||
public static native ArrayBuffer downloadRemoteURI(String assetPackageURI, boolean forceCache);
|
||||
|
||||
private static void downloadRemoteURI(String assetPackageURI, boolean useCache, final AsyncCallback<ArrayBuffer> cb) {
|
||||
private static void downloadRemoteURI(String assetPackageURI, boolean useCache,
|
||||
final AsyncCallback<ArrayBuffer> cb) {
|
||||
doFetchDownload(assetPackageURI, useCache ? "force-cache" : "no-store", cb::complete);
|
||||
}
|
||||
|
||||
|
@ -513,10 +520,12 @@ public class PlatformRuntime {
|
|||
return recording && canRec;
|
||||
}
|
||||
|
||||
@JSBody(params = { "canvas", "audio" }, script = "const stream = canvas.captureStream(); stream.addTrack(audio.getTracks()[0]); return stream;")
|
||||
@JSBody(params = { "canvas",
|
||||
"audio" }, script = "const stream = canvas.captureStream(); stream.addTrack(audio.getTracks()[0]); return stream;")
|
||||
private static native MediaStream captureStreamAndAddAudio(HTMLCanvasElement canvas, MediaStream audio);
|
||||
|
||||
@JSBody(params = { "stream" }, script = "const rec = new MediaRecorder(stream, { mimeType: MediaRecorder.isTypeSupported(\"video/webm;codecs=vp9,opus\") ? \"video/webm;codecs=vp9,opus\" : \"video/webm\" }); rec.start(); return rec;")
|
||||
@JSBody(params = {
|
||||
"stream" }, script = "const rec = new MediaRecorder(stream, { mimeType: MediaRecorder.isTypeSupported(\"video/webm;codecs=vp9,opus\") ? \"video/webm;codecs=vp9,opus\" : \"video/webm\" }); rec.start(); return rec;")
|
||||
private static native JSObject createMediaRecorder(MediaStream stream);
|
||||
|
||||
@JSBody(params = { "rec" }, script = "rec.stop();")
|
||||
|
@ -553,7 +562,8 @@ public class PlatformRuntime {
|
|||
void onMedia(MediaStream stream);
|
||||
}
|
||||
|
||||
@JSBody(params = { "cb" }, script = "if (\"navigator\" in window && \"mediaDevices\" in window.navigator && \"getUserMedia\" in window.navigator.mediaDevices) { try { window.navigator.mediaDevices.getUserMedia({ audio: true, video: false }).then(function(stream) { cb(stream); }).catch(function(err) { console.error(err); cb(null); }); } catch(e) { console.error(\"getUserMedia Error!\"); cb(null); } } else { console.error(\"No getUserMedia!\"); cb(null); }")
|
||||
@JSBody(params = {
|
||||
"cb" }, script = "if (\"navigator\" in window && \"mediaDevices\" in window.navigator && \"getUserMedia\" in window.navigator.mediaDevices) { try { window.navigator.mediaDevices.getUserMedia({ audio: true, video: false }).then(function(stream) { cb(stream); }).catch(function(err) { console.error(err); cb(null); }); } catch(e) { console.error(\"getUserMedia Error!\"); cb(null); } } else { console.error(\"No getUserMedia!\"); cb(null); }")
|
||||
private static native void getMic0(MediaHandler cb);
|
||||
|
||||
@Async
|
||||
|
@ -610,7 +620,8 @@ public class PlatformRuntime {
|
|||
FixWebMDurationJS.getRecUrl(evt, (int) (System.currentTimeMillis() - startTime), url -> {
|
||||
HTMLAnchorElement a = (HTMLAnchorElement) doc.createElement("a");
|
||||
dateInstance.setTime(startTime);
|
||||
a.setDownload(EaglercraftVersion.mainMenuStringB + " - " + EaglerProfile.getName() + " - " + fmt.format(dateInstance) + ".webm");
|
||||
a.setDownload(EaglercraftVersion.mainMenuStringB + " - " + EaglerProfile.getName() + " - "
|
||||
+ fmt.format(dateInstance) + ".webm");
|
||||
a.setHref(url);
|
||||
a.click();
|
||||
TeaVMUtils.freeDataURL(url);
|
||||
|
|
|
@ -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;
|
||||
|
@ -15,14 +14,21 @@ import net.lax1dude.eaglercraft.v1_8.update.UpdateProgressStruct;
|
|||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
|
@ -62,7 +68,7 @@ public class PlatformUpdateSvc {
|
|||
logger.error("Failed to download client bundle or signature URL!");
|
||||
return null;
|
||||
}
|
||||
return TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(buf));
|
||||
return TeaVMUtils.wrapByteArrayBuffer(buf);
|
||||
}
|
||||
|
||||
public static byte[] getClientSignatureData() {
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.teavm.jso.dom.events.Event;
|
|||
import org.teavm.jso.dom.events.EventListener;
|
||||
import org.teavm.jso.json.JSON;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
import org.teavm.jso.websocket.WebSocket;
|
||||
|
||||
import com.google.common.collect.LinkedListMultimap;
|
||||
|
@ -37,14 +36,21 @@ import java.util.*;
|
|||
/**
|
||||
* Copyright (c) 2022-2024 ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
|
@ -77,7 +83,8 @@ public class PlatformWebRTC {
|
|||
@JSBody(params = { "item" }, script = "return item.candidate.candidate;")
|
||||
static native String getCandidate(JSObject item);
|
||||
|
||||
@JSBody(params = { "iceServers" }, script = "return new RTCPeerConnection({ iceServers: JSON.parse(iceServers), optional: [ { DtlsSrtpKeyAgreement: true } ] });")
|
||||
@JSBody(params = {
|
||||
"iceServers" }, script = "return new RTCPeerConnection({ iceServers: JSON.parse(iceServers), optional: [ { DtlsSrtpKeyAgreement: true } ] });")
|
||||
static native JSObject createRTCPeerConnection(String iceServers);
|
||||
|
||||
@JSBody(params = { "peerConnection", "name" }, script = "return peerConnection.createDataChannel(name);")
|
||||
|
@ -95,19 +102,24 @@ public class PlatformWebRTC {
|
|||
@JSBody(params = { "peerConnection", "h1", "h2" }, script = "return peerConnection.createOffer(h1, h2);")
|
||||
static native void createOffer(JSObject peerConnection, DescHandler h1, ErrorHandler h2);
|
||||
|
||||
@JSBody(params = { "peerConnection", "desc", "h1", "h2" }, script = "return peerConnection.setLocalDescription(desc, h1, h2);")
|
||||
@JSBody(params = { "peerConnection", "desc", "h1",
|
||||
"h2" }, script = "return peerConnection.setLocalDescription(desc, h1, h2);")
|
||||
static native void setLocalDescription(JSObject peerConnection, JSObject desc, EmptyHandler h1, ErrorHandler h2);
|
||||
|
||||
@JSBody(params = { "peerConnection", "str" }, script = "return peerConnection.setRemoteDescription(JSON.parse(str));")
|
||||
@JSBody(params = { "peerConnection",
|
||||
"str" }, script = "return peerConnection.setRemoteDescription(JSON.parse(str));")
|
||||
static native void setRemoteDescription(JSObject peerConnection, String str);
|
||||
|
||||
@JSBody(params = { "peerConnection", "str" }, script = "const candidateList = JSON.parse(str); for (let i = 0; i < candidateList.length; ++i) { peerConnection.addIceCandidate(candidateList[i]); }; return null;")
|
||||
@JSBody(params = { "peerConnection",
|
||||
"str" }, script = "const candidateList = JSON.parse(str); for (let i = 0; i < candidateList.length; ++i) { peerConnection.addIceCandidate(candidateList[i]); }; return null;")
|
||||
static native void addIceCandidates(JSObject peerConnection, String str);
|
||||
|
||||
@JSBody(params = { "peerConnection", "str" }, script = "const candidateList = JSON.parse(str); for (let i = 0; i < candidateList.length; ++i) { peerConnection.addIceCandidate(new RTCIceCandidate(candidateList[i])); }; return null;")
|
||||
@JSBody(params = { "peerConnection",
|
||||
"str" }, script = "const candidateList = JSON.parse(str); for (let i = 0; i < candidateList.length; ++i) { peerConnection.addIceCandidate(new RTCIceCandidate(candidateList[i])); }; return null;")
|
||||
static native void addIceCandidates2(JSObject peerConnection, String str);
|
||||
|
||||
@JSBody(params = { "peerConnection", "str", "h1", "h2" }, script = "return peerConnection.setRemoteDescription(JSON.parse(str), h1, h2);")
|
||||
@JSBody(params = { "peerConnection", "str", "h1",
|
||||
"h2" }, script = "return peerConnection.setRemoteDescription(JSON.parse(str), h1, h2);")
|
||||
static native void setRemoteDescription2(JSObject peerConnection, String str, EmptyHandler h1, ErrorHandler h2);
|
||||
|
||||
@JSBody(params = { "peerConnection", "h1", "h2" }, script = "return peerConnection.createAnswer(h1, h2);")
|
||||
|
@ -211,7 +223,7 @@ public class PlatformWebRTC {
|
|||
|
||||
TeaVMUtils.addEventListener(dataChannel, "message", (EventListener<Event>) evt -> {
|
||||
synchronized (clientLANPacketBuffer) {
|
||||
clientLANPacketBuffer.add(TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(getData(evt))));
|
||||
clientLANPacketBuffer.add(TeaVMUtils.wrapByteArrayBuffer(getData(evt)));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -270,7 +282,8 @@ public class PlatformWebRTC {
|
|||
if (peerConnection != null) {
|
||||
closeIt(peerConnection);
|
||||
}
|
||||
if (!quiet) clientDataChannelClosed = true;
|
||||
if (!quiet)
|
||||
clientDataChannelClosed = true;
|
||||
readyState = READYSTATE_DISCONNECTED;
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +309,8 @@ public class PlatformWebRTC {
|
|||
if (iceCandidates.isEmpty()) {
|
||||
Window.setTimeout(() -> {
|
||||
if (peerConnection != null && !"disconnected".equals(getConnectionState(peerConnection))) {
|
||||
LANPeerEvent.LANPeerICECandidateEvent e = new LANPeerEvent.LANPeerICECandidateEvent(peerId, JSONWriter.valueToString(iceCandidates));
|
||||
LANPeerEvent.LANPeerICECandidateEvent e = new LANPeerEvent.LANPeerICECandidateEvent(
|
||||
peerId, JSONWriter.valueToString(iceCandidates));
|
||||
synchronized (serverLANEventBuffer) {
|
||||
serverLANEventBuffer.put(peerId, e);
|
||||
}
|
||||
|
@ -317,7 +331,8 @@ public class PlatformWebRTC {
|
|||
Window.setTimeout(() -> ((EventListener<Event>) evtHandler[0]).handleEvent(evt), 1);
|
||||
return;
|
||||
}
|
||||
if (getChannel(evt) == null) return;
|
||||
if (getChannel(evt) == null)
|
||||
return;
|
||||
JSObject dataChannel = getChannel(evt);
|
||||
synchronized (fuckTeaVM) {
|
||||
fuckTeaVM.put(peerId, dataChannel);
|
||||
|
@ -326,7 +341,8 @@ public class PlatformWebRTC {
|
|||
serverLANEventBuffer.put(peerId, new LANPeerEvent.LANPeerDataChannelEvent(peerId));
|
||||
}
|
||||
TeaVMUtils.addEventListener(dataChannel, "message", (EventListener<Event>) evt2 -> {
|
||||
LANPeerEvent.LANPeerPacketEvent e = new LANPeerEvent.LANPeerPacketEvent(peerId, TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(getData(evt2))));
|
||||
LANPeerEvent.LANPeerPacketEvent e = new LANPeerEvent.LANPeerPacketEvent(peerId,
|
||||
TeaVMUtils.wrapByteArrayBuffer(getData(evt2)));
|
||||
synchronized (serverLANEventBuffer) {
|
||||
serverLANEventBuffer.put(peerId, e);
|
||||
}
|
||||
|
@ -340,9 +356,11 @@ public class PlatformWebRTC {
|
|||
if ("disconnected".equals(connectionState)) {
|
||||
client.signalRemoteDisconnect(peerId);
|
||||
} else if ("connected".equals(connectionState)) {
|
||||
if (client.peerState != PEERSTATE_SUCCESS) client.peerState = PEERSTATE_SUCCESS;
|
||||
if (client.peerState != PEERSTATE_SUCCESS)
|
||||
client.peerState = PEERSTATE_SUCCESS;
|
||||
} else if ("failed".equals(connectionState)) {
|
||||
if (client.peerState == PEERSTATE_LOADING) client.peerState = PEERSTATE_FAILED;
|
||||
if (client.peerState == PEERSTATE_LOADING)
|
||||
client.peerState = PEERSTATE_FAILED;
|
||||
client.signalRemoteDisconnect(peerId);
|
||||
}
|
||||
});
|
||||
|
@ -365,30 +383,37 @@ public class PlatformWebRTC {
|
|||
if (remoteDesc.has("type") && "offer".equals(remoteDesc.getString("type"))) {
|
||||
createAnswer(peerConnection, desc -> {
|
||||
setLocalDescription(peerConnection, desc, () -> {
|
||||
LANPeerEvent.LANPeerDescriptionEvent e = new LANPeerEvent.LANPeerDescriptionEvent(peerId, JSON.stringify(desc));
|
||||
LANPeerEvent.LANPeerDescriptionEvent e = new LANPeerEvent.LANPeerDescriptionEvent(
|
||||
peerId, JSON.stringify(desc));
|
||||
synchronized (serverLANEventBuffer) {
|
||||
serverLANEventBuffer.put(peerId, e);
|
||||
}
|
||||
if (client.peerStateDesc != PEERSTATE_SUCCESS) client.peerStateDesc = PEERSTATE_SUCCESS;
|
||||
if (client.peerStateDesc != PEERSTATE_SUCCESS)
|
||||
client.peerStateDesc = PEERSTATE_SUCCESS;
|
||||
}, err -> {
|
||||
logger.error("Failed to set local description for \"{}\"! {}", peerId, err.getMessage());
|
||||
if (client.peerStateDesc == PEERSTATE_LOADING) client.peerStateDesc = PEERSTATE_FAILED;
|
||||
logger.error("Failed to set local description for \"{}\"! {}", peerId,
|
||||
err.getMessage());
|
||||
if (client.peerStateDesc == PEERSTATE_LOADING)
|
||||
client.peerStateDesc = PEERSTATE_FAILED;
|
||||
client.signalRemoteDisconnect(peerId);
|
||||
});
|
||||
}, err -> {
|
||||
logger.error("Failed to create answer for \"{}\"! {}", peerId, err.getMessage());
|
||||
if (client.peerStateDesc == PEERSTATE_LOADING) client.peerStateDesc = PEERSTATE_FAILED;
|
||||
if (client.peerStateDesc == PEERSTATE_LOADING)
|
||||
client.peerStateDesc = PEERSTATE_FAILED;
|
||||
client.signalRemoteDisconnect(peerId);
|
||||
});
|
||||
}
|
||||
}, err -> {
|
||||
logger.error("Failed to set remote description for \"{}\"! {}", peerId, err.getMessage());
|
||||
if (client.peerStateDesc == PEERSTATE_LOADING) client.peerStateDesc = PEERSTATE_FAILED;
|
||||
if (client.peerStateDesc == PEERSTATE_LOADING)
|
||||
client.peerStateDesc = PEERSTATE_FAILED;
|
||||
client.signalRemoteDisconnect(peerId);
|
||||
});
|
||||
} catch (Throwable err) {
|
||||
logger.error("Failed to parse remote description for \"{}\"! {}", peerId, err.getMessage());
|
||||
if (client.peerStateDesc == PEERSTATE_LOADING) client.peerStateDesc = PEERSTATE_FAILED;
|
||||
if (client.peerStateDesc == PEERSTATE_LOADING)
|
||||
client.peerStateDesc = PEERSTATE_FAILED;
|
||||
client.signalRemoteDisconnect(peerId);
|
||||
}
|
||||
}
|
||||
|
@ -396,10 +421,12 @@ public class PlatformWebRTC {
|
|||
public void addICECandidate(String candidates) {
|
||||
try {
|
||||
addIceCandidates2(peerConnection, candidates);
|
||||
if (client.peerStateIce != PEERSTATE_SUCCESS) client.peerStateIce = PEERSTATE_SUCCESS;
|
||||
if (client.peerStateIce != PEERSTATE_SUCCESS)
|
||||
client.peerStateIce = PEERSTATE_SUCCESS;
|
||||
} catch (Throwable err) {
|
||||
logger.error("Failed to parse ice candidate for \"{}\"! {}", peerId, err.getMessage());
|
||||
if (client.peerStateIce == PEERSTATE_LOADING) client.peerStateIce = PEERSTATE_FAILED;
|
||||
if (client.peerStateIce == PEERSTATE_LOADING)
|
||||
client.peerStateIce = PEERSTATE_FAILED;
|
||||
client.signalRemoteDisconnect(peerId);
|
||||
}
|
||||
}
|
||||
|
@ -437,7 +464,8 @@ public class PlatformWebRTC {
|
|||
if (thePeer != null) {
|
||||
boolean b = false;
|
||||
synchronized (fuckTeaVM) {
|
||||
if (fuckTeaVM.get(thePeer.peerId) != null && "open".equals(getReadyState(fuckTeaVM.get(thePeer.peerId)))) {
|
||||
if (fuckTeaVM.get(thePeer.peerId) != null
|
||||
&& "open".equals(getReadyState(fuckTeaVM.get(thePeer.peerId)))) {
|
||||
try {
|
||||
sendIt(fuckTeaVM.get(thePeer.peerId), buffer);
|
||||
} catch (Throwable e) {
|
||||
|
@ -462,9 +490,11 @@ public class PlatformWebRTC {
|
|||
JSObject peerConnection = createRTCPeerConnection(JSONWriter.valueToString(iceServers));
|
||||
LANPeer peerInstance = new LANPeer(this, peerId, peerConnection);
|
||||
peerList.put(peerId, peerInstance);
|
||||
if (peerStateConnect != PEERSTATE_SUCCESS) peerStateConnect = PEERSTATE_SUCCESS;
|
||||
if (peerStateConnect != PEERSTATE_SUCCESS)
|
||||
peerStateConnect = PEERSTATE_SUCCESS;
|
||||
} catch (Throwable e) {
|
||||
if (peerStateConnect == PEERSTATE_LOADING) peerStateConnect = PEERSTATE_FAILED;
|
||||
if (peerStateConnect == PEERSTATE_LOADING)
|
||||
peerStateConnect = PEERSTATE_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -488,9 +518,11 @@ public class PlatformWebRTC {
|
|||
if (thePeer != null) {
|
||||
try {
|
||||
thePeer.disconnect();
|
||||
} catch (Throwable ignored) {}
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
synchronized (serverLANEventBuffer) {
|
||||
serverLANEventBuffer.put(thePeer.peerId, new LANPeerEvent.LANPeerDisconnectEvent(thePeer.peerId));
|
||||
serverLANEventBuffer.put(thePeer.peerId,
|
||||
new LANPeerEvent.LANPeerDisconnectEvent(thePeer.peerId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -505,7 +537,8 @@ public class PlatformWebRTC {
|
|||
peerList.remove(peerId);
|
||||
try {
|
||||
thePeer.disconnect();
|
||||
} catch (Throwable ignored) {}
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
synchronized (fuckTeaVM) {
|
||||
fuckTeaVM.remove(peerId);
|
||||
}
|
||||
|
@ -538,10 +571,6 @@ public class PlatformWebRTC {
|
|||
@JSBody(params = { "obj" }, script = "return typeof obj === \"string\";")
|
||||
private static native boolean isString(JSObject obj);
|
||||
|
||||
private static ArrayBuffer convertToArrayBuffer(byte[] arr) {
|
||||
return TeaVMUtils.unwrapUnsignedByteArray(arr).getBuffer();
|
||||
}
|
||||
|
||||
private static final Map<String, Long> relayQueryLimited = new HashMap<>();
|
||||
private static final Map<String, Long> relayQueryBlocked = new HashMap<>();
|
||||
|
||||
|
@ -587,9 +616,8 @@ public class PlatformWebRTC {
|
|||
sock.onOpen(evt -> {
|
||||
try {
|
||||
connectionPingStart = System.currentTimeMillis();
|
||||
PlatformNetworking.nativeBinarySend(sock, convertToArrayBuffer(
|
||||
IPacket.writePacket(new IPacket00Handshake(0x03, RelayManager.preferredRelayVersion, ""))
|
||||
));
|
||||
PlatformNetworking.nativeBinarySend(sock, TeaVMUtils.unwrapArrayBuffer(
|
||||
IPacket.writePacket(new IPacket00Handshake(0x03, RelayManager.preferredRelayVersion, ""))));
|
||||
} catch (IOException e) {
|
||||
logger.error(e.toString());
|
||||
sock.close();
|
||||
|
@ -599,7 +627,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,9 +870,8 @@ public class PlatformWebRTC {
|
|||
sock = s;
|
||||
sock.onOpen(evt -> {
|
||||
try {
|
||||
PlatformNetworking.nativeBinarySend(sock, convertToArrayBuffer(
|
||||
IPacket.writePacket(new IPacket00Handshake(0x04, RelayManager.preferredRelayVersion, ""))
|
||||
));
|
||||
PlatformNetworking.nativeBinarySend(sock, TeaVMUtils.unwrapArrayBuffer(
|
||||
IPacket.writePacket(new IPacket00Handshake(0x04, RelayManager.preferredRelayVersion, ""))));
|
||||
} catch (IOException e) {
|
||||
logger.error(e.toString());
|
||||
sock.close();
|
||||
|
@ -855,7 +882,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 +1092,8 @@ 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 +1164,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 +1311,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() {
|
||||
|
@ -1306,7 +1334,8 @@ public class PlatformWebRTC {
|
|||
|
||||
public static void clientLANSetICEServersAndConnect(String[] servers) {
|
||||
rtcLANClient.setIceServers(servers);
|
||||
if(clientLANReadyState() == LANClient.READYSTATE_CONNECTED || clientLANReadyState() == LANClient.READYSTATE_CONNECTING) {
|
||||
if (clientLANReadyState() == LANClient.READYSTATE_CONNECTED
|
||||
|| clientLANReadyState() == LANClient.READYSTATE_CONNECTING) {
|
||||
rtcLANClient.signalRemoteDisconnect(true);
|
||||
}
|
||||
rtcLANClient.initialize();
|
||||
|
@ -1409,7 +1438,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) {
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.internal;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglerZLIB;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||
|
||||
public class RenderResolution {
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static float parseFloat(String parString1) {
|
||||
return parString1.equals("true") ? 1.0F : (parString1.equals("false") ? 0.0F : Float.parseFloat(parString1));
|
||||
}
|
||||
public static double renderScale = 1.0D;
|
||||
public static void loadRenderScale() {
|
||||
try {
|
||||
byte[] options = EagRuntime.getStorage("g");
|
||||
if (options == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
BufferedReader bufferedreader = new BufferedReader(
|
||||
new InputStreamReader(EaglerZLIB.newGZIPInputStream(new EaglerInputStream(options))));
|
||||
String s = "";
|
||||
|
||||
while ((s = bufferedreader.readLine()) != null) {
|
||||
try {
|
||||
String[] astring = s.split(":");
|
||||
if (astring[0].equals("renderScale")) {
|
||||
renderScale = parseFloat(astring[1]);
|
||||
}
|
||||
} catch (Exception var8) {
|
||||
logger.warn("Skipping bad option: " + s);
|
||||
}
|
||||
}
|
||||
|
||||
KeyBinding.resetKeyBindingArrayAndHash();
|
||||
} catch (Exception exception) {
|
||||
logger.error("Failed to load options", exception);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -67,6 +67,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();
|
||||
|
@ -91,6 +92,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);
|
||||
|
@ -191,6 +193,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
|
|||
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) {
|
||||
|
@ -350,6 +353,11 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
|
|||
return localStorageNamespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnableMinceraft() {
|
||||
return enableMinceraft;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClientConfigAdapterHooks getHooks() {
|
||||
return hooks;
|
||||
|
@ -375,6 +383,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
|
|||
jsonObject.put("allowVoiceClient", allowVoiceClient);
|
||||
jsonObject.put("allowFNAWSkins", allowFNAWSkins);
|
||||
jsonObject.put("localStorageNamespace", localStorageNamespace);
|
||||
jsonObject.put("enableMinceraft", enableMinceraft);
|
||||
JSONArray serversArr = new JSONArray();
|
||||
for (int i = 0, l = defaultServers.size(); i < l; ++i) {
|
||||
DefaultServer srv = defaultServers.get(i);
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.teavm.jso.dom.events.Event;
|
|||
import org.teavm.jso.dom.events.EventListener;
|
||||
import org.teavm.jso.dom.events.MessageEvent;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
import org.teavm.jso.websocket.WebSocket;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.EnumServerRateLimit;
|
||||
|
@ -22,14 +21,21 @@ import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
|||
/**
|
||||
* Copyright (c) 2022 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
|
@ -116,7 +122,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 +149,7 @@ public class TeaVMServerQuery implements IServerQuery {
|
|||
@Override
|
||||
public void send(byte[] bytes) {
|
||||
if (open) {
|
||||
nativeBinarySend(sock, TeaVMUtils.unwrapByteArray(bytes).getBuffer());
|
||||
nativeBinarySend(sock, TeaVMUtils.unwrapArrayBuffer(bytes));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.teavm.jso.browser.Window;
|
|||
import org.teavm.jso.dom.events.Event;
|
||||
import org.teavm.jso.dom.events.EventListener;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
|
||||
import com.google.common.collect.ListMultimap;
|
||||
|
||||
|
@ -35,14 +34,21 @@ import net.lax1dude.eaglercraft.v1_8.update.UpdateService;
|
|||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
|
@ -167,8 +173,10 @@ public class TeaVMUpdateThread implements Runnable {
|
|||
PlatformUpdateSvc.updateThread = null;
|
||||
updateProg.isBusy = false;
|
||||
if (!success) {
|
||||
logger.error("Failed to download updates! No valid URL was found for {}", updateCert.bundleDisplayVersion);
|
||||
Window.alert("ERROR: Failed to download updates!\n\nIf you are on a device with restricted internet access, try a different device or connect to a different WiFi network\n\nCheck the debug console for more info");
|
||||
logger.error("Failed to download updates! No valid URL was found for {}",
|
||||
updateCert.bundleDisplayVersion);
|
||||
Window.alert(
|
||||
"ERROR: Failed to download updates!\n\nIf you are on a device with restricted internet access, try a different device or connect to a different WiFi network\n\nCheck the debug console for more info");
|
||||
} else {
|
||||
UpdateService.dismiss(updateCert);
|
||||
}
|
||||
|
@ -220,13 +228,15 @@ 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);
|
||||
logger.error("Unexpected response length {} (expect: {}) from URL: {}", xhr.getStatus(),
|
||||
xhr.getStatusText(), url);
|
||||
cb.complete(null);
|
||||
}
|
||||
} else {
|
||||
logger.error("Got response code {} \"{}\" for url: {}", xhr.getStatus(), xhr.getStatusText(), url);
|
||||
logger.error("Got response code {} \"{}\" for url: {}", xhr.getStatus(), xhr.getStatusText(),
|
||||
url);
|
||||
cb.complete(null);
|
||||
}
|
||||
}
|
||||
|
@ -251,11 +261,15 @@ public class TeaVMUpdateThread implements Runnable {
|
|||
}
|
||||
|
||||
public static void downloadSignedOffline(UpdateCertificate cert, byte[] data) {
|
||||
PlatformApplication.downloadFileWithName(cert.bundleDisplayName.replaceAll("[^a-zA-Z0-9\\-_\\.]", "_") + "_" + cert.bundleDisplayVersion.replaceAll("[^a-zA-Z0-9\\-_]", "_") + "_Offline_Signed.html", generateSignedOffline(cert, data));
|
||||
PlatformApplication.downloadFileWithName(
|
||||
cert.bundleDisplayName.replaceAll("[^a-zA-Z0-9\\-_\\.]", "_") + "_"
|
||||
+ cert.bundleDisplayVersion.replaceAll("[^a-zA-Z0-9\\-_]", "_") + "_Offline_Signed.html",
|
||||
generateSignedOffline(cert, data));
|
||||
}
|
||||
|
||||
public static byte[] generateSignedOffline(UpdateCertificate cert, byte[] data) {
|
||||
return generateSignedOffline(cert.rawCertData, data, EagRuntime.fixDateFormat(new SimpleDateFormat("MM/dd/yyyy")).format(new Date(cert.sigTimestamp)));
|
||||
return generateSignedOffline(cert.rawCertData, data,
|
||||
EagRuntime.fixDateFormat(new SimpleDateFormat("MM/dd/yyyy")).format(new Date(cert.sigTimestamp)));
|
||||
}
|
||||
|
||||
public static byte[] generateSignedOffline(byte[] cert, byte[] data, String date) {
|
||||
|
|
|
@ -19,14 +19,21 @@ import net.lax1dude.eaglercraft.v1_8.EagUtils;
|
|||
/**
|
||||
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
|
@ -51,89 +58,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 +258,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);
|
||||
|
|
|
@ -113,4 +113,8 @@ public abstract class JSEaglercraftXOptsRoot implements JSObject {
|
|||
"def" }, script = "return (typeof this.localStorageNamespace === \"string\") ? this.localStorageNamespace : def;")
|
||||
public native String getLocalStorageNamespace(String defaultValue);
|
||||
|
||||
@JSBody(params = {
|
||||
"def" }, script = "return (typeof this.enableMinceraft === \"boolean\") ? this.enableMinceraft : def;")
|
||||
public native boolean getEnableMinceraft(boolean defaultValue);
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.teavm.jso.JSObject;
|
|||
import org.teavm.jso.dom.events.ErrorEvent;
|
||||
import org.teavm.jso.dom.events.EventListener;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
import org.teavm.jso.workers.Worker;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IPCPacketData;
|
||||
|
@ -23,14 +22,21 @@ import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
|||
/**
|
||||
* Copyright (c) 2023-2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
|
@ -50,7 +56,8 @@ public class ClientPlatformSingleplayer {
|
|||
@JSBody(params = {}, script = "try{throw new Error();}catch(ex){return ex.stack;}return null;")
|
||||
private static native String loadIntegratedServerSourceStack();
|
||||
|
||||
@JSBody(params = { "csc" }, script = "if(typeof csc.src === \"string\" && csc.src.length > 0) return csc.src; else return null;")
|
||||
@JSBody(params = {
|
||||
"csc" }, script = "if(typeof csc.src === \"string\" && csc.src.length > 0) return csc.src; else return null;")
|
||||
private static native String loadIntegratedServerSourceURL(JSObject scriptTag);
|
||||
|
||||
@JSBody(params = { "csc", "tail" }, script = "const cscText = csc.text;"
|
||||
|
@ -92,7 +99,7 @@ public class ClientPlatformSingleplayer {
|
|||
}
|
||||
|
||||
synchronized (messageQueue) {
|
||||
messageQueue.add(new IPCPacketData(channel, TeaVMUtils.wrapUnsignedByteArray(Uint8Array.create(buf))));
|
||||
messageQueue.add(new IPCPacketData(channel, TeaVMUtils.wrapByteArrayBuffer(buf)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +108,8 @@ public class ClientPlatformSingleplayer {
|
|||
@JSBody(params = { "blobObj" }, script = "return URL.createObjectURL(blobObj);")
|
||||
private static native String createWorkerScriptURL(JSObject blobObj);
|
||||
|
||||
@JSBody(params = { "cscText", "tail" }, script = "return new Blob([cscText, tail], { type: \"text/javascript;charset=utf8\" });")
|
||||
@JSBody(params = { "cscText",
|
||||
"tail" }, script = "return new Blob([cscText, tail], { type: \"text/javascript;charset=utf8\" });")
|
||||
private static native JSObject createBlobObj(ArrayBuffer buf, String tail);
|
||||
|
||||
private static final String workerBootstrapCode = "\n\nmain([\"_worker_process_\"]);";
|
||||
|
@ -152,7 +160,8 @@ public class ClientPlatformSingleplayer {
|
|||
}
|
||||
logger.info("Could not resolve the location of client's classes.js!");
|
||||
logger.info("Make sure client's classes.js is linked/embedded in a dedicated <script> tag");
|
||||
logger.info("Define \"window.eaglercraftXClientScriptElement\" or \"window.eaglercraftXClientScriptURL\" to force");
|
||||
logger.info(
|
||||
"Define \"window.eaglercraftXClientScriptElement\" or \"window.eaglercraftXClientScriptURL\" to force");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -179,7 +188,8 @@ public class ClientPlatformSingleplayer {
|
|||
}
|
||||
|
||||
if (integratedServerSource == null) {
|
||||
throw new RuntimeException("Could not resolve the location of client's classes.js! Make sure client's classes.js is linked/embedded in a dedicated <script> tag. Define \"window.eaglercraftXClientScriptElement\" or \"window.eaglercraftXClientScriptURL\" to force");
|
||||
throw new RuntimeException(
|
||||
"Could not resolve the location of client's classes.js! Make sure client's classes.js is linked/embedded in a dedicated <script> tag. Define \"window.eaglercraftXClientScriptElement\" or \"window.eaglercraftXClientScriptURL\" to force");
|
||||
}
|
||||
|
||||
workerObj = Worker.create(integratedServerSource);
|
||||
|
@ -196,10 +206,7 @@ public class ClientPlatformSingleplayer {
|
|||
}
|
||||
|
||||
public static void sendPacket(IPCPacketData packet) {
|
||||
ArrayBuffer arb = ArrayBuffer.create(packet.contents.length);
|
||||
Uint8Array ar = Uint8Array.create(arb);
|
||||
ar.set(packet.contents);
|
||||
sendPacketTeaVM(packet.channel, TeaVMUtils.unwrapUnsignedByteArray(packet.contents).getBuffer());
|
||||
sendPacketTeaVM(packet.channel, TeaVMUtils.unwrapArrayBuffer(packet.contents));
|
||||
}
|
||||
|
||||
public static void sendPacketTeaVM(String channel, ArrayBuffer packet) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.teavm.jso.JSBody;
|
|||
import org.teavm.jso.JSFunctor;
|
||||
import org.teavm.jso.JSObject;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IClientConfigAdapter;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IPCPacketData;
|
||||
|
@ -21,14 +20,21 @@ import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
|||
/**
|
||||
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
|
@ -58,7 +64,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 +85,7 @@ public class ServerPlatformSingleplayer {
|
|||
public static native void sendPacketTeaVM(String channel, ArrayBuffer arr);
|
||||
|
||||
public static void sendPacket(IPCPacketData packet) {
|
||||
ArrayBuffer arb = ArrayBuffer.create(packet.contents.length);
|
||||
Uint8Array ar = Uint8Array.create(arb);
|
||||
ar.set(packet.contents);
|
||||
sendPacketTeaVM(packet.channel, arb);
|
||||
sendPacketTeaVM(packet.channel, TeaVMUtils.unwrapArrayBuffer(packet.contents));
|
||||
}
|
||||
|
||||
public static List<IPCPacketData> recieveAllPacket() {
|
||||
|
|
Loading…
Reference in New Issue