mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-16 21:11:22 +00:00
skip too long ticks and don't try to do 2 ticks at the same time
This commit is contained in:
parent
5940f91fce
commit
19b4c98608
1 changed files with 7 additions and 1 deletions
|
|
@ -1,5 +1,9 @@
|
|||
module.exports.server=function(serv) {
|
||||
let ticking=false;
|
||||
serv.on('tick', function(delta) {
|
||||
if(ticking || delta>1)
|
||||
return;
|
||||
ticking=true;
|
||||
Promise.all(
|
||||
Object.keys(serv.entities).map(async (id) => {
|
||||
const entity = serv.entities[id];
|
||||
|
|
@ -20,7 +24,9 @@ module.exports.server=function(serv) {
|
|||
const posAndOnGround = await entity.calculatePhysics(delta);
|
||||
if (entity.type == 'mob') entity.sendPosition(posAndOnGround.position, posAndOnGround.onGround);
|
||||
})
|
||||
).catch((err)=> setTimeout(() => {throw err;},0));
|
||||
)
|
||||
.then(() => ticking=false)
|
||||
.catch((err)=> setTimeout(() => {throw err;},0));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue