// eaglermobile for eaglerforge function isMobile() { try { document.createEvent("TouchEvent"); return true; } catch (e) { return false; } } if(!isMobile()){alert("WARNING: This script doesn't play well with non-mobile browsers. Proceed at your own risk!")}; // Hides inventory button window.inInventory = false; // Used for changing touchmove events to mousemove events var previousX = null; var previousY = null; // Key and mouse events function keyEvent(name, state) { const keyName = name.toUpperCase().charCodeAt(0) window.dispatchEvent(new KeyboardEvent(state, { key: name, keyCode: keyName, which: keyName })); } function shiftKey(state) { window.dispatchEvent(new KeyboardEvent(state, { keyCode: 16, which: 16 })); } function mouseEvent(number, state, canvas) { canvas.dispatchEvent(new PointerEvent(state, {"button": number})) } // POINTERLOCK // When requestpointerlock is called, this dispatches an event, saves the requested element to window.fakelock, and unhides the touch controls window.fakelock = null; Element.prototype.requestPointerLock = function() { window.fakelock = this document.dispatchEvent(new Event('pointerlockchange')); console.log("requested pointerlock") var hideButtonStyleDOM = document.getElementById('hideButtonStyle'); var hideInventoryStyleDOM = document.getElementById('hideInventoryStyle'); hideButtonStyleDOM.disabled = true; hideInventoryStyleDOM.disabled = true; return true } // Makes pointerLockElement return window.fakelock Object.defineProperty(document, "pointerLockElement", { get: function() { return window.fakelock; } }); // When exitPointerLock is called, this dispatches an event, clears the document.exitPointerLock = function() { window.fakelock = null document.dispatchEvent(new Event('pointerlockchange')); var hideButtonStyleDOM = document.getElementById('hideButtonStyle'); var hideInventoryStyleDOM = document.getElementById('hideInventoryStyle'); hideButtonStyleDOM.disabled = false; hideInventoryStyleDOM.disabled = window.inInventory; return true } // FULLSCREEN window.fakefull = null; // Stops the client from crashing when fullscreen is requested Element.prototype.requestFullscreen = function() { window.fakefull = this document.dispatchEvent(new Event('fullscreenchange')); return true } Object.defineProperty(document, "fullscreenElement", { get: function() { return window.fakefull; } }); document.exitFullscreen = function() { window.fakefull = null document.dispatchEvent(new Event('fullscreenchange')); return true } // FILE UPLOADING // Safari doesn't recognize the element.click() used to display the file uplaoder as an action performed by the user, so it ignores it. // This hijacks the element.createElement() function to add the file upload to the DOM, so the user can manually press the button again. var oldCreate = document.createElement; document.createElement = function(type) { this.oldCreate = oldCreate; var element = this.oldCreate(type); if(type == "input") { var newElement = document.querySelector('input'); if(!newElement) { this.body.appendChild(element); newElement = document.querySelector('input'); newElement.addEventListener('change', function(e) { this.hidden = true; }) } newElement.value = null; newElement.style.cssText ="position:absolute;left:0%;right:100%;top:0%;bottom:100%;width:100%;height:100%;background-color:rgba(255,255,255,0.5);"; newElement.hidden = false; return newElement; } return this.oldCreate(type); } // CSS for touch screen buttons, along with fixing iOS's issues with 100vh ignoring the naviagtion bar, and actually disabling zoom because safari ignores user-scalable=no :( let customStyle = document.createElement("style"); customStyle.textContent = ` button { position: absolute; width: 9.5vh; height: 9.5vh; font-size:4vh; -webkit-user-select: none; -ms-user-select: none; user-select: none; line-height: 0px; padding:0px; color: #ffffff; text-shadow: 0.35vh 0.35vh #000000; box-sizing: content-box; image-rendering: pixelated; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAAUCAYAAACnOeyiAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAUGVYSWZNTQAqAAAACAACARIAAwAAAAEAAQAAh2kABAAAAAEAAAAmAAAAAAADoAEAAwAAAAEAAQAAoAIABAAAAAEAAAACoAMABAAAAAEAAAAUAAAAABBl8JYAAAIvaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA2LjAuMCI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOmV4aWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vZXhpZi8xLjAvIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWURpbWVuc2lvbj4yMDwvZXhpZjpQaXhlbFlEaW1lbnNpb24+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yPC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6Q29sb3JTcGFjZT4xPC9leGlmOkNvbG9yU3BhY2U+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgp+x0mNAAAAU0lEQVQIHV2OXQoAIAiDdSIdt0N3iAiMfhz00IPzw01URWSdEtRabxe01ghmRlgrIwJ352TOSUg9ggdjDFqlFAJAF733z3pbqvqF34mISOsG8o8N3G8YG4Y+w98AAAAASUVORK5CYII=) no-repeat right center, url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAAAUCAYAAADIpHLKAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAUGVYSWZNTQAqAAAACAACARIAAwAAAAEAAQAAh2kABAAAAAEAAAAmAAAAAAADoAEAAwAAAAEAAQAAoAIABAAAAAEAAADIoAMABAAAAAEAAAAUAAAAAMWDgdMAAAIxaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA2LjAuMCI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3Jp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emvjww8Az577hfHKd+8UNZ5WvZsNJ3yI6f/Sy0wFfv9UJx48Hpkviw+fpF51OA27ozuL+EjC5zvXE59zaXwTc9vnh+Tqn10oXMwcYNSc/n0c8LDwMnb007pCW2Z8cNTLcTO6sYW8G4mrhiLf+xNxp+VY+T18A8c77nPhpwa9e+e6EP53yYFnzhNGLtTgeOWlaCecPcXOivzrrC/Lq1avT69evF04BAANkESNlSBVP1HL+z0cD8CWazahDeAbnZbJ6eWnI5Kkvx5P44v4NC5+mPa4HNuN86uhTTcPhU8eDAz5ftdIhHgZPe/hmiNcj1n+27Ix71pSnBzNIQzVb8TD8MM3PC4q3M24YNn3O8vqy9MKonZVnxeOBx0OfRy0+XDis5dl3F3L1032G00e18eJj/PHIjTt91RbbbeaKVQu2udGMy1P9nWc/L2UayLwwflH4iK2wVVEx1gD5wsRhJUJDcDg9hgFLHOFy+RuK1f8jKo9pCLYB8cnfDQ8cPA5nxld+OnH7N6668PrE75JgxNNoL18Mbw/tnnrcNTmnXS35flTgPdXBkT46vExqZHjm2V6+vPid+f1w0VsffPJhp6lXX/bx16dYs0qbv4x48OE3u/rgU7v4XPGkjwZ84q1i1cDroccj10zE+4sq7qyeurTGN3uctezr1/sHz/BnuJpDeznM3/g/yOW6/bidwO0EmsBvfPs6RnkPn1AAAAAASUVORK5CYII=) no-repeat left center; background-size: contain, cover; outline:none; box-shadow: none; border: none; } button:active { position: absolute; width: 9.5vh; height: 9.5vh; font-size:4vh; -webkit-user-select: none; -ms-user-select: none; user-select: none; line-height: 0px; padding:0px; color: #ffffff; text-shadow: 0.35vh 0.35vh #000000; box-sizing: content-box; image-rendering: pixelated; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAAUCAYAAACnOeyiAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAUGVYSWZNTQAqAAAACAACARIAAwAAAAEAAQAAh2kABAAAAAEAAAAmAAAAAAADoAEAAwAAAAEAAQAAoAIABAAAAAEAAAACoAMABAAAAAEAAAAUAAAAABBl8JYAAAIvaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA2LjAuMCI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOmV4aWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vZXhpZi8xLjAvIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWURpbWVuc2lvbj4yMDwvZXhpZjpQaXhlbFlEaW1lbnNpb24+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yPC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6Q29sb3JTcGFjZT4xPC9leGlmOkNvbG9yU3BhY2U+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgp+x0mNAAAAWUlEQVQIHV2OUQrAMAhDNaX01vverXYPL1IES9ca1o99GB8moioic5Xgup/dBWZGKKUQ5syIoNbKyRiDkLoEB9ydVmuNANBF7/1nnS1VpXWORgQnH+xA/vECGrAYeIZg8CAAAAAASUVORK5CYII=) no-repeat right center, url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAAAUCAYAAADIpHLKAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAA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4e3jGRd9ZBD+BT35XDbiE5yZydnW4COoBd+DPGdIxufVf3g80lNCp+PHPh4LV21CyfsnKcWbDeXm2ELR/TkwU4sdYaXGE98tvEdfHTlae5UprbmEotueINZvnJI/FM/p9cDmb/ARnw5WV5dzRQd2AR2FPSy5og5wY1FJz4cU3B6fJ4XOAm+HsgZtpWs8ZCC8Nubh5EAHxaXREKQsSTrPAJDKY6iIWBc1yTb2AcncryhEBfZ8uRf0ekorkZmB69jv/3pxk/eWTx0TjG5nh+wP9zfjzg2FXGCDw4cBN+uFuumFke4kNspr+b4YDeavLANnzVu44IdrtfCRJc93alM83KeeM7xMWp0qGmwbevRhx/+8HRe9RQrnI4N4jA/1QteGAl/5kes8pNGNc+v+Phhx7cFT1c8Qse1eGoEq3yNnYqx5J44T4dNmi7/kSnPOWdDeD5qjqHv/3xn4DsDYeB/zW/ARYhb8IkAAAAASUVORK5CYII=) no-repeat left center; background-size: contain, cover; outline:none; box-shadow: none; border: none; } html, body { height: -webkit-fill-available !important; touch-action: pan-x pan-y; } `; document.documentElement.appendChild(customStyle); // Lazy way to hide touch controls through CSS. let hideButtonStyle = document.createElement("style"); hideButtonStyle.id = "hideButtonStyle"; hideButtonStyle.textContent = ` #hideButton { display: none; }`; document.documentElement.appendChild(hideButtonStyle); let hideInventoryStyle = document.createElement("style"); hideInventoryStyle.id = "hideInventoryStyle"; hideInventoryStyle.textContent = ` #hideInventory { display: none; }`; document.documentElement.appendChild(hideInventoryStyle); // The canvas is created by the client after it finishes unzipping and loading. When the canvas is created, this applies any necessary event listeners function waitForElm(selector) { return new Promise(resolve => { if (document.querySelector(selector)) { return resolve(document.querySelector(selector)); } const observer = new MutationObserver(mutations => { if (document.querySelector(selector)) { observer.disconnect(); resolve(document.querySelector(selector)); } }); observer.observe(document.documentElement, { childList: true, subtree: true }); }); } waitForElm('canvas').then(() => {insertCanvasElements()}); function insertCanvasElements() { // Translates touchmove events to mousemove events var canvas = document.querySelector('canvas'); canvas.addEventListener("touchmove", (e) => { const touch = e.targetTouches[0]; // We can get away with this because every other touch event will be on different elements if (!previousX) { previousX = touch.pageX; previousY = touch.pageY; } e.movementX = touch.pageX - previousX; e.movementY = touch.pageY - previousY; var evt = window.fakelock ? new MouseEvent("mousemove", {movementX: e.movementX, movementY: e.movementY}) : new WheelEvent("wheel", {"wheelDeltaY": e.movementY}); canvas.dispatchEvent(evt); previousX = touch.pageX; previousY = touch.pageY; event.preventDefault(); }, false); canvas.addEventListener("touchend", (e) => { previousX = null; previousY = null; }, false) // Adds all of the touch screen controls // Theres probably a better way to do this but this works for now var forwardButton = document.createElement('button'); forwardButton.id = "hideButton" forwardButton.textContent = "▲"; forwardButton.style.cssText = "left:10vh;bottom:20vh;" forwardButton.addEventListener("touchstart", function(e){keyEvent("w", "keydown")}, false); forwardButton.addEventListener("touchend", function(e){keyEvent("w", "keyup")}, false); forwardButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(forwardButton); var rightButton = document.createElement('button'); rightButton.id = "hideButton" rightButton.textContent = "▶"; rightButton.style.cssText = "left:20vh;bottom:10vh;" rightButton.addEventListener("touchstart", function(e){keyEvent("d", "keydown")}, false); rightButton.addEventListener("touchend", function(e){keyEvent("d", "keyup")}, false); rightButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(rightButton); var leftButton = document.createElement('button'); leftButton.id = "hideButton" leftButton.textContent = "◀"; leftButton.style.cssText = "left: 0vh; bottom:10vh;" leftButton.addEventListener("touchstart", function(e){keyEvent("a", "keydown")}, false); leftButton.addEventListener("touchend", function(e){keyEvent("a", "keyup")}, false); leftButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(leftButton); var backButton = document.createElement('button'); backButton.id = "hideButton" backButton.textContent = "▼"; backButton.style.cssText = "left:10vh;bottom:0vh;" backButton.addEventListener("touchstart", function(e){keyEvent("s", "keydown")}, false); backButton.addEventListener("touchend", function(e){keyEvent("s", "keyup")}, false); backButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(backButton); var jumpButton = document.createElement('button'); jumpButton.id = "hideButton" jumpButton.textContent = "⇧"; jumpButton.style.cssText = "right:10vh;bottom:10vh;" jumpButton.addEventListener("touchstart", function(e){keyEvent(" ", "keydown")}, false); jumpButton.addEventListener("touchend", function(e){keyEvent(" ", "keyup")}, false); jumpButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(jumpButton); var crouchButton = document.createElement('button'); crouchButton.id = "hideButton" crouchButton.textContent = "⇩"; crouchButton.style.cssText = "left:10vh;bottom:10vh;" crouchButton.addEventListener("touchstart", function(e){shiftKey("keydown")}, false); crouchButton.addEventListener("touchend", function(e){shiftKey("keyup")}, false); crouchButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(crouchButton); var inventoryButton = document.createElement('button'); inventoryButton.id = "hideInventory" inventoryButton.textContent = "🎒"; inventoryButton.style.cssText = "right:0vh;bottom:0vh;" inventoryButton.addEventListener("touchstart", function(e){ window.inInventory = (window.fakelock != null) keyEvent("e", "keydown"); }, false); inventoryButton.addEventListener("touchend", function(e){keyEvent("e", "keyup")}, false); inventoryButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(inventoryButton); var chatButton = document.createElement('button'); chatButton.id = "hideButton" chatButton.textContent = "💬"; chatButton.style.cssText = "right:0vh;top:0vh;" chatButton.addEventListener("touchstart", function(e){keyEvent("¿", "keydown")}, false); chatButton.addEventListener("touchend", function(e){keyEvent("¿", "keydown")}, false); chatButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(chatButton); var exitButton = document.createElement('button'); exitButton.id = "exitButton" exitButton.textContent = "⮐"; exitButton.style.cssText = "left:0vh;top:0vh;" exitButton.addEventListener("touchstart", function(e){keyEvent("À", "keydown")}, false); exitButton.addEventListener("touchend", function(e){keyEvent("À", "keyup")}, false); exitButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(exitButton); var hiddenInput = document.createElement('input'); hiddenInput.id = "hiddenInput" hiddenInput.style.cssText = "opacity:0;z-index:-99999"; document.body.appendChild(hiddenInput); var keyboardButton = document.createElement('button'); keyboardButton.id = "keyboardButton" keyboardButton.textContent = "⌨️"; keyboardButton.style.cssText = "left:10vh;top:0vh;" keyboardButton.addEventListener("touchstart", function(e){e.preventDefault();hiddenInput.blur()}, false); keyboardButton.addEventListener("touchend", function(e){hiddenInput.select()}, false); keyboardButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(keyboardButton); var placeButton = document.createElement('button'); placeButton.id = "hideButton" placeButton.textContent = "⊹"; placeButton.style.cssText = "right:0vh;bottom:20vh;" placeButton.addEventListener("touchstart", function(e){mouseEvent(2, "mousedown", canvas)}, false); placeButton.addEventListener("touchend", function(e){mouseEvent(2, "mouseup", canvas)}, false); placeButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(placeButton); var breakButton = document.createElement('button'); breakButton.id = "hideButton" breakButton.textContent = "🗡"; breakButton.style.cssText = "right:10vh;bottom:20vh;" breakButton.addEventListener("touchstart", function(e){mouseEvent(0, "mousedown", canvas)}, false); breakButton.addEventListener("touchend", function(e){mouseEvent(0, "mouseup", canvas)}, false); breakButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(breakButton); var selectButton = document.createElement('button'); selectButton.id = "hideButton" selectButton.textContent = "⬚"; selectButton.style.cssText = "right:20vh;bottom:20vh;" selectButton.addEventListener("touchstart", function(e){mouseEvent(1, "mousedown", canvas)}, false); selectButton.addEventListener("touchend", function(e){mouseEvent(1, "mouseup", canvas)}, false); selectButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(selectButton); var scrollUpButton = document.createElement('button'); scrollUpButton.id = "hideButton" scrollUpButton.textContent = "⇨"; scrollUpButton.style.cssText = "right:0vh;bottom:30vh;" scrollUpButton.addEventListener("touchstart", function(e){ canvas.dispatchEvent(new WheelEvent("wheel", {"wheelDeltaY": -10})) }, false); scrollUpButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(scrollUpButton); var scrollDownButton = document.createElement('button'); scrollDownButton.id = "hideButton" scrollDownButton.textContent = "⇦"; scrollDownButton.style.cssText = "right:10vh;bottom:30vh;" scrollDownButton.addEventListener("touchstart", function(e){ canvas.dispatchEvent(new WheelEvent("wheel", {"wheelDeltaY": 10})) }, false); scrollDownButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(scrollDownButton); var throwButton = document.createElement('button'); throwButton.id = "hideButton" throwButton.textContent = "Q"; throwButton.style.cssText = "right:0vh;bottom:10vh;" throwButton.addEventListener("touchstart", function(e){ window.inInventory = (window.fakelock != null) keyEvent("q", "keydown"); }, false); throwButton.addEventListener("touchend", function(e){keyEvent("q", "keyup")}, false); throwButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); document.body.appendChild(throwButton); }