fix: hotbar jank
This commit is contained in:
parent
58baea68f2
commit
902adc9de2
|
@ -43,7 +43,22 @@ const Play = () => {
|
|||
if (selfEntity) {
|
||||
selfEntity.inputStream = inputStream;
|
||||
}
|
||||
socket.send(['Input', inputStream]);
|
||||
const sending = inputStream.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]);
|
||||
}
|
||||
}
|
||||
}, 1000 / 60);
|
||||
ref.current.focus();
|
||||
|
|
|
@ -17,7 +17,7 @@ export default () => class Controllable extends Trait {
|
|||
const {action, value} = inputStream[i];
|
||||
const normalized = 0 === value ? -1 : 1;
|
||||
const hotbarMatch = action.match(/^HotbarSlot(\d)/);
|
||||
if (hotbarMatch) {
|
||||
if (hotbarMatch && value) {
|
||||
this.entity.activeSlotIndex = (parseInt(hotbarMatch[1], 10) + 10) % 10;
|
||||
}
|
||||
switch (action) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user