import{system as t}from"@minecraft/server";import{vec3 as r}from"../utils.js";import{ITEM_COUNT_KEY as s}from"../drawers.js";import{Hand as e}from"../render.js";import{getPlayerHeldItem as o}from"../utils/players.js";import{DrawerType as a}from"../base/drawer_type.js";import"../main.js";class n extends a{constructor(){super(...arguments),this.tick=t=>{const s=this.getEntityFromBlock(t);this.processHopperInteraction(s,r(0,1,0),0,t,e.MAIN_HAND),this.processHopperInteraction(s,r(0,0,1),2,t,e.MAIN_HAND),this.processHopperInteraction(s,r(0,0,-1),3,t,e.MAIN_HAND),this.processHopperInteraction(s,r(1,0,0),4,t,e.MAIN_HAND),this.processHopperInteraction(s,r(-1,0,0),5,t,e.MAIN_HAND),s&&this.processHopperTake(s,e.MAIN_HAND)},this.onUse=(t,r)=>{const s=o(r),a=this.getOrCreateEntity(t);this.handleUpgradesAndKeys(r,a,t,s)||this.handleItemTypeInDrawer(r,a,s,e.MAIN_HAND,t)},this.onPlace=(t,r)=>{t&&(t.runCommand('scoreboard players add "ftb_sd:drawers_placed" "ftb_sd:jig_computer.addon_stats" 1'),t.runCommand('scoreboard players add "ftb_sd:drawers_in_world" "ftb_sd:jig_computer.addon_stats" 1'))},this.canBreak=(t,r)=>{const s=this.getEntityFromBlock(r);if(!s)return!0;return!(void 0!==this.getStackInDrawer(s,e.MAIN_HAND)&&0!==this.getDrawerItemCount(s,e.MAIN_HAND))},this.onBreak=(r,s)=>{super.onBreak(r,s),t.run((()=>{r&&(r.runCommand('scoreboard players add "ftb_sd:drawers_removed" "ftb_sd:jig_computer.addon_stats" 1'),r.runCommand('scoreboard players remove "ftb_sd:drawers_in_world" "ftb_sd:jig_computer.addon_stats" 1'))}))},this.onHit=(t,r,s)=>{const o=this.getEntityFromBlock(s);if(!o)return;const a=this.getStackInDrawer(o,e.MAIN_HAND);null!=a&&this.requestRemoveFromDrawer(t.isSneaking?a.maxAmount:1,t,a,e.MAIN_HAND,o,s)},this.getKeyForHand=t=>s,this.getSlotForHand=t=>0}}class i extends n{constructor(){super(...arguments),this.getBlockTag="ftb:drawer",this.getEntityTypeId="ftb_sd:storage_drawer"}}class d extends n{constructor(){super(...arguments),this.getBlockTag="ftb:half_drawer",this.getEntityTypeId="ftb_sd:half_storage_drawer"}}export{d as HalfSingleDrawer,i as SingleDrawer};
