mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-06-05 18:41:58 -09:00
timescale updated
This commit is contained in:
parent
442a33d222
commit
623c5b057a
@ -2,20 +2,28 @@
|
||||
ModAPI.meta.title("Timescale Command");
|
||||
ModAPI.meta.description("/timescale 0.5 to halve the speed of time");
|
||||
ModAPI.meta.credits("By ZXMushroom63");
|
||||
globalThis.timeScale = 1n;
|
||||
globalThis.timeScaleDividing = false;
|
||||
PluginAPI.addEventListener("sendchatmessage", (event) => {
|
||||
if (event.message.toLowerCase().startsWith("/timescale")) {
|
||||
var speed = parseFloat(event.message.split(" ")[1]);
|
||||
if (!speed) {
|
||||
speed = 1;
|
||||
globalThis.timeScale = 1n;
|
||||
globalThis.timeScaleDividing = false;
|
||||
PluginAPI.mc.timer.timerSpeed = 1;
|
||||
} else {
|
||||
if (speed < 1) {
|
||||
speed = 1 / Math.round(1 / speed);
|
||||
globalThis.timeScaleDividing = true;
|
||||
globalThis.timeScale = BigInt(Math.round(1 / speed));
|
||||
} else {
|
||||
speed = Math.round(speed);
|
||||
globalThis.timeScaleDividing = false;
|
||||
globalThis.timeScale = BigInt(Math.round(speed));
|
||||
}
|
||||
PluginAPI.mc.timer.timerSpeed = speed;
|
||||
}
|
||||
PluginAPI.mc.systemTime = PluginAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.Minecraft", "getSystemTime")]();
|
||||
PluginAPI.mc.debugUpdateTime = PluginAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.Minecraft", "getSystemTime")]() - 1000n;
|
||||
PluginAPI.mc.timer.lastSyncSysClock = PluginAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.Minecraft", "getSystemTime")]();
|
||||
PluginAPI.displayToChat("[Timescale] Set world timescale to " + speed.toFixed(2) + ".");
|
||||
}
|
||||
});
|
||||
@ -52,4 +60,12 @@
|
||||
}
|
||||
};
|
||||
});
|
||||
const original_getSystemTime = ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.Minecraft", "getSystemTime")];
|
||||
PluginAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.Minecraft", "getSystemTime")] = function () {
|
||||
if (globalThis.timeScaleDividing) {
|
||||
return original_getSystemTime() / globalThis.timeScale;
|
||||
} else {
|
||||
return original_getSystemTime() * globalThis.timeScale;
|
||||
}
|
||||
};
|
||||
})();
|
Loading…
x
Reference in New Issue
Block a user