This commit is contained in:
eaglercraft 2024-11-20 20:24:20 -08:00
parent fef7defbe7
commit 8b8ae0669a
30 changed files with 169 additions and 198 deletions

View File

@ -1 +1 @@
u42 u43

View File

@ -600,10 +600,11 @@ public abstract class GuiScreen extends Gui implements GuiYesNoCallback {
} }
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

@ -92,7 +92,6 @@ public class ChunkRenderWorker {
this.chunkRenderDispatcher.uploadChunk(enumworldblocklayer, this.chunkRenderDispatcher.uploadChunk(enumworldblocklayer,
generator.getRegionRenderCacheBuilder().getWorldRendererByLayer(enumworldblocklayer), generator.getRegionRenderCacheBuilder().getWorldRendererByLayer(enumworldblocklayer),
generator.getRenderChunk(), compiledchunk); generator.getRenderChunk(), compiledchunk);
generator.getRenderChunk().setCompiledChunk(compiledchunk);
generator.setStatus(ChunkCompileTaskGenerator.Status.DONE); generator.setStatus(ChunkCompileTaskGenerator.Status.DONE);
} }
} }
@ -107,7 +106,6 @@ public class ChunkRenderWorker {
.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

@ -1,5 +1,6 @@
package net.minecraft.client.renderer.chunk; package net.minecraft.client.renderer.chunk;
import java.util.Arrays;
import java.util.List; import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -30,7 +31,7 @@ import net.minecraft.util.EnumWorldBlockLayer;
* *
*/ */
public class CompiledChunk { public class CompiledChunk {
public static final CompiledChunk DUMMY = new CompiledChunk() { public static final CompiledChunk DUMMY = new CompiledChunk(null) {
protected void setLayerUsed(EnumWorldBlockLayer layer) { protected void setLayerUsed(EnumWorldBlockLayer layer) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@ -43,6 +44,7 @@ public class CompiledChunk {
return true; return true;
} }
}; };
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];
private boolean empty = true; private boolean empty = true;
@ -51,6 +53,20 @@ public class CompiledChunk {
private WorldRenderer.State state; private WorldRenderer.State state;
private WorldRenderer.State stateWater; private WorldRenderer.State stateWater;
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);
}
public boolean isEmpty() { public boolean isEmpty() {
return this.empty; return this.empty;
} }
@ -93,6 +109,9 @@ public class CompiledChunk {
} }
public void setState(WorldRenderer.State stateIn) { public void setState(WorldRenderer.State stateIn) {
if (this.state != stateIn && this.state != null) {
this.state.release();
}
this.state = stateIn; this.state = stateIn;
} }
@ -101,6 +120,9 @@ public class CompiledChunk {
} }
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

@ -131,7 +131,11 @@ public class RenderChunk {
} }
public void rebuildChunk(float x, float y, float z, ChunkCompileTaskGenerator generator) { public void rebuildChunk(float x, float y, float z, ChunkCompileTaskGenerator generator) {
CompiledChunk compiledchunk = new CompiledChunk(); if (compiledChunk == CompiledChunk.DUMMY) {
compiledChunk = new CompiledChunk(this);
} else {
compiledChunk.reset();
}
boolean flag = true; boolean flag = true;
BlockPos blockpos = this.position; BlockPos blockpos = this.position;
BlockPos blockpos1 = blockpos.add(15, 15, 15); BlockPos blockpos1 = blockpos.add(15, 15, 15);
@ -142,7 +146,7 @@ public class RenderChunk {
} }
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);
VisGraph visgraph = new VisGraph(); VisGraph visgraph = new VisGraph();
HashSet hashset = Sets.newHashSet(); HashSet hashset = Sets.newHashSet();
@ -163,7 +167,7 @@ public class RenderChunk {
TileEntitySpecialRenderer tileentityspecialrenderer = TileEntityRendererDispatcher.instance TileEntitySpecialRenderer tileentityspecialrenderer = TileEntityRendererDispatcher.instance
.getSpecialRenderer(tileentity); .getSpecialRenderer(tileentity);
if (tileentity != null && tileentityspecialrenderer != null) { if (tileentity != null && tileentityspecialrenderer != null) {
compiledchunk.addTileEntity(tileentity); compiledChunk.addTileEntity(tileentity);
if (tileentityspecialrenderer.func_181055_a()) { if (tileentityspecialrenderer.func_181055_a()) {
hashset.add(tileentity); hashset.add(tileentity);
} }
@ -174,8 +178,8 @@ public class RenderChunk {
int i = enumworldblocklayer1.ordinal(); int i = enumworldblocklayer1.ordinal();
if (block.getRenderType() != -1) { if (block.getRenderType() != -1) {
WorldRenderer worldrenderer = generator.getRegionRenderCacheBuilder().getWorldRendererByLayerId(i); WorldRenderer worldrenderer = generator.getRegionRenderCacheBuilder().getWorldRendererByLayerId(i);
if (!compiledchunk.isLayerStarted(enumworldblocklayer1)) { if (!compiledChunk.isLayerStarted(enumworldblocklayer1)) {
compiledchunk.setLayerStarted(enumworldblocklayer1); compiledChunk.setLayerStarted(enumworldblocklayer1);
this.preRenderBlocks(worldrenderer, blockpos); this.preRenderBlocks(worldrenderer, blockpos);
} }
@ -186,8 +190,8 @@ public class RenderChunk {
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);
} }
@ -201,18 +205,18 @@ public class RenderChunk {
for (int i = 0; i < layers.length; ++i) { for (int i = 0; i < layers.length; ++i) {
EnumWorldBlockLayer enumworldblocklayer = layers[i]; EnumWorldBlockLayer enumworldblocklayer = layers[i];
if (aboolean[enumworldblocklayer.ordinal()]) { if (aboolean[enumworldblocklayer.ordinal()]) {
compiledchunk.setLayerUsed(enumworldblocklayer); compiledChunk.setLayerUsed(enumworldblocklayer);
} }
if (compiledchunk.isLayerStarted(enumworldblocklayer)) { if (compiledChunk.isLayerStarted(enumworldblocklayer)) {
this.postRenderBlocks(enumworldblocklayer, x, y, z, this.postRenderBlocks(enumworldblocklayer, x, y, z,
generator.getRegionRenderCacheBuilder().getWorldRendererByLayer(enumworldblocklayer), generator.getRegionRenderCacheBuilder().getWorldRendererByLayer(enumworldblocklayer),
compiledchunk); compiledChunk);
} }
} }
} }
compiledchunk.setVisibility(visgraph.computeVisibility()); compiledChunk.setVisibility(visgraph.computeVisibility());
HashSet hashset1 = Sets.newHashSet(hashset); HashSet hashset1 = Sets.newHashSet(hashset);
HashSet hashset2 = Sets.newHashSet(this.field_181056_j); HashSet hashset2 = Sets.newHashSet(this.field_181056_j);
@ -287,13 +291,13 @@ public class RenderChunk {
return this.compiledChunk; return this.compiledChunk;
} }
public void setCompiledChunk(CompiledChunk compiledChunkIn) {
this.compiledChunk = compiledChunkIn;
}
public void stopCompileTask() { public void stopCompileTask() {
this.finishCompileTask(); this.finishCompileTask();
this.compiledChunk = CompiledChunk.DUMMY; if (this.compiledChunk != CompiledChunk.DUMMY) {
this.compiledChunk.setState(null);
this.compiledChunk.setStateRealisticWater(null);
this.compiledChunk = CompiledChunk.DUMMY;
}
} }
public void deleteGlResources() { public void deleteGlResources() {

View File

@ -213,7 +213,7 @@ public class GameSettings {
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;
public int voiceListenRadius = 16; public int voiceListenRadius = 16;
public float voiceListenVolume = 0.5f; public float voiceListenVolume = 0.5f;

View File

@ -115,7 +115,8 @@ public abstract class TileEntity {
tileentity = (TileEntity) oclass.get(); tileentity = (TileEntity) oclass.get();
} }
} catch (Exception exception) { } catch (Exception exception) {
logger.error("Could not create TileEntity", exception); logger.error("Could not create TileEntity");
logger.error(exception);
} }
if (tileentity != null) { if (tileentity != null) {

View File

@ -61,7 +61,7 @@ public class BlockPos extends Vec3i {
} }
public BlockPos(Vec3i source) { public BlockPos(Vec3i source) {
this(source.getX(), source.getY(), source.getZ()); this(source.x, source.y, source.z);
} }
/**+ /**+

View File

@ -1929,7 +1929,7 @@ public abstract class World implements IBlockAccess {
public void setTileEntity(BlockPos pos, TileEntity tileEntityIn) { public void setTileEntity(BlockPos pos, TileEntity tileEntityIn) {
if (tileEntityIn != null && !tileEntityIn.isInvalid()) { if (tileEntityIn != null && !tileEntityIn.isInvalid()) {
if (this.processingLoadedTiles) { if (this.processingLoadedTiles) {
tileEntityIn.setPos(pos); tileEntityIn.setPos(new BlockPos(pos));
Iterator iterator = this.addedTileEntityList.iterator(); Iterator iterator = this.addedTileEntityList.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {

View File

@ -261,6 +261,9 @@ public class Chunk {
} }
private void recheckGaps(boolean parFlag) { private void recheckGaps(boolean parFlag) {
if (!this.worldObj.isRemote) {
++EaglerMinecraftServer.counterLightUpdate;
}
if (this.worldObj.isAreaLoaded(new BlockPos(this.xPosition * 16 + 8, 0, this.zPosition * 16 + 8), 16)) { if (this.worldObj.isAreaLoaded(new BlockPos(this.xPosition * 16 + 8, 0, this.zPosition * 16 + 8), 16)) {
for (int i = 0; i < 16; ++i) { for (int i = 0; i < 16; ++i) {
for (int j = 0; j < 16; ++j) { for (int j = 0; j < 16; ++j) {
@ -766,11 +769,12 @@ public class Chunk {
public TileEntity getTileEntity(BlockPos blockpos, Chunk.EnumCreateEntityType chunk$enumcreateentitytype) { public TileEntity getTileEntity(BlockPos blockpos, Chunk.EnumCreateEntityType chunk$enumcreateentitytype) {
TileEntity tileentity = (TileEntity) this.chunkTileEntityMap.get(blockpos); TileEntity tileentity = (TileEntity) this.chunkTileEntityMap.get(blockpos);
if (tileentity == null) { if (tileentity == null) {
BlockPos pos2 = new BlockPos(blockpos);
if (chunk$enumcreateentitytype == Chunk.EnumCreateEntityType.IMMEDIATE) { if (chunk$enumcreateentitytype == Chunk.EnumCreateEntityType.IMMEDIATE) {
tileentity = this.createNewTileEntity(blockpos); tileentity = this.createNewTileEntity(pos2);
this.worldObj.setTileEntity(blockpos, tileentity); this.worldObj.setTileEntity(pos2, tileentity);
} else if (chunk$enumcreateentitytype == Chunk.EnumCreateEntityType.QUEUED) { } else if (chunk$enumcreateentitytype == Chunk.EnumCreateEntityType.QUEUED) {
this.tileEntityPosQueue.add(blockpos); this.tileEntityPosQueue.add(pos2);
} }
} else if (tileentity.isInvalid()) { } else if (tileentity.isInvalid()) {
this.chunkTileEntityMap.remove(blockpos); this.chunkTileEntityMap.remove(blockpos);
@ -790,6 +794,7 @@ public class Chunk {
public void addTileEntity(BlockPos blockpos, TileEntity tileentity) { public void addTileEntity(BlockPos blockpos, TileEntity tileentity) {
tileentity.setWorldObj(this.worldObj); tileentity.setWorldObj(this.worldObj);
blockpos = new BlockPos(blockpos);
tileentity.setPos(blockpos); tileentity.setPos(blockpos);
if (this.getBlock(blockpos) instanceof ITileEntityProvider) { if (this.getBlock(blockpos) instanceof ITileEntityProvider) {
if (this.chunkTileEntityMap.containsKey(blockpos)) { if (this.chunkTileEntityMap.containsKey(blockpos)) {

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

@ -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();