forked from NorthernOceanS/NormaConstructor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.js
30 lines (27 loc) · 838 Bytes
/
init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
let {eventCenter} = require('./create-event-center.js');
let serverSystem = server._serverSystem;
let clientSystem = client._clientSystem;
function TimeoutPromise(ms) {
return new Promise((reslove, reject) => {
setTimeout(()=>{reslove()}, ms);
});
}
(async function(){
serverSystem.initialize();
clientSystem.initialize();
await TimeoutPromise(0)
eventCenter.broadcastMessage({
eventIdentifier: "minecraft:client_entered_world",
eventData: {data: {player:{__unique_id__: 1}}}
});
await TimeoutPromise(0);
for(let i = 0; i < 20; i++) {
let wait = TimeoutPromise(1000/20);
serverSystem.update && serverSystem.update();
clientSystem.update && clientSystem.update();
await wait;
}
await TimeoutPromise(0);
clientSystem.shutdown && clientSystem.shutdown();
serverSystem.shutdown && serverSystem.shutdown();
})();