import{Container,ContainerSlot,Entity,EntityEquippableComponent,EntityInventoryComponent,EntityTypeFamilyComponent,ItemStack}from"@minecraft/server";export class EntityUtils{static getHandItem(t){return t.getComponent(EntityEquippableComponent.componentId).getEquipment(EquipmentSlot.Mainhand)??new ItemStack("minecraft:air",1)}static getHandSlot(t){return t.getComponent(EntityEquippableComponent.componentId).getEquipmentSlot("Mainhand")}static hasFamily(t,n){const e=t.getComponent(EntityTypeFamilyComponent.componentId);return!!e&&e.hasTypeFamily(n)}static getInventoryItems(t){const n=t.getComponent("inventory")?.container;if(n){const t=[];for(let e=0;e<n.size;e++){const o=n.getSlot(e);o&&o.hasItem()&&t.push(o)}return t}}static getContainer(t){const n=t.getComponent("inventory")?.container;return n}static hasItems(t,n,e=1){const o=t.getComponent(EntityInventoryComponent.componentId);let i=e;for(let t=0;t<o.inventorySize;t++){const e=o.container.getItem(t);if(e&&e.typeId==n&&(i-=e.amount,i<=0))return!0}return i<=0}static transformType(t,n){const e=t.getItem().clone(),o=new ItemStack(n);o.setLore(e.getLore()),o.amount=e.amount,o.keepOnDeath=e.keepOnDeath,o.lockMode=e.lockMode,e.getDynamicPropertyIds().forEach((t=>{o.setDynamicProperty(t,e.getDynamicProperty(t))})),t.setItem(o)}}