import*as mc from"@minecraft/server";import*as vector from"../utils/vector";const maskEffects={"hf_mzs:mask_bliss":{id:0,effect:"jump_boost"},"hf_mzs:mask_faith":{id:1,effect:"health_boost"},"hf_mzs:mask_fear":{id:2,effect:"speed"},"hf_mzs:mask_fury":{id:3,effect:"strength"},"hf_mzs:mask_misery":{id:4,effect:"resistance"},"hf_mzs:mask_rage":{id:5,effect:"haste"}};export function umvuthanaMaskEffects(e){const t=e.getComponent("equippable").getEquipment("Head");void 0!==t&&t.hasTag("hf_mzs:mask")&&e.addEffect(maskEffects[t.typeId].effect,25,{amplifier:0,showParticles:!1})}export function umvuthanaBeforeUse(e){const t=e.source.getComponent("equippable").getEquipment("Head");if(void 0===t||"hf_mzs:sol_visage"!==t.typeId)return;const s=e.itemStack;void 0!==s&&s.hasTag("hf_mzs:mask")&&(void 0===s.getDynamicProperty("hf_mzs:entity")&&("hf_mzs:mask_faith"===s.typeId?s.setDynamicProperty("hf_mzs:entity","hf_mzs:umvuthana_crane"):"hf_mzs:mask_fury"===s.typeId?s.setDynamicProperty("hf_mzs:entity","hf_mzs:umvuthana_raptor"):s.setDynamicProperty("hf_mzs:entity","hf_mzs:umvuthana")),mc.system.run((()=>{let t=0;if(e.source.dimension.getEntities({location:e.source.location,maxDistance:48,families:["hf_mzs_umvuthana"],excludeFamilies:["hf_mzs_umvuthi"]}).forEach((s=>{s.isValid()&&s.getProperty("hf_mzs:tamed")&&s.getComponent("tameable").tamedToPlayerId===e.source.id&&t++})),t>=10)return void e.source.runCommand('/tellraw @s {"rawtext":[{"translate":"message.hf_mzs.sol_visage_limit"}]}');e.source.runCommand("/playsound hf_mzs:mob.umvuthi.drum @a[r=16] ~~~");const a=e.source.dimension.spawnEntity(s.getDynamicProperty("hf_mzs:entity"),e.source.location);a.triggerEvent("tamed"),void 0!==s.nameTag&&(a.nameTag=s.nameTag);const m=s.getComponent("enchantable").getEnchantments();for(const e of m)a.setProperty("hf_mzs:enchanted",!0),a.setDynamicProperty("hf_mzs:"+e.type.id,e.level);const o=(55-s.getComponent("minecraft:durability").damage)/55*20;a.getComponent("minecraft:health").setCurrentValue(o),a.triggerEvent("spawn"),a.getComponent("tameable").tame(e.source),a.setProperty("hf_mzs:tamed",!0),a.setProperty("hf_mzs:mask",maskEffects[s.typeId].id),a.setProperty("hf_mzs:y_rot",e.source.getRotation().y),"survival"!==e.source.getGameMode()&&"adventure"!==e.source.getGameMode()||e.source.getComponent("equippable").setEquipment("Mainhand"),a.applyImpulse(vector.multiply(e.source.getViewDirection(),1.2))})),e.cancel=!0)}