From 8307f9a095b038842b801e14e2b04935a7cb8da4 Mon Sep 17 00:00:00 2001 From: redbirdly <155550833+redbirdly@users.noreply.github.com> Date: Mon, 17 Jun 2024 09:52:25 +0800 Subject: [PATCH] add velocity.js compatability, conflict warning and fix pause step bug --- mods/fast_lightmap.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/mods/fast_lightmap.js b/mods/fast_lightmap.js index 673eedeb..57601821 100644 --- a/mods/fast_lightmap.js +++ b/mods/fast_lightmap.js @@ -349,8 +349,29 @@ tick = function() { // Even after updating tick(), setInterval still uses the old tick(), reset setInterval resetInterval(tps); -let originalDrawPixels = drawPixels; -drawPixels = function(forceTick = false) { - originalDrawPixels(forceTick); - renderLightmap(); +// Add code to functions instead of replacing them +let originalDoFrame = doFrame; +doFrame = function() { + originalDoFrame(); + propagateLightmap(); }; + +if (enabledMods.includes("mods/lightmap.js")) { + alert("Warning: both fast_lightmap.js and lightmap.js are active and it will not properly work"); +} + +if (enabledMods.includes("mods/velocity.js")) { + runAfterAutogen(()=>{ + let originalDrawPixels = drawPixels; + drawPixels = function(forceTick = false) { + originalDrawPixels(forceTick); + renderLightmap(); + }; + }); +} else { + let originalDrawPixels = drawPixels; + drawPixels = function(forceTick = false) { + originalDrawPixels(forceTick); + renderLightmap(); + }; +}