var D=(t,e)=>()=>(t&&(e=t(t=0)),e);import"@minecraft/server";var b=D(()=>{});import"@minecraft/server";var l,r,y=D(()=>{b();l=new Set,r=class{static add(e){l.add(e)}static remove(e){l.delete(e)}static get(e=null){if(e){let i=new Set;for(let n of l){if(!n.isValid()){l.delete(n);continue}n.matches(e)&&i.add(n)}return i}else{for(let i of l)i.isValid()||l.delete(i);return l}}}});import"@minecraft/server";var p,o,h=D(()=>{b();p=new Set,o=class{static add(e){p.add(e)}static remove(e){p.delete(e)}static get(e=null){if(e){let i=new Set;for(let n of p){if(!n.isValid()){p.delete(n);continue}n.matches(e)&&i.add(n)}return i}else{for(let i of p)i.isValid()||p.delete(i);return p}}}});import{system as O}from"@minecraft/server";y();import{world as u}from"@minecraft/server";import{world as f}from"@minecraft/server";var c=new Map;function P(t){if(typeof t!="object"||t===null)return!1;let e=Object.keys(t);return!(e.length!==3||!e.includes("x")||!e.includes("y")||!e.includes("z")||typeof t.x!="number"||typeof t.y!="number"||typeof t.z!="number")}function v(t){return!(typeof t!="string"&&typeof t!="number"&&typeof t!="boolean"&&!P(t))}var a=class{static add(e,i,n,s=!1){let m=`${i}-${e}`;if(c.set(m,n),!s)return v(n)?f.setDynamicProperty(m,JSON.stringify(n)):f.setDynamicProperty(m,n)}static remove(e,i){let n=`${i}-${e}`;c.delete(n),f.setDynamicProperty(n,null)}static fetch(e,i){let n=`${i}-${e}`;if(c.has(n))return c.get(n);let s=f.getDynamicProperty(n);return s?(c.set(n,s),v(s)?JSON.parse(s):s):null}static cacheAllData(e){let i=f.getDynamicPropertyIds().filter(n=>n.includes(e.id));for(let n of i){let s=n.split("-")[0],m=this.fetch(e.id,s);c.set(n,m)}}static removeCachedData(e){let i=f.getDynamicPropertyIds().filter(n=>n.includes(e.id));for(let n of i)c.delete(n)}static removeAll(){c.clear,f.clearDynamicProperties()}static getCacheSize(){return c.size}};var C=["overworld","nether","the_end"];for(let t of C){let e=u.getDimension(t).getEntities();for(let i of e)a.cacheAllData(i),r.add(i)}u.afterEvents.entityLoad.subscribe(t=>{a.cacheAllData(t.entity),r.add(t.entity)});u.afterEvents.entitySpawn.subscribe(t=>{a.cacheAllData(t.entity),r.add(t.entity)});u.beforeEvents.entityRemove.subscribe(t=>{a.removeCachedData(t.removedEntity),r.remove(t.removedEntity)});h();import{world as E}from"@minecraft/server";for(let t of E.getAllPlayers())a.cacheAllData(t),o.add(t);E.afterEvents.playerSpawn.subscribe(t=>{a.cacheAllData(t.player),o.add(t.player)});E.beforeEvents.playerLeave.subscribe(t=>{a.removeCachedData(t.player),o.remove(t.player)});y();import{world as nt,ItemStack as it,EnchantmentType as st}from"@minecraft/server";import"@minecraft/server";h();h();y();import{system as k}from"@minecraft/server";var g=class{static#t(e,i){let n=`${i.name}_${e.id}`;e[n]||(e[n]={currentState:i.initialState??Object.keys(i.states)[0],hasEntered:!1});for(let s in i.states)if(e[n].currentState==s){if(e[n].hasEntered||(typeof i.states[s].onEntry=="function"&&i.states[s].onEntry(),i.states[s].loop||(e[n].hasEntered=!0)),!i.states[s].transitions)break;for(let d of i.states[s].transitions)if(Object.values(d).includes(!0)){let x=Object.keys(d);typeof i.states[s].onExit=="function"&&i.states[s].onExit(),e[n].currentState=x,e[n].hasEntered=!1;break}}}static add(e,i){k.runInterval(()=>{if(e=="minecraft:player")for(let n of o.get())this.#t(n,i(n));else for(let n of r.get({type:e}))this.#t(n,i(n))},1)}};var S=t=>({name:"sittingController",states:{default:{onEntry:()=>t.sitCharge=0,transitions:[{sitCharge:t.isSneaking&&Math.round(t.getRotation().x)>=85&&t.isOnGround}]},sitCharge:{loop:!0,onEntry:()=>t.sitCharge++,transitions:[{default:!t.isSneaking||Math.round(t.getRotation().x)<85||!t.isOnGround},{sit:t.sitCharge==20}]},sit:{onEntry:()=>{let{dimension:i}=t,{x:n,y:s,z:m}=t.location,d={x:n,y:Math.ceil(s),z:m},x=i.getBlock(d).below().bottomCenter();i.spawnEntity("coptaine:seat",x,{initialRotation:t.getRotation().y}).addTag(`sf_afm.${t.id}`),t.runCommandAsync(`ride @s start_riding @e[type=coptaine:seat,c=1,tag=sf_afm.${t.id}]`)},transitions:[{default:!0}]}}});g.add("minecraft:player",S);O.runInterval(()=>{for(let t of o.get())try{t.getComponent("riding")?.entityRidingOn?.typeId=="coptaine:seat"?t.getDynamicProperty("coptaine:is_sitting")||(t.setDynamicProperty("coptaine:is_sitting",!0),t.playAnimation("animation.coptaine_sa.player.sit",{blendOutTime:99999})):t.getDynamicProperty("coptaine:is_sitting")&&(t.setDynamicProperty("coptaine:is_sitting",!1),t.playAnimation("animation.coptaine_sa.player.sit",{blendOutTime:0}))}catch{return}},1);
