fix: defer actions until connection entity exists
This commit is contained in:
parent
e65e9e30f6
commit
e3ebe46bf4
|
@ -51,15 +51,19 @@ export default class Engine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.server.addPacketListener('Action', (connection, payload) => {
|
this.server.addPacketListener('Action', (connection, payload) => {
|
||||||
this.incomingActions.push([this.connectedPlayers.get(connection).entity, payload]);
|
this.incomingActions.push([connection, payload]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
acceptActions() {
|
acceptActions() {
|
||||||
for (const [
|
for (const [
|
||||||
entity,
|
connection,
|
||||||
payload,
|
payload,
|
||||||
] of this.incomingActions) {
|
] of this.incomingActions) {
|
||||||
|
if (!this.connectedPlayers.get(connection)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const {entity} = this.connectedPlayers.get(connection);
|
||||||
const {Controlled, Ecs, Interacts, Inventory, Wielder} = entity;
|
const {Controlled, Ecs, Interacts, Inventory, Wielder} = entity;
|
||||||
switch (payload.type) {
|
switch (payload.type) {
|
||||||
case 'changeSlot': {
|
case 'changeSlot': {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user