Skip to content

Commit 9e7df33

Browse files
authored
Fix deltaTime (JaylyDev#122)
Update index.js in tick-event
1 parent 32b9c1f commit 9e7df33

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

scripts/tick-event/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Script examples for ScriptAPI
2+
// Author: Jayly#1397 <Jayly Discord>
3+
14
import { system, TickEvent } from "@minecraft/server";
25

36
let lastTick = NaN;
@@ -9,6 +12,7 @@ const callbacks = [];
912
system.runInterval(() => {
1013
const { currentTick } = system;
1114
const deltaTime = (Date.now() - lastTick) / 1000;
15+
lastTick = Date.now();
1216

1317
for (const callback of callbacks) {
1418
callback({ deltaTime, currentTick });
@@ -32,4 +36,4 @@ export class TickEventSignal {
3236
}
3337
};
3438

35-
export const tick = new TickEventSignal();
39+
export const tick = new TickEventSignal();

0 commit comments

Comments
 (0)