From c46dab16c9efff2eab0cdcd4a78c95c631a3803b Mon Sep 17 00:00:00 2001 From: ComputerGuy <63362464+Ocean-OS@users.noreply.github.com> Date: Sat, 7 Oct 2023 11:19:49 -0700 Subject: [PATCH] Create mods.js --- mc-assets/0.48/mods.js | 118 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 mc-assets/0.48/mods.js diff --git a/mc-assets/0.48/mods.js b/mc-assets/0.48/mods.js new file mode 100644 index 0000000..89670e2 --- /dev/null +++ b/mc-assets/0.48/mods.js @@ -0,0 +1,118 @@ +localStorage.clear(); +const modScript = "}catch(err){console.log(err);};function newBlock(json){if(!window.blockData.includes(json)){window.blockData.push(json);}}; function newTexture(json){if(!window.textures.includes(json)){window.textures.push(json);}};"; +const modOtherScript = "function newBlock(json){if(!window.blockData.includes(json)){window.blockData.push(json);}}; function newTexture(json){if(!window.textures.includes(json)){window.textures.push(json);}};"; +const fs = require('fs'); +const path = require('path'); +var gameMods = []; +window.gameShaders = []; +function getModFiles() { + var justCreated; + if (!fs.existsSync(__dirname + '/mods')){ + fs.mkdirSync(__dirname + '/mods'); + var justCreated = true; + } + if(justCreated !== true){ + var modFileDir = fs.readdirSync(__dirname + "\\mods"); + window.gameModFiles = []; + window.blockData = []; + window.textures = []; + for(var modFileGet = 0; modFileGet < modFileDir.length; modFileGet++){ + if(path.extname(__dirname + "\\mods\\" + modFileDir[modFileGet]) == ".js"){ + window.gameModFiles.push(fs.readFileSync(__dirname + "\\mods\\" + modFileDir[modFileGet], "utf8")); + eval(fs.readFileSync(__dirname + "\\mods\\" + modFileDir[modFileGet], "utf8") + modOtherScript); + } + } + } +} +function runMods(){ + var modsRun = 0; + var modIds = []; + if(gameMods.length > 0){ + localStorage.setItem("modsActive", "true"); + }else{ + localStorage.setItem("modsActive", "false"); + } + while(modsRun !== gameMods.length){ + gameMods[modsRun].id = modsRun.toString(); + if(gameMods[modsRun].version !== version){ + console.log("Error: " + gameMods[modsRun].name + " Mod failed to run, version is not compatible"); + }else{ + const modSafetyCheck = /((window)[\.;])|(atob)|(Buffer(\.from\(|;))|(location(\.|;))|(document(;|\.))/g; + if(modSafetyCheck.test(gameMods[modsRun].script)){ + console.log(gameMods[modsRun].name + " Mod seems suspicious, skipping mod."); + }else{ + eval("try{" + gameMods[modsRun].script + modScript); + console.log("Run " + gameMods[modsRun].name + " Mod Successfully.");} + } + modIds.push(gameMods[modsRun].id); + modsRun++; + } + console.log("Ran all available mods"); + console.log(modIds); + const allMods = modIds; + window.mods = gameMods; + return modIds; +} +function getModIds() { + return allMods; +} +//Music +var musicFiles = [ + "Aria Math.mp3", +"Biome Fest.mp3", +"Blind Spots.mp3", +"Clark.mp3", +"Danny.mp3", +"Dreiton.mp3", +"Dry Hands.mp3", +"Haggstrom.mp3", +"Haunt Muskie.mp3", +"Living Mice.mp3", +"Mice On Venus.mp3", +"Minecraft.mp3", +"Moog City 2.mp3", +"Moog City.mp3", +"Shuniji.mp3", +"Subwoofer Lullaby.mp3", +"Wet Hands.mp3", +"Ki.mp3", +"Chris.mp3", +"Beginning.mp3", +"otherside.mp3", +"Taswell.mp3", +"Beginning 2.mp3", +"Mutation.mp3", +"Dead Voxel.mp3"]; +var lastMusic; +var musicPlaying = new Audio(); +var gettingMusic = true; +var musicUnverifiedFiles = []; +var musicVerifiedFiles = []; +var checkingMusic = true; +for(var musicCheck = 0; musicCheck < musicFiles.length; musicCheck++){ + if(!fs.existsSync(path.join(__dirname, musicFiles[musicCheck]))){ + musicUnverifiedFiles.push(musicFiles[musicCheck]); + } +} +for(var musicAdd = 0; musicAdd < musicFiles.length; musicAdd++){ + if(!musicFiles.includes(musicUnverifiedFiles[musicAdd])){ + musicVerifiedFiles.push(musicFiles[musicAdd]); + } +} +musicFiles = musicVerifiedFiles; +checkingMusic = false; +musicPlaying.src = musicFiles[Math.round(Math.random()*(musicFiles.length-1))]; +lastMusic = musicPlaying.src; +musicPlaying.loop = false; +musicPlaying.play(); +musicPlaying.addEventListener("ended", function(){ + var gettingMusic = true; + musicPlaying.src = musicFiles[Math.round(Math.random()*(musicFiles.length-1))]; + musicPlaying.play(); + gettingMusic = false; +}); +musicPlaying.onpause = function(){ + if(!musicPause){ + musicPlaying.play(); + } +}