CursedSliver

macadamia test

Aug 15th, 2024 (edited)
1,141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Game.LoadMod("https://requirejs.org/docs/release/2.3.6/minified/require.js", () => {
  2.     define("logs", ["require", "exports"], function (require, exports) {
  3.         "use strict";
  4.         Object.defineProperty(exports, "__esModule", { value: true });
  5.         exports.Logger = void 0;
  6.         exports.boot = boot;
  7.         exports.welcome = welcome;
  8.         exports.init = init;
  9.         exports.log = log;
  10.         function boot(id) {
  11.             console.log(`%cbooting %c${id}%c...`, "color: #d9b99b;", "color: #fff0db;", "color: #d9b99b;");
  12.         }
  13.         function welcome() {
  14.             console.log("%cmacadamia has booted!\n%cif you're a modder, read the docs here:\nhttps://macadamia.redbigz.com/docs", "color: #d9b99b; font-weight: 700; font-size: 1.5em;", "color: #fff0db;");
  15.         }
  16.         function init() {
  17.             console.log(`%c🥜 macadamia %cby redbigz\n%cv${window.Macadamia.Version} | main | CC v${window.VERSION}`, "color: #d9b99b; font-size: 2em;", "font-weight: 700;", "color: #fff0db;");
  18.         }
  19.         function log(from, msg) {
  20.             console.log(`%c[${from}] %c${msg}`, "color: #d9b99b;", "color: #fff0db;");
  21.         }
  22.         class Logger {
  23.             from;
  24.             constructor(from) {
  25.                 this.from = from;
  26.             }
  27.             log(msg) {
  28.                 log(this.from, msg);
  29.             }
  30.         }
  31.         exports.Logger = Logger;
  32.     });
  33.     define("cleaner", ["require", "exports", "logs"], function (require, exports, logs_1) {
  34.         "use strict";
  35.         Object.defineProperty(exports, "__esModule", { value: true });
  36.         exports.clean = clean;
  37.         function clean() {
  38.             const logger = new logs_1.Logger("macadamia::cleaner");
  39.             logger.log("cleaning up localStorage...");
  40.             let macadamiaUnusedSaves = Object.keys(localStorage).filter(key => key.startsWith("macadamia_"));
  41.             for (var key of macadamiaUnusedSaves) {
  42.                 localStorage.removeItem(key);
  43.             }
  44.             logger.log(`cleaned up ${macadamiaUnusedSaves.length} unused save${macadamiaUnusedSaves.length == 1 ? "" : "s"}.`);
  45.         }
  46.     });
  47.     define("raisin", ["require", "exports"], function (require, exports) {
  48.         "use strict";
  49.         Object.defineProperty(exports, "__esModule", { value: true });
  50.         exports.ModRaisin = exports.Raisin = void 0;
  51.         // https://stackoverflow.com/questions/1007981/how-to-get-function-parameter-names-values-dynamically
  52.         var STRIP_COMMENTS = /(\/\/.*$)|(\/\*[\s\S]*?\*\/)|(\s*=[^,\)]*(('(?:\\'|[^'\r\n])*')|("(?:\\"|[^"\r\n])*"))|(\s*=[^,\)]*))/mg;
  53.         var ARGUMENT_NAMES = /([^\s,]+)/g;
  54.         function getParamNames(func) {
  55.             var fnStr = func.toString().replace(STRIP_COMMENTS, '');
  56.             var result = fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')).match(ARGUMENT_NAMES);
  57.             if (result === null)
  58.                 return [];
  59.             return result;
  60.         }
  61.         function getFunctionBody(func) {
  62.             var fnStr = func.toString();
  63.             if (fnStr.indexOf('{') == -1) {
  64.                 return fnStr.split("=>")[1].trim();
  65.             }
  66.             var start = fnStr.indexOf('{') + 1;
  67.             var end = fnStr.lastIndexOf('}');
  68.             return fnStr.substring(start, end).trim();
  69.         }
  70.         window.RaisinUUIDs = {};
  71.         class Raisin {
  72.             body;
  73.             params;
  74.             /**
  75.              * Initialises a new Raisin.
  76.              *
  77.              * @param {function} func - The function.
  78.              */
  79.             constructor(func) {
  80.                 this.body = getFunctionBody(func).split("\n");
  81.                 this.params = getParamNames(func);
  82.             }
  83.             /**
  84.              * Inserts the specified code at the given line.
  85.              *
  86.              * @param {number} line - The line number to insert the code.
  87.              * @param {string|function} code - The code to insert. If a function, a decorator is added.
  88.              * @param {boolean} [replace=false] - Whether to replace the existing code at the line.
  89.              * @return {this}
  90.              */
  91.             insert(line, code, replace = false) {
  92.                 if (line < 0) {
  93.                     line = this.body.length + 1 + line;
  94.                 }
  95.                 if (typeof code === "string") {
  96.                     var inject = code;
  97.                 }
  98.                 else {
  99.                     var codeParams = getParamNames(code).join(",");
  100.                     var inject = `([${codeParams}] = ((${codeParams}) => {${getFunctionBody(code)};return [${codeParams}]}).call(this, ${codeParams}));`;
  101.                 }
  102.                 // console.log(inject)
  103.                 this.body.splice(line, replace ? 1 : 0, inject);
  104.                 return this;
  105.             }
  106.             /**
  107.              * Inserts the specified code at the given line, based on a signature match.
  108.              *
  109.              * @param {string} signature - The signature to match in the code.
  110.              * @param {string|function} code - The code to insert. If a function, a decorator is added.
  111.              * @param {boolean} [entireLine=true] - Whether to replace the entire line or just the matched signature.
  112.              * @param {boolean} [replaceLine=false] - Whether to replace the existing code at the line.
  113.              * @return {this}
  114.              */
  115.             insertPerSignature(signature, code, entireLine = true, replaceLine = false) {
  116.                 for (var i in this.body) {
  117.                     if (this.body[i].match(signature)) {
  118.                         if (entireLine)
  119.                             this.insert(i + replaceLine ? 0 : 1, code, replaceLine);
  120.                         else
  121.                             this.body[i] = this.body[i].replaceAll(signature, code);
  122.                     }
  123.                 }
  124.                 return this;
  125.             }
  126.             /**
  127.              * Runs the function code through a transpiler.
  128.              *
  129.              * @param {function} transpiler - The transpiler function to use.
  130.              * @return {this}
  131.              */
  132.             transpile(transpiler) {
  133.                 this.body = transpiler(this.body);
  134.                 return this;
  135.             }
  136.             /**
  137.              * Compiles the function body and parameters into a new function.
  138.              *
  139.              * @return {function} The compiled function.
  140.              */
  141.             compile() {
  142.                 return new Function(...this.params, this.body.join("\n"));
  143.             }
  144.         }
  145.         exports.Raisin = Raisin;
  146.         class ModRaisin extends Raisin {
  147.             modID;
  148.             constructor(modID, func) {
  149.                 super(func);
  150.                 this.modID = modID;
  151.             }
  152.             insert(line, code, replace) {
  153.                 if (line < 0) {
  154.                     line = this.body.length + 1 + line;
  155.                 }
  156.                 if (typeof code === "string") {
  157.                     var inject = code;
  158.                 }
  159.                 else {
  160.                     var codeParams = getParamNames(code).join(",");
  161.                     var inject = `if (window.MacadamiaModList['${this.modID}'].enabled) ([${codeParams}] = ((${codeParams}) => {${getFunctionBody(code)};return [${codeParams}]}).call(this, ${codeParams}));`;
  162.                 }
  163.                 // console.log(inject)
  164.                 this.body.splice(line, replace ? 1 : 0, inject);
  165.                 return this;
  166.             }
  167.             transpile(transpiler) {
  168.                 this.body = ["if (window.MacadamiaModList['" + this.modID + "'].enabled) {", ...transpiler(this.body), "} else {", ...this.body, "}"];
  169.                 return this;
  170.             }
  171.         }
  172.         exports.ModRaisin = ModRaisin;
  173.     });
  174.     define("hooks", ["require", "exports"], function (require, exports) {
  175.         "use strict";
  176.         Object.defineProperty(exports, "__esModule", { value: true });
  177.         exports.Hooks = exports.HookList = void 0;
  178.         exports.buildHooks = buildHooks;
  179.         class Hook {
  180.             id;
  181.             subscribers;
  182.             enabled = true;
  183.             constructor(id) {
  184.                 this.id = id;
  185.                 this.subscribers = [];
  186.             }
  187.             subscribe(callback) {
  188.                 this.subscribers.push(callback);
  189.             }
  190.             publish(message) {
  191.                 if (!this.enabled)
  192.                     return;
  193.                 for (var i in this.subscribers) {
  194.                     this.subscribers[i](message);
  195.                 }
  196.             }
  197.             feed(message) {
  198.                 let output = message;
  199.                 for (var i in this.subscribers) {
  200.                     output = this.subscribers[i](output);
  201.                 }
  202.                 return output;
  203.             }
  204.         }
  205.         class HookList {
  206.             hooks;
  207.             #enabled = true;
  208.             constructor() {
  209.                 this.hooks = {};
  210.             }
  211.             addHook(hook) {
  212.                 this.hooks[hook.id] = hook;
  213.                 return hook;
  214.             }
  215.             hook(id) {
  216.                 return this.hooks[id];
  217.             }
  218.             get enabled() {
  219.                 return this.#enabled;
  220.             }
  221.             set enabled(value) {
  222.                 this.#enabled = value;
  223.                 for (var i in this.hooks) {
  224.                     this.hooks[i].enabled = value;
  225.                 }
  226.             }
  227.         }
  228.         exports.HookList = HookList;
  229.         var VanillaHooks;
  230.         (function (VanillaHooks) {
  231.             VanillaHooks["Draw"] = "vanilla/draw";
  232.             VanillaHooks["Logic"] = "vanilla/logic";
  233.             VanillaHooks["CPS"] = "vanilla/cps";
  234.         })(VanillaHooks || (VanillaHooks = {}));
  235.         exports.Hooks = {
  236.             Vanilla: VanillaHooks,
  237.         };
  238.         function buildHooks() {
  239.             let hooks = new HookList();
  240.             // Create hooks
  241.             let drawHook = hooks.addHook(new Hook(exports.Hooks.Vanilla.Draw));
  242.             let logicHook = hooks.addHook(new Hook(exports.Hooks.Vanilla.Logic));
  243.             let cpsHook = hooks.addHook(new Hook(exports.Hooks.Vanilla.CPS));
  244.             // Implement vanilla hooks
  245.             Game.registerHook("draw", () => drawHook.publish({}));
  246.             Game.registerHook("logic", () => logicHook.publish({}));
  247.             Game.registerHook("cps", (cps) => cpsHook.feed({ cps }).cps);
  248.             return hooks;
  249.         }
  250.     });
  251.     define("core/modManager", ["require", "exports", "logs"], function (require, exports, logs_2) {
  252.         "use strict";
  253.         Object.defineProperty(exports, "__esModule", { value: true });
  254.         exports.loadModManager = loadModManager;
  255.         let pages = {
  256.             mods() {
  257.                 function buildContainer(mods) {
  258.                     return mods.map((mod) => {
  259.                         let disabler = `<a class="option${mod.enabled ? "" : " warning"}" style="font-size: 8pt; padding: 4px; float: right;" onclick="this.className = this.className == 'option warning' ? 'option' : 'option warning'; this.innerHTML = this.innerHTML == '✕ disabled' ? '✓ enabled' : '✕ disabled'; window.Macadamia.toggleMod('${mod.manifest.uuid}')">${mod.enabled ? "✓ enabled" : "✕ disabled"}</a>`;
  260.                         return `<div style="display: block; height: 48px;">
  261.                         <img src="${mod.manifest.icon || "favicon.ico"}" style="image-rendering: pixelated; float: left; padding-right: 15px; overflow: hidden;" height="48px">
  262.                         <div style="text-align: left;">
  263.                             <span style='font-size: 12pt; font-weight: 700; position: relative;'>${mod.manifest.name}</span>
  264.                             <small>${mod.manifest.version}</small><br>
  265.                             by ${mod.manifest.author}<br>
  266.    
  267.                             ${mod.manifest.uuid != "macadamia" ? disabler : ""}
  268.                         </div>
  269.                     </div>`;
  270.                     });
  271.                 }
  272.                 return `${[...buildContainer(Object.values(window.MacadamiaModList))].join("<br>")}`;
  273.             },
  274.             settings() {
  275.                 return `<a class="option${localStorage.getItem("streamerMode") !== "true" ? " warning" : ""}" onclick="window.Macadamia.toggleStreamerMode(); this.innerHTML = this.innerHTML == '✕ Streamer Mode' ? '✓ Streamer Mode' : '✕ Streamer Mode'; this.className = this.className == 'option warning' ? 'option' : 'option warning';">${localStorage.getItem("streamerMode") !== "true" ? "✕ Streamer Mode" : "✓ Streamer Mode"}</a><br><small>regenerates your peer id every time you restart the game.</small><br>For changes to take effect, restart the game.`;
  276.             },
  277.             about() {
  278.                 return `<img src="https://redbigz.com/lfs/macadamia/res/logo.png" style="image-rendering: pixelated; width: 32px; height: 32px; vertical-align: middle;"><b>Macadamia</b><br>by RedBigz<br><small>${window.MacadamiaModList.macadamia.manifest.version}</small>`;
  279.             }
  280.         };
  281.         function generateLinks(links, current) {
  282.             return Object.values(links).map((key) => {
  283.                 return `${key == current ? "<b>" : ""}<a href="javascript:window.ShowModManager('${key}')">${key}</a>${key == current ? "</b>" : ""}`;
  284.             }).join(" | ");
  285.         }
  286.         async function loadModManager() {
  287.             const logger = new logs_2.Logger("macadamia::modManager");
  288.             logger.log("loading mod manager...");
  289.             window.ShowModManager = (page) => {
  290.                 Game.Prompt(`<h3>Macadamia</h3><br>${generateLinks(["mods", "settings", "about"], page)}<br><div class=block style="position: relative; top: 5px; margin-bottom: 10px;">${pages[page]()}</div>`, []);
  291.             };
  292.             logger.log("mod manager loaded.");
  293.         }
  294.     });
  295.     define("util", ["require", "exports"], function (require, exports) {
  296.         "use strict";
  297.         Object.defineProperty(exports, "__esModule", { value: true });
  298.         exports.injectCSS = injectCSS;
  299.         function injectCSS(css) {
  300.             const style = document.createElement("style");
  301.             style.textContent = css;
  302.             document.head.appendChild(style);
  303.         }
  304.     });
  305.     define("core/multiplayer", ["require", "exports", "logs", "raisin", "util"], function (require, exports, logs_3, raisin_1, util_1) {
  306.         "use strict";
  307.         Object.defineProperty(exports, "__esModule", { value: true });
  308.         exports.SharedVariable = exports.RPC = void 0;
  309.         exports.loadMultiplayer = loadMultiplayer;
  310.         var metadata = {
  311.             name: "Unnamed",
  312.         };
  313.         const logger = new logs_3.Logger("macadamia::multiplayer");
  314.         let connections = [];
  315.         window.connectedPlayers = [];
  316.         let rpcFunctions = {};
  317.         let netcodeSettings = {
  318.             syncPeriod: 60000,
  319.             hosting: true,
  320.             host: ""
  321.         };
  322.         window.netcodeSettingsExport = netcodeSettings;
  323.         window.inGame = false;
  324.         var alreadyLoadedSave = false
  325.         function loadPeerJS() {
  326.             return new Promise((resolve) => {
  327.                 Game.LoadMod("https://unpkg.com/[email protected]/dist/peerjs.min.js", () => {
  328.                     resolve();
  329.                 });
  330.             });
  331.         }
  332.         window.DO_NOT_RPC = false;
  333.         var playerListElement = document.createElement("div");
  334.         playerListElement.style.cssText = "position: fixed; top: 40px; left: 10px; color: yellow; text-shadow: black 0 0 5px; font-family: Tahoma; z-index: 9999;";
  335.         playerListElement.id = "playerList";
  336.         document.body.appendChild(playerListElement);
  337.         window.ShowInvitePrompt = () => {
  338.             Game.Prompt(`<h3>Invite Friends</h3><br><div class=block><b>Peer ID</b><br><code style='font-family: monospace; user-select: text;'>${window.peer.id}</code></div><span style='color:#e33;font-weight:700;'><br>Your IP address is visible to those who join you/know your peer id! DO NOT HAND IT TO ANYONE THAT YOU DO NOT TRUST.</span><br>`, []);
  339.         };
  340.         var saveToOld = Game.SaveTo;
  341.         window.CloseConnection = () => {
  342.             for (var connection in connections) {
  343.                 connections[connection].close();
  344.             }
  345.             Game.SaveTo = saveToOld;
  346.             Game.LoadSave();
  347.             localStorage.removeItem(Game.SaveTo);
  348.         };
  349.         window.JoinGame = () => {
  350.             Game.Prompt("<h3>Join Game</h3><br>Macadamia uses a P2P system for playing multiplayer. <b>Your IP address will be shared with users in your lobby due to how the networking is managed.</b><br><br><input id=peeridinput class=block placeholder='Peer ID' style='text-align:center;background-color:rgba(0,0,0,0);color:white;width:120px;margin-bottom:10px;'>", [["Join", "window.StartJoinGame(document.getElementById('peeridinput').value)"]]);
  351.         };
  352.         window.StartJoinGame = (peerID) => {
  353.             Game.ClosePrompt();
  354.             if (peerID == window.peer.id) {
  355.                 Game.Prompt("You can't join yourself!", []);
  356.                 return;
  357.             }
  358.             if (peerID == "") {
  359.                 Game.Prompt("Invalid peer ID!", []);
  360.                 return;
  361.             }
  362.             for (var connection in connections) {
  363.                 connections[connection].close();
  364.             }
  365.             connections.splice(0, Infinity);
  366.             Game.SaveTo = peerID;
  367.             window.CreateConnection(peerID);
  368.             if (MacadamiaModList.mouse) { MacadamiaModList.mouse.mod.initMouses([peerID]); setTimeout(() => { window.MacadamiaModList.mouse.mod.newMouseRPC.send({ uuid: window.peer.id, x: Game.mouseX, y: Game.mouseY }); }, 5000); }
  369.             if (MacadamiaModList.tduuid) { MacadamiaModList.tduuid.mod.constructDisplayList([peerID]); setTimeout(() => { MacadamiaModList.tduuid.mod.newRowRPC.send({ id: window.peer.id }); }, 5000); }
  370.         };
  371.         window.setUsername = (name) => {
  372.             localStorage.setItem('macadamiaUsername', name);
  373.             sendDataToPeers({ type: "newName", data: name });
  374.             metadata.name = name;
  375.             rebuildPlayerList();
  376.         };
  377.         window.ChangeUsername = () => {
  378.             Game.Prompt("<h3>Change Username</h3><br>Choose a username:<br><br><input id=nameinput class=block placeholder='Username' style='text-align:center;background-color:rgba(0,0,0,0);color:white;width:120px;margin-bottom:10px;'>", [["Change", "window.setUsername(document.getElementById('nameinput').value); Game.ClosePrompt();"]]);
  379.         };
  380.         function rebuildPlayerList() {
  381.             let output = `${metadata.name} (you)`;
  382.             for (var connection in connections) {
  383.                 output += `\n${connections[connection].macaName}`;
  384.             }
  385.             playerListElement.innerText = output;
  386.             var menuArea = "";
  387.             menuArea += "<a class='option' onclick='window.ShowModManager(\"mods\")'>☰ Mods & Settings</a>";
  388.             if (connections.length == 0)
  389.                 netcodeSettings.hosting = true;
  390.             if (!netcodeSettings.hosting) {
  391.                 if (connections.length > 0)
  392.                     menuArea += "<a class='option' onclick='window.CloseConnection()'>✕ Leave</a>";
  393.             }
  394.             if (netcodeSettings.hosting) {
  395.                 menuArea += "<a class='option' onclick='window.ShowInvitePrompt()'>➕ Invite</a>";
  396.                 menuArea += "<a class='option' onclick='window.JoinGame()'>⮐ Join Game</a>";
  397.             }
  398.             menuArea += "<a class='option' onclick='window.ChangeUsername()'>✎</a>";
  399.             playerListElement.innerHTML = menuArea + "<br><br>" + playerListElement.innerHTML;
  400.         }
  401.         async function loadMultiplayer() {
  402.             logger.log("loading multiplayer...");
  403.             if (localStorage.getItem("multiplayerID") == null || localStorage.getItem("streamerMode") == "true")
  404.                 localStorage.setItem("multiplayerID", crypto.randomUUID());
  405.             if (localStorage.getItem("macadamiaUsername") !== null) {
  406.                 metadata.name = localStorage.getItem("macadamiaUsername");
  407.             }
  408.             // load peerjs
  409.             logger.log("waiting for peerjs...");
  410.             await loadPeerJS();
  411.             logger.log("peerjs loaded successfully!");
  412.             var peer = new window.Peer(`macadamia_${localStorage.getItem("multiplayerID")}`);
  413.             logger.log("created peer");
  414.             window.peer = peer;
  415.             logger.log("loading player list...");
  416.             (0, util_1.injectCSS)("#playerList { pointer-events: none; } #playerList > * { pointer-events: auto; }");
  417.             rebuildPlayerList();
  418.             console.log(`%cmacadamia::multiplayer\n%c🌐 network\n%cpeer id: %c${peer.id}\n\n%c/!\\ warning\n%cyour IP address is visible to those who join you/know your peer id!\nDO NOT HAND IT TO ANYONE THAT YOU DO NOT TRUST.`, "font-size: 0.5rem;", "color: #7289da; font-size: 1rem;", "color: #d9b99b;", "color: #fff0db;", "color: #e22; font-size: 1rem; font-weight: 700; text-shadow: #F00 1px 0 3px;", "color: #e22");
  419.             let onConnection = (connection, connectionFromNewPeer) => {
  420.                 connection.macaName = "Unnamed";
  421.                 connection.on("open", () => {
  422.                     if (connections.length >= 4) {
  423.                         connection.close();
  424.                         logger.log(`received connection from ${connection.peer}, but kicked because server is full`);
  425.                         return;
  426.                     }
  427.                     if (connection.peer != window.peer.id) {
  428.                         logger.log(`received connection from ${connection.peer}`);
  429.                     }
  430.                     if (!connectionFromNewPeer && netcodeSettings.hosting) {
  431.                         // sendDataToPeers({ type: "newPeer", peer: connection.peer })
  432.                         for (var otherConnection in connections) {
  433.                             connection.send({ type: "newPeer", data: connections[otherConnection].peer });
  434.                         }
  435.                     }
  436.                     connections.push(connection); // add connection to connections array
  437.                     connection.send({ type: "newName", data: metadata.name });
  438.                     rebuildPlayerList();
  439.                     if (netcodeSettings.hosting) {
  440.                         connection.send({ type: "saveData", data: Game.WriteSave(1) });
  441.                     }
  442.                     connection.on("data", (data) => {
  443.                         // console.log(data)
  444.                         if (!data.type || !data.data)
  445.                             return;
  446.                         switch (data.type) {
  447.                             case "macadamiaSync":
  448.                                 // handle cookies
  449.                                 if (connection.peer != netcodeSettings.host)
  450.                                     return;
  451.                                 if (!data.data)
  452.                                     return;
  453.                                 //Game.LoadSave(data.data);
  454.                                 // Game.cookies = data.cookies;
  455.                                 break;
  456.                             case "rpc":
  457.                                 // handle rpc
  458.                                 if (!data.data.modID)
  459.                                     return;
  460.                                 if (!data.data.name)
  461.                                     return;
  462.                                 if (!rpcFunctions[data.data.modID])
  463.                                     return;
  464.                                 if (!rpcFunctions[data.data.modID][data.data.name])
  465.                                     return;
  466.                                 if (window.MacadamiaModList[data.data.modID].enabled == false)
  467.                                     return;
  468.                                 if (data.data.payload)
  469.                                     rpcFunctions[data.data.modID][data.data.name](data.data.payload);
  470.                                 else
  471.                                     rpcFunctions[data.data.modID][data.data.name]();
  472.                                 break;
  473.                             case "saveData":
  474.                                 if (data.data && !alreadyLoadedSave && !netcodeSettings.hosting && connection.peer == netcodeSettings.host) {
  475.                                     Game.LoadSave(data.data);
  476.                                     alreadyLoadedSave = true;
  477.                                 }
  478.                                 break;
  479.                             case "newPeer":
  480.                                 if (data.data && typeof data.data === "string" && connections.length < 4) {
  481.                                     var conn = peer.connect(data.data);
  482.                                     onConnection(conn, true);
  483.                                 }
  484.                                 break;
  485.                             case "newName":
  486.                                 if (data.data && typeof data.data === "string") {
  487.                                     connection.macaName = data.data;
  488.                                     rebuildPlayerList();
  489.                                 }
  490.                             default:
  491.                                 return;
  492.                         }
  493.                     });
  494.                     connection.on("close", () => {
  495.                         connections.splice(connections.indexOf(connection), 1);
  496.                         rebuildPlayerList();
  497.                     });
  498.                 });
  499.             };
  500.             peer.on("connection", (conn) => onConnection(conn, false));
  501.             window.CreateConnection = (id) => { onConnection(peer.connect(id), true); netcodeSettings.host = id; netcodeSettings.hosting = false; alreadyLoadedSave = false; };
  502.             // establish hooks
  503.             // On click cookie
  504.             var clickRPC = new RPC("macadamia", "clickCookie");
  505.             clickRPC.setCallback(() => {
  506.                 window.DO_NOT_RPC = true; Game.ClickCookie(); window.DO_NOT_RPC = false;
  507.             });
  508.             var bigCookie = document.querySelector("button#bigCookie");
  509.             // @ts-ignore
  510.             bigCookie.removeEventListener("click", Game.ClickCookie);
  511.             bigCookie.onclick = (event) => {
  512.                 clickRPC.rpc();
  513.             };
  514.             window.upgradeRPC = new RPC("macadamia", "upgradePurchased");
  515.             window.upgradeRPC.setCallback((data) => {
  516.                 var upgrade = Game.UpgradesById[data.id];
  517.                 if (!upgrade)
  518.                     return;
  519.                 if (!upgrade.vanilla)
  520.                     return;
  521.                 if (upgrade.bought)
  522.                     return;
  523.                 window.DO_NOT_RPC = true;
  524.                 upgrade.buy(false);
  525.                 window.DO_NOT_RPC = false;
  526.             });
  527.             Game.Upgrade.prototype.buy = new raisin_1.Raisin(Game.Upgrade.prototype.buy)
  528.                 .insert(0, function () {
  529.                 if (!this.vanilla)
  530.                     return;
  531.                 window.upgradeRPC.send({ id: this.id });
  532.             })
  533.                 .compile();
  534.             // On upgrade purchased
  535.             for (var objectID in Game.ObjectsById) {
  536.                 var object = Game.ObjectsById[objectID];
  537.                 // On building purchased
  538.                 window.buildingRPC = new RPC("macadamia", "buildingPurchased");
  539.                 window.buildingRPC.setCallback((data) => {
  540.                     if (!data.amount)
  541.                         return;
  542.                     var building = Game.ObjectsById[data.id];
  543.                     if (!building)
  544.                         return;
  545.                     if (!building.vanilla)
  546.                         return;
  547.                     window.DO_NOT_RPC = true; // TODO: Find a better way to do this
  548.                     var oldBuyMode = Game.buyMode;
  549.                     Game.buyMode = 1;
  550.                     building.buy(data.amount);
  551.                     Game.buyMode = oldBuyMode;
  552.                     window.DO_NOT_RPC = false;
  553.                 });
  554.                 object.buy = new raisin_1.Raisin(object.buy)
  555.                     .insert(0, function () {
  556.                     if (!this.vanilla)
  557.                         return [];
  558.                     if (Game.buyMode == -1)
  559.                         return []; // sell mode
  560.                     window.buildingRPC.send({ id: this.id, amount: Game.buyBulk });
  561.                 })
  562.                     .compile();
  563.                 // On building sold
  564.                 window.buildingSellRPC = new RPC("macadamia", "buildingSold");
  565.                 window.buildingSellRPC.setCallback((data) => {
  566.                     if (!data.amount)
  567.                         return;
  568.                     var building = Game.ObjectsById[data.id];
  569.                     if (!building)
  570.                         return;
  571.                     if (!building.vanilla)
  572.                         return;
  573.                     window.DO_NOT_RPC = true;
  574.                     building.sell(data.amount, undefined);
  575.                     window.DO_NOT_RPC = false;
  576.                 });
  577.                 object.sell = new raisin_1.Raisin(object.sell)
  578.                     .insert(0, function () {
  579.                     if (!this.vanilla)
  580.                         return [];
  581.                     window.buildingSellRPC.send({ id: this.id, amount: Game.buyBulk });
  582.                 })
  583.                     .compile();
  584.                 // On building upgrade
  585.                 window.buildingUpgradeRPC = new RPC("macadamia", "buildingUpgrade");
  586.                 window.buildingUpgradeRPC.setCallback((data) => {
  587.                     if (!data.id)
  588.                         return;
  589.                     var building = Game.ObjectsById[data.id];
  590.                     if (!building)
  591.                         return;
  592.                     if (!building.vanilla)
  593.                         return;
  594.                     var oldLumps = Game.prefs.askLumps;
  595.                     Game.prefs.askLumps = false;
  596.                     window.DO_NOT_RPC = true;
  597.                     building.levelUp();
  598.                     window.DO_NOT_RPC = false;
  599.                     Game.prefs.askLumps = oldLumps;
  600.                 });
  601.                 object.levelUp = new raisin_1.Raisin(object.levelUp)
  602.                     .insert(0, function () {
  603.                     if (!this.vanilla)
  604.                         return [];
  605.                     window.buildingUpgradeRPC.send({ id: this.id });
  606.                 })
  607.                     .insertPerSignature(/(?<!Ga)(?<!miniga)me\./g, `Game.ObjectsById[${object.id}].`, false)
  608.                     .compile();
  609.             }
  610.         }
  611.         function sendDataToPeers(data) {
  612.             for (var connection in connections) {
  613.                 connections[connection].send(data);
  614.             }
  615.         }
  616.         ;
  617.         class RPC {
  618.             modID;
  619.             name;
  620.             constructor(modID, name) {
  621.                 this.modID = modID;
  622.                 this.name = name;
  623.             }
  624.             execute(payload) {
  625.                 if (payload) {
  626.                     rpcFunctions[this.modID][this.name](payload);
  627.                 } else {
  628.                     rpcFunctions[this.modID][this.name]();
  629.                 }
  630.             }
  631.             send(payload) {
  632.                 if (window.DO_NOT_RPC)
  633.                     return;
  634.                 sendDataToPeers({
  635.                     type: "rpc",
  636.                     data: {
  637.                         modID: this.modID,
  638.                         name: this.name,
  639.                         payload: payload
  640.                     }
  641.                 });
  642.             }
  643.             rpc(payload) {
  644.                 if (window.DO_NOT_RPC)
  645.                     return;
  646.                 this.send(payload);
  647.                 if (payload)
  648.                     rpcFunctions[this.modID][this.name](payload);
  649.                 else
  650.                     rpcFunctions[this.modID][this.name]();
  651.             }
  652.             setCallback(callback) {
  653.                 rpcFunctions[this.modID] = rpcFunctions[this.modID] || {};
  654.                 rpcFunctions[this.modID][this.name] = callback;
  655.                 return this;
  656.             }
  657.         }
  658.         exports.RPC = RPC;
  659.         class SharedVariable extends RPC {
  660.             #value;
  661.             settings;
  662.             subscribers = [];
  663.             constructor(modID, name, settings) {
  664.                 super(modID, name);
  665.                 this.#value = settings.defaultValue;
  666.                 this.settings = settings;
  667.                 this.setCallback((payload) => {
  668.                     if (payload) {
  669.                         this.value = payload;
  670.                     }
  671.                     for (var subscriber in this.subscribers) {
  672.                         this.subscribers[subscriber](this.value);
  673.                     }
  674.                 });
  675.             }
  676.             default() {
  677.                 this.value = this.settings.defaultValue;
  678.             }
  679.             get value() {
  680.                 return this.#value;
  681.             }
  682.             set value(val) {
  683.                 if (this.settings.sanitizer) {
  684.                     if (!this.settings.sanitizer(val))
  685.                         return;
  686.                 }
  687.                 this.#value = val;
  688.                 this.send(val);
  689.             }
  690.             subscribe(callback) {
  691.                 this.subscribers.push(callback);
  692.                 return this;
  693.             }
  694.         }
  695.         exports.SharedVariable = SharedVariable;
  696.         setInterval(() => {
  697.             if (netcodeSettings.hosting)
  698.                 sendDataToPeers({
  699.                     type: "macadamiaSync",
  700.                     data: Game.WriteSave(1)
  701.                 });
  702.         }, netcodeSettings.syncPeriod);
  703.     });
  704.     define("core/core", ["require", "exports", "logs", "core/modManager", "core/multiplayer"], function (require, exports, logs_4, modManager_1, multiplayer_1) {
  705.         "use strict";
  706.         Object.defineProperty(exports, "__esModule", { value: true });
  707.         exports.loadCore = loadCore;
  708.         const logger = new logs_4.Logger("macadamia::core");
  709.         async function loadCore() {
  710.             logger.log("loading core features...");
  711.             await (0, multiplayer_1.loadMultiplayer)(); // multiplayer
  712.             await (0, modManager_1.loadModManager)(); // mod manager
  713.             logger.log("core loaded successfully!");
  714.         }
  715.     });
  716.     define("mod", ["require", "exports", "core/multiplayer", "hooks", "logs", "raisin"], function (require, exports, multiplayer_2, hooks_1, logs_5, raisin_2) {
  717.         "use strict";
  718.         Object.defineProperty(exports, "__esModule", { value: true });
  719.         exports.Mod = void 0;
  720.         class Mod {
  721.             uuid;
  722.             logger;
  723.             hooks;
  724.             constructor(uuid) {
  725.                 this.uuid = uuid;
  726.                 this.logger = new logs_5.Logger(this.uuid);
  727.                 this.hooks = (0, hooks_1.buildHooks)();
  728.             }
  729.             async awake() { }
  730.             async sleep() { }
  731.             async hookBuilder() { }
  732.             async rpcBuilder() { }
  733.             // Helper utils
  734.             createSharedVariable(name, settings) {
  735.                 return new multiplayer_2.SharedVariable(this.uuid, name, settings);
  736.             }
  737.             createRPC(name) {
  738.                 return new multiplayer_2.RPC(this.uuid, name);
  739.             }
  740.             createRaisin(func) {
  741.                 return new raisin_2.ModRaisin(this.uuid, func);
  742.             }
  743.         }
  744.         exports.Mod = Mod;
  745.     });
  746.     define("index", ["require", "exports", "cleaner", "core/core", "logs", "mod"], function (require, exports, cleaner_1, core_1, logs_6, mod_1) {
  747.         "use strict";
  748.         Object.defineProperty(exports, "__esModule", { value: true });
  749.         window.Macadamia = {
  750.             Version: "1.0.0beta",
  751.             Defaults: {
  752.             // Defaults for Macadamia will go here.
  753.             },
  754.             Mod: mod_1.Mod,
  755.             async register(mod, manifest) {
  756.                 var currMod = new mod(manifest.uuid);
  757.                 window.MacadamiaModList[manifest.uuid] = {
  758.                     mod: currMod,
  759.                     manifest: manifest,
  760.                     enabled: true
  761.                 };
  762.                 await currMod.rpcBuilder();
  763.                 await currMod.awake();
  764.                 await currMod.hookBuilder();
  765.                 (0, logs_6.log)("macadamia", `registered ${manifest.uuid}.`);
  766.             },
  767.             async disableMod(uuid) {
  768.                 if (uuid == "macadamia")
  769.                     return;
  770.                 var mod = window.MacadamiaModList[uuid];
  771.                 if (!mod) {
  772.                     (0, logs_6.log)("macadamia", `mod ${uuid} not found.`);
  773.                     return;
  774.                 }
  775.                 mod.enabled = false;
  776.                 mod.mod.hooks.enabled = false;
  777.                 await mod.mod.sleep();
  778.                 (0, logs_6.log)("macadamia", `disabled ${uuid}.`);
  779.             },
  780.             enableMod(uuid) {
  781.                 if (uuid == "macadamia")
  782.                     return;
  783.                 var mod = window.MacadamiaModList[uuid];
  784.                 if (!mod) {
  785.                     (0, logs_6.log)("macadamia", `mod ${uuid} not found.`);
  786.                     return;
  787.                 }
  788.                 mod.enabled = true;
  789.                 mod.mod.hooks.enabled = true;
  790.                 (0, logs_6.log)("macadamia", `enabled ${uuid}.`);
  791.             },
  792.             toggleMod(uuid) {
  793.                 if (window.MacadamiaModList[uuid].enabled) {
  794.                     window.Macadamia.disableMod(uuid);
  795.                 }
  796.                 else {
  797.                     window.Macadamia.enableMod(uuid);
  798.                 }
  799.             },
  800.             toggleStreamerMode() {
  801.                 if (localStorage.getItem("streamerMode") === "true") {
  802.                     localStorage.setItem("streamerMode", "false");
  803.                 }
  804.                 else {
  805.                     localStorage.setItem("streamerMode", "true");
  806.                 }
  807.             }
  808.         };
  809.         window.MacadamiaModList = { macadamia: { mod: null, manifest: {
  810.                     uuid: "macadamia",
  811.                     name: "Macadamia",
  812.                     description: "Macadamia",
  813.                     author: "RedBigz",
  814.                     version: window.Macadamia.Version,
  815.                     icon: "https://redbigz.com/lfs/macadamia/res/logo.png"
  816.                 }, enabled: true } }; // { [key: string]: { mod: Mod, manifest: { uuid: string; }, enabled: boolean } }
  817.         async function main() {
  818.             (0, cleaner_1.clean)();
  819.             (0, logs_6.init)();
  820.             await (0, core_1.loadCore)();
  821.             (0, logs_6.welcome)();
  822.         }
  823.         main();
  824.     });
  825.     require(["index"]);
  826. });
  827.  
  828. var cssList = '';
  829.  
  830. var availableChars = '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM-=[]\\{}|;\'":,./<>+_?!@#$%^&*()`~'.split('').concat(' ').concat('  ');
  831.  
  832. var colorList = ['#ffffff', '#a8ffbf'];
  833.  
  834. var previousContents = {};
  835.  
  836. class charRow {
  837.     constructor(uuid) {
  838.         this.id = uuid;
  839.         previousContents[uuid] = this;
  840.        
  841.         this.l = window.createTypingDisplay(uuid, colorList[Object.keys(previousContents).length]);
  842.         this.c = [];
  843.     }
  844.    
  845.     removeL() {
  846.         this.l.remove();
  847.     }
  848. }
  849.  
  850. class char {
  851.     constructor(content, color, parent) {
  852.         this.c = content;
  853.         this.mt = 15 * Game.fps;
  854.         this.mtFulllengthMax = 14 * Game.fps;
  855.         this.t = this.mt;
  856.         this.l = null;
  857.         this.parentL = parent;
  858.         this.margins = 1;
  859.         this.color = color;
  860.  
  861.         this.createL();
  862.     }
  863.  
  864.     createL() {
  865.         var div = document.createElement('span');
  866.         div.classList.add('character');
  867.         div.innerText = this.c;
  868.         div.style.color = this.color;
  869.         div.style.margin = this.margins;
  870.         this.l = div;
  871.  
  872.         this.parentL.appendChild(this.l);
  873.     }
  874.  
  875.     removeL() {
  876.         this.l.remove();
  877.     }
  878.  
  879.     scale() {
  880.         return Math.min(this.t / (this.mt - this.mtFulllengthMax), 1)*100;
  881.     }
  882. }
  883.  
  884. function createTypingDisplayMod() {
  885.     window.addEventListener('keydown', function(e) { if (e.key == ' ') { e.preventDefault(); } });
  886.  
  887.     window.createTypingDisplay = function(peerid, color) {
  888.         var div = document.createElement('div');
  889.         div.classList.add('typingDisplayContainer');
  890.         div.id = 'typingDisplayContainer';
  891.         div.style.color = color;
  892.         l('typingDisplayMaster').appendChild(div);
  893.        
  894.         return div;
  895.     }
  896.    
  897.     let mdiv = document.createElement('div');
  898.     mdiv.classList.add('typingDisplayMaster');
  899.     mdiv.id = 'typingDisplayMaster';
  900.     l('game').appendChild(mdiv);
  901.  
  902.     function injectCSS(str) {
  903.         cssList += str + '\n';
  904.     }
  905.  
  906.     injectCSS('.typingDisplayContainer { z-index: 100000000; transform: translate(-50%, 0%); padding: 5px; border-radius: 5px; background: rgba(0, 0, 0, 0.25); }');
  907.     injectCSS('.typingDisplayMaster { position: absolute; z-index: 1000; left: 50%; bottom: 10%; pointer-events: none; }')
  908.     injectCSS('.character { display: inline-block; margin: 1px; font-size: 15px; }');
  909.  
  910.     let allStyles = document.createElement('style');
  911.     allStyles.textContent = cssList;
  912.     cssList = '';
  913.     l('game').appendChild(allStyles);
  914.  
  915.     addEventListener('keydown', function (event) {
  916.         if (!event.ctrlKey && availableChars.includes(event.key)) { MacadamiaModList.tduuid.mod.addChar(event.key); }
  917.     });
  918.  
  919.     Game.registerHook('logic', function() {
  920.         for (let i in previousContents) {
  921.             let c = previousContents[i];
  922.             if (!c.c.length) { c.l.style.display = 'none'; } else { c.l.style.display = ''; }
  923.             for (let i = 0; i < c.c.length; i++) {
  924.                 var me = c.c[i];
  925.                 if (!me) { continue; }
  926.                 me.t--;
  927.                 if (me.t <= 0) { me.removeL(); c.c.shift(); i--; MacadamiaModList.tduuid.mod.charCountOffset++; continue; }
  928.                 me.l.style.transform = 'scaleX(' + me.scale() + '%)';
  929.             }
  930.         }
  931.     })
  932.  
  933.     Game.registerHook('check', function() {
  934.         for (let i in previousContents) {
  935.             if (previousContents[i].c.length == 0) {
  936.                 while (previousContents[i].l.firstChild) {
  937.                     previousContents[i].l.removeChild(previousContents[i].l.firstChild);
  938.                 }
  939.             }
  940.         }
  941.     })
  942.  
  943.     class TypingDisplay extends Macadamia.Mod {
  944.         async hookBuilder() {
  945.            
  946.         }
  947.  
  948.         async rpcBuilder() {
  949.             this.charCount = 0;
  950.             this.charCountOffset = 0;
  951.  
  952.             this.charRPC = this.createRPC("char");
  953.             this.charRPC.setCallback((arg) => {
  954.                 const ch = new char(arg.char, arg.color, previousContents[arg.id].l);
  955.                 if (arg.char == ' ') { ch.margins = 2; }
  956.                 const arr = previousContents[arg.id].c;
  957.                 while (arr.length + this.charCountOffset < arg.count - 1) {
  958.                     arr.push(null);
  959.                 }
  960.                 arr[arg.count - 1] = ch;
  961.             });
  962.            
  963.             this.newRowRPC = this.createRPC('newRow');
  964.             this.newRowRPC.setCallback((arg) => {
  965.                 new charRow(arg.id);
  966.                 //Game.Notify('new row! '+arg.id, '', 0);
  967.                 //console.log('new row '+arg.id);
  968.             });
  969.            
  970.             setTimeout(function() { new charRow(window.peer.id); }, 100);
  971.         }
  972.        
  973.         constructDisplayList(connected) {
  974.             for (let i in previousContents) {
  975.                 previousContents[i].removeL();
  976.             }
  977.             previousContents = {};
  978.             new charRow(window.peer.id);
  979.             for (let i in connected) {
  980.                 new charRow(connected[i]);
  981.             }
  982.         }
  983.  
  984.         async awake() {
  985.            
  986.         }
  987.  
  988.         async sleep() {
  989.             // When your mod is disabled this is called. If you use any other modding APIs make sure you destroy any changes created with them here.
  990.         }
  991.  
  992.         addChar(key) {
  993.             this.charCount++;
  994.             this.charRPC.send({ id: window.peer.id, char: key, count: this.charCount });
  995.             this.charRPC.execute({ id: window.peer.id, char: key, count: this.charCount });
  996.         }
  997.     }
  998.  
  999.     Macadamia.register(TypingDisplay, {
  1000.         uuid: "tduuid",
  1001.         name: "TypingDisplay",
  1002.         description: "Displays what you typed onto the screen for all connected players.",
  1003.         author: "CursedSliver",
  1004.         version: "1.0.0"
  1005.     });
  1006. }
  1007.  
  1008. class mouse {
  1009.     constructor(uuid) {
  1010.         let ele = document.createElement('div');
  1011.         ele.style.backgroundImage = 'url(\'https://cursedsliver.github.io/asdoindwalk/mouse.png\')';
  1012.         ele.style.backgroundSize = 'contain';
  1013.         ele.style.backgroundRepeat = 'no-repeat';
  1014.         ele.style.width = '512px';
  1015.         ele.style.height = '512px';
  1016.         ele.style.transform = 'scale(0.1) translate(-50%, -50%)';
  1017.         ele.style.margin = '-216px -160px'
  1018.         ele.style.position = 'absolute';
  1019.         ele.style.pointerEvents = 'none';
  1020.         ele.style.top = '0px';
  1021.         ele.style.left = '0px';
  1022.         ele.style.zIndex = 10000000000;
  1023.         this.l = ele;
  1024.         this.uuid = uuid;
  1025.         this.x = 0;
  1026.         this.y = 0;
  1027.  
  1028.         l('mouseDisplay').appendChild(this.l);
  1029.     }
  1030.  
  1031.     updatePosition(x, y) {
  1032.         x = parseFloat(x);
  1033.         y = parseFloat(y);
  1034.         //console.log(x, y);
  1035.         this.x = x;
  1036.         this.l.style.left = Math.round(this.x * l('game').offsetWidth) + 'px';
  1037.         this.y = y;
  1038.         this.l.style.top = Math.round(this.y * l('game').offsetHeight) + 'px';
  1039.     }
  1040. }
  1041.  
  1042. let lastMovedFrame = Game.T;
  1043.  
  1044. function createMouseDisplay() {
  1045.     let mouseDisplayLayer = document.createElement('div');
  1046.     mouseDisplayLayer.style = 'position: absolute; left: -48px; top: 0px; filter:drop-shadow(0px 4px 4px rgba(0,0,0,0.75)); pointer-events: none; -webkit-filter:drop-shadow(0px 4px 4px rgba(0,0,0,0.75)); z-index: 100000000000;';
  1047.     mouseDisplayLayer.id = 'mouseDisplay';
  1048.     l('game').appendChild(mouseDisplayLayer);
  1049.  
  1050.     window.mouseList = {};
  1051.  
  1052.  
  1053.     AddEvent(document, 'mousemove', (e) => {
  1054.         if (lastMovedFrame == Game.T) { return; }
  1055.         window.MacadamiaModList.mouse.mod.newPosRPC.send({ uuid: window.peer.id, x: Game.mouseX / l('game').offsetWidth, y: Game.mouseY / l('game').offsetHeight });
  1056.         lastMovedFrame = Game.T;
  1057.     });
  1058.  
  1059.     class mouseDisplayMod extends Macadamia.Mod {
  1060.         async awake() {
  1061.         }
  1062.  
  1063.         async rpcBuilder() {
  1064.             this.newPosRPC = this.createRPC('mousePosUpdate');
  1065.             this.newPosRPC.setCallback((arg) => {
  1066.                 if (window.mouseList[arg.uuid]) { window.mouseList[arg.uuid].updatePosition(arg.x, arg.y); }
  1067.             });
  1068.  
  1069.             this.newMouseRPC = this.createRPC('newMouse');
  1070.             this.newMouseRPC.setCallback((arg) => {
  1071.                 window.MacadamiaModList.mouse.mod.addMouse(arg.uuid, arg.x, arg.y);
  1072.             });
  1073.         }
  1074.  
  1075.         initMouses(peerIds) {
  1076.             window.mouseList = {};
  1077.             for (let i in peerIds) {
  1078.                 window.mouseList[peerIds[i]] = new mouse(peerIds[i]);
  1079.             }
  1080.             this.newMouseRPC.send({ uuid: window.peer.id, x: Game.mouseX / l('game').offsetWidth, y: Game.mouseY / l('game').offsetHeight });
  1081.         }
  1082.  
  1083.         addMouse(peerId, x, y) {
  1084.             window.mouseList[peerId] = new mouse(peerId);
  1085.             if (typeof x === 'number' && typeof y === 'number') {
  1086.                 window.mouseList[peerId].updatePosition(x, y);
  1087.             }
  1088.         }
  1089.     }
  1090.  
  1091.     Macadamia.register(mouseDisplayMod, {
  1092.         uuid: "mouse",
  1093.         name: "Mouse display",
  1094.         description: "Displays the mouses of all other connected players",
  1095.         author: "CursedSliver",
  1096.         version: "1.0.0"
  1097.     });
  1098. }
  1099.  
  1100. var isHost = true;
  1101. function createGCSyncer() {
  1102.     Game.registerHook('logic', () => {
  1103.         for (let i in Game.shimmers) {
  1104.             if (!Game.shimmers[i].sent) {
  1105.                 Game.shimmers[i].sent = true;
  1106.                 window.sendShimmerRPC.call(Game.shimmers[i]);
  1107.             }
  1108.         }
  1109.     }); //obligatory one frame delay yay!!!
  1110.     //screw raisins those suck so much
  1111.  
  1112.     class GCSyncer extends Macadamia.Mod {
  1113.         async hookBuilder() {
  1114.             eval('Game.updateShimmers='+Game.updateShimmers.toString().replace('//cookie storm!', `if (!netcodeSettingsExport.hosting) { return; } //cookie storm!`));
  1115.             Game.shimmer.prototype.getForceObjString = function() {
  1116.                 //gets a string representation for rpc purposes
  1117.                 //honestly idk what forceobj is used for so I just left it blank
  1118.                 let str = '';
  1119.                 return str;
  1120.             }
  1121.             Game.shimmer.prototype.modifyPayload = function(obj) {
  1122.                 if (this.type == 'golden') {
  1123.                     obj.wrath = this.wrath;
  1124.                    
  1125.                 }
  1126.                 obj.dur = this.dur;
  1127.                 obj.spawnLead = this.spawnLead;
  1128.             }
  1129.  
  1130.             window.sendShimmerRPC = function() {
  1131.                 let obj = {
  1132.                     x: this.x,
  1133.                     y: this.y,
  1134.                     id: this.id,
  1135.                     force: this.force,
  1136.                     type: this.type,
  1137.                     noCount: this.noCount,
  1138.                     backgroundImage: this.l.style.backgroundImage,
  1139.                     forceObj: this.getForceObjString()
  1140.                 };
  1141.                 this.modifyPayload(obj);
  1142.                 MacadamiaModList.gcsy.mod.shimmerSpawnRPC.send(obj);
  1143.             };
  1144.  
  1145.             Game.shimmer.prototype.pop = this.createRaisin(Game.shimmer.prototype.pop).insert(0, () => { window.MacadamiaModList.gcsy.mod.shimmerPopRPC.send({ id: this.id }); }).compile();
  1146.            
  1147.             Game.killShimmers = this.createRaisin(Game.killShimmers).insert(0, () => { window.MacadamiaModList.gcsy.mod.killShimmersRPC.send(); }).compile();
  1148.  
  1149.             Game.Popup = this.createRaisin(Game.Popup).insert(0, (text, x, y) => { if (Game.popups) { window.MacadamiaModList.gcsy.mod.popupRPC.send({ text: text, x: x, y: y }); } }).compile();
  1150.  
  1151.             Game.gainBuff = this.createRaisin(Game.gainBuff).insert(0, (type, time, arg1, arg2, arg3) => { window.MacadamiaModList.gcsy.mod.gainBuffRPC.send({ type: type, time: time, arg1: arg1, arg2: arg2, arg3: arg3 }); }).compile();
  1152.  
  1153.             Game.killBuff = this.createRaisin(Game.killBuff).insert(0, (what) => { window.MacadamiaModList.gcsy.mod.killBuffRPC.send({ buff: what }); }).compile();
  1154.            
  1155.             Game.killBuffs = this.createRaisin(Game.killBuffs).insert(0, () => { window.MacadamiaModList.gcsy.mod.killBuffsRPC.send(); }).compile();
  1156.  
  1157.             Game.Earn = this.createRaisin(Game.Earn).insert(0, (howmuch) => { window.MacadamiaModList.gcsy.mod.earnRPC.send({ n: parseInt(howmuch) }); }).compile();
  1158.  
  1159.             Game.Notify = this.createRaisin(Game.Notify).insert(0, (title, desc, pic, quick, noLog) => { if (Game.popups) { window.MacadamiaModList.gcsy.mod.notifRPC.send({ title: title, text: desc, iconX: Array.isArray(pic)?pic[0]:null, iconY: pic[1], iconPic: pic[2], quick: quick, noLog: noLog }); } }).compile();
  1160.  
  1161.             //make it so that non-hosts cant generate achievement or game saved notifs
  1162.  
  1163.             AddEvent(l('prefsButton'),'click',function(){ window.MacadamiaModList.gcsy.mod.openMenuRPC.send({ menu: 'prefs' }); });
  1164.             AddEvent(l('statsButton'),'click',function(){ window.MacadamiaModList.gcsy.mod.openMenuRPC.send({ menu: 'stats' }); });
  1165.             AddEvent(l('logButton'),'click',function(){ window.MacadamiaModList.gcsy.mod.openMenuRPC.send({ menu: 'log' }); });
  1166.  
  1167.             Game.ClosePrompt = this.createRaisin(Game.ClosePrompt).insert(0, () => { window.MacadamiaModList.gcsy.mod.closePromptRPC.send(); }).compile();
  1168.  
  1169.             Game.Prompt = this.createRaisin(Game.Prompt).insert(0, (content, options, updateFunc, style ) => { window.MacadamiaModList.gcsy.mod.promptRPC.send({ content: content, options: options, updateFunc: (updateFunc?updateFunc.toString():''), style: style }); }).compile();
  1170.  
  1171.             AddEvent(l('commentsText1'),'click',function() { window.MacadamiaModList.gcsy.mod.tickerRPC.send(); });
  1172.  
  1173.             Game.ToggleSpecialMenu = this.createRaisin(Game.ToggleSpecialMenu).insert(0, (on) => {  window.MacadamiaModList.gcsy.mod.toggleSpecialRPC.send({ on: on, tab: Game.specialTab }); }).compile();
  1174.  
  1175.             eval('Game.SelectDragonAura='+Game.SelectDragonAura.toString().replace(`(slot==0?'Game.dragonAura':'Game.dragonAura2')+'=Game.SelectingDragonAura;'`, `(slot==0?'Game.dragonAura':'Game.dragonAura2')+'=Game.SelectingDragonAura; window.MacadamiaModList.gcsy.mod.confirmAuraRPC.send({ slot: '+slot+', aura: Game.SelectingDragonAura });'`));
  1176.             Game.SelectDragonAura = this.createRaisin(Game.SelectDragonAura).insert(0, (slot) => { window.MacadamiaModList.gcsy.mod.selectAuraRPC.send({ slot: slot }); }).compile();
  1177.  
  1178.             Game.SetDragonAura = this.createRaisin(Game.SetDragonAura).insert(0, (aura, slot) => { window.MacadamiaModList.gcsy.mod.setAuraRPC.send({ aura: aura, slot: slot }); }).compile();
  1179.  
  1180.             for (let i in Game.Objects) {
  1181.                 eval('Game.Objects["'+i+'"].buyFree='+Game.Objects[i].buyFree.toString().replace('>=price', '>=this.price'));
  1182.                 Game.Objects[i].buyFree = this.createRaisin(Game.Objects[i].buyFree).insert(0, (amount) => { window.MacadamiaModList.gcsy.mod.buyFreeRPC.send({ amount: amount, building: this.name }); }).compile();
  1183.                 Game.Objects[i].sacrifice = this.createRaisin(Game.Objects[i].sacrifice).insert(0, (amount) => { window.MacadamiaModList.gcsy.mod.sacrificeBuildingRPC.send({ amount: amount, building: this.name }); }).compile();
  1184.             }
  1185.         }
  1186.  
  1187.         async rpcBuilder() {
  1188.             this.shimmerSpawnRPC = this.createRPC('shimmerSpawn');
  1189.             this.shimmerSpawnRPC.setCallback((arg) => {
  1190.                 //arg format: x, y, type, id, force, noCount, backgroundImage, forceObj (from getString), other stuff from modifyPayload
  1191.                 let s = new Game.shimmer(arg.type, null, arg.noCount);
  1192.                 s.x = arg.x;
  1193.                 s.y = arg.y;
  1194.                 s.id = arg.id;
  1195.                 s.force = arg.force;
  1196.                 s.l.style.backgroundImage = arg.backgroundImage;
  1197.                 if (arg.spawnLead) { s.spawnLead = arg.spawnLead; }
  1198.                 s.dur = arg.dur;
  1199.                 s.life = Math.ceil(arg.dur * Game.fps);
  1200.                 if (s.type == 'golden') { s.wrath = arg.wrath; }
  1201.                 s.sent = true;
  1202.             });
  1203.  
  1204.             this.shimmerPopRPC = this.createRPC('shimmerPop')
  1205.             this.shimmerPopRPC.setCallback((arg) => {
  1206.                 for (let i in Game.shimmers) {
  1207.                     if (Game.shimmers[i].id == arg.id) {
  1208.                         Game.shimmers[i].die();
  1209.                         break;
  1210.                     }
  1211.                 }
  1212.             });
  1213.            
  1214.             this.killShimmersRPC = this.createRPC('killShimmers');
  1215.             this.killShimmersRPC.setCallback(() => {
  1216.                 window.DO_NOT_RPC = true;
  1217.                 Game.killShimmers();
  1218.                 window.DO_NOT_RPC = false;
  1219.             });
  1220.  
  1221.             this.popupRPC = this.createRPC('popup');
  1222.             this.popupRPC.setCallback((arg) => {
  1223.                 Game.textParticlesAdd(arg.text,0,arg.x,arg.y);
  1224.             });
  1225.  
  1226.             this.gainBuffRPC = this.createRPC('gainBuff');
  1227.             this.gainBuffRPC.setCallback((arg) => {
  1228.                 window.DO_NOT_RPC = true;
  1229.                 Game.gainBuff(arg.type, arg.time, arg.arg1, arg.arg2, arg.arg3);
  1230.                 window.DO_NOT_RPC = false;
  1231.             });
  1232.            
  1233.             this.killBuffRPC = this.createRPC('killBuff');
  1234.             this.killBuffRPC.setCallback((arg) => {
  1235.                 window.DO_NOT_RPC = true;
  1236.                 Game.killBuff(arg.buff);
  1237.                 window.DO_NOT_RPC = false;
  1238.             });
  1239.            
  1240.             this.killBuffsRPC = this.createRPC('killBuffs');
  1241.             this.killBuffsRPC.setCallback(() => {
  1242.                 window.DO_NOT_RPC = true;
  1243.                 Game.killBuffs();
  1244.                 window.DO_NOT_RPC = false;
  1245.             });
  1246.  
  1247.             this.earnRPC = this.createRPC('earn');
  1248.             this.earnRPC.setCallback((howmuch) => {
  1249.                 Game.cookies += howmuch.n;
  1250.                 Game.cookiesEarned += howmuch.n;
  1251.             });
  1252.  
  1253.             this.notifRPC = this.createRPC('notifs');
  1254.             this.notifRPC.setCallback((arg) => {
  1255.                 window.DO_NOT_RPC = true;
  1256.                 let arr = [arg.iconX, arg.iconY];
  1257.                 if (arg.iconPic) { arr.push(arg.iconPic); }
  1258.                 if (typeof arg.iconX === 'undefined') { arr = 0; }
  1259.                 Game.Notify(arg.title, arg.text, arr, arg.quick, arg.noLog);
  1260.                 window.DO_NOT_RPC = false;
  1261.             });
  1262.  
  1263.             this.openMenuRPC = this.createRPC('openMenu');
  1264.             this.openMenuRPC.setCallback((arg) => {
  1265.                 Game.ShowMenu(arg.menu);
  1266.             });
  1267.  
  1268.             this.closePromptRPC = this.createRPC('closePrompt');
  1269.             this.closePromptRPC.setCallback(() => {
  1270.                 window.DO_NOT_RPC = true;
  1271.                 Game.ClosePrompt();
  1272.                 window.DO_NOT_RPC = false;
  1273.             });
  1274.  
  1275.             this.promptRPC = this.createRPC('prompt');
  1276.             this.promptRPC.setCallback((arg) => {
  1277.                 window.DO_NOT_RPC = true;
  1278.                 Game.Prompt(arg.content, arg.options, arg.updateFunc?(new Function('let hhhhhh = ' + arg.updateFunc + ' hhhhhh(); ')):0, arg.style);
  1279.                 window.DO_NOT_RPC = false;
  1280.             });
  1281.  
  1282.             this.tickerRPC = this.createRPC('ticker');
  1283.             this.tickerRPC.setCallback(() => {
  1284.                 window.DO_NOT_RPC = true;
  1285.                 l('commentsText1').click();
  1286.                 window.DO_NOT_RPC = false;
  1287.             });
  1288.  
  1289.             this.toggleSpecialRPC = this.createRPC('toggleSpecial');
  1290.             this.toggleSpecialRPC.setCallback((arg) => {
  1291.                 Game.specialTab = arg.tab;
  1292.                 window.DO_NOT_RPC = true;
  1293.                 Game.ToggleSpecialMenu(arg.on);
  1294.                 window.DO_NOT_RPC = false;
  1295.             });
  1296.  
  1297.             this.selectAuraRPC = this.createRPC('selectAura');
  1298.             this.selectAuraRPC.setCallback((arg) => {
  1299.                 window.DO_NOT_RPC = true;
  1300.                 Game.SelectDragonAura(arg.slot, 0);
  1301.                 window.DO_NOT_RPC = false;
  1302.             });
  1303.  
  1304.             this.setAuraRPC = this.createRPC('setAura');
  1305.             this.setAuraRPC.setCallback((arg) => {
  1306.                 Game.SelectingDragonAura = arg.aura;
  1307.                 //Game.Notify('Aura set: '+arg.aura, '', 0);
  1308.                 window.DO_NOT_RPC = true;
  1309.                 Game.SelectDragonAura(arg.slot,1);
  1310.                 window.DO_NOT_RPC = false;
  1311.                 //Game.Notify('Current aura: '+Game.SelectingDragonAura, '', 0);
  1312.             });
  1313.  
  1314.             this.confirmAuraRPC = this.createRPC('confirmAura');
  1315.             this.confirmAuraRPC.setCallback((arg) => {
  1316.                 if (arg.slot == 0) {
  1317.                     Game.dragonAura = arg.aura;
  1318.                 } else {
  1319.                     Game.dragonAura2 = arg.aura;
  1320.                 }
  1321.                 //Game.Notify('Aura confirmed: '+Game.SelectingDragonAura, '', 0);
  1322.             });
  1323.  
  1324.             this.buyFreeRPC = this.createRPC('buyFree');
  1325.             this.buyFreeRPC.setCallback((arg) => {
  1326.                 window.DO_NOT_RPC = true;
  1327.                 Game.Objects[arg.building].buyFree(arg.amount);
  1328.                 window.DO_NOT_RPC = false;
  1329.             });
  1330.  
  1331.             this.sacrificeBuildingRPC = this.createRPC('sacrificeBuilding');
  1332.             this.sacrificeBuildingRPC.setCallback((arg) => {
  1333.                 window.DO_NOT_RPC = true;
  1334.                 Game.Objects[arg.building].sacrifice(arg.amount);
  1335.                 window.DO_NOT_RPC = false;
  1336.             });
  1337.         }
  1338.     }
  1339.  
  1340.     Macadamia.register(GCSyncer, {
  1341.         uuid: "gcsy",
  1342.         name: "Shimmer integration",
  1343.         description: "Syncs golden cookie behaviors across all current players... alongside some other things",
  1344.         author: "CursedSliver",
  1345.         version: "1.0.0"
  1346.     });
  1347. }
  1348.  
  1349. function createMinigameSyncer() {
  1350.     class minigameSyncer extends Macadamia.Mod {
  1351.         async hookBuilder() {
  1352.             this.syncGarden();
  1353.             this.syncStocks();
  1354.             this.syncPantheon();
  1355.             this.syncGrimoire();
  1356.         }
  1357.  
  1358.         syncGarden() {
  1359.             if (!Game.Objects.Farm.minigameLoaded) { setTimeout(function() { MacadamiaModList.minigames.mod.syncGarden(); }, 20); return; }
  1360.            
  1361.             let M = Game.Objects['Farm'].minigame;
  1362.  
  1363.             eval('M.clickTile='+M.clickTile.toString().replace('//', 'MacadamiaModList.minigames.mod.clickTileRPC.send({ x: x, y: y, shift: Game.keys[16], seedHolding: M.seedSelected }) //'));
  1364.             M.buildPlot();
  1365.  
  1366.             eval('M.buildPanel='+M.buildPanel.toString().replace('if (/* !M.freeze && */G', 'MacadamiaModList.minigames.mod.clickSeedRPC.send({ id: me.id }); if (/* !M.freeze && */G').replace('M.nextSoil=Date.now()', 'MacadamiaModList.minigames.mod.soilRPC.send({ id: me.id }); M.nextSoil=Date.now()'));
  1367.             eval('M.tools.harvestAll.func='+M.tools.harvestAll.func.toString().replace('PlaySound', 'MacadamiaModList.minigames.mod.harvestAllRPC.send(); PlaySound'));
  1368.             eval('M.tools.freeze.func='+M.tools.freeze.func.toString().replace('//if (!M.freeze && M.nextFreeze>Date.now()) return false;', 'MacadamiaModList.minigames.mod.freezeRPC.send(); //if (!M.freeze && M.nextFreeze>Date.now()) return false;'));
  1369.             eval('M.convert='+M.convert.toString().replace('M.harvestAll();', 'MacadamiaModList.minigames.mod.sacrificeRPC.send(); M.harvestAll();'));
  1370.             M.buildPanel();
  1371.  
  1372.             eval('M.logic='+M.logic.toString().replace('M.computeBoostPlot();', 'if (!netcodeSettingsExport.hosting) { return; } M.computeBoostPlot();').replace('if (M.toCompute) M.computeEffs(); if (netcodeSettingsExport.hosting) { MacadamiaModList.minigames.mod.plotSyncRPC.send({ code: M.exportPlot() }); }'));
  1373.  
  1374.             M.exportPlot = function() {
  1375.                 let str = '';
  1376.                 for (var y = 0; y < 6; y++) {
  1377.                     for (var x = 0; x < 6; x++) {
  1378.                         str += parseInt(M.plot[y][x][0]) + ':' + parseInt(M.plot[y][x][1]) + ':';
  1379.                     }
  1380.                 }
  1381.                 return str;
  1382.             }
  1383.  
  1384.             M.importPlot = function(str) {
  1385.                 let plot = str.split(':');
  1386.                 var n = 0;
  1387.                 for (var y = 0; y < 6; y++) {
  1388.                     for (var x = 0; x < 6; x++) {
  1389.                         M.plot[y][x] = [parseInt(plot[n]), parseInt(plot[n + 1])];
  1390.                         n += 2;
  1391.                     }
  1392.                 }
  1393.                 M.buildPlot();
  1394.                 M.buildPanel();
  1395.             }
  1396.            
  1397.             AddEvent(M.lumpRefill, 'click', function() { MacadamiaModList.minigames.mod.gardenRefillRPC.send(); });
  1398.         }
  1399.  
  1400.         syncStocks() {
  1401.             if (!Game.Objects.Bank.minigameLoaded) { setTimeout(function() { MacadamiaModList.minigames.mod.syncStocks(); }, 20); return; }
  1402.            
  1403.             //only gonna sync the loans
  1404.             let M = Game.Objects['Bank'].minigame;
  1405.  
  1406.             for (let i = 1; i <= 3; i++) {
  1407.                 AddEvent(l('bankLoan'+i), 'click', function() { MacadamiaModList.minigames.mod.loanRPC.send({ id: i, interest: 0 }); });
  1408.             }
  1409.             Game.takeLoan = M.takeLoan;
  1410.         }
  1411.  
  1412.         syncPantheon() {
  1413.             if (!Game.Objects.Temple.minigameLoaded) { setTimeout(function() { MacadamiaModList.minigames.mod.syncPantheon(); }, 20); return; }
  1414.            
  1415.             //only gonna sync god slotting and unslotting
  1416.             let M = Game.Objects['Temple'].minigame;
  1417.  
  1418.             eval('M.dropGod='+M.dropGod.toString().replace('var div', 'MacadamiaModList.minigames.mod.dropGodRPC.send({ dragging: M.dragging, slotHovered: M.slotHovered }); var div'));
  1419.            
  1420.             AddEvent(M.lumpRefill, 'click', function() { MacadamiaModList.minigames.mod.pantheonRefillRPC.send(); });
  1421.         }
  1422.        
  1423.         syncGrimoire() {
  1424.             if (!Game.Objects['Wizard tower'].minigameLoaded) { setTimeout(function() { MacadamiaModList.minigames.mod.syncGrimoire(); }, 20); return; }
  1425.            
  1426.             let M = Game.Objects['Wizard tower'].minigame;
  1427.  
  1428.             eval('M.castSpell='+M.castSpell.toString().replace('M.magic=Math.max(0,M.magic);', 'M.magic=Math.max(0,M.magic); MacadamiaModList.minigames.mod.syncMagicRPC.send({ magic: M.magic }); MacadamiaModList.minigames.mod.castSpellRPC.send({ passthrough: (spell.passthrough || obj.passthrough) });'));
  1429.             eval('M.logic='+M.logic.toString().replace('M.magic+=M.magicPS;', 'if (netcodeSettingsExport.hosting) { M.magic+=M.magicPS; MacadamiaModList.minigames.mod.syncMagicRPC.send({ magic: M.magic }); }'))
  1430.  
  1431.             eval('M.spells["stretch time"].win='+M.spells['stretch time'].win.toString().replace('var changed=0;', 'var changed=0; MacadamiaModList.minigames.mod.stSuccessRPC.send();'));
  1432.             eval('M.spells["stretch time"].fail='+M.spells['stretch time'].fail.toString().replace('var changed=0;', 'var changed=0; MacadamiaModList.minigames.mod.stBackfireRPC.send();'));
  1433.            
  1434.             AddEvent(M.lumpRefill, 'click', function() { MacadamiaModList.minigames.mod.grimoireRefillRPC.send(); });
  1435.         }
  1436.  
  1437.         async rpcBuilder() {
  1438.             this.clickTileRPC = this.createRPC('clickTile');
  1439.             this.clickTileRPC.setCallback((arg) => {
  1440.                 window.DO_NOT_RPC = true;
  1441.                 let prevShift = Game.keys[16];
  1442.                 if (arg.shift) { Game.keys[16] = 1; }
  1443.                 Game.Objects.Farm.minigame.seedHolding = arg.seedHolding;
  1444.                 Game.Objects.Farm.minigame.clickTile(arg.x, arg.y);
  1445.                 if (prevShift) { Game.keys[16] = prevShift; }
  1446.                 window.DO_NOT_RPC = false;
  1447.             });
  1448.  
  1449.             this.clickSeedRPC = this.createRPC('clickSeed');
  1450.             this.clickSeedRPC.setCallback((arg) => {
  1451.                 window.DO_NOT_RPC = true;
  1452.                 l('gardenSeed-'+arg.id).click();
  1453.                 window.DO_NOT_RPC = false;
  1454.             });
  1455.  
  1456.             this.harvestAllRPC = this.createRPC('harvestAll');
  1457.             this.harvestAllRPC.setCallback(() => {
  1458.                 window.DO_NOT_RPC = true;
  1459.                 l('gardenTool-1').click();
  1460.                 window.DO_NOT_RPC = false;
  1461.             });
  1462.  
  1463.             this.freezeRPC = this.createRPC('freeze');
  1464.             this.freezeRPC.setCallback(() => {
  1465.                 window.DO_NOT_RPC = true;
  1466.                 l('gardenTool-2').click();
  1467.                 window.DO_NOT_RPC = false;
  1468.             });
  1469.  
  1470.             this.sacrificeRPC = this.createRPC('sacrifice');
  1471.             this.sacrificeRPC.setCallback(() => {
  1472.                 window.DO_NOT_RPC = true;
  1473.                 Game.Objects.Farm.minigame.convert();
  1474.                 window.DO_NOT_RPC = false;
  1475.             });
  1476.  
  1477.             this.soilRPC = this.createRPC('soil');
  1478.             this.soilRPC.setCallback((arg) => {
  1479.                 window.DO_NOT_RPC = true;
  1480.                 l('gardenSoil-'+arg.id).click();
  1481.                 window.DO_NOT_RPC = false;
  1482.             });
  1483.  
  1484.             this.plotSyncRPC = this.createRPC('plotSync');
  1485.             this.plotSyncRPC.setCallback((arg) => {
  1486.                 //console.log(arg.code);
  1487.                 Game.Objects.Farm.minigame.importPlot(arg.code);
  1488.             });
  1489.  
  1490.             this.loanRPC = this.createRPC('loan');
  1491.             this.loanRPC.setCallback((arg) => {
  1492.                 window.DO_NOT_RPC = true;
  1493.                 Game.Objects.Bank.minigame.takeLoan(arg.id, arg.interest);
  1494.                 window.DO_NOT_RPC = false;
  1495.             });
  1496.            
  1497.             this.syncMagicRPC = this.createRPC('syncMagic');
  1498.             this.syncMagicRPC.setCallback((arg) => {
  1499.                 Game.Objects['Wizard tower'].minigame.magic = arg.magic;
  1500.             });
  1501.  
  1502.             this.stSuccessRPC = this.createRPC('stSuccess');
  1503.             this.stSuccessRPC.setCallback(() => {
  1504.                 for (var i in Game.buffs)
  1505.                 {
  1506.                     var me=Game.buffs[i];
  1507.                     var gain=Math.min(Game.fps*60*5,me.maxTime*0.1);
  1508.                     me.maxTime+=gain;
  1509.                     me.time+=gain;
  1510.                 }
  1511.             });
  1512.  
  1513.             this.stBackfireRPC = this.createRPC('stBackfire');
  1514.             this.stBackfireRPC.setCallback(() => {
  1515.                 for (var i in Game.buffs)
  1516.                 {
  1517.                     var me=Game.buffs[i];
  1518.                     var loss=Math.min(Game.fps*60*10,me.time*0.2);
  1519.                     me.time-=loss;
  1520.                     me.time=Math.max(me.time,0);
  1521.                 }
  1522.             });
  1523.  
  1524.             this.castSpellRPC = this.createRPC('castSpell');
  1525.             this.castSpellRPC.setCallback((arg) => {
  1526.                 if (!arg.passthrough) {
  1527.                     Game.Objects['Wizard tower'].minigame.spellsCast++;
  1528.                     Game.Objects['Wizard tower'].minigame.spellsCastTotal++;
  1529.                 }
  1530.             });
  1531.  
  1532.             this.dropGodRPC = this.createRPC('dropGod');
  1533.             this.dropGodRPC.setCallback((arg) => {
  1534.                 let M = Game.Objects.Temple.minigame;
  1535.                
  1536.                 Game.Objects.Temple.minigame.slot=[Game.Objects.Temple.minigame.slot[0],Game.Objects.Temple.minigame.slot[1],Game.Objects.Temple.minigame.slot[2]];
  1537.  
  1538.                 const prevDrag = M.dragging;
  1539.                 const prevSlotHovered = M.slotHovered;
  1540.                 M.dragging = arg.dragging;
  1541.                 M.slotHovered = arg.slotHovered;
  1542.                 window.DO_NOT_RPC = true;
  1543.                 M.dropGod();
  1544.                 window.DO_NOT_RPC = false;
  1545.                 M.dragging = prevDrag;
  1546.                 M.slotHovered = prevSlotHovered;
  1547.             });
  1548.            
  1549.             this.gardenRefillRPC = this.createRPC('gardenRefill');
  1550.             this.gardenRefillRPC.setCallback(() => {
  1551.                 window.DO_NOT_RPC = true;
  1552.                 Game.Objects.Farm.minigame.lumpRefill.click();
  1553.                 window.DO_NOT_RPC = false;
  1554.             });
  1555.            
  1556.             this.pantheonRefillRPC = this.createRPC('pantheonRefill');
  1557.             this.pantheonRefillRPC.setCallback(() => {
  1558.                 window.DO_NOT_RPC = true;
  1559.                 Game.Objects.Temple.minigame.lumpRefill.click();
  1560.                 window.DO_NOT_RPC = false;
  1561.             });
  1562.            
  1563.             this.grimoireRefillRPC = this.createRPC('grimoireRefill');
  1564.             this.grimoireRefillRPC.setCallback(() => {
  1565.                 window.DO_NOT_RPC = true;
  1566.                 Game.Objects['Wizard tower'].minigame.lumpRefill.click();
  1567.                 window.DO_NOT_RPC = false;
  1568.             });
  1569.         }
  1570.     }
  1571.  
  1572.     Macadamia.register(minigameSyncer, {
  1573.         uuid: "minigames",
  1574.         name: "Minigame integration",
  1575.         description: "Syncs all minigame behavior.",
  1576.         author: "CursedSliver",
  1577.         version: "1.0.0"
  1578.     });
  1579. }
  1580.  
  1581. var intervaltest = setInterval(function() {
  1582.     if (typeof MacadamiaModList === 'object' && MacadamiaModList.macadamia) {
  1583.         createTypingDisplayMod();
  1584.         createMouseDisplay();
  1585.         createGCSyncer();
  1586.         createMinigameSyncer();
  1587.         if (typeof toLoad666 != 'undefined' && toLoad666) { setTimeout(function() { Game.LoadMod("https://glander.club/asjs/Hjs3ULwZ/"); }, 2000); }
  1588.         clearInterval(intervaltest);
  1589.     }
  1590. }, 10);
Advertisement
Add Comment
Please, Sign In to add comment