Update #43 - Fix invisible block entities and other issues

This commit is contained in:
lax1dude 2024-11-20 19:39:40 -08:00
parent 6cd2eed5b3
commit 1e235f93bf
31 changed files with 237 additions and 198 deletions

View File

@ -1 +1 @@
u42 u43

View File

@ -303,7 +303,7 @@
~ this.handleMouseInput(); ~ this.handleMouseInput();
~ } ~ }
> INSERT 11 : 95 @ 11 > INSERT 11 : 96 @ 11
+ public final Map<Integer, int[]> touchStarts = new HashMap<>(); + public final Map<Integer, int[]> touchStarts = new HashMap<>();
+ +
@ -331,10 +331,11 @@
+ } + }
+ i = applyEaglerScale(scaleFac, i * this.width / this.mc.displayWidth, this.width); + i = applyEaglerScale(scaleFac, i * this.width / this.mc.displayWidth, this.width);
+ j = applyEaglerScale(scaleFac, this.height - j * this.height / this.mc.displayHeight - 1, this.height); + j = applyEaglerScale(scaleFac, this.height - j * this.height / this.mc.displayHeight - 1, this.height);
+ float si = Touch.getEventTouchRadiusX(t) * this.width / this.mc.displayWidth / scaleFac; + float rad = Touch.getEventTouchRadiusMixed(t);
+ float si = rad * this.width / this.mc.displayWidth / scaleFac;
+ if (si < 1.0f) + if (si < 1.0f)
+ si = 1.0f; + si = 1.0f;
+ float sj = Touch.getEventTouchRadiusY(t) * this.height / this.mc.displayHeight / scaleFac; + float sj = rad * this.height / this.mc.displayHeight / scaleFac;
+ if (sj < 1.0f) + if (sj < 1.0f)
+ sj = 1.0f; + sj = 1.0f;
+ int[] ck = touchStarts.remove(u); + int[] ck = touchStarts.remove(u);

View File

@ -77,17 +77,16 @@
~ if (!compiledchunk.isLayerEmpty(enumworldblocklayer)) { ~ if (!compiledchunk.isLayerEmpty(enumworldblocklayer)) {
~ this.chunkRenderDispatcher.uploadChunk(enumworldblocklayer, ~ this.chunkRenderDispatcher.uploadChunk(enumworldblocklayer,
> CHANGE 1 : 4 @ 1 : 2 > CHANGE 1 : 3 @ 1 : 2
~ generator.getRenderChunk(), compiledchunk); ~ generator.getRenderChunk(), compiledchunk);
~ generator.getRenderChunk().setCompiledChunk(compiledchunk);
~ generator.setStatus(ChunkCompileTaskGenerator.Status.DONE); ~ generator.setStatus(ChunkCompileTaskGenerator.Status.DONE);
> CHANGE 3 : 4 @ 3 : 4 > CHANGE 3 : 4 @ 3 : 4
~ this.chunkRenderDispatcher.uploadChunk( ~ this.chunkRenderDispatcher.uploadChunk(
> CHANGE 2 : 11 @ 2 : 3 > CHANGE 2 : 10 @ 2 : 3
~ generator.getRenderChunk(), compiledchunk); ~ generator.getRenderChunk(), compiledchunk);
~ if (DeferredStateManager.isRenderingRealisticWater()) { ~ if (DeferredStateManager.isRenderingRealisticWater()) {
@ -96,7 +95,6 @@
~ .getWorldRendererByLayer(EnumWorldBlockLayer.REALISTIC_WATER), ~ .getWorldRendererByLayer(EnumWorldBlockLayer.REALISTIC_WATER),
~ generator.getRenderChunk(), compiledchunk); ~ generator.getRenderChunk(), compiledchunk);
~ } ~ }
~ generator.getRenderChunk().setCompiledChunk(compiledchunk);
~ generator.setStatus(ChunkCompileTaskGenerator.Status.DONE); ~ generator.setStatus(ChunkCompileTaskGenerator.Status.DONE);
> DELETE 2 @ 2 : 42 > DELETE 2 @ 2 : 42

View File

@ -5,7 +5,9 @@
# Version: 1.0 # Version: 1.0
# Author: lax1dude # Author: lax1dude
> DELETE 2 @ 2 : 3 > CHANGE 2 : 3 @ 2 : 3
~ import java.util.Arrays;
> CHANGE 1 : 5 @ 1 : 3 > CHANGE 1 : 5 @ 1 : 3
@ -14,12 +16,17 @@
~ ~
~ import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer; ~ import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
> CHANGE 15 : 16 @ 15 : 16 > CHANGE 5 : 6 @ 5 : 6
~ public static final CompiledChunk DUMMY = new CompiledChunk(null) {
> CHANGE 9 : 10 @ 9 : 10
~ return true; ~ return true;
> CHANGE 2 : 4 @ 2 : 4 > CHANGE 2 : 5 @ 2 : 4
~ private final RenderChunk chunk;
~ private final boolean[] layersUsed = new boolean[EnumWorldBlockLayer._VALUES.length]; ~ private final boolean[] layersUsed = new boolean[EnumWorldBlockLayer._VALUES.length];
~ private final boolean[] layersStarted = new boolean[EnumWorldBlockLayer._VALUES.length]; ~ private final boolean[] layersStarted = new boolean[EnumWorldBlockLayer._VALUES.length];
@ -27,7 +34,30 @@
+ private WorldRenderer.State stateWater; + private WorldRenderer.State stateWater;
> INSERT 45 : 53 @ 45 > INSERT 1 : 15 @ 1
+ public CompiledChunk(RenderChunk chunk) {
+ this.chunk = chunk;
+ }
+
+ public void reset() {
+ Arrays.fill(layersUsed, false);
+ Arrays.fill(layersStarted, false);
+ empty = true;
+ tileEntities.clear();
+ setVisibility.setAllVisible(false);
+ setState(null);
+ setStateRealisticWater(null);
+ }
+
> INSERT 42 : 45 @ 42
+ if (this.state != stateIn && this.state != null) {
+ this.state.release();
+ }
> INSERT 2 : 13 @ 2
+ +
+ public WorldRenderer.State getStateRealisticWater() { + public WorldRenderer.State getStateRealisticWater() {
@ -35,6 +65,9 @@
+ } + }
+ +
+ public void setStateRealisticWater(WorldRenderer.State stateIn) { + public void setStateRealisticWater(WorldRenderer.State stateIn) {
+ if (this.stateWater != stateIn && this.stateWater != null) {
+ this.stateWater.release();
+ }
+ this.stateWater = stateIn; + this.stateWater = stateIn;
+ } + }

View File

@ -69,7 +69,15 @@
+ .getWorldRendererByLayer(EnumWorldBlockLayer.REALISTIC_WATER), compiledchunk); + .getWorldRendererByLayer(EnumWorldBlockLayer.REALISTIC_WATER), compiledchunk);
+ } + }
> DELETE 7 @ 7 : 8 > CHANGE 3 : 8 @ 3 : 4
~ if (compiledChunk == CompiledChunk.DUMMY) {
~ compiledChunk = new CompiledChunk(this);
~ } else {
~ compiledChunk.reset();
~ }
> DELETE 3 @ 3 : 4
> CHANGE 2 : 4 @ 2 : 11 > CHANGE 2 : 4 @ 2 : 11
@ -79,7 +87,7 @@
> INSERT 2 : 5 @ 2 > INSERT 2 : 5 @ 2
+ regionrendercache = new RegionRenderCache(this.world, blockpos.add(-1, -1, -1), blockpos1.add(1, 1, 1), 1); + regionrendercache = new RegionRenderCache(this.world, blockpos.add(-1, -1, -1), blockpos1.add(1, 1, 1), 1);
+ generator.setCompiledChunk(compiledchunk); + generator.setCompiledChunk(compiledChunk);
+ +
> CHANGE 4 : 5 @ 4 : 5 > CHANGE 4 : 5 @ 4 : 5
@ -95,15 +103,24 @@
~ TileEntity tileentity = regionrendercache.getTileEntity(blockpos$mutableblockpos); ~ TileEntity tileentity = regionrendercache.getTileEntity(blockpos$mutableblockpos);
> INSERT 21 : 34 @ 21 > CHANGE 3 : 4 @ 3 : 4
~ compiledChunk.addTileEntity(tileentity);
> CHANGE 10 : 12 @ 10 : 12
~ if (!compiledChunk.isLayerStarted(enumworldblocklayer1)) {
~ compiledChunk.setLayerStarted(enumworldblocklayer1);
> INSERT 5 : 18 @ 5
+ +
+ if (block.eaglerShadersShouldRenderGlassHighlights()) { + if (block.eaglerShadersShouldRenderGlassHighlights()) {
+ enumworldblocklayer1 = EnumWorldBlockLayer.GLASS_HIGHLIGHTS; + enumworldblocklayer1 = EnumWorldBlockLayer.GLASS_HIGHLIGHTS;
+ worldrenderer = generator.getRegionRenderCacheBuilder() + worldrenderer = generator.getRegionRenderCacheBuilder()
+ .getWorldRendererByLayerId(enumworldblocklayer1.ordinal()); + .getWorldRendererByLayerId(enumworldblocklayer1.ordinal());
+ if (!compiledchunk.isLayerStarted(enumworldblocklayer1)) { + if (!compiledChunk.isLayerStarted(enumworldblocklayer1)) {
+ compiledchunk.setLayerStarted(enumworldblocklayer1); + compiledChunk.setLayerStarted(enumworldblocklayer1);
+ this.preRenderBlocks(worldrenderer, blockpos); + this.preRenderBlocks(worldrenderer, blockpos);
+ } + }
+ +
@ -117,7 +134,21 @@
~ for (int i = 0; i < layers.length; ++i) { ~ for (int i = 0; i < layers.length; ++i) {
~ EnumWorldBlockLayer enumworldblocklayer = layers[i]; ~ EnumWorldBlockLayer enumworldblocklayer = layers[i];
> DELETE 13 @ 13 : 14 > CHANGE 1 : 2 @ 1 : 2
~ compiledChunk.setLayerUsed(enumworldblocklayer);
> CHANGE 2 : 3 @ 2 : 3
~ if (compiledChunk.isLayerStarted(enumworldblocklayer)) {
> CHANGE 2 : 3 @ 2 : 3
~ compiledChunk);
> CHANGE 4 : 5 @ 4 : 6
~ compiledChunk.setVisibility(visgraph.computeVisibility());
> CHANGE 1 : 8 @ 1 : 12 > CHANGE 1 : 8 @ 1 : 12
@ -173,10 +204,16 @@
~ compiledChunkIn.setState(worldRendererIn.func_181672_a()); ~ compiledChunkIn.setState(worldRendererIn.func_181672_a());
~ } ~ }
> CHANGE 25 : 26 @ 25 : 33 > DELETE 24 @ 24 : 35
~ this.compiledChunk = compiledChunkIn; > CHANGE 2 : 7 @ 2 : 3
> DELETE 10 @ 10 : 17 ~ if (this.compiledChunk != CompiledChunk.DUMMY) {
~ this.compiledChunk.setState(null);
~ this.compiledChunk.setStateRealisticWater(null);
~ this.compiledChunk = CompiledChunk.DUMMY;
~ }
> DELETE 5 @ 5 : 12
> EOF > EOF

View File

@ -118,7 +118,7 @@
+ public boolean hasShownProfanityFilter = false; + public boolean hasShownProfanityFilter = false;
+ public float touchControlOpacity = 1.0f; + public float touchControlOpacity = 1.0f;
+ public boolean hideDefaultUsernameWarning = false; + public boolean hideDefaultUsernameWarning = false;
+ public boolean hideVideoSettingsWarning = false; + public boolean hideVideoSettingsWarning = EagRuntime.getPlatformType() == EnumPlatformType.DESKTOP;
> CHANGE 1 : 15 @ 1 : 2 > CHANGE 1 : 15 @ 1 : 2

View File

@ -41,9 +41,10 @@
~ tileentity = (TileEntity) oclass.get(); ~ tileentity = (TileEntity) oclass.get();
> CHANGE 2 : 3 @ 2 : 3 > CHANGE 2 : 4 @ 2 : 3
~ logger.error("Could not create TileEntity", exception); ~ logger.error("Could not create TileEntity");
~ logger.error(exception);
> CHANGE 84 : 85 @ 84 : 85 > CHANGE 84 : 85 @ 84 : 85

View File

@ -22,7 +22,11 @@
+ } + }
+ +
> CHANGE 22 : 23 @ 22 : 23 > CHANGE 17 : 18 @ 17 : 18
~ this(source.x, source.y, source.z);
> CHANGE 4 : 5 @ 4 : 5
~ : new BlockPos((double) this.x + x, (double) this.y + y, (double) this.z + z); ~ : new BlockPos((double) this.x + x, (double) this.y + y, (double) this.z + z);

View File

@ -154,7 +154,11 @@
~ BlockPos blockpos$mutableblockpos = new BlockPos(); ~ BlockPos blockpos$mutableblockpos = new BlockPos();
> CHANGE 224 : 225 @ 224 : 225 > CHANGE 122 : 123 @ 122 : 123
~ tileEntityIn.setPos(new BlockPos(pos));
> CHANGE 101 : 102 @ 101 : 102
~ if (!this.provider.getHasNoSky() && this.getGameRules().getBoolean("doWeatherCycle")) { ~ if (!this.provider.getHasNoSky() && this.getGameRules().getBoolean("doWeatherCycle")) {

View File

@ -45,7 +45,11 @@
+ ++EaglerMinecraftServer.counterLightUpdate; + ++EaglerMinecraftServer.counterLightUpdate;
+ } + }
> DELETE 9 @ 9 : 10 > CHANGE 9 : 12 @ 9 : 10
~ if (!this.worldObj.isRemote) {
~ ++EaglerMinecraftServer.counterLightUpdate;
~ }
> CHANGE 10 : 13 @ 10 : 11 > CHANGE 10 : 13 @ 10 : 11
@ -158,7 +162,24 @@
+ } + }
+ +
> CHANGE 176 : 178 @ 176 : 178 > INSERT 58 : 59 @ 58
+ BlockPos pos2 = new BlockPos(blockpos);
> CHANGE 1 : 3 @ 1 : 3
~ tileentity = this.createNewTileEntity(pos2);
~ this.worldObj.setTileEntity(pos2, tileentity);
> CHANGE 1 : 2 @ 1 : 2
~ this.tileEntityPosQueue.add(pos2);
> INSERT 19 : 20 @ 19
+ blockpos = new BlockPos(blockpos);
> CHANGE 94 : 96 @ 94 : 96
~ && (predicate == null || predicate.apply((T) entity))) { ~ && (predicate == null || predicate.apply((T) entity))) {
~ list.add((T) entity); ~ list.add((T) entity);

View File

@ -679,16 +679,8 @@ public class PlatformInput {
return 0; return 0;
} }
public static float touchGetEventTouchRadiusX(int pointId) {
return 0.0f;
}
public static float touchGetEventTouchRadiusY(int pointId) {
return 0.0f;
}
public static float touchGetEventTouchRadiusMixed(int pointId) { public static float touchGetEventTouchRadiusMixed(int pointId) {
return touchGetEventTouchRadiusX(pointId) * 0.5f + touchGetEventTouchRadiusY(pointId) * 0.5f; return 0.0f;
} }
public static float touchGetEventTouchForce(int pointId) { public static float touchGetEventTouchForce(int pointId) {
@ -711,16 +703,8 @@ public class PlatformInput {
return 0; return 0;
} }
public static float touchRadiusX(int pointId) {
return 0.0f;
}
public static float touchRadiusY(int pointId) {
return 0.0f;
}
public static float touchRadiusMixed(int pointId) { public static float touchRadiusMixed(int pointId) {
return touchRadiusX(pointId) * 0.5f + touchRadiusY(pointId) * 0.5f; return 0.0f;
} }
public static float touchForce(int pointId) { public static float touchForce(int pointId) {

View File

@ -413,15 +413,11 @@ public class PlatformWebRTC {
synchronized (serverLANEventBuffer) { synchronized (serverLANEventBuffer) {
serverLANEventBuffer.put(peerId, e); serverLANEventBuffer.put(peerId, e);
} }
if (client.peerStateDesc != PEERSTATE_SUCCESS)
client.peerStateDesc = PEERSTATE_SUCCESS;
} }
@Override @Override
public void onFailure(String s) { public void onFailure(String s) {
logger.error("Failed to set local description for \"{}\"! {}", peerId, s); logger.error("Failed to set local description for \"{}\"! {}", peerId, s);
if (client.peerStateDesc == PEERSTATE_LOADING)
client.peerStateDesc = PEERSTATE_FAILED;
client.signalRemoteDisconnect(peerId); client.signalRemoteDisconnect(peerId);
} }
}); });
@ -430,8 +426,6 @@ public class PlatformWebRTC {
@Override @Override
public void onFailure(String s) { public void onFailure(String s) {
logger.error("Failed to create answer for \"{}\"! {}", peerId, s); logger.error("Failed to create answer for \"{}\"! {}", peerId, s);
if (client.peerStateDesc == PEERSTATE_LOADING)
client.peerStateDesc = PEERSTATE_FAILED;
client.signalRemoteDisconnect(peerId); client.signalRemoteDisconnect(peerId);
} }
}); });
@ -441,13 +435,11 @@ public class PlatformWebRTC {
@Override @Override
public void onFailure(String s) { public void onFailure(String s) {
logger.error("Failed to set remote description for \"{}\"! {}", peerId, s); logger.error("Failed to set remote description for \"{}\"! {}", peerId, s);
if (client.peerStateDesc == PEERSTATE_LOADING) client.peerStateDesc = PEERSTATE_FAILED;
client.signalRemoteDisconnect(peerId); client.signalRemoteDisconnect(peerId);
} }
}); });
} catch (Throwable err) { } catch (Throwable err) {
logger.error("Failed to parse remote description for \"{}\"! {}", peerId, err.getMessage()); logger.error("Failed to parse remote description for \"{}\"! {}", peerId, err.getMessage());
if (client.peerStateDesc == PEERSTATE_LOADING) client.peerStateDesc = PEERSTATE_FAILED;
client.signalRemoteDisconnect(peerId); client.signalRemoteDisconnect(peerId);
} }
} }
@ -459,10 +451,8 @@ public class PlatformWebRTC {
JSONObject candidate = jsonArray.getJSONObject(i); JSONObject candidate = jsonArray.getJSONObject(i);
peerConnection.addIceCandidate(new RTCIceCandidate(null, candidate.getInt("sdpMLineIndex"), candidate.getString("candidate"))); peerConnection.addIceCandidate(new RTCIceCandidate(null, candidate.getInt("sdpMLineIndex"), candidate.getString("candidate")));
} }
if (client.peerStateIce != PEERSTATE_SUCCESS) client.peerStateIce = PEERSTATE_SUCCESS;
} catch (Throwable err) { } catch (Throwable err) {
logger.error("Failed to parse ice candidate for \"{}\"! {}", peerId, err.getMessage()); logger.error("Failed to parse ice candidate for \"{}\"! {}", peerId, err.getMessage());
if (client.peerStateIce == PEERSTATE_LOADING) client.peerStateIce = PEERSTATE_FAILED;
client.signalRemoteDisconnect(peerId); client.signalRemoteDisconnect(peerId);
} }
} }
@ -490,11 +480,6 @@ public class PlatformWebRTC {
public Set<Map<String, String>> iceServers = new HashSet<>(); public Set<Map<String, String>> iceServers = new HashSet<>();
public Map<String, LANPeer> peerList = new HashMap<>(); public Map<String, LANPeer> peerList = new HashMap<>();
public Map<String, LANPeer> ipcMapList = new HashMap<>(); public Map<String, LANPeer> ipcMapList = new HashMap<>();
public byte peerState = PEERSTATE_LOADING;
public byte peerStateConnect = PEERSTATE_LOADING;
public byte peerStateInitial = PEERSTATE_LOADING;
public byte peerStateDesc = PEERSTATE_LOADING;
public byte peerStateIce = PEERSTATE_LOADING;
private final Object lock3 = new Object(); private final Object lock3 = new Object();
public void setIceServers(String[] urls) { public void setIceServers(String[] urls) {
@ -541,10 +526,6 @@ public class PlatformWebRTC {
} }
} }
public void resetPeerStates() {
peerState = peerStateConnect = peerStateInitial = peerStateDesc = peerStateIce = PEERSTATE_LOADING;
}
public void signalRemoteConnect(String peerId) { public void signalRemoteConnect(String peerId) {
try { try {
List<Map<String, String>> iceCandidates = new ArrayList<>(); List<Map<String, String>> iceCandidates = new ArrayList<>();
@ -597,7 +578,6 @@ public class PlatformWebRTC {
final Runnable[] retry = new Runnable[1]; final Runnable[] retry = new Runnable[1];
final int[] loopCount = new int[1]; final int[] loopCount = new int[1];
scheduleTask(-1l, retry[0] = () -> { scheduleTask(-1l, retry[0] = () -> {
int i = 0;
f: { f: {
synchronized (lock3) { synchronized (lock3) {
if (iceCandidates.isEmpty()) { if (iceCandidates.isEmpty()) {
@ -650,14 +630,7 @@ public class PlatformWebRTC {
@Override @Override
public void onConnectionChange(RTCPeerConnectionState connectionState) { public void onConnectionChange(RTCPeerConnectionState connectionState) {
if (connectionState == RTCPeerConnectionState.DISCONNECTED) { if (connectionState == RTCPeerConnectionState.DISCONNECTED || connectionState == RTCPeerConnectionState.FAILED) {
LANServer.this.signalRemoteDisconnect(peerId);
} else if (connectionState == RTCPeerConnectionState.CONNECTED) {
if (LANServer.this.peerState != PEERSTATE_SUCCESS)
LANServer.this.peerState = PEERSTATE_SUCCESS;
} else if (connectionState == RTCPeerConnectionState.FAILED) {
if (LANServer.this.peerState == PEERSTATE_LOADING)
LANServer.this.peerState = PEERSTATE_FAILED;
LANServer.this.signalRemoteDisconnect(peerId); LANServer.this.signalRemoteDisconnect(peerId);
} }
} }
@ -666,9 +639,10 @@ public class PlatformWebRTC {
synchronized(peerList) { synchronized(peerList) {
peerList.put(peerId, peerInstance[0]); peerList.put(peerId, peerInstance[0]);
} }
if (peerStateConnect != PEERSTATE_SUCCESS) peerStateConnect = PEERSTATE_SUCCESS;
} catch (Throwable e) { } catch (Throwable e) {
if (peerStateConnect == PEERSTATE_LOADING) peerStateConnect = PEERSTATE_FAILED; logger.error("Failed to create peer for \"{}\"", peerId);
logger.error(e);
signalRemoteDisconnect(peerId);
} }
} }
@ -871,7 +845,6 @@ public class PlatformWebRTC {
synchronized(serverLANEventBuffer) { synchronized(serverLANEventBuffer) {
serverLANEventBuffer.clear(); serverLANEventBuffer.clear();
} }
rtcLANServer.resetPeerStates();
rtcLANServer.setIceServers(servers); rtcLANServer.setIceServers(servers);
} }

View File

@ -25,11 +25,20 @@ public class EaglerLWJGLAllocator {
} }
} }
private static final boolean enableAllocCount = false;
private static volatile int allocCount = 0;
public static int getAllocCount() {
if(!enableAllocCount) throw new UnsupportedOperationException();
return allocCount;
}
public static ByteBuffer allocByteBuffer(int len) { public static ByteBuffer allocByteBuffer(int len) {
long ret = JEmalloc.nje_malloc(len); long ret = JEmalloc.nje_malloc(len);
if(ret == 0l) { if(ret == 0l) {
throw new OutOfMemoryError("Native je_malloc call returned null pointer!"); throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
} }
if(enableAllocCount) ++allocCount;
return new EaglerLWJGLByteBuffer(ret, len, true); return new EaglerLWJGLByteBuffer(ret, len, true);
} }
@ -38,6 +47,7 @@ public class EaglerLWJGLAllocator {
if(ret == 0l) { if(ret == 0l) {
throw new OutOfMemoryError("Native je_malloc call returned null pointer!"); throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
} }
if(enableAllocCount) ++allocCount;
return new EaglerLWJGLShortBuffer(ret, len, true); return new EaglerLWJGLShortBuffer(ret, len, true);
} }
@ -46,6 +56,7 @@ public class EaglerLWJGLAllocator {
if(ret == 0l) { if(ret == 0l) {
throw new OutOfMemoryError("Native je_malloc call returned null pointer!"); throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
} }
if(enableAllocCount) ++allocCount;
return new EaglerLWJGLIntBuffer(ret, len, true); return new EaglerLWJGLIntBuffer(ret, len, true);
} }
@ -54,6 +65,7 @@ public class EaglerLWJGLAllocator {
if(ret == 0l) { if(ret == 0l) {
throw new OutOfMemoryError("Native je_malloc call returned null pointer!"); throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
} }
if(enableAllocCount) ++allocCount;
return new EaglerLWJGLFloatBuffer(ret, len, true); return new EaglerLWJGLFloatBuffer(ret, len, true);
} }
@ -62,6 +74,7 @@ public class EaglerLWJGLAllocator {
EaglerLWJGLByteBuffer buf = (EaglerLWJGLByteBuffer)buffer; EaglerLWJGLByteBuffer buf = (EaglerLWJGLByteBuffer)buffer;
if(buf.original) { if(buf.original) {
JEmalloc.nje_free(buf.address); JEmalloc.nje_free(buf.address);
if(enableAllocCount) --allocCount;
}else { }else {
throwNotOriginal(buffer); throwNotOriginal(buffer);
} }
@ -84,6 +97,7 @@ public class EaglerLWJGLAllocator {
EaglerLWJGLShortBuffer buf = (EaglerLWJGLShortBuffer)buffer; EaglerLWJGLShortBuffer buf = (EaglerLWJGLShortBuffer)buffer;
if(buf.original) { if(buf.original) {
JEmalloc.nje_free(buf.address); JEmalloc.nje_free(buf.address);
if(enableAllocCount) --allocCount;
}else { }else {
throwNotOriginal(buffer); throwNotOriginal(buffer);
} }
@ -106,6 +120,7 @@ public class EaglerLWJGLAllocator {
EaglerLWJGLIntBuffer buf = (EaglerLWJGLIntBuffer)buffer; EaglerLWJGLIntBuffer buf = (EaglerLWJGLIntBuffer)buffer;
if(buf.original) { if(buf.original) {
JEmalloc.nje_free(buf.address); JEmalloc.nje_free(buf.address);
if(enableAllocCount) --allocCount;
}else { }else {
throwNotOriginal(buffer); throwNotOriginal(buffer);
} }
@ -128,6 +143,7 @@ public class EaglerLWJGLAllocator {
EaglerLWJGLFloatBuffer buf = (EaglerLWJGLFloatBuffer)buffer; EaglerLWJGLFloatBuffer buf = (EaglerLWJGLFloatBuffer)buffer;
if(buf.original) { if(buf.original) {
JEmalloc.nje_free(buf.address); JEmalloc.nje_free(buf.address);
if(enableAllocCount) --allocCount;
}else { }else {
throwNotOriginal(buffer); throwNotOriginal(buffer);
} }

View File

@ -10,7 +10,7 @@ public class EaglercraftVersion {
/// Customize these to fit your fork: /// Customize these to fit your fork:
public static final String projectForkName = "EaglercraftX"; public static final String projectForkName = "EaglercraftX";
public static final String projectForkVersion = "u42"; public static final String projectForkVersion = "u43";
public static final String projectForkVendor = "lax1dude"; public static final String projectForkVendor = "lax1dude";
public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";
@ -20,20 +20,20 @@ public class EaglercraftVersion {
public static final String projectOriginName = "EaglercraftX"; public static final String projectOriginName = "EaglercraftX";
public static final String projectOriginAuthor = "lax1dude"; public static final String projectOriginAuthor = "lax1dude";
public static final String projectOriginRevision = "1.8"; public static final String projectOriginRevision = "1.8";
public static final String projectOriginVersion = "u42"; public static final String projectOriginVersion = "u43";
public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace
// EPK Version Identifier // EPK Version Identifier
public static final String EPKVersionIdentifier = "u42"; // Set to null to disable EPK version check public static final String EPKVersionIdentifier = "u43"; // Set to null to disable EPK version check
// Updating configuration // Updating configuration
public static final boolean enableUpdateService = true; public static final boolean enableUpdateService = true;
public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client"; public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client";
public static final int updateBundlePackageVersionInt = 42; public static final int updateBundlePackageVersionInt = 43;
public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName; public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName;

View File

@ -31,8 +31,6 @@ import java.math.BigInteger;
import java.math.MathContext; import java.math.MathContext;
import java.nio.CharBuffer; import java.nio.CharBuffer;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.DateFormatSymbols; import java.text.DateFormatSymbols;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
@ -1449,12 +1447,7 @@ public final class HFormatter implements Closeable, Flushable {
} }
if (null == lineSeparator) { if (null == lineSeparator) {
lineSeparator = AccessController.doPrivileged(new PrivilegedAction<String>() { lineSeparator = System.getProperty("line.separator");
public String run() {
return System.getProperty("line.separator"); //$NON-NLS-1$
}
});
} }
return lineSeparator; return lineSeparator;
} }

View File

@ -40,14 +40,6 @@ public class Touch {
return PlatformInput.touchGetEventTouchY(pointId); return PlatformInput.touchGetEventTouchY(pointId);
} }
public static float getEventTouchRadiusX(int pointId) {
return PlatformInput.touchGetEventTouchRadiusX(pointId);
}
public static float getEventTouchRadiusY(int pointId) {
return PlatformInput.touchGetEventTouchRadiusY(pointId);
}
public static float getEventTouchRadiusMixed(int pointId) { public static float getEventTouchRadiusMixed(int pointId) {
return PlatformInput.touchGetEventTouchRadiusMixed(pointId); return PlatformInput.touchGetEventTouchRadiusMixed(pointId);
} }
@ -72,14 +64,6 @@ public class Touch {
return PlatformInput.touchPointY(pointId); return PlatformInput.touchPointY(pointId);
} }
public static float touchPointRadiusX(int pointId) {
return PlatformInput.touchRadiusX(pointId);
}
public static float touchPointRadiusY(int pointId) {
return PlatformInput.touchRadiusY(pointId);
}
public static float touchPointRadiusMixed(int pointId) { public static float touchPointRadiusMixed(int pointId) {
return PlatformInput.touchRadiusMixed(pointId); return PlatformInput.touchRadiusMixed(pointId);
} }

View File

@ -84,7 +84,6 @@ public class ChunkUpdateManager {
generator.setStatus(ChunkCompileTaskGenerator.Status.DONE); generator.setStatus(ChunkCompileTaskGenerator.Status.DONE);
} }
} }
generator.getRenderChunk().setCompiledChunk(compiledchunk);
} else if (chunkcompiletaskgenerator$type == ChunkCompileTaskGenerator.Type.RESORT_TRANSPARENCY) { } else if (chunkcompiletaskgenerator$type == ChunkCompileTaskGenerator.Type.RESORT_TRANSPARENCY) {
if(!compiledchunk.isLayerEmpty(EnumWorldBlockLayer.TRANSLUCENT)) { if(!compiledchunk.isLayerEmpty(EnumWorldBlockLayer.TRANSLUCENT)) {
this.uploadChunk(EnumWorldBlockLayer.TRANSLUCENT, generator.getRegionRenderCacheBuilder() this.uploadChunk(EnumWorldBlockLayer.TRANSLUCENT, generator.getRegionRenderCacheBuilder()
@ -96,7 +95,6 @@ public class ChunkUpdateManager {
.getWorldRendererByLayer(EnumWorldBlockLayer.REALISTIC_WATER), .getWorldRendererByLayer(EnumWorldBlockLayer.REALISTIC_WATER),
generator.getRenderChunk(), compiledchunk); generator.getRenderChunk(), compiledchunk);
} }
generator.getRenderChunk().setCompiledChunk(compiledchunk);
generator.setStatus(ChunkCompileTaskGenerator.Status.DONE); generator.setStatus(ChunkCompileTaskGenerator.Status.DONE);
} }
} }

View File

@ -9,6 +9,7 @@ import java.util.Comparator;
import net.lax1dude.eaglercraft.v1_8.EagRuntime; import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.vector.Vector3f; import net.lax1dude.eaglercraft.v1_8.vector.Vector3f;
import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
@ -30,6 +31,8 @@ import net.minecraft.util.MathHelper;
*/ */
public class WorldRenderer { public class WorldRenderer {
private static final Logger logger = LogManager.getLogger("WorldRenderer");
private boolean needsUpdate; private boolean needsUpdate;
private int drawMode; private int drawMode;
private double xOffset; private double xOffset;
@ -68,7 +71,7 @@ public class WorldRenderer {
int i = this.byteBuffer.capacity() >> 2; int i = this.byteBuffer.capacity() >> 2;
if (parInt1 > (i - pos)) { if (parInt1 > (i - pos)) {
int k = (((pos + parInt1 + (parInt1 >> 1)) >> 16) + 1) << 16; int k = (((pos + parInt1 + (parInt1 >> 1)) >> 16) + 1) << 16;
LogManager.getLogger() .warn("Needed to grow BufferBuilder buffer: Old size " + (i << 2) + logger.warn("Needed to grow BufferBuilder buffer: Old size " + (i << 2) +
" bytes, new size " + (k << 2) + " bytes."); " bytes, new size " + (k << 2) + " bytes.");
ByteBuffer bytebuffer = GLAllocation.createDirectByteBuffer(k << 2); ByteBuffer bytebuffer = GLAllocation.createDirectByteBuffer(k << 2);
this.byteBuffer.position(0); this.byteBuffer.position(0);
@ -139,17 +142,15 @@ public class WorldRenderer {
} }
/**
* SLOW AND STUPID UPLOAD QUEUE SYSTEM, MUST BE REPLACED
*/
public WorldRenderer.State func_181672_a() { public WorldRenderer.State func_181672_a() {
this.intBuffer.position(0);
VertexFormat fmt = this.vertexFormat; VertexFormat fmt = this.vertexFormat;
int i = (fmt.attribStride >> 2) * vertexCount; int i = (fmt.attribStride >> 2) * vertexCount;
IntBuffer buf = EagRuntime.allocateIntBuffer(i);
this.intBuffer.position(0);
this.intBuffer.limit(i); this.intBuffer.limit(i);
int[] aint = new int[i]; buf.put(this.intBuffer);
this.intBuffer.get(aint); buf.flip();
return new WorldRenderer.State(aint, fmt); return new WorldRenderer.State(buf, fmt);
} }
private static float func_181665_a(FloatBuffer parFloatBuffer, float parFloat1, float parFloat2, float parFloat3, private static float func_181665_a(FloatBuffer parFloatBuffer, float parFloat1, float parFloat2, float parFloat3,
@ -172,14 +173,14 @@ public class WorldRenderer {
return f12 * f12 + f13 * f13 + f14 * f14; return f12 * f12 + f13 * f13 + f14 * f14;
} }
/**
* SLOW AND STUPID COMPANION FUNCTION TO 'func_181672_a'
*/
public void setVertexState(WorldRenderer.State state) { public void setVertexState(WorldRenderer.State state) {
this.grow(state.getRawBuffer().length); IntBuffer buf = state.getRawBuffer();
int pp = buf.position();
this.grow(buf.remaining());
int p = intBuffer.position(); int p = intBuffer.position();
this.intBuffer.position(0); this.intBuffer.position(0);
this.intBuffer.put(state.getRawBuffer()); this.intBuffer.put(buf);
buf.position(pp);
this.intBuffer.position(p); this.intBuffer.position(p);
this.vertexCount = state.getVertexCount(); this.vertexCount = state.getVertexCount();
this.vertexFormat = state.getVertexFormat(); this.vertexFormat = state.getVertexFormat();
@ -521,24 +522,38 @@ public class WorldRenderer {
} }
public class State { public class State {
private final int[] stateRawBuffer; private final IntBuffer stateRawBuffer;
private final VertexFormat stateVertexFormat; private final VertexFormat stateVertexFormat;
private int refCount = 1;
public State(int[] parArrayOfInt, VertexFormat parVertexFormat) { public State(IntBuffer parArrayOfInt, VertexFormat parVertexFormat) {
this.stateRawBuffer = parArrayOfInt; this.stateRawBuffer = parArrayOfInt;
this.stateVertexFormat = parVertexFormat; this.stateVertexFormat = parVertexFormat;
} }
public int[] getRawBuffer() { public IntBuffer getRawBuffer() {
return this.stateRawBuffer; return this.stateRawBuffer;
} }
public int getVertexCount() { public int getVertexCount() {
return this.stateRawBuffer.length / (this.stateVertexFormat.attribStride >> 2); return this.stateRawBuffer.remaining() / (this.stateVertexFormat.attribStride >> 2);
} }
public VertexFormat getVertexFormat() { public VertexFormat getVertexFormat() {
return this.stateVertexFormat; return this.stateVertexFormat;
} }
public void retain() {
++refCount;
}
public void release() {
if(--refCount == 0) {
EagRuntime.freeIntBuffer(stateRawBuffer);
}
if(refCount < 0) {
logger.error("WorldRenderer.State released multiple times");
}
}
} }
} }

View File

@ -164,7 +164,7 @@ public class LANClientNetworkManager extends EaglercraftNetworkManager {
} }
EagUtils.sleep(20); EagUtils.sleep(20);
}while(EagRuntime.steadyTimeMillis() - lm < 5000l); }while(EagRuntime.steadyTimeMillis() - lm < 10000l);
// no channel was opened // no channel was opened
sock.writePacket(new RelayPacket06ClientFailure(ipkt.peerId)); sock.writePacket(new RelayPacket06ClientFailure(ipkt.peerId));
@ -203,7 +203,7 @@ public class LANClientNetworkManager extends EaglercraftNetworkManager {
continue mainLoop; continue mainLoop;
} }
EagUtils.sleep(20); EagUtils.sleep(20);
}while(EagRuntime.steadyTimeMillis() - lm < 5000l); }while(EagRuntime.steadyTimeMillis() - lm < 10000l);
// no ice candidates were sent // no ice candidates were sent
sock.close(); sock.close();

View File

@ -84,7 +84,7 @@ class LANClientPeer {
protected void update() { protected void update() {
if(state != CLOSED) { if(state != CLOSED) {
if(state != CONNECTED && EagRuntime.steadyTimeMillis() - startTime > 10000l) { if(state != CONNECTED && EagRuntime.steadyTimeMillis() - startTime > 13000l) {
logger.info("LAN client '{}' handshake timed out", clientId); logger.info("LAN client '{}' handshake timed out", clientId);
disconnect(); disconnect();
return; return;

View File

@ -1 +1 @@
u42 u43

Binary file not shown.

View File

@ -210,7 +210,7 @@ public class BootMenuDatastore {
TeaVMUtils.addEventListener(f, "blocked", new EventHandler() { TeaVMUtils.addEventListener(f, "blocked", new EventHandler() {
@Override @Override
public void handleEvent() { public void handleEvent() {
cb.complete(new DatabaseOpen(false, true, null, null)); cb.complete(new DatabaseOpen(false, true, "database locked", null));
} }
}); });
TeaVMUtils.addEventListener(f, "success", new EventHandler() { TeaVMUtils.addEventListener(f, "success", new EventHandler() {

View File

@ -100,7 +100,7 @@ public class PlatformAudio {
this.gain = gain; this.gain = gain;
this.pitch = pitch; this.pitch = pitch;
this.repeat = repeat; this.repeat = repeat;
source.setOnEnded(this); TeaVMUtils.addEventListener(source, "ended", this);
} }
@Override @Override
@ -249,12 +249,11 @@ public class PlatformAudio {
private static native boolean detectLoadViaAudioBufferSupport(AudioContext ctx); private static native boolean detectLoadViaAudioBufferSupport(AudioContext ctx);
private static void detectOGGSupport() { private static void detectOGGSupport() {
byte[] fileData = EagRuntime.getRequiredResourceBytes("/assets/eagler/audioctx_test_ogg.dat");
if(((TeaVMClientConfigAdapter)PlatformRuntime.getClientConfigAdapter()).isUseJOrbisAudioDecoderTeaVM()) { if(((TeaVMClientConfigAdapter)PlatformRuntime.getClientConfigAdapter()).isUseJOrbisAudioDecoderTeaVM()) {
logger.info("Note: Using embedded JOrbis OGG decoder"); logger.info("Note: Using embedded JOrbis OGG decoder");
oggSupport = false; oggSupport = false;
}else { }else {
byte[] fileData = EagRuntime.getRequiredResourceBytes("/assets/eagler/audioctx_test_ogg.dat");
try { try {
Int8Array arr = Int8Array.create(fileData.length); Int8Array arr = Int8Array.create(fileData.length);
arr.set(TeaVMUtils.unwrapByteArray(fileData), 0); arr.set(TeaVMUtils.unwrapByteArray(fileData), 0);

View File

@ -8,7 +8,6 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import net.lax1dude.eaglercraft.v1_8.internal.teavm.TeaVMUtils; import net.lax1dude.eaglercraft.v1_8.internal.teavm.TeaVMUtils;
import net.lax1dude.eaglercraft.v1_8.internal.teavm.Touch;
import net.lax1dude.eaglercraft.v1_8.internal.teavm.TouchEvent; import net.lax1dude.eaglercraft.v1_8.internal.teavm.TouchEvent;
import net.lax1dude.eaglercraft.v1_8.internal.teavm.VisualViewport; import net.lax1dude.eaglercraft.v1_8.internal.teavm.VisualViewport;
@ -102,6 +101,7 @@ public class PlatformInput {
private static EventListener<?> focus = null; private static EventListener<?> focus = null;
private static EventListener<?> blur = null; private static EventListener<?> blur = null;
private static EventListener<?> pointerlock = null; private static EventListener<?> pointerlock = null;
private static EventListener<?> fullscreen = null;
private static Map<String,LegacyKeycodeTranslator.LegacyKeycode> keyCodeTranslatorMap = null; private static Map<String,LegacyKeycodeTranslator.LegacyKeycode> keyCodeTranslatorMap = null;
@ -685,7 +685,7 @@ public class PlatformInput {
if(fullscreenSupported != FULLSCREEN_NONE) { if(fullscreenSupported != FULLSCREEN_NONE) {
fullscreenQuery = fullscreenMediaQuery(); fullscreenQuery = fullscreenMediaQuery();
if(fullscreenSupported == FULLSCREEN_CORE && (keyboardLockSupported = checkKeyboardLockSupported())) { if(fullscreenSupported == FULLSCREEN_CORE && (keyboardLockSupported = checkKeyboardLockSupported())) {
TeaVMUtils.addEventListener(fullscreenQuery, "change", new EventListener<Event>() { TeaVMUtils.addEventListener(fullscreenQuery, "change", fullscreen = new EventListener<Event>() {
@Override @Override
public void handleEvent(Event evt) { public void handleEvent(Event evt) {
if (!mediaQueryMatches(evt)) { if (!mediaQueryMatches(evt)) {
@ -840,7 +840,7 @@ public class PlatformInput {
@JSBody(params = { "e" }, script = "return (typeof e.location === \"number\") ? e.location : 0;") @JSBody(params = { "e" }, script = "return (typeof e.location === \"number\") ? e.location : 0;")
private static native int getLocationSafe(KeyboardEvent e); private static native int getLocationSafe(KeyboardEvent e);
@JSBody(params = { "el", "i", "j" }, script = "el.setSelectionRange(el, i, j)") @JSBody(params = { "el", "i", "j" }, script = "el.setSelectionRange(i, j)")
private static native boolean setSelectionRange(HTMLElement el, int i, int j); private static native boolean setSelectionRange(HTMLElement el, int i, int j);
public static int getWindowWidth() { public static int getWindowWidth() {
@ -1513,6 +1513,10 @@ public class PlatformInput {
win.getDocument().removeEventListener("pointerlockchange", pointerlock); win.getDocument().removeEventListener("pointerlockchange", pointerlock);
pointerlock = null; pointerlock = null;
} }
if(fullscreen != null) {
TeaVMUtils.removeEventListener(fullscreenQuery, "change", fullscreen);
fullscreen = null;
}
if(mouseUngrabTimeout != -1) { if(mouseUngrabTimeout != -1) {
Window.clearTimeout(mouseUngrabTimeout); Window.clearTimeout(mouseUngrabTimeout);
mouseUngrabTimeout = -1; mouseUngrabTimeout = -1;
@ -1786,19 +1790,9 @@ public class PlatformInput {
return currentTouchEvent != null ? currentTouchEvent.getEventTouches().get(pointId).posY : 0; return currentTouchEvent != null ? currentTouchEvent.getEventTouches().get(pointId).posY : 0;
} }
public static float touchGetEventTouchRadiusX(int pointId) {
return currentTouchEvent != null ? (float)currentTouchEvent.getEventTouches().get(pointId).touch.getRadiusXSafe(5.0 * windowDPI) : 1.0f;
}
public static float touchGetEventTouchRadiusY(int pointId) {
return currentTouchEvent != null ? (float)currentTouchEvent.getEventTouches().get(pointId).touch.getRadiusYSafe(5.0 * windowDPI) : 1.0f;
}
public static float touchGetEventTouchRadiusMixed(int pointId) { public static float touchGetEventTouchRadiusMixed(int pointId) {
if(currentTouchEvent != null) { if(currentTouchEvent != null) {
Touch t = currentTouchEvent.getEventTouches().get(pointId).touch; return currentTouchEvent.getEventTouches().get(pointId).radius;
double d = 5.0 * windowDPI;
return (float)(t.getRadiusXSafe(d) * 0.5 + t.getRadiusYSafe(d) * 0.5);
}else { }else {
return 1.0f; return 1.0f;
} }
@ -1834,8 +1828,7 @@ public class PlatformInput {
public static float touchRadiusMixed(int pointId) { public static float touchRadiusMixed(int pointId) {
if(currentTouchState != null) { if(currentTouchState != null) {
Touch t = currentTouchState.getTargetTouches().get(pointId).touch; return currentTouchState.getTargetTouches().get(pointId).radius;
return (float)(t.getRadiusX() * 0.5 + t.getRadiusY() * 0.5);
}else { }else {
return 1.0f; return 1.0f;
} }
@ -1907,7 +1900,7 @@ public class PlatformInput {
evt.preventDefault(); evt.preventDefault();
evt.stopPropagation(); evt.stopPropagation();
JSObject obj = evt.getTimeStamp(); JSObject obj = evt.getTimeStamp();
if(TeaVMUtils.isTruthy(obj)) { if(obj != null && TeaVMUtils.isTruthy(obj)) {
double d = ((JSNumber)obj).doubleValue(); double d = ((JSNumber)obj).doubleValue();
if(lastTouchKeyboardEvtA != 0.0 && (d - lastTouchKeyboardEvtA) < 10.0) { if(lastTouchKeyboardEvtA != 0.0 && (d - lastTouchKeyboardEvtA) < 10.0) {
return; return;
@ -1953,7 +1946,7 @@ public class PlatformInput {
shownTouchKeyboardEventWarning = true; shownTouchKeyboardEventWarning = true;
} }
JSObject obj = evt.getTimeStamp(); JSObject obj = evt.getTimeStamp();
if(TeaVMUtils.isTruthy(obj)) { if(obj != null && TeaVMUtils.isTruthy(obj)) {
double d = ((JSNumber)obj).doubleValue(); double d = ((JSNumber)obj).doubleValue();
if(lastTouchKeyboardEvtA != 0.0 && (d - lastTouchKeyboardEvtA) < 10.0) { if(lastTouchKeyboardEvtA != 0.0 && (d - lastTouchKeyboardEvtA) < 10.0) {
return; return;
@ -2013,7 +2006,7 @@ public class PlatformInput {
case "deleteByCut": case "deleteByCut":
break; break;
default: default:
PlatformRuntime.logger.info("Ingoring InputEvent.inputType \"{}\" from on-screen keyboard", evt.getInputType()); PlatformRuntime.logger.info("Ignoring InputEvent.inputType \"{}\" from on-screen keyboard", evt.getInputType());
break; break;
} }
} }
@ -2027,7 +2020,7 @@ public class PlatformInput {
PlatformRuntime.logger.info("Note: Caught legacy input events from on-screen keyboard, browser could be outdated and doesn't support beforeinput event, or does not respond to cancelling beforeinput"); PlatformRuntime.logger.info("Note: Caught legacy input events from on-screen keyboard, browser could be outdated and doesn't support beforeinput event, or does not respond to cancelling beforeinput");
shownLegacyTouchKeyboardWarning = true; shownLegacyTouchKeyboardWarning = true;
} }
if(TeaVMUtils.isTruthy(obj)) { if(obj != null && TeaVMUtils.isTruthy(obj)) {
double d = ((JSNumber)obj).doubleValue(); double d = ((JSNumber)obj).doubleValue();
if(lastTouchKeyboardEvtA != 0.0 && (d - lastTouchKeyboardEvtA) < 10.0) { if(lastTouchKeyboardEvtA != 0.0 && (d - lastTouchKeyboardEvtA) < 10.0) {
return; return;

View File

@ -252,19 +252,21 @@ public class PlatformRuntime {
} }
useVisualViewport = false; useVisualViewport = false;
if(isVisualViewportSupported()) { if(teavmCfg.isUseVisualViewportTeaVM()) {
if(isEmbeddedInBody) { if(isVisualViewportSupported()) {
useVisualViewport = true; if(isEmbeddedInBody) {
}else {
HTMLElement bodyTag = doc.getBody();
if (Math.abs(bodyTag.getClientWidth() - parent.getClientWidth()) <= 10
&& Math.abs(bodyTag.getClientHeight() - parent.getClientHeight()) <= 10) {
useVisualViewport = true; useVisualViewport = true;
}else {
HTMLElement bodyTag = doc.getBody();
if (Math.abs(bodyTag.getClientWidth() - parent.getClientWidth()) <= 10
&& Math.abs(bodyTag.getClientHeight() - parent.getClientHeight()) <= 10) {
useVisualViewport = true;
}
} }
} }
} if(useVisualViewport) {
if(useVisualViewport) { logger.info("Note: Detected game is embedded in body, some screens may be resized to window.visualViewport instead for a better mobile experience");
logger.info("Note: Detected game is embedded in body, some screens may be resized to window.visualViewport instead for a better mobile experience"); }
} }
ByteBuffer endiannessTestBytes = allocateByteBuffer(4); ByteBuffer endiannessTestBytes = allocateByteBuffer(4);

View File

@ -149,6 +149,7 @@ public class PlatformVoiceClient {
private GainNode gain = null; private GainNode gain = null;
private PannerNode panner = null; private PannerNode panner = null;
private AudioNode recNode = null; private AudioNode recNode = null;
private HTMLAudioElement mediaElement = null;
public VoicePeer(EaglercraftUUID peerId, JSObject peerConnection, boolean offer) { public VoicePeer(EaglercraftUUID peerId, JSObject peerConnection, boolean offer) {
this.peerId = peerId; this.peerId = peerId;
@ -164,10 +165,10 @@ public class PlatformVoiceClient {
}); });
TeaVMUtils.addEventListener(peerConnection, "track", (EventListener<Event>) evt -> { TeaVMUtils.addEventListener(peerConnection, "track", (EventListener<Event>) evt -> {
rawStream = getFirstStream(evt); rawStream = getFirstStream(evt);
HTMLAudioElement aud = (HTMLAudioElement) PlatformRuntime.doc.createElement("audio"); mediaElement = (HTMLAudioElement) PlatformRuntime.doc.createElement("audio");
aud.setAutoplay(true); mediaElement.setAutoplay(true);
aud.setMuted(true); mediaElement.setMuted(true);
setSrcObject(aud, rawStream); setSrcObject(mediaElement, rawStream);
handlePeerTrack(this, rawStream); handlePeerTrack(this, rawStream);
}); });

View File

@ -496,10 +496,6 @@ public class PlatformWebRTC {
} }
} }
public static final byte PEERSTATE_FAILED = 0;
public static final byte PEERSTATE_SUCCESS = 1;
public static final byte PEERSTATE_LOADING = 2;
public static class LANPeer { public static class LANPeer {
public LANServer client; public LANServer client;
public String peerId; public String peerId;
@ -575,12 +571,7 @@ public class PlatformWebRTC {
TeaVMUtils.addEventListener(peerConnection, "connectionstatechange", (EventListener<Event>) evt -> { TeaVMUtils.addEventListener(peerConnection, "connectionstatechange", (EventListener<Event>) evt -> {
String connectionState = getConnectionState(peerConnection); String connectionState = getConnectionState(peerConnection);
if ("disconnected".equals(connectionState)) { if ("disconnected".equals(connectionState) || "failed".equals(connectionState)) {
client.signalRemoteDisconnect(peerId);
} else if ("connected".equals(connectionState)) {
if (client.peerState != PEERSTATE_SUCCESS) client.peerState = PEERSTATE_SUCCESS;
} else if ("failed".equals(connectionState)) {
if (client.peerState == PEERSTATE_LOADING) client.peerState = PEERSTATE_FAILED;
client.signalRemoteDisconnect(peerId); client.signalRemoteDisconnect(peerId);
} }
}); });
@ -604,27 +595,22 @@ public class PlatformWebRTC {
synchronized(serverLANEventBuffer) { synchronized(serverLANEventBuffer) {
serverLANEventBuffer.put(peerId, e); serverLANEventBuffer.put(peerId, e);
} }
if (client.peerStateDesc != PEERSTATE_SUCCESS) client.peerStateDesc = PEERSTATE_SUCCESS;
}, err -> { }, err -> {
logger.error("Failed to set local description for \"{}\"! {}", peerId, TeaVMUtils.safeErrorMsgToString(err)); logger.error("Failed to set local description for \"{}\"! {}", peerId, TeaVMUtils.safeErrorMsgToString(err));
if (client.peerStateDesc == PEERSTATE_LOADING) client.peerStateDesc = PEERSTATE_FAILED;
client.signalRemoteDisconnect(peerId); client.signalRemoteDisconnect(peerId);
}); });
}, err -> { }, err -> {
logger.error("Failed to create answer for \"{}\"! {}", peerId, TeaVMUtils.safeErrorMsgToString(err)); logger.error("Failed to create answer for \"{}\"! {}", peerId, TeaVMUtils.safeErrorMsgToString(err));
if (client.peerStateDesc == PEERSTATE_LOADING) client.peerStateDesc = PEERSTATE_FAILED;
client.signalRemoteDisconnect(peerId); client.signalRemoteDisconnect(peerId);
}); });
} }
}, err -> { }, err -> {
logger.error("Failed to set remote description for \"{}\"! {}", peerId, TeaVMUtils.safeErrorMsgToString(err)); logger.error("Failed to set remote description for \"{}\"! {}", peerId, TeaVMUtils.safeErrorMsgToString(err));
if (client.peerStateDesc == PEERSTATE_LOADING) client.peerStateDesc = PEERSTATE_FAILED;
client.signalRemoteDisconnect(peerId); client.signalRemoteDisconnect(peerId);
}); });
} catch (Throwable err) { } catch (Throwable err) {
logger.error("Failed to parse remote description for \"{}\"! {}", peerId, err.getMessage()); logger.error("Failed to parse remote description for \"{}\"! {}", peerId, err.getMessage());
logger.error(err); logger.error(err);
if (client.peerStateDesc == PEERSTATE_LOADING) client.peerStateDesc = PEERSTATE_FAILED;
client.signalRemoteDisconnect(peerId); client.signalRemoteDisconnect(peerId);
} }
} }
@ -632,10 +618,8 @@ public class PlatformWebRTC {
public void addICECandidate(String candidates) { public void addICECandidate(String candidates) {
try { try {
addIceCandidates(peerConnection, candidates); addIceCandidates(peerConnection, candidates);
if (client.peerStateIce != PEERSTATE_SUCCESS) client.peerStateIce = PEERSTATE_SUCCESS;
} catch (Throwable err) { } catch (Throwable err) {
logger.error("Failed to parse ice candidate for \"{}\"! {}", peerId, err.getMessage()); logger.error("Failed to parse ice candidate for \"{}\"! {}", peerId, err.getMessage());
if (client.peerStateIce == PEERSTATE_LOADING) client.peerStateIce = PEERSTATE_FAILED;
client.signalRemoteDisconnect(peerId); client.signalRemoteDisconnect(peerId);
} }
} }
@ -659,11 +643,6 @@ public class PlatformWebRTC {
public Set<Map<String, String>> iceServers = new HashSet<>(); public Set<Map<String, String>> iceServers = new HashSet<>();
public Map<String, LANPeer> peerList = new HashMap<>(); public Map<String, LANPeer> peerList = new HashMap<>();
public Map<String, LANPeer> ipcMapList = new HashMap<>(); public Map<String, LANPeer> ipcMapList = new HashMap<>();
public byte peerState = PEERSTATE_LOADING;
public byte peerStateConnect = PEERSTATE_LOADING;
public byte peerStateInitial = PEERSTATE_LOADING;
public byte peerStateDesc = PEERSTATE_LOADING;
public byte peerStateIce = PEERSTATE_LOADING;
public void setIceServers(String[] urls) { public void setIceServers(String[] urls) {
iceServers.clear(); iceServers.clear();
@ -706,18 +685,15 @@ public class PlatformWebRTC {
} }
} }
public void resetPeerStates() {
peerState = peerStateConnect = peerStateInitial = peerStateDesc = peerStateIce = PEERSTATE_LOADING;
}
public void signalRemoteConnect(String peerId) { public void signalRemoteConnect(String peerId) {
try { try {
JSObject peerConnection = createRTCPeerConnection(JSONWriter.valueToString(iceServers)); JSObject peerConnection = createRTCPeerConnection(JSONWriter.valueToString(iceServers));
LANPeer peerInstance = new LANPeer(this, peerId, peerConnection); LANPeer peerInstance = new LANPeer(this, peerId, peerConnection);
peerList.put(peerId, peerInstance); peerList.put(peerId, peerInstance);
if (peerStateConnect != PEERSTATE_SUCCESS) peerStateConnect = PEERSTATE_SUCCESS;
} catch (Throwable e) { } catch (Throwable e) {
if (peerStateConnect == PEERSTATE_LOADING) peerStateConnect = PEERSTATE_FAILED; logger.error("Failed to create peer for \"{}\"", peerId);
logger.error(e);
signalRemoteDisconnect(peerId);
} }
} }
@ -907,7 +883,6 @@ public class PlatformWebRTC {
synchronized(serverLANEventBuffer) { synchronized(serverLANEventBuffer) {
serverLANEventBuffer.clear(); serverLANEventBuffer.clear();
} }
rtcLANServer.resetPeerStates();
rtcLANServer.setIceServers(servers); rtcLANServer.setIceServers(servers);
} }

View File

@ -205,7 +205,7 @@ public class IndexedDBFilesystem implements IEaglerFilesystem {
TeaVMUtils.addEventListener(f, "blocked", new EventHandler() { TeaVMUtils.addEventListener(f, "blocked", new EventHandler() {
@Override @Override
public void handleEvent() { public void handleEvent() {
cb.complete(new DatabaseOpen(false, true, null, null)); cb.complete(new DatabaseOpen(false, true, "database locked", null));
} }
}); });
TeaVMUtils.addEventListener(f, "success", new EventHandler() { TeaVMUtils.addEventListener(f, "success", new EventHandler() {

View File

@ -24,19 +24,23 @@ public class OffsetTouch {
public final int eventUID; public final int eventUID;
public final int posX; public final int posX;
public final int posY; public final int posY;
public final float radius;
public OffsetTouch(Touch touch, int eventUID, int posX, int posY) { public OffsetTouch(Touch touch, int eventUID, int posX, int posY, float radius) {
this.touch = touch; this.touch = touch;
this.eventUID = eventUID; this.eventUID = eventUID;
this.posX = posX; this.posX = posX;
this.posY = posY; this.posY = posY;
this.radius = radius;
} }
public static OffsetTouch create(Touch touch, ITouchUIDMapper mapper, int originX, int originY) { public static OffsetTouch create(Touch touch, ITouchUIDMapper mapper, int originX, int originY) {
double contentScale = PlatformInput.getDPI(); double contentScale = PlatformInput.getDPI();
double d = 5.0 * contentScale;
OffsetTouch ot = new OffsetTouch(touch, mapper.call(touch.getIdentifier()), OffsetTouch ot = new OffsetTouch(touch, mapper.call(touch.getIdentifier()),
(int) ((touch.getPageX() - originX) * contentScale), (int) ((touch.getPageX() - originX) * contentScale),
PlatformInput.getWindowHeight() - (int) ((touch.getPageY() - originY) * contentScale) - 1); PlatformInput.getWindowHeight() - (int) ((touch.getPageY() - originY) * contentScale) - 1,
(float)(touch.getRadiusXSafe(d) * 0.5 + touch.getRadiusYSafe(d) * 0.5));
return ot; return ot;
} }

View File

@ -52,6 +52,9 @@ public class TeaVMUtils {
@JSBody(params = { "obj", "name", "handler" }, script = "obj.addEventListener(name, handler);") @JSBody(params = { "obj", "name", "handler" }, script = "obj.addEventListener(name, handler);")
public static native void addEventListener(JSObject obj, String name, JSObject handler); public static native void addEventListener(JSObject obj, String name, JSObject handler);
@JSBody(params = { "obj", "name", "handler" }, script = "obj.removeEventListener(name, handler);")
public static native void removeEventListener(JSObject obj, String name, JSObject handler);
@JSBody(params = {}, script = "return (new Error()).stack;") @JSBody(params = {}, script = "return (new Error()).stack;")
public static native String dumpJSStackTrace(); public static native String dumpJSStackTrace();