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

@ -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;
}