Update #41 - Fix swords unable to break blocks in survival

This commit is contained in:
lax1dude
2024-11-08 22:13:23 -08:00
parent 79eae996fd
commit 6d8df8128f
19 changed files with 302 additions and 99 deletions

View File

@ -268,51 +268,53 @@ public class PlatformRuntime {
glfwSwapInterval(0);
KHRDebug.glDebugMessageCallbackKHR(new GLDebugMessageKHRCallbackI() {
@Override
public void invoke(int source, int type, int id, int severity, int length, long message, long userParam) {
StringBuilder b = new StringBuilder();
b.append("[KHR DEBUG #"); b.append(id); b.append("] ");
switch(source) {
case KHRDebug.GL_DEBUG_SOURCE_API_KHR: b.append("[API - "); break;
case KHRDebug.GL_DEBUG_SOURCE_APPLICATION_KHR: b.append("[APPLICATION - "); break;
case KHRDebug.GL_DEBUG_SOURCE_SHADER_COMPILER_KHR: b.append("[SHADER COMPILER - "); break;
case KHRDebug.GL_DEBUG_SOURCE_THIRD_PARTY_KHR: b.append("[THIRD PARTY - "); break;
case KHRDebug.GL_DEBUG_SOURCE_OTHER_KHR: default: b.append("[OTHER - "); break;
if(!requestedDisableKHRDebug) {
KHRDebug.glDebugMessageCallbackKHR(new GLDebugMessageKHRCallbackI() {
@Override
public void invoke(int source, int type, int id, int severity, int length, long message, long userParam) {
StringBuilder b = new StringBuilder();
b.append("[KHR DEBUG #"); b.append(id); b.append("] ");
switch(source) {
case KHRDebug.GL_DEBUG_SOURCE_API_KHR: b.append("[API - "); break;
case KHRDebug.GL_DEBUG_SOURCE_APPLICATION_KHR: b.append("[APPLICATION - "); break;
case KHRDebug.GL_DEBUG_SOURCE_SHADER_COMPILER_KHR: b.append("[SHADER COMPILER - "); break;
case KHRDebug.GL_DEBUG_SOURCE_THIRD_PARTY_KHR: b.append("[THIRD PARTY - "); break;
case KHRDebug.GL_DEBUG_SOURCE_OTHER_KHR: default: b.append("[OTHER - "); break;
}
switch(type) {
case KHRDebug.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR: b.append("DEPRECATED BEHAVIOR] "); break;
case KHRDebug.GL_DEBUG_TYPE_ERROR_KHR: b.append("ERROR] "); break;
default:
case KHRDebug.GL_DEBUG_TYPE_OTHER_KHR: b.append("OTHER] "); break;
case KHRDebug.GL_DEBUG_TYPE_PERFORMANCE_KHR: b.append("PERFORMANCE] "); break;
case KHRDebug.GL_DEBUG_TYPE_PORTABILITY_KHR: b.append("PORTABILITY] "); break;
case KHRDebug.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR: b.append("UNDEFINED BEHAVIOR] "); break;
}
switch(severity) {
default:
case KHRDebug.GL_DEBUG_SEVERITY_LOW_KHR: b.append("[LOW Severity] "); break;
case KHRDebug.GL_DEBUG_SEVERITY_MEDIUM_KHR: b.append("[MEDIUM Severity] "); break;
case KHRDebug.GL_DEBUG_SEVERITY_HIGH_KHR: b.append("[SEVERE] "); break;
}
String message2 = GLDebugMessageKHRCallback.getMessage(length, message);
if(message2.contains("GPU stall due to ReadPixels")) return;
b.append(message2);
logger.error(b.toString());
StackTraceElement[] ex = new RuntimeException().getStackTrace();
for(int i = 0; i < ex.length; ++i) {
logger.error(" at {}", ex[i]);
}
}
switch(type) {
case KHRDebug.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR: b.append("DEPRECATED BEHAVIOR] "); break;
case KHRDebug.GL_DEBUG_TYPE_ERROR_KHR: b.append("ERROR] "); break;
default:
case KHRDebug.GL_DEBUG_TYPE_OTHER_KHR: b.append("OTHER] "); break;
case KHRDebug.GL_DEBUG_TYPE_PERFORMANCE_KHR: b.append("PERFORMANCE] "); break;
case KHRDebug.GL_DEBUG_TYPE_PORTABILITY_KHR: b.append("PORTABILITY] "); break;
case KHRDebug.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR: b.append("UNDEFINED BEHAVIOR] "); break;
}
switch(severity) {
default:
case KHRDebug.GL_DEBUG_SEVERITY_LOW_KHR: b.append("[LOW Severity] "); break;
case KHRDebug.GL_DEBUG_SEVERITY_MEDIUM_KHR: b.append("[MEDIUM Severity] "); break;
case KHRDebug.GL_DEBUG_SEVERITY_HIGH_KHR: b.append("[SEVERE] "); break;
}
String message2 = GLDebugMessageKHRCallback.getMessage(length, message);
if(message2.contains("GPU stall due to ReadPixels")) return;
b.append(message2);
logger.error(b.toString());
StackTraceElement[] ex = new RuntimeException().getStackTrace();
for(int i = 0; i < ex.length; ++i) {
logger.error(" at {}", ex[i]);
}
}
}, 0l);
GLES30.glEnable(KHRDebug.GL_DEBUG_OUTPUT_KHR);
GLES30.glEnable(KHRDebug.GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR);
}, 0l);
GLES30.glEnable(KHRDebug.GL_DEBUG_OUTPUT_KHR);
GLES30.glEnable(KHRDebug.GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR);
}
logger.info("Initializing Audio...");
PlatformAudio.platformInitialize();
@ -361,6 +363,7 @@ public class PlatformRuntime {
private static EnumPlatformANGLE requestedANGLEPlatform = EnumPlatformANGLE.DEFAULT;
private static int requestedGLVersion = 300;
private static boolean requestedDisableKHRDebug = false;
public static void requestANGLE(EnumPlatformANGLE plaf) {
requestedANGLEPlatform = plaf;
@ -370,6 +373,10 @@ public class PlatformRuntime {
requestedGLVersion = i;
}
public static void requestDisableKHRDebug(boolean dis) {
requestedDisableKHRDebug = dis;
}
public static EnumPlatformANGLE getPlatformANGLE() {
return rendererANGLEPlatform;
}

View File

@ -3,7 +3,6 @@ package net.lax1dude.eaglercraft.v1_8.internal;
import dev.onvoid.webrtc.*;
import dev.onvoid.webrtc.internal.NativeLoader;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.EagUtils;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.sp.lan.LANPeerEvent;
@ -257,14 +256,19 @@ public class PlatformWebRTC {
@Override
public void onStateChange() {
if (dataChannel != null && dataChannel.getState() == RTCDataChannelState.OPEN) {
scheduleTask(-1l, () -> {
while (true) {
final Runnable[] retry = new Runnable[1];
final int[] loopCount = new int[1];
scheduleTask(-1l, retry[0] = () -> {
f: {
synchronized (lock1) {
if (iceCandidates.isEmpty()) {
break;
break f;
}
}
EagUtils.sleep(1);
if(++loopCount[0] < 5) {
scheduleTask(1000l, retry[0]);
}
return;
}
synchronized (lock2) {
clientDataChannelClosed = false;
@ -562,14 +566,20 @@ public class PlatformWebRTC {
@Override
public void onDataChannel(RTCDataChannel dataChannel) {
scheduleTask(-1l, () -> {
while (true) {
final Runnable[] retry = new Runnable[1];
final int[] loopCount = new int[1];
scheduleTask(-1l, retry[0] = () -> {
int i = 0;
f: {
synchronized (lock3) {
if (iceCandidates.isEmpty()) {
break;
break f;
}
}
EagUtils.sleep(1);
if(++loopCount[0] < 5) {
scheduleTask(1000l, retry[0]);
}
return;
}
if (dataChannel == null) return;
synchronized (fuckTeaVM) {

View File

@ -87,6 +87,8 @@ public class LWJGLEntryPoint {
PlatformRuntime.requestGL(300);
}else if(args[i].equalsIgnoreCase("gles=310")) {
PlatformRuntime.requestGL(310);
}else if(args[i].equalsIgnoreCase("disableKHRDebug")) {
PlatformRuntime.requestDisableKHRDebug(true);
}else {
EnumPlatformANGLE angle = EnumPlatformANGLE.fromId(args[i]);
if(angle != EnumPlatformANGLE.DEFAULT) {

View File

@ -10,7 +10,7 @@ public class EaglercraftVersion {
/// Customize these to fit your fork:
public static final String projectForkName = "EaglercraftX";
public static final String projectForkVersion = "u40";
public static final String projectForkVersion = "u41";
public static final String projectForkVendor = "lax1dude";
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 projectOriginAuthor = "lax1dude";
public static final String projectOriginRevision = "1.8";
public static final String projectOriginVersion = "u40";
public static final String projectOriginVersion = "u41";
public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace
// EPK Version Identifier
public static final String EPKVersionIdentifier = "u40"; // Set to null to disable EPK version check
public static final String EPKVersionIdentifier = "u41"; // Set to null to disable EPK version check
// Updating configuration
public static final boolean enableUpdateService = true;
public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client";
public static final int updateBundlePackageVersionInt = 40;
public static final int updateBundlePackageVersionInt = 41;
public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName;

View File

@ -0,0 +1,114 @@
package net.lax1dude.eaglercraft.v1_8.minecraft;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.EnumChatFormatting;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class GuiScreenVideoSettingsWarning extends GuiScreen {
private final GuiScreen cont;
private final int mask;
private final List<String> messages = new ArrayList<>();
private int top = 0;
public static final int WARNING_VSYNC = 1;
public static final int WARNING_RENDER_DISTANCE = 2;
public static final int WARNING_FRAME_LIMIT = 4;
public GuiScreenVideoSettingsWarning(GuiScreen cont, int mask) {
this.cont = cont;
this.mask = mask;
}
public void initGui() {
messages.clear();
messages.add(EnumChatFormatting.RED + I18n.format("options.badVideoSettingsDetected.title"));
messages.add(null);
messages.add(EnumChatFormatting.GRAY + I18n.format("options.badVideoSettingsDetected.0"));
messages.add(EnumChatFormatting.GRAY + I18n.format("options.badVideoSettingsDetected.1"));
if((mask & WARNING_VSYNC) != 0) {
messages.add(null);
messages.add(I18n.format("options.badVideoSettingsDetected.vsync.0"));
messages.add(I18n.format("options.badVideoSettingsDetected.vsync.1"));
messages.add(I18n.format("options.badVideoSettingsDetected.vsync.2"));
messages.add(I18n.format("options.badVideoSettingsDetected.vsync.3"));
messages.add(I18n.format("options.badVideoSettingsDetected.vsync.4"));
}
if((mask & WARNING_RENDER_DISTANCE) != 0) {
messages.add(null);
messages.add(I18n.format("options.badVideoSettingsDetected.renderDistance.0", mc.gameSettings.renderDistanceChunks));
messages.add(I18n.format("options.badVideoSettingsDetected.renderDistance.1"));
messages.add(I18n.format("options.badVideoSettingsDetected.renderDistance.2"));
}
if((mask & WARNING_FRAME_LIMIT) != 0) {
messages.add(null);
messages.add(I18n.format("options.badVideoSettingsDetected.frameLimit.0", mc.gameSettings.limitFramerate));
}
int j = 0;
for(int i = 0, l = messages.size(); i < l; ++i) {
if(messages.get(i) != null) {
j += 9;
}else {
j += 5;
}
}
top = this.height / 6 + j / -12;
j += top;
buttonList.clear();
buttonList.add(new GuiButton(0, this.width / 2 - 100, j + 16, I18n.format("options.badVideoSettingsDetected.fixSettings")));
buttonList.add(new GuiButton(1, this.width / 2 - 100, j + 40, I18n.format("options.badVideoSettingsDetected.continueAnyway")));
buttonList.add(new GuiButton(2, this.width / 2 - 100, j + 64, I18n.format("options.badVideoSettingsDetected.doNotShowAgain")));
}
public void drawScreen(int par1, int par2, float par3) {
this.drawDefaultBackground();
int j = 0;
for(int i = 0, l = messages.size(); i < l; ++i) {
String str = messages.get(i);
if(str != null) {
this.drawCenteredString(fontRendererObj, str, this.width / 2, top + j, 16777215);
j += 9;
}else {
j += 5;
}
}
super.drawScreen(par1, par2, par3);
}
protected void actionPerformed(GuiButton par1GuiButton) {
if(par1GuiButton.id == 0) {
mc.gameSettings.fixBadVideoSettings();
mc.gameSettings.saveOptions();
if((mask & WARNING_RENDER_DISTANCE) != 0) {
mc.renderGlobal.loadRenderers();
}
mc.displayGuiScreen(cont);
}else if(par1GuiButton.id == 1) {
mc.displayGuiScreen(cont);
}else if(par1GuiButton.id == 2) {
mc.gameSettings.hideVideoSettingsWarning = true;
mc.gameSettings.saveOptions();
mc.displayGuiScreen(cont);
}
}
}

View File

@ -50,6 +50,7 @@ class LANClientPeer {
PlatformWebRTC.serverLANPeerICECandidates(clientId, candidates);
long millis = EagRuntime.steadyTimeMillis();
do {
PlatformWebRTC.runScheduledTasks();
LANPeerEvent evt;
if((evt = PlatformWebRTC.serverLANGetEvent(clientId)) != null) {
if(evt instanceof LANPeerEvent.LANPeerICECandidateEvent) {
@ -78,6 +79,7 @@ class LANClientPeer {
PlatformWebRTC.serverLANPeerDescription(clientId, description);
long millis = EagRuntime.steadyTimeMillis();
do {
PlatformWebRTC.runScheduledTasks();
LANPeerEvent evt;
if((evt = PlatformWebRTC.serverLANGetEvent(clientId)) != null) {
if(evt instanceof LANPeerEvent.LANPeerDescriptionEvent) {
@ -105,6 +107,7 @@ class LANClientPeer {
if(state == SENT_ICE_CANDIDATE) {
long millis = EagRuntime.steadyTimeMillis();
do {
PlatformWebRTC.runScheduledTasks();
LANPeerEvent evt;
while((evt = PlatformWebRTC.serverLANGetEvent(clientId)) != null && evt instanceof LANPeerEvent.LANPeerICECandidateEvent) {
// skip ice candidates

View File

@ -1 +1 @@
u40
u41

Binary file not shown.

View File

@ -314,7 +314,7 @@ public class BootMenuDatastore {
@Override
public void handleEvent() {
IDBCursor c = r.getResult();
if(c == null || c.getKey() == null || c.getValue() == null) {
if(c == null || c.getKey() == null) {
cb.complete(res[0]);
return;
}

View File

@ -68,29 +68,34 @@ public class PlatformApplication {
}
public static void setClipboard(String text) {
boolean b = false;
try {
setClipboard0(text);
b = setClipboard0(text);
}catch(Throwable t) {
PlatformRuntime.logger.error("Exception setting clipboard data");
}
if(!b) {
try {
Window.prompt("Here is the text you're trying to copy:", text);
}catch(Throwable t2) {
}
}
}
public static String getClipboard() {
String ret = null;
try {
return getClipboard0();
ret = getClipboard0();
}catch(Throwable t) {
PlatformRuntime.logger.error("Exception getting clipboard data");
}
if(ret == null) {
try {
String ret = Window.prompt("Please enter the text to paste:");
return ret != null ? ret : "";
ret = Window.prompt("Please enter the text to paste:");
}catch(Throwable t2) {
return "";
}
}
return ret != null ? ret : "";
}
@JSFunctor
@ -114,11 +119,11 @@ public class PlatformApplication {
});
}
@JSBody(params = { "cb" }, script = "if(!navigator.clipboard) { cb(prompt(\"Please enter the text to paste:\") || \"\"); } else if (!navigator.clipboard.readText) cb(\"\"); else navigator.clipboard.readText().then(function(s) { cb(s); }, function(s) { cb(\"\"); });")
@JSBody(params = { "cb" }, script = "if(!navigator.clipboard) { cb(null); } else if (!navigator.clipboard.readText) cb(null); else navigator.clipboard.readText().then(function(s) { cb(s || null); }, function() { cb(null); });")
private static native void getClipboard1(StupidFunctionResolveString cb);
@JSBody(params = { "str" }, script = "if(navigator.clipboard) navigator.clipboard.writeText(str);")
private static native void setClipboard0(String str);
@JSBody(params = { "str" }, script = "if(navigator.clipboard) { navigator.clipboard.writeText(str); return true; } else { return false; }")
private static native boolean setClipboard0(String str);
public static void setLocalStorage(String name, byte[] data) {
setLocalStorage(name, data, true);

View File

@ -252,7 +252,7 @@ public class PlatformRuntime {
}
useVisualViewport = false;
if(isVisualViewportSupported(System.currentTimeMillis())) {
if(isVisualViewportSupported()) {
if(isEmbeddedInBody) {
useVisualViewport = true;
}else {
@ -525,8 +525,8 @@ public class PlatformRuntime {
return EnumPlatformOS.getFromUA(getUserAgentString());
}
@JSBody(params = { "ts" }, script = "if(ts > 1728322572561 && window[decodeURIComponent(\"%6C%6F%63%61%74%69%6F%6E\")][decodeURIComponent(\"%68%6F%73%74%6E%61%6D%65\")] === decodeURIComponent(\"%65%61%67%6C%65%72%63%72%61%66%74%2E%64%65%76\")) setTimeout(function() { var i = 1; while(i > 0) { ++i; } }, 353000); return (typeof visualViewport !== \"undefined\");")
private static native boolean isVisualViewportSupported(double ts);
@JSBody(params = { }, script = "return (typeof visualViewport !== \"undefined\");")
private static native boolean isVisualViewportSupported();
@JSBody(params = { }, script = "return visualViewport;")
static native VisualViewport getVisualViewport();

View File

@ -279,6 +279,10 @@ public class EarlyLoadScreen {
}
public static void loadFinal(byte[] image) {
ImageData img = PlatformAssets.loadImageFile(image);
if(img == null) {
return;
}
finalTexture = _wglGenTextures();
_wglActiveTexture(GL_TEXTURE0);
_wglBindTexture(GL_TEXTURE_2D, finalTexture);
@ -286,11 +290,10 @@ public class EarlyLoadScreen {
_wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
_wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
_wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
ImageData img = PlatformAssets.loadImageFile(image);
IntBuffer upload = PlatformRuntime.allocateIntBuffer(256*256);
IntBuffer upload = PlatformRuntime.allocateIntBuffer(img.width * img.height);
upload.put(img.pixels);
upload.flip();
_wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, upload);
_wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.width, img.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, upload);
PlatformRuntime.freeIntBuffer(upload);
}

View File

@ -290,7 +290,7 @@ public class IndexedDBFilesystem implements IEaglerFilesystem {
@Override
public void handleEvent() {
IDBCursor c = r.getResult();
if(c == null || c.getKey() == null || c.getValue() == null) {
if(c == null || c.getKey() == null) {
cb.complete(res[0]);
return;
}