refactor: acceptAction
This commit is contained in:
parent
73e03d2c00
commit
dcb57ba53c
|
@ -40,26 +40,26 @@ export default (latus) => class Wielder extends decorate(Trait) {
|
|||
};
|
||||
}
|
||||
|
||||
listeners() {
|
||||
hooks() {
|
||||
return {
|
||||
|
||||
acceptAction: ({action, value}) => {
|
||||
const hotbarMatch = action.match(/^HotbarSlot(\d)/);
|
||||
if (hotbarMatch && value) {
|
||||
this.entity.activeSlotIndex = (parseInt(hotbarMatch[1], 10) + 10) % 10;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
switch (action) {
|
||||
case 'HotbarSlotNext':
|
||||
if (value) {
|
||||
this.entity.activeSlotIndex = (this.entity.activeSlotIndex + 1) % 10;
|
||||
}
|
||||
break;
|
||||
return false;
|
||||
case 'HotbarSlotPrevious':
|
||||
if (value) {
|
||||
this.entity.activeSlotIndex = (this.entity.activeSlotIndex + 9) % 10;
|
||||
}
|
||||
break;
|
||||
return false;
|
||||
case 'UseItem':
|
||||
if ('client' !== process.env.SIDE) {
|
||||
this.#itemUseRequest = value;
|
||||
|
@ -67,6 +67,7 @@ export default (latus) => class Wielder extends decorate(Trait) {
|
|||
break;
|
||||
default:
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user