fix: do send hotbar input

This commit is contained in:
cha0s 2021-03-17 05:01:07 -05:00
parent d3ad91779a
commit 667573ce63
2 changed files with 4 additions and 19 deletions

View File

@ -87,22 +87,7 @@ const Play = () => {
const inputHandle = setInterval(() => {
const actionStream = selfEntity.drainInput();
if (actionStream.length > 0) {
const sending = actionStream.filter(({action}) => {
if (action.match(/^HotbarSlot(\d)/)) {
return false;
}
switch (action) {
case 'HotbarSlotNext':
case 'HotbarSlotPrevious':
return false;
default:
break;
}
return true;
});
if (sending.length > 0) {
socket.send(['Input', sending]);
}
socket.send(['Input', actionStream]);
}
}, 1000 / 60);
ref.current.focus();

View File

@ -47,19 +47,19 @@ export default (latus) => class Wielder extends decorate(Trait) {
const hotbarMatch = action.match(/^HotbarSlot(\d)/);
if (hotbarMatch && value) {
this.entity.activeSlotIndex = (parseInt(hotbarMatch[1], 10) + 10) % 10;
return false;
return undefined;
}
switch (action) {
case 'HotbarSlotNext':
if (value) {
this.entity.activeSlotIndex = (this.entity.activeSlotIndex + 1) % 10;
}
return false;
break;
case 'HotbarSlotPrevious':
if (value) {
this.entity.activeSlotIndex = (this.entity.activeSlotIndex + 9) % 10;
}
return false;
break;
case 'UseItem':
if ('client' !== process.env.SIDE) {
this.#itemUseRequest = value;