refactor: acceptAction

This commit is contained in:
cha0s 2021-02-16 00:07:39 -06:00
parent 73e03d2c00
commit dcb57ba53c

View File

@ -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;
},
};