minecraft-renderer 0.1.35 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mesher.js +64 -64
- package/dist/mesher.js.map +3 -3
- package/dist/mesherWasm.js +1 -1
- package/dist/minecraft-renderer.js +4 -4
- package/dist/minecraft-renderer.js.meta.json +1 -1
- package/dist/threeWorker.js +22 -22
- package/package.json +1 -1
- package/src/graphicsBackend/config.ts +4 -0
- package/src/graphicsBackend/playerState.ts +1 -0
- package/src/lib/worldrendererCommon.ts +6 -0
- package/src/mesher/models.ts +15 -6
- package/src/mesher/shared.ts +3 -1
- package/src/playerState/playerState.ts +2 -0
- package/src/three/worldRendererThree.ts +5 -1
|
@@ -10,10 +10,10 @@ var fs=Object.create;var Ie=Object.defineProperty;var hs=Object.getOwnPropertyDe
|
|
|
10
10
|
`),this.displayStateStack(m.states,c);else{c.push("Unexpected "+l+`. Instead, I was expecting to see one of the following:
|
|
11
11
|
`);var g=p.map(function(y){return this.buildFirstStateStack(y,[])||[y]},this);g.forEach(function(y){var E=y[0],w=E.rule.symbols[E.dot],_=this.getSymbolDisplay(w);c.push("A "+_+" based on:"),this.displayStateStack(y,c)},this)}return c.push(""),c.join(`
|
|
12
12
|
`)},s.prototype.displayStateStack=function(v,l){for(var c,d=0,m=0;m<v.length;m++){var p=v[m],g=p.rule.toString(p.dot);g===c?d++:(d>0&&l.push(" ^ "+d+" more lines identical to this"),d=0,l.push(" "+g)),c=g}},s.prototype.getSymbolDisplay=function(v){return o(v)},s.prototype.buildFirstStateStack=function(v,l){if(l.indexOf(v)!==-1)return null;if(v.wantedBy.length===0)return[v];var c=v.wantedBy[0],d=[v].concat(l),m=this.buildFirstStateStack(c,d);return m===null?null:[v].concat(m)},s.prototype.save=function(){var v=this.table[this.current];return v.lexerState=this.lexerState,v},s.prototype.restore=function(v){var l=v.index;this.current=l,this.table[l]=v,this.table.splice(l+1),this.lexerState=v.lexerState,this.results=this.finish()},s.prototype.rewind=function(v){if(!this.options.keepHistory)throw new Error("set option `keepHistory` to enable rewinding");this.restore(this.table[v])},s.prototype.finish=function(){var v=[],l=this.grammar.start,c=this.table[this.table.length-1];return c.states.forEach(function(d){d.rule.name===l&&d.dot===d.rule.symbols.length&&d.reference===0&&d.data!==s.fail&&v.push(d)}),v.map(function(d){return d.data})};function o(v){var l=typeof v;if(l==="string")return v;if(l==="object"){if(v.literal)return JSON.stringify(v.literal);if(v instanceof RegExp)return"character matching "+v;if(v.type)return v.type+" token";if(v.test)return"token matching "+String(v.test);throw new Error("Unknown symbol type: "+v)}}function a(v){var l=typeof v;if(l==="string")return v;if(l==="object"){if(v.literal)return JSON.stringify(v.literal);if(v instanceof RegExp)return v.toString();if(v.type)return"%"+v.type;if(v.test)return"<"+String(v.test)+">";throw new Error("Unknown symbol type: "+v)}}return{Parser:s,Grammar:i,Rule:r}})});var wr=Z0((xh,V5)=>{x();R();T();k();(function(){function r(v){return v[0]}function t(v){if(v==="true")return{type:"boolean",value:!0};if(v==="false")return{type:"boolean",value:!1};let l="bslfdi",c={b:"byte",s:"short",l:"long",f:"float",d:"double",i:"int"},d=v.charAt(v.length-1).toLowerCase();if(l.indexOf(d)!==-1){let y=parseFloat(v.substring(0,v.length-1));return isNaN(y)?{value:v,type:"string"}:{value:y,type:c[d]}}let m=parseFloat(v),p=v.includes("."),g=m>>0===m;return!isNaN(v)&&(p||g)?{value:m,type:p?"double":"int"}:{value:v,type:"string"}}function e(v,l){v[0]!==void 0&&(l[v[0]]=v[1])}function i(v){let l={};e(v[2],l);for(let c in v[3])e(v[3][c][3],l);return{type:"compound",value:l}}function n(v){let l=[v[6]];for(let d in v[7])l.push(v[7][d][3]);return{type:{B:"byteArray",I:"intArray",L:"longArray"}[v[2]],value:{type:l[0].type,value:l.map(d=>d.value)}}}function s(v){let l=[v[2]];for(let c in v[3])l.push(v[3][c][3]);return{type:"list",value:{type:l[0].type,value:l.map(c=>c.value)}}}function o(v){let l=[];e(v[2],l);for(let c in v[3])e(v[3][c][3],l);return{type:"list",value:{type:l[0].type,value:l.map(c=>c.value)}}}var a={Lexer:void 0,ParserRules:[{name:"_$ebnf$1",symbols:[]},{name:"_$ebnf$1",symbols:["_$ebnf$1","wschar"],postprocess:function(l){return l[0].concat([l[1]])}},{name:"_",symbols:["_$ebnf$1"],postprocess:function(v){return null}},{name:"__$ebnf$1",symbols:["wschar"]},{name:"__$ebnf$1",symbols:["__$ebnf$1","wschar"],postprocess:function(l){return l[0].concat([l[1]])}},{name:"__",symbols:["__$ebnf$1"],postprocess:function(v){return null}},{name:"wschar",symbols:[/[ \t\n\v\f]/],postprocess:r},{name:"MAIN",symbols:["_","JVALUE","_"],postprocess:v=>v[1]},{name:"JVALUE",symbols:["JOBJECT"],postprocess:v=>v[0]},{name:"JVALUE",symbols:[{literal:"'"},"_","JOBJECT","_",{literal:"'"}],postprocess:v=>v[2]},{name:"JVALUE",symbols:["JARRAY"],postprocess:v=>v[0]},{name:"JVALUE",symbols:["STRING"],postprocess:v=>v[0]},{name:"JVALUE$string$1",symbols:[{literal:"n"},{literal:"u"},{literal:"l"},{literal:"l"}],postprocess:function(l){return l.join("")}},{name:"JVALUE",symbols:["JVALUE$string$1"],postprocess:v=>null},{name:"JOBJECT",symbols:[{literal:"{"},"_",{literal:"}"}],postprocess:v=>({type:"compound",value:{}})},{name:"JOBJECT$ebnf$1",symbols:[]},{name:"JOBJECT$ebnf$1$subexpression$1",symbols:["_",{literal:","},"_","PAIR"]},{name:"JOBJECT$ebnf$1",symbols:["JOBJECT$ebnf$1","JOBJECT$ebnf$1$subexpression$1"],postprocess:function(l){return l[0].concat([l[1]])}},{name:"JOBJECT$ebnf$2$subexpression$1",symbols:["_",{literal:","}]},{name:"JOBJECT$ebnf$2",symbols:["JOBJECT$ebnf$2$subexpression$1"],postprocess:r},{name:"JOBJECT$ebnf$2",symbols:[],postprocess:function(v){return null}},{name:"JOBJECT",symbols:[{literal:"{"},"_","PAIR","JOBJECT$ebnf$1","JOBJECT$ebnf$2",{literal:"}"}],postprocess:i},{name:"JARRAY",symbols:[{literal:"["},"_",{literal:"]"}],postprocess:v=>({type:"list",value:{}})},{name:"JARRAY$ebnf$1",symbols:[]},{name:"JARRAY$ebnf$1$subexpression$1",symbols:["_",{literal:","},"_","JVALUE"]},{name:"JARRAY$ebnf$1",symbols:["JARRAY$ebnf$1","JARRAY$ebnf$1$subexpression$1"],postprocess:function(l){return l[0].concat([l[1]])}},{name:"JARRAY$ebnf$2$subexpression$1",symbols:["_",{literal:","}]},{name:"JARRAY$ebnf$2",symbols:["JARRAY$ebnf$2$subexpression$1"],postprocess:r},{name:"JARRAY$ebnf$2",symbols:[],postprocess:function(v){return null}},{name:"JARRAY",symbols:[{literal:"["},"_",/[BIL]/,"_",{literal:";"},"_","JVALUE","JARRAY$ebnf$1","JARRAY$ebnf$2","_",{literal:"]"}],postprocess:n},{name:"JARRAY$ebnf$3",symbols:[]},{name:"JARRAY$ebnf$3$subexpression$1",symbols:["_",{literal:","},"_","JVALUE"]},{name:"JARRAY$ebnf$3",symbols:["JARRAY$ebnf$3","JARRAY$ebnf$3$subexpression$1"],postprocess:function(l){return l[0].concat([l[1]])}},{name:"JARRAY$ebnf$4$subexpression$1",symbols:["_",{literal:","}]},{name:"JARRAY$ebnf$4",symbols:["JARRAY$ebnf$4$subexpression$1"],postprocess:r},{name:"JARRAY$ebnf$4",symbols:[],postprocess:function(v){return null}},{name:"JARRAY",symbols:[{literal:"["},"_","JVALUE","JARRAY$ebnf$3","JARRAY$ebnf$4","_",{literal:"]"}],postprocess:s},{name:"JARRAY$ebnf$5",symbols:[]},{name:"JARRAY$ebnf$5$subexpression$1",symbols:["_",{literal:","},"_","PAIR"]},{name:"JARRAY$ebnf$5",symbols:["JARRAY$ebnf$5","JARRAY$ebnf$5$subexpression$1"],postprocess:function(l){return l[0].concat([l[1]])}},{name:"JARRAY$ebnf$6$subexpression$1",symbols:["_",{literal:","}]},{name:"JARRAY$ebnf$6",symbols:["JARRAY$ebnf$6$subexpression$1"],postprocess:r},{name:"JARRAY$ebnf$6",symbols:[],postprocess:function(v){return null}},{name:"JARRAY",symbols:[{literal:"["},"_","PAIR","JARRAY$ebnf$5","JARRAY$ebnf$6","_",{literal:"]"}],postprocess:o},{name:"PAIR",symbols:["STRING","_",{literal:":"},"_","JVALUE"],postprocess:v=>[v[0].value,v[4]]},{name:"STRING$ebnf$1",symbols:[]},{name:"STRING$ebnf$1$subexpression$1",symbols:[/[^\\"]/]},{name:"STRING$ebnf$1$subexpression$1",symbols:[{literal:"\\"},/["bfnrt\/\\]/]},{name:"STRING$ebnf$1$subexpression$1$string$1",symbols:[{literal:"\\"},{literal:"u"}],postprocess:function(l){return l.join("")}},{name:"STRING$ebnf$1$subexpression$1",symbols:["STRING$ebnf$1$subexpression$1$string$1",/[a-fA-F0-9]/,/[a-fA-F0-9]/,/[a-fA-F0-9]/,/[a-fA-F0-9]/]},{name:"STRING$ebnf$1",symbols:["STRING$ebnf$1","STRING$ebnf$1$subexpression$1"],postprocess:function(l){return l[0].concat([l[1]])}},{name:"STRING",symbols:[{literal:'"'},"STRING$ebnf$1",{literal:'"'}],postprocess:v=>t(JSON.parse(v.flat(3).map(l=>l.replace(`
|
|
13
|
-
`,"\\n")).join("")))},{name:"STRING$ebnf$2",symbols:[/[^\"\'}\]:;,\s]/]},{name:"STRING$ebnf$2",symbols:["STRING$ebnf$2",/[^\"\'}\]:;,\s]/],postprocess:function(l){return l[0].concat([l[1]])}},{name:"STRING",symbols:["STRING$ebnf$2"],postprocess:v=>t(v[0].join(""))}],ParserStart:"MAIN"};typeof V5<"u"&&typeof V5.exports<"u"?V5.exports=a:window.grammar=a})()});var c2=Z0((Sh,kr)=>{x();R();T();k();var _r=yr(),bo=wr();function xr(r){function t(e,i){return i==="compound"?Object.keys(e).reduce(function(n,s){return n[s]=xr(e[s]),n},{}):i==="list"?Array.isArray(e.value)?e.value.map(function(n){return t(n,e.type)}):[]:e}return t(r.value,r.type)}function N5({value:r,type:t}){if(t==="compound"){let i=[],n=Object.entries(r);for(let s=0;s<n.length;s++){let o=n[s][0],a=N5(n[s][1]);o==="string"&&(a=Ar(a)),i.push(`${o}:${a}`)}return`{${i.join(",")}}`}else{if(t==="list")return Array.isArray(r.value)?`[${Er(r)}]`:"[]";if(t==="byteArray"||t==="intArray"||t==="longArray"){let i=wo(t),n=Er(r);return`[${i}${n}]`}}let e=r+_o(r,t);return t==="string"&&(e=Ar(e)),e}function Ar(r){return r=r.replace(/"/g,'\\"'),(/'|{|}|\[|\]|:|;|,|\(|\)|§|=/g.test(r)||r==="")&&(r=`"${r}"`),r}function Er({value:r,type:t}){let e=yo(r),i=[];for(let n=0;n<r.length;n++){let s=r[n];s!==void 0&&(s=N5({value:s,type:t}),e?i.push(`${n}:${s}`):i.push(s))}return i.join(",")}function yo(r){for(let t=0;t<r.length;t++)if(r[t]===void 0)return!0;return!1}var wo=r=>r.charAt(0).toUpperCase()+";";function _o(r,t){return t==="double"?r>>0===r?"d":"":{int:"",byte:"b",short:"s",float:"f",long:"l",string:""}[t]}function Ao(r){return N5(Rr(r))}function Rr(r){try{let t=new _r.Parser(_r.Grammar.fromCompiled(bo));return t.feed(r),t.results[0]}catch(t){throw t.message=`Error parsing text '${r}'`,t}}kr.exports={parse:Rr,simplify:xr,stringify:N5,normalize:Ao}});var Pr={};b5(Pr,{camelCase:()=>To,capitalCase:()=>u2,constantCase:()=>Co,dotCase:()=>Po,kebabCase:()=>Bo,noCase:()=>Qe,pascalCase:()=>Mo,pascalSnakeCase:()=>So,pathCase:()=>Io,sentenceCase:()=>Ho,snakeCase:()=>f2,split:()=>d2,splitSeparateNumbers:()=>Sr,trainCase:()=>zo});function d2(r){let t=r.trim();t=t.replace(Eo,Tr).replace(xo,Tr),t=t.replace(ko,"\0");let e=0,i=t.length;for(;t.charAt(e)==="\0";)e++;if(e===i)return[];for(;t.charAt(i-1)==="\0";)i--;return t.slice(e,i).split(/\0/g)}function Sr(r){let t=d2(r);for(let e=0;e<t.length;e++){let i=t[e],n=Ro.exec(i);if(n){let s=n.index+(n[1]??n[2]).length;t.splice(e,1,i.slice(0,s),i.slice(s))}}return t}function Qe(r,t){let[e,i,n]=he(r,t);return e+i.map(Ke(t?.locale)).join(t?.delimiter??" ")+n}function To(r,t){let[e,i,n]=he(r,t),s=Ke(t?.locale),o=Je(t?.locale),a=t?.mergeAmbiguousCharacters?j5(s,o):Cr(s,o);return e+i.map((v,l)=>l===0?s(v):a(v,l)).join(t?.delimiter??"")+n}function Mo(r,t){let[e,i,n]=he(r,t),s=Ke(t?.locale),o=Je(t?.locale),a=t?.mergeAmbiguousCharacters?j5(s,o):Cr(s,o);return e+i.map(a).join(t?.delimiter??"")+n}function So(r,t){return u2(r,{delimiter:"_",...t})}function u2(r,t){let[e,i,n]=he(r,t),s=Ke(t?.locale),o=Je(t?.locale);return e+i.map(j5(s,o)).join(t?.delimiter??" ")+n}function Co(r,t){let[e,i,n]=he(r,t);return e+i.map(Je(t?.locale)).join(t?.delimiter??"_")+n}function Po(r,t){return Qe(r,{delimiter:".",...t})}function Bo(r,t){return Qe(r,{delimiter:"-",...t})}function Io(r,t){return Qe(r,{delimiter:"/",...t})}function Ho(r,t){let[e,i,n]=he(r,t),s=Ke(t?.locale),o=Je(t?.locale),a=j5(s,o);return e+i.map((v,l)=>l===0?a(v):s(v)).join(t?.delimiter??" ")+n}function f2(r,t){return Qe(r,{delimiter:"_",...t})}function zo(r,t){return u2(r,{delimiter:"-",...t})}function Ke(r){return r===!1?t=>t.toLowerCase():t=>t.toLocaleLowerCase(r)}function Je(r){return r===!1?t=>t.toUpperCase():t=>t.toLocaleUpperCase(r)}function j5(r,t){return e=>`${t(e[0])}${r(e.slice(1))}`}function Cr(r,t){return(e,i)=>{let n=e[0];return(i>0&&n>="0"&&n<="9"?"_"+n:t(n))+r(e.slice(1))}}function he(r,t={}){let e=t.split??(t.separateNumbers?Sr:d2),i=t.prefixCharacters??Mr,n=t.suffixCharacters??Mr,s=0,o=r.length;for(;s<r.length;){let a=r.charAt(s);if(!i.includes(a))break;s++}for(;o>s;){let a=o-1,v=r.charAt(a);if(!n.includes(v))break;o=a}return[r.slice(0,s),e(r.slice(s,o)),r.slice(o)]}var Eo,xo,Ro,ko,Tr,Mr,h2=ut(()=>{x();R();T();k();Eo=/([\p{Ll}\d])(\p{Lu})/gu,xo=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,Ro=/(\d)\p{Ll}|(\p{L})\d/u,ko=/[^\p{L}\d]+/giu,Tr="$1\0$2",Mr=""});var Br=Z0((Lh,Oo)=>{Oo.exports={version:"1.21.4",attackable:["acacia_boat","acacia_chest_boat","allay","armadillo","armor_stand","axolotl","bamboo_chest_raft","bamboo_raft","bat","bee","birch_boat","birch_chest_boat","blaze","bogged","breeze","camel","cat","cave_spider","cherry_boat","cherry_chest_boat","chest_minecart","chicken","cod","command_block_minecart","cow","creaking","creeper","dark_oak_boat","dark_oak_chest_boat","dolphin","donkey","drowned","elder_guardian","end_crystal","ender_dragon","enderman","endermite","evoker","falling_block","fox","frog","furnace_minecart","ghast","giant","glow_item_frame","glow_squid","goat","guardian","hoglin","hopper_minecart","horse","husk","illusioner","iron_golem","item_frame","jungle_boat","jungle_chest_boat","leash_knot","llama","magma_cube","mangrove_boat","mangrove_chest_boat","minecart","mooshroom","mule","oak_boat","oak_chest_boat","ocelot","painting","pale_oak_boat","pale_oak_chest_boat","panda","parrot","phantom","pig","piglin","piglin_brute","pillager","player","polar_bear","pufferfish","rabbit","ravager","salmon","sheep","shulker","shulker_bullet","silverfish","skeleton","skeleton_horse","slime","sniffer","snow_golem","spawner_minecart","spider","spruce_boat","spruce_chest_boat","squid","stray","strider","tadpole","tnt","tnt_minecart","trader_llama","tropical_fish","turtle","vex","villager","vindicator","wandering_trader","warden","wind_charge","witch","wither","wither_skeleton","wolf","zoglin","zombie","zombie_horse","zombie_villager","zombified_piglin"],notAttackable:["area_effect_cloud","arrow","block_display","breeze_wind_charge","dragon_fireball","egg","ender_pearl","evoker_fangs","experience_bottle","experience_orb","eye_of_ender","fireball","firework_rocket","fishing_bobber","interaction","item","item_display","lightning_bolt","llama_spit","marker","ominous_item_spawner","potion","small_fireball","snowball","spectral_arrow","text_display","trident","wither_skull"],entityRenames:{Boat:"oak_boat",EnderCrystal:"end_crystal",EntityHorse:"horse",EyeOfEnderSignal:"eye_of_ender",FallingSand:"falling_block",FireworksRocketEntity:"firework_rocket","Fishing Float":"fishing_bobber","Fishing Hook":"fishing_bobber",LavaSlime:"magma_cube",MinecartRideable:"minecart",Mob:!1,Monster:!1,MushroomCow:"mooshroom",Ozelot:"ocelot",PigZombie:"zombified_piglin",PrimedTnt:"tnt",SnowMan:"snow_golem",ThrownEgg:"egg",ThrownEnderpearl:"ender_pearl",ThrownExpBottle:"experience_bottle",ThrownPotion:"potion",VillagerGolem:"iron_golem",WitherBoss:"wither",XPOrb:"experience_orb",activated_tnt:"tnt",armorstand:"armor_stand",boat:"oak_boat",chest_boat:"oak_chest_boat",commandblock_minecart:"command_block_minecart",creaking_transient:"creaking",ender_crystal:"end_crystal",endercrystal:"end_crystal",evocation_fangs:"evoker_fangs",evocation_illager:"evoker",eye_of_ender_signal:"eye_of_ender",falling_objects:"falling_block",firecharge:"fireball",fireworks_rocket:"firework_rocket",fishing_hook:"fishing_bobber",illusion_illager:"illusioner",item_frames:"item_frame",item_stack:"item",snowman:"snow_golem",thrown_enderpearl:"ender_pearl","thrown_exp bottle":"experience_bottle",thrown_exp_bottle:"experience_bottle",thrown_potion:"potion",tipped_arrow:"arrow",villager_golem:"iron_golem",vindication_illager:"vindicator",xp_bottle:"experience_bottle",xp_orb:"experience_orb",zombie_pigman:"zombified_piglin"}}});var Hr=Z0((Fh,Ir)=>{x();R();T();k();var me=1e3,pe=me*60,ge=pe*60,Jt=ge*24,Do=Jt*7,Lo=Jt*365.25;Ir.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Fo(r);if(e==="number"&&isFinite(r))return t.long?Go(r):Uo(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Fo(r){if(r=String(r),!(r.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(t){var e=parseFloat(t[1]),i=(t[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return e*Lo;case"weeks":case"week":case"w":return e*Do;case"days":case"day":case"d":return e*Jt;case"hours":case"hour":case"hrs":case"hr":case"h":return e*ge;case"minutes":case"minute":case"mins":case"min":case"m":return e*pe;case"seconds":case"second":case"secs":case"sec":case"s":return e*me;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Uo(r){var t=Math.abs(r);return t>=Jt?Math.round(r/Jt)+"d":t>=ge?Math.round(r/ge)+"h":t>=pe?Math.round(r/pe)+"m":t>=me?Math.round(r/me)+"s":r+"ms"}function Go(r){var t=Math.abs(r);return t>=Jt?Y5(r,t,Jt,"day"):t>=ge?Y5(r,t,ge,"hour"):t>=pe?Y5(r,t,pe,"minute"):t>=me?Y5(r,t,me,"second"):r+" ms"}function Y5(r,t,e,i){var n=t>=e*1.5;return Math.round(r/e)+" "+i+(n?"s":"")}});var Or=Z0((Nh,zr)=>{x();R();T();k();function Wo(r){e.debug=e,e.default=e,e.coerce=v,e.disable=o,e.enable=n,e.enabled=a,e.humanize=Hr(),e.destroy=l,Object.keys(r).forEach(c=>{e[c]=r[c]}),e.names=[],e.skips=[],e.formatters={};function t(c){let d=0;for(let m=0;m<c.length;m++)d=(d<<5)-d+c.charCodeAt(m),d|=0;return e.colors[Math.abs(d)%e.colors.length]}e.selectColor=t;function e(c){let d,m=null,p,g;function y(...E){if(!y.enabled)return;let w=y,_=Number(new Date),C=_-(d||_);w.diff=C,w.prev=d,w.curr=_,d=_,E[0]=e.coerce(E[0]),typeof E[0]!="string"&&E.unshift("%O");let M=0;E[0]=E[0].replace(/%([a-zA-Z%])/g,(H,B)=>{if(H==="%%")return"%";M++;let I=e.formatters[B];if(typeof I=="function"){let W=E[M];H=I.call(w,W),E.splice(M,1),M--}return H}),e.formatArgs.call(w,E),(w.log||e.log).apply(w,E)}return y.namespace=c,y.useColors=e.useColors(),y.color=e.selectColor(c),y.extend=i,y.destroy=e.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(p!==e.namespaces&&(p=e.namespaces,g=e.enabled(c)),g),set:E=>{m=E}}),typeof e.init=="function"&&e.init(y),y}function i(c,d){let m=e(this.namespace+(typeof d>"u"?":":d)+c);return m.log=this.log,m}function n(c){e.save(c),e.namespaces=c,e.names=[],e.skips=[];let d=(typeof c=="string"?c:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let m of d)m[0]==="-"?e.skips.push(m.slice(1)):e.names.push(m)}function s(c,d){let m=0,p=0,g=-1,y=0;for(;m<c.length;)if(p<d.length&&(d[p]===c[m]||d[p]==="*"))d[p]==="*"?(g=p,y=m,p++):(m++,p++);else if(g!==-1)p=g+1,y++,m=y;else return!1;for(;p<d.length&&d[p]==="*";)p++;return p===d.length}function o(){let c=[...e.names,...e.skips.map(d=>"-"+d)].join(",");return e.enable(""),c}function a(c){for(let d of e.skips)if(s(c,d))return!1;for(let d of e.names)if(s(c,d))return!0;return!1}function v(c){return c instanceof Error?c.stack||c.message:c}function l(){}return e.enable(e.load()),e}zr.exports=Wo});var Dr=Z0((J0,Q5)=>{x();R();T();k();J0.formatArgs=No;J0.save=jo;J0.load=Yo;J0.useColors=Vo;J0.storage=Qo();J0.destroy=(()=>{let r=!1;return()=>{r||(r=!0)}})();J0.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Vo(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let r;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(r=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(r[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function No(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Q5.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,i=0;r[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(e++,n==="%c"&&(i=e))}),r.splice(i,0,t)}J0.log=console.debug||console.log||(()=>{});function jo(r){try{r?J0.storage.setItem("debug",r):J0.storage.removeItem("debug")}catch{}}function Yo(){let r;try{r=J0.storage.getItem("debug")||J0.storage.getItem("DEBUG")}catch{}return!r&&typeof D<"u"&&"env"in D&&(r=D.env.DEBUG),r}function Qo(){try{return localStorage}catch{}}Q5.exports=Or()(J0);var{formatters:Ko}=Q5.exports;Ko.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Lr=Z0(be=>{"use strict";x();R();T();k();var Jo=be&&be.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(be,"__esModule",{value:!0});be.debug=void 0;var qo=Jo(Dr());be.debug=(0,qo.default)("mineflayer-mouse")});var Wr=Z0(qt=>{"use strict";x();R();T();k();var Zo=qt&&qt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(qt,"__esModule",{value:!0});qt.isEntityAttackable=void 0;qt.isArmorStandAttackable=Gr;var Fr=(h2(),ws(Pr)),qe=Zo(Br()),Xo=Lr(),Ur=Object.fromEntries([...qe.default.attackable,...qe.default.notAttackable].map(r=>[r,!0])),$o=qe.default.attackable,ta=(r,t)=>{if(!t.name)throw new Error("Entity has no name");let e=r.entitiesByName[t.name],n=qe.default.entityRenames[t.name]||qe.default.entityRenames[(0,Fr.snakeCase)(t.name)]||t.name;if(!Ur[n]&&(n=(0,Fr.snakeCase)(n),!Ur[n]))return(0,Xo.debug)(`Cannot find entity ${n} in entityData.json`),!1;let s=ea[n];return s?s(t,e):$o.includes(n)};qt.isEntityAttackable=ta;var ea={armor_stand:Gr};function Gr(r,t){let e=Number(r.metadata?.[t.metadataKeys?.indexOf("client_flags")??14]??0),i=(e&16)!==0,n=(e&8)!==0,s=(e&4)!==0,o=(e&1)!==0;return!i}});var E6=Z0((g_,w8)=>{w8.exports={version:"1.20.4","1.8":{blocks:[["wood_planks","planks"],["large_flowers","double_plant"]]},"1.12":{items:[["totem","totem_of_undying"]]},"1.13":{blocks:[["grass","grass_block"],["planks","oak_planks"],["planks","spruce_planks"],["planks","birch_planks"],["planks","jungle_planks"],["planks","acacia_planks"],["planks","dark_oak_planks"],["sapling","oak_sapling"],["sapling","spruce_sapling"],["sapling","birch_sapling"],["sapling","jungle_sapling"],["sapling","acacia_sapling"],["sapling","dark_oak_sapling"],["sand","red_sand"],["log","oak_log"],["log","spruce_log"],["log","birch_log"],["log","jungle_log"],["log","oak_wood"],["log","spruce_wood"],["log","birch_wood"],["log","jungle_wood"],["leaves","oak_leaves"],["leaves","spruce_leaves"],["leaves","birch_leaves"],["leaves","jungle_leaves"],["sponge","wet_sponge"],["sandstone","chiseled_sandstone"],["sandstone","cut_sandstone"],["noteblock","note_block"],["bed","red_bed"],["golden_rail","powered_rail"],["web","cobweb"],["tallgrass","dead_bush"],["tallgrass","grass"],["tallgrass","fern"],["deadbush","dead_bush"],["wool","white_wool"],["wool","orange_wool"],["wool","magenta_wool"],["wool","light_blue_wool"],["wool","yellow_wool"],["wool","lime_wool"],["wool","pink_wool"],["wool","gray_wool"],["wool","light_gray_wool"],["wool","cyan_wool"],["wool","purple_wool"],["wool","blue_wool"],["wool","brown_wool"],["wool","green_wool"],["wool","red_wool"],["wool","black_wool"],["piston_extension","moving_piston"],["yellow_flower","dandelion"],["red_flower","poppy"],["red_flower","blue_orchid"],["red_flower","allium"],["red_flower","azure_bluet"],["red_flower","red_tulip"],["red_flower","orange_tulip"],["red_flower","white_tulip"],["red_flower","pink_tulip"],["red_flower","oxeye_daisy"],["double_stone_slab","stone_slab"],["double_stone_slab","sandstone_slab"],["double_stone_slab","petrified_oak_slab"],["double_stone_slab","cobblestone_slab"],["double_stone_slab","brick_slab"],["double_stone_slab","stone_brick_slab"],["double_stone_slab","nether_brick_slab"],["double_stone_slab","quartz_slab"],["double_stone_slab","smooth_stone"],["double_stone_slab","smooth_sandstone"],["double_stone_slab","smooth_quartz"],["stone_slab","sandstone_slab"],["stone_slab","petrified_oak_slab"],["stone_slab","cobblestone_slab"],["stone_slab","brick_slab"],["stone_slab","stone_brick_slab"],["stone_slab","nether_brick_slab"],["stone_slab","quartz_slab"],["brick_block","bricks"],["mob_spawner","spawner"],["lit_furnace","furnace"],["standing_sign","sign"],["wooden_door","oak_door"],["stone_stairs","cobblestone_stairs"],["wooden_pressure_plate","oak_pressure_plate"],["lit_redstone_ore","redstone_ore"],["unlit_redstone_torch","redstone_wall_torch"],["unlit_redstone_torch","redstone_torch"],["redstone_torch","redstone_wall_torch"],["snow_layer","snow"],["snow","snow_block"],["reeds","sugar_cane"],["fence","oak_fence"],["pumpkin","carved_pumpkin"],["portal","nether_portal"],["lit_pumpkin","jack_o_lantern"],["unpowered_repeater","repeater"],["powered_repeater","repeater"],["stained_glass","white_stained_glass"],["stained_glass","orange_stained_glass"],["stained_glass","magenta_stained_glass"],["stained_glass","light_blue_stained_glass"],["stained_glass","yellow_stained_glass"],["stained_glass","lime_stained_glass"],["stained_glass","pink_stained_glass"],["stained_glass","gray_stained_glass"],["stained_glass","light_gray_stained_glass"],["stained_glass","cyan_stained_glass"],["stained_glass","purple_stained_glass"],["stained_glass","blue_stained_glass"],["stained_glass","brown_stained_glass"],["stained_glass","green_stained_glass"],["stained_glass","red_stained_glass"],["stained_glass","black_stained_glass"],["trapdoor","oak_trapdoor"],["monster_egg","infested_stone"],["monster_egg","infested_cobblestone"],["monster_egg","infested_stone_bricks"],["monster_egg","infested_mossy_stone_bricks"],["monster_egg","infested_cracked_stone_bricks"],["monster_egg","infested_chiseled_stone_bricks"],["stonebrick","stone_bricks"],["stonebrick","mossy_stone_bricks"],["stonebrick","cracked_stone_bricks"],["stonebrick","chiseled_stone_bricks"],["brown_mushroom_block","mushroom_stem"],["red_mushroom_block","mushroom_stem"],["melon_block","melon"],["fence_gate","oak_fence_gate"],["waterlily","lily_pad"],["nether_brick","nether_bricks"],["lit_redstone_lamp","redstone_lamp"],["double_wooden_slab","oak_slab"],["double_wooden_slab","spruce_slab"],["double_wooden_slab","birch_slab"],["double_wooden_slab","jungle_slab"],["double_wooden_slab","acacia_slab"],["double_wooden_slab","dark_oak_slab"],["wooden_slab","oak_slab"],["wooden_slab","spruce_slab"],["wooden_slab","birch_slab"],["wooden_slab","jungle_slab"],["wooden_slab","acacia_slab"],["wooden_slab","dark_oak_slab"],["cobblestone_wall","mossy_cobblestone_wall"],["flower_pot","potted_poppy"],["flower_pot","potted_dandelion"],["flower_pot","potted_oak_sapling"],["flower_pot","potted_spruce_sapling"],["flower_pot","potted_birch_sapling"],["flower_pot","potted_jungle_sapling"],["flower_pot","potted_red_mushroom"],["flower_pot","potted_brown_mushroom"],["flower_pot","potted_cactus"],["flower_pot","potted_dead_bush"],["flower_pot","potted_fern"],["flower_pot","potted_acacia_sapling"],["flower_pot","potted_dark_oak_sapling"],["flower_pot","potted_blue_orchid"],["flower_pot","potted_allium"],["wooden_button","oak_button"],["skull","skeleton_skull"],["skull","skeleton_wall_skull"],["anvil","chipped_anvil"],["anvil","damaged_anvil"],["unpowered_comparator","comparator"],["powered_comparator","comparator"],["quartz_ore","nether_quartz_ore"],["quartz_block","chiseled_quartz_block"],["quartz_block","quartz_pillar"],["stained_hardened_clay","white_terracotta"],["stained_hardened_clay","orange_terracotta"],["stained_hardened_clay","magenta_terracotta"],["stained_hardened_clay","light_blue_terracotta"],["stained_hardened_clay","yellow_terracotta"],["stained_hardened_clay","lime_terracotta"],["stained_hardened_clay","pink_terracotta"],["stained_hardened_clay","gray_terracotta"],["stained_hardened_clay","light_gray_terracotta"],["stained_hardened_clay","cyan_terracotta"],["stained_hardened_clay","purple_terracotta"],["stained_hardened_clay","blue_terracotta"],["stained_hardened_clay","brown_terracotta"],["stained_hardened_clay","green_terracotta"],["stained_hardened_clay","red_terracotta"],["stained_hardened_clay","black_terracotta"],["stained_glass_pane","white_stained_glass_pane"],["stained_glass_pane","orange_stained_glass_pane"],["stained_glass_pane","magenta_stained_glass_pane"],["stained_glass_pane","light_blue_stained_glass_pane"],["stained_glass_pane","yellow_stained_glass_pane"],["stained_glass_pane","lime_stained_glass_pane"],["stained_glass_pane","pink_stained_glass_pane"],["stained_glass_pane","gray_stained_glass_pane"],["stained_glass_pane","light_gray_stained_glass_pane"],["stained_glass_pane","cyan_stained_glass_pane"],["stained_glass_pane","purple_stained_glass_pane"],["stained_glass_pane","blue_stained_glass_pane"],["stained_glass_pane","brown_stained_glass_pane"],["stained_glass_pane","green_stained_glass_pane"],["stained_glass_pane","red_stained_glass_pane"],["stained_glass_pane","black_stained_glass_pane"],["leaves2","acacia_leaves"],["leaves2","dark_oak_leaves"],["log2","acacia_log"],["log2","dark_oak_log"],["log2","acacia_wood"],["log2","dark_oak_wood"],["slime","slime_block"],["prismarine","prismarine_bricks"],["prismarine","dark_prismarine"],["carpet","white_carpet"],["carpet","orange_carpet"],["carpet","magenta_carpet"],["carpet","light_blue_carpet"],["carpet","yellow_carpet"],["carpet","lime_carpet"],["carpet","pink_carpet"],["carpet","gray_carpet"],["carpet","light_gray_carpet"],["carpet","cyan_carpet"],["carpet","purple_carpet"],["carpet","blue_carpet"],["carpet","brown_carpet"],["carpet","green_carpet"],["carpet","red_carpet"],["carpet","black_carpet"],["hardened_clay","terracotta"],["double_plant","sunflower"],["double_plant","lilac"],["double_plant","tall_grass"],["double_plant","large_fern"],["double_plant","rose_bush"],["double_plant","peony"],["standing_banner","white_banner"],["wall_banner","white_wall_banner"],["daylight_detector_inverted","daylight_detector"],["red_sandstone","chiseled_red_sandstone"],["red_sandstone","cut_red_sandstone"],["double_stone_slab2","red_sandstone_slab"],["double_stone_slab2","smooth_red_sandstone"],["stone_slab2","red_sandstone_slab"],["purpur_double_slab","purpur_slab"],["end_bricks","end_stone_bricks"],["magma","magma_block"],["red_nether_brick","red_nether_bricks"],["concrete","white_concrete"],["concrete","orange_concrete"],["concrete","magenta_concrete"],["concrete","light_blue_concrete"],["concrete","yellow_concrete"],["concrete","lime_concrete"],["concrete","pink_concrete"],["concrete","gray_concrete"],["concrete","light_gray_concrete"],["concrete","cyan_concrete"],["concrete","purple_concrete"],["concrete","blue_concrete"],["concrete","brown_concrete"],["concrete","green_concrete"],["concrete","red_concrete"],["concrete","black_concrete"],["concrete_powder","white_concrete_powder"],["concrete_powder","orange_concrete_powder"],["concrete_powder","magenta_concrete_powder"],["concrete_powder","light_blue_concrete_powder"],["concrete_powder","yellow_concrete_powder"],["concrete_powder","lime_concrete_powder"],["concrete_powder","pink_concrete_powder"],["concrete_powder","gray_concrete_powder"],["concrete_powder","light_gray_concrete_powder"],["concrete_powder","cyan_concrete_powder"],["concrete_powder","purple_concrete_powder"],["concrete_powder","blue_concrete_powder"],["concrete_powder","brown_concrete_powder"],["concrete_powder","green_concrete_powder"],["concrete_powder","red_concrete_powder"],["concrete_powder","black_concrete_powder"]],items:[["stone","granite"],["stone","polished_granite"],["stone","diorite"],["stone","polished_diorite"],["stone","andesite"],["stone","polished_andesite"],["grass","grass_block"],["dirt","coarse_dirt"],["dirt","podzol"],["planks","oak_planks"],["planks","spruce_planks"],["planks","birch_planks"],["planks","jungle_planks"],["planks","acacia_planks"],["planks","dark_oak_planks"],["sapling","oak_sapling"],["sapling","spruce_sapling"],["sapling","birch_sapling"],["sapling","jungle_sapling"],["sapling","acacia_sapling"],["sapling","dark_oak_sapling"],["sand","red_sand"],["log","oak_log"],["log","spruce_log"],["log","birch_log"],["log","jungle_log"],["leaves","oak_leaves"],["leaves","spruce_leaves"],["leaves","birch_leaves"],["leaves","jungle_leaves"],["sponge","wet_sponge"],["sandstone","chiseled_sandstone"],["sandstone","cut_sandstone"],["noteblock","note_block"],["golden_rail","powered_rail"],["web","cobweb"],["tallgrass","grass"],["tallgrass","fern"],["deadbush","dead_bush"],["wool","white_wool"],["wool","orange_wool"],["wool","magenta_wool"],["wool","light_blue_wool"],["wool","yellow_wool"],["wool","lime_wool"],["wool","pink_wool"],["wool","gray_wool"],["wool","light_gray_wool"],["wool","cyan_wool"],["wool","purple_wool"],["wool","blue_wool"],["wool","brown_wool"],["wool","green_wool"],["wool","red_wool"],["wool","black_wool"],["yellow_flower","dandelion"],["red_flower","poppy"],["red_flower","blue_orchid"],["red_flower","allium"],["red_flower","azure_bluet"],["red_flower","red_tulip"],["red_flower","orange_tulip"],["red_flower","white_tulip"],["red_flower","pink_tulip"],["red_flower","oxeye_daisy"],["stone_slab","sandstone_slab"],["stone_slab","cobblestone_slab"],["stone_slab","brick_slab"],["stone_slab","stone_brick_slab"],["stone_slab","nether_brick_slab"],["stone_slab","quartz_slab"],["brick_block","bricks"],["mob_spawner","spawner"],["stone_stairs","cobblestone_stairs"],["wooden_pressure_plate","oak_pressure_plate"],["snow_layer","snow"],["snow","snow_block"],["fence","oak_fence"],["pumpkin","carved_pumpkin"],["lit_pumpkin","jack_o_lantern"],["stained_glass","white_stained_glass"],["stained_glass","orange_stained_glass"],["stained_glass","magenta_stained_glass"],["stained_glass","light_blue_stained_glass"],["stained_glass","yellow_stained_glass"],["stained_glass","lime_stained_glass"],["stained_glass","pink_stained_glass"],["stained_glass","gray_stained_glass"],["stained_glass","light_gray_stained_glass"],["stained_glass","cyan_stained_glass"],["stained_glass","purple_stained_glass"],["stained_glass","blue_stained_glass"],["stained_glass","brown_stained_glass"],["stained_glass","green_stained_glass"],["stained_glass","red_stained_glass"],["stained_glass","black_stained_glass"],["trapdoor","oak_trapdoor"],["monster_egg","infested_stone"],["monster_egg","infested_cobblestone"],["monster_egg","infested_stone_bricks"],["monster_egg","infested_mossy_stone_bricks"],["monster_egg","infested_cracked_stone_bricks"],["monster_egg","infested_chiseled_stone_bricks"],["stonebrick","stone_bricks"],["stonebrick","mossy_stone_bricks"],["stonebrick","cracked_stone_bricks"],["stonebrick","chiseled_stone_bricks"],["melon_block","melon"],["fence_gate","oak_fence_gate"],["waterlily","lily_pad"],["nether_brick","nether_bricks"],["wooden_slab","oak_slab"],["wooden_slab","spruce_slab"],["wooden_slab","birch_slab"],["wooden_slab","jungle_slab"],["wooden_slab","acacia_slab"],["wooden_slab","dark_oak_slab"],["cobblestone_wall","mossy_cobblestone_wall"],["wooden_button","oak_button"],["anvil","chipped_anvil"],["anvil","damaged_anvil"],["quartz_ore","nether_quartz_ore"],["quartz_block","chiseled_quartz_block"],["quartz_block","quartz_pillar"],["stained_hardened_clay","white_terracotta"],["stained_hardened_clay","orange_terracotta"],["stained_hardened_clay","magenta_terracotta"],["stained_hardened_clay","light_blue_terracotta"],["stained_hardened_clay","yellow_terracotta"],["stained_hardened_clay","lime_terracotta"],["stained_hardened_clay","pink_terracotta"],["stained_hardened_clay","gray_terracotta"],["stained_hardened_clay","light_gray_terracotta"],["stained_hardened_clay","cyan_terracotta"],["stained_hardened_clay","purple_terracotta"],["stained_hardened_clay","blue_terracotta"],["stained_hardened_clay","brown_terracotta"],["stained_hardened_clay","green_terracotta"],["stained_hardened_clay","red_terracotta"],["stained_hardened_clay","black_terracotta"],["stained_glass_pane","white_stained_glass_pane"],["stained_glass_pane","orange_stained_glass_pane"],["stained_glass_pane","magenta_stained_glass_pane"],["stained_glass_pane","light_blue_stained_glass_pane"],["stained_glass_pane","yellow_stained_glass_pane"],["stained_glass_pane","lime_stained_glass_pane"],["stained_glass_pane","pink_stained_glass_pane"],["stained_glass_pane","gray_stained_glass_pane"],["stained_glass_pane","light_gray_stained_glass_pane"],["stained_glass_pane","cyan_stained_glass_pane"],["stained_glass_pane","purple_stained_glass_pane"],["stained_glass_pane","blue_stained_glass_pane"],["stained_glass_pane","brown_stained_glass_pane"],["stained_glass_pane","green_stained_glass_pane"],["stained_glass_pane","red_stained_glass_pane"],["stained_glass_pane","black_stained_glass_pane"],["leaves2","acacia_leaves"],["leaves2","dark_oak_leaves"],["log2","acacia_log"],["log2","dark_oak_log"],["slime","slime_block"],["prismarine","prismarine_bricks"],["prismarine","dark_prismarine"],["carpet","white_carpet"],["carpet","orange_carpet"],["carpet","magenta_carpet"],["carpet","light_blue_carpet"],["carpet","yellow_carpet"],["carpet","lime_carpet"],["carpet","pink_carpet"],["carpet","gray_carpet"],["carpet","light_gray_carpet"],["carpet","cyan_carpet"],["carpet","purple_carpet"],["carpet","blue_carpet"],["carpet","brown_carpet"],["carpet","green_carpet"],["carpet","red_carpet"],["carpet","black_carpet"],["hardened_clay","terracotta"],["double_plant","sunflower"],["double_plant","lilac"],["double_plant","tall_grass"],["double_plant","large_fern"],["double_plant","rose_bush"],["double_plant","peony"],["red_sandstone","chiseled_red_sandstone"],["red_sandstone","cut_red_sandstone"],["stone_slab2","red_sandstone_slab"],["end_bricks","end_stone_bricks"],["magma","magma_block"],["red_nether_brick","red_nether_bricks"],["silver_shulker_box","light_gray_shulker_box"],["silver_glazed_terracotta","light_gray_glazed_terracotta"],["concrete","white_concrete"],["concrete","orange_concrete"],["concrete","magenta_concrete"],["concrete","light_blue_concrete"],["concrete","yellow_concrete"],["concrete","lime_concrete"],["concrete","pink_concrete"],["concrete","gray_concrete"],["concrete","light_gray_concrete"],["concrete","cyan_concrete"],["concrete","purple_concrete"],["concrete","blue_concrete"],["concrete","brown_concrete"],["concrete","green_concrete"],["concrete","red_concrete"],["concrete","black_concrete"],["concrete_powder","white_concrete_powder"],["concrete_powder","orange_concrete_powder"],["concrete_powder","magenta_concrete_powder"],["concrete_powder","light_blue_concrete_powder"],["concrete_powder","yellow_concrete_powder"],["concrete_powder","lime_concrete_powder"],["concrete_powder","pink_concrete_powder"],["concrete_powder","gray_concrete_powder"],["concrete_powder","light_gray_concrete_powder"],["concrete_powder","cyan_concrete_powder"],["concrete_powder","purple_concrete_powder"],["concrete_powder","blue_concrete_powder"],["concrete_powder","brown_concrete_powder"],["concrete_powder","green_concrete_powder"],["concrete_powder","red_concrete_powder"],["concrete_powder","black_concrete_powder"],["coal","charcoal"],["golden_apple","enchanted_golden_apple"],["wooden_door","oak_door"],["boat","oak_boat"],["reeds","sugar_cane"],["fish","cod"],["fish","salmon"],["fish","tropical_fish"],["fish","pufferfish"],["cooked_fish","cooked_cod"],["cooked_fish","cooked_salmon"],["dye","ink_sac"],["dye","rose_red"],["dye","cactus_green"],["dye","cocoa_beans"],["dye","lapis_lazuli"],["dye","purple_dye"],["dye","cyan_dye"],["dye","light_gray_dye"],["dye","gray_dye"],["dye","pink_dye"],["dye","lime_dye"],["dye","dandelion_yellow"],["dye","light_blue_dye"],["dye","magenta_dye"],["dye","orange_dye"],["dye","bone_meal"],["bed","white_bed"],["bed","orange_bed"],["bed","magenta_bed"],["bed","light_blue_bed"],["bed","yellow_bed"],["bed","lime_bed"],["bed","pink_bed"],["bed","gray_bed"],["bed","light_gray_bed"],["bed","cyan_bed"],["bed","purple_bed"],["bed","blue_bed"],["bed","brown_bed"],["bed","green_bed"],["bed","red_bed"],["bed","black_bed"],["melon","melon_slice"],["speckled_melon","glistering_melon_slice"],["spawn_egg","pig_spawn_egg"],["skull","skeleton_skull"],["skull","wither_skeleton_skull"],["skull","zombie_head"],["skull","player_head"],["skull","creeper_head"],["skull","dragon_head"],["fireworks","firework_rocket"],["firework_charge","firework_star"],["netherbrick","nether_brick"],["banner","black_banner"],["banner","red_banner"],["banner","green_banner"],["banner","brown_banner"],["banner","blue_banner"],["banner","purple_banner"],["banner","cyan_banner"],["banner","light_gray_banner"],["banner","gray_banner"],["banner","pink_banner"],["banner","lime_banner"],["banner","yellow_banner"],["banner","light_blue_banner"],["banner","magenta_banner"],["banner","orange_banner"],["banner","white_banner"],["chorus_fruit_popped","popped_chorus_fruit"],["record_13","music_disc_13"],["record_cat","music_disc_cat"],["record_blocks","music_disc_blocks"],["record_chirp","music_disc_chirp"],["record_far","music_disc_far"],["record_mall","music_disc_mall"],["record_mellohi","music_disc_mellohi"],["record_stal","music_disc_stal"],["record_strad","music_disc_strad"],["record_ward","music_disc_ward"],["record_11","music_disc_11"],["record_wait","music_disc_wait"]]},"1.14":{blocks:[["sign","oak_sign"],["wall_sign","oak_wall_sign"]],items:[["sign","oak_sign"],["rose_red","red_dye"],["cactus_green","green_dye"],["dandelion_yellow","yellow_dye"]]},"1.15.2":{blocks:[],items:[]},"1.16.1":{blocks:[],items:[["zombie_pigman_spawn_egg","zombified_piglin_spawn_egg"]]},"1.16.2":{blocks:[],items:[]},"1.17":{blocks:[["grass_path","dirt_path"]],items:[["grass_path","dirt_path"]]},"1.18":{blocks:[],items:[]},"1.19":{blocks:[],items:[]},"1.19.3":{blocks:[],items:[]},"1.19.4":{blocks:[],items:[]},"1.20":{blocks:[],items:[["pottery_shard_archer","archer_pottery_sherd"],["pottery_shard_prize","prize_pottery_sherd"],["pottery_shard_arms_up","arms_up_pottery_sherd"],["pottery_shard_skull","skull_pottery_sherd"]]},"1.16":{items:[["zombie_pigman_spawn_egg","zombified_piglin_spawn_egg"]]},"1.20.3":{blocks:[["grass","short_grass"]],items:[["grass","short_grass"]]}}});var x6=Z0(o1=>{"use strict";x();R();T();k();Object.defineProperty(o1,"__esModule",{value:!0});o1.versionToNumber=void 0;var _8=r=>{let[t,e="0",i="0"]=r.split(".");return+`${t.padStart(2,"0")}${parseInt(e).toString().padStart(2,"0")}${parseInt(i).toString().padStart(2,"0")}`};o1.versionToNumber=_8});var k6=Z0(xe=>{"use strict";x();R();T();k();var A8=xe&&xe.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(xe,"__esModule",{value:!0});xe.getRenamedData=void 0;var R6=A8(E6()),Ct=x6(),E8=(r,t,e,i)=>{let n=(0,Ct.versionToNumber)(e),s=(0,Ct.versionToNumber)(i),o=n<s?1:-1,a=o>0?1:0,v=t,l=Object.keys(R6.default).sort((m,p)=>o*((0,Ct.versionToNumber)(m)-(0,Ct.versionToNumber)(p))),c=o>0?s:n,d=o>0?n:s;for(let m of l.filter(p=>(0,Ct.versionToNumber)(p)<=c&&(0,Ct.versionToNumber)(p)>=d)){if(o>0&&(0,Ct.versionToNumber)(m)>=c||o<0&&(0,Ct.versionToNumber)(m)<=d)break;let p=R6.default[m][r];if(p)for(let g of p){let y=g[a],E=g[1-a];if(Array.isArray(v))v.includes(E)&&(v=v.map(w=>w===E?y:w));else if(v===E){v=y;break}}}return v};xe.getRenamedData=E8});var D6={};b5(D6,{applyWorldGeometryExport:()=>I8,createMeshesFromExport:()=>z6,downloadWorldGeometry:()=>V2,exportWorldGeometry:()=>H6,loadTextureFromDataUrl:()=>O6,loadWorldGeometryFromUrl:()=>P8});import*as R0 from"three";function H6(r,t,e,i=!1){let n=[];for(let[o,a]of Object.entries(r.sectionObjects)){let v=a.children.find(E=>E.name==="mesh");if(!v?.geometry)continue;let{geometry:l}=v,c=l.getAttribute("position"),d=l.getAttribute("normal"),m=l.getAttribute("color"),p=l.getAttribute("uv"),g=l.index;if(!c||!g)continue;let y=r.sceneOrigin.getWorldPosition(v);n.push({key:o,position:{x:y?.x??r.sceneOrigin.toWorldX(v.position.x),y:y?.y??r.sceneOrigin.toWorldY(v.position.y),z:y?.z??r.sceneOrigin.toWorldZ(v.position.z)},geometry:{positions:[...c.array],normals:d?[...d.array]:[],colors:m?[...m.array]:[],uvs:p?[...p.array]:[],indices:[...g.array]}})}let s={version:r.version??"unknown",exportedAt:new Date().toISOString(),camera:{position:t,rotation:e},sections:n};if(i&&r.material.map){let o=document.createElement("canvas"),a=r.material.map,{image:v}=a;v&&(o.width=v.width,o.height=v.height,o.getContext("2d").drawImage(v,0,0),s.textureAtlasDataUrl=o.toDataURL("image/png"))}return s}function V2(r,t,e,i="world-geometry.json",n=!1){let s=H6(r,t,e,n),o=JSON.stringify(s),a=new Blob([o],{type:"application/json"}),v=URL.createObjectURL(a),l=document.createElement("a");l.href=v,l.download=i,l.click(),URL.revokeObjectURL(v)}async function P8(r){let t=await fetch(r);if(!t.ok)throw new Error(`Failed to fetch world geometry: ${t.statusText}`);return t.json()}function z6(r,t){let e=[];for(let i of r.sections){let n=new R0.BufferGeometry;n.setAttribute("position",new R0.Float32BufferAttribute(i.geometry.positions,3)),i.geometry.normals.length&&n.setAttribute("normal",new R0.Float32BufferAttribute(i.geometry.normals,3)),i.geometry.colors.length&&n.setAttribute("color",new R0.Float32BufferAttribute(i.geometry.colors,3)),i.geometry.uvs.length&&n.setAttribute("uv",new R0.Float32BufferAttribute(i.geometry.uvs,2));let o=Math.max(...i.geometry.indices)>65535?Uint32Array:Uint16Array;n.setIndex(new R0.BufferAttribute(new o(i.geometry.indices),1));let a=new R0.Mesh(n,t);a.position.set(i.position.x,i.position.y,i.position.z),a.name="mesh";let v=new R0.Group;v.name="chunk",v.add(a),e.push(v)}return e}async function O6(r){return new Promise((t,e)=>{let i=new Image;i.onload=()=>{let n=new R0.Texture(i);n.magFilter=R0.NearestFilter,n.minFilter=R0.NearestFilter,n.needsUpdate=!0,n.flipY=!1,t(n)},i.onerror=e,i.src=r})}async function I8(r,t){let{scene:e,renderUpdateEmitter:i,material:n}=r,s=e.getObjectByName(I6);s&&(e.remove(s),B8(s));let o=!!t.textureAtlasDataUrl,a;if(o&&t.textureAtlasDataUrl){let c=await O6(t.textureAtlasDataUrl);a=new R0.MeshLambertMaterial({map:c,vertexColors:!0,transparent:!0,alphaTest:.1}),a.name="geometry-export-material"}else a=n;let v=z6(t,a),l=new R0.Group;l.name=I6,o&&(l.userData.geometryExportMaterial=a);for(let c of v)l.add(c);return e.add(l),i.emit("update"),v.length}var I6,B8,N2=ut(()=>{"use strict";x();R();T();k();I6="geometry-export-root";B8=r=>{r.traverse(e=>{e.isMesh&&e.geometry?.dispose()});let t=r.userData?.geometryExportMaterial;t&&(t.map?.dispose?.(),t.dispose?.())}});x();R();T();k();x();R();T();k();x();R();T();k();x();R();T();k();import{proxy as zn}from"valtio";var Oe={paused:!1,showChunkBorders:!1,enableDebugOverlay:!0,debugModelVariant:void 0,futuristicReveal:!1,wasmMesher:!1,mesherWorkers:1,addChunksBatchWaitTime:200,_experimentalSmoothChunkLoading:!0,_renderByChunks:!1,autoLowerRenderDistance:!1,dayCycle:!0,smoothLighting:!0,enableLighting:!0,starfield:!0,defaultSkybox:!0,renderEntities:!0,extraBlockRenderers:!0,foreground:!0,fov:75,volume:1,showHand:!1,viewBobbing:!1,handRenderer:"vanilla",renderEars:!0,highlightBlockColor:"blue",fetchPlayerSkins:!0,skinTexturesProxy:void 0,vrSupport:!0,vrPageGameRendering:!0,clipWorldBelowY:void 0,isPlayground:!1,instantCameraUpdate:!1,isRaining:!1,moduleStates:{}},On={fpsLimit:void 0,powerPreference:void 0,sceneBackground:"lightblue",timeoutRendering:!1},Kv=(r={})=>zn({...Oe,...r}),Gt=()=>({reactive:zn({world:{chunksLoaded:new Set,heightmaps:new Map,allChunksLoaded:!1,mesherWork:!1,intersectMedia:null},renderer:"...",preventEscapeMenu:!1}),nonReactive:{fps:0,worstRenderTime:0,avgRenderTime:0,world:{chunksLoaded:new Set,chunksTotalNumber:0},renderer:{timeline:{live:[],frozen:[],lastSecond:[]}}}});x();R();T();k();import{proxy as xs}from"valtio";var P1=()=>xs({playerSkin:void 0,inWater:!1,waterBreathing:!1,backgroundColor:[0,0,0],ambientLight:0,directionalLight:0,eyeHeight:0,gameMode:void 0,lookingAtBlock:void 0,diggingBlock:void 0,movementState:"NOT_MOVING",onGround:!0,sneaking:!1,flying:!1,sprinting:!1,walkDist:0,prevWalkDist:0,bob:0,prevBob:0,itemUsageTicks:0,username:"",onlineMode:!1,lightingDisabled:!1,shouldHideHand:!1,heldItemMain:void 0,heldItemOff:void 0,perspective:"first_person",onFire:!1,cameraSpectatingEntity:void 0,team:void 0}),Dn=r=>({isSpectator(){return r.gameMode==="spectator"},isSpectatingEntity(){return r.cameraSpectatingEntity!==void 0&&r.gameMode==="spectator"},isThirdPerson(){return this.isSpectatingEntity()?!1:r.perspective==="third_person_back"||r.perspective==="third_person_front"}}),Ln=()=>({reactive:P1()});x();R();T();k();import{Vec3 as Fs}from"vec3";import{proxy as Wn}from"valtio";x();R();T();k();x();R();T();k();x();R();T();k();x();R();T();k();var E5={},Fn=!1;function Rs(){if(Fn)return E5;Fn=!0;var r=typeof Reflect=="object"?Reflect:null,t=r&&typeof r.apply=="function"?r.apply:function(S,H,B){return Function.prototype.apply.call(S,H,B)},e;r&&typeof r.ownKeys=="function"?e=r.ownKeys:Object.getOwnPropertySymbols?e=function(S){return Object.getOwnPropertyNames(S).concat(Object.getOwnPropertySymbols(S))}:e=function(S){return Object.getOwnPropertyNames(S)};function i(M){}var n=Number.isNaN||function(S){return S!==S};function s(){s.init.call(this)}E5=s,E5.once=w,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(M){if(typeof M!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof M)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(M){if(typeof M!="number"||M<0||n(M))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+M+".");o=M}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(S){if(typeof S!="number"||S<0||n(S))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+S+".");return this._maxListeners=S,this};function v(M){return M._maxListeners===void 0?s.defaultMaxListeners:M._maxListeners}s.prototype.getMaxListeners=function(){return v(this)},s.prototype.emit=function(S){for(var H=[],B=1;B<arguments.length;B++)H.push(arguments[B]);var I=S==="error",W=this._events;if(W!==void 0)I=I&&W.error===void 0;else if(!I)return!1;if(I){var z;if(H.length>0&&(z=H[0]),z instanceof Error)throw z;var j=new Error("Unhandled error."+(z?" ("+z.message+")":""));throw j.context=z,j}var q=W[S];if(q===void 0)return!1;if(typeof q=="function")t(q,this,H);else for(var e0=q.length,N=g(q,e0),B=0;B<e0;++B)t(N[B],this,H);return!0};function l(M,S,H,B){var I,W,z;if(a(H),W=M._events,W===void 0?(W=M._events=Object.create(null),M._eventsCount=0):(W.newListener!==void 0&&(M.emit("newListener",S,H.listener?H.listener:H),W=M._events),z=W[S]),z===void 0)z=W[S]=H,++M._eventsCount;else if(typeof z=="function"?z=W[S]=B?[H,z]:[z,H]:B?z.unshift(H):z.push(H),I=v(M),I>0&&z.length>I&&!z.warned){z.warned=!0;var j=new Error("Possible EventEmitter memory leak detected. "+z.length+" "+String(S)+" listeners added. Use emitter.setMaxListeners() to increase limit");j.name="MaxListenersExceededWarning",j.emitter=M,j.type=S,j.count=z.length}return M}s.prototype.addListener=function(S,H){return l(this,S,H,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(S,H){return l(this,S,H,!0)};function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(M,S,H){var B={fired:!1,wrapFn:void 0,target:M,type:S,listener:H},I=c.bind(B);return I.listener=H,B.wrapFn=I,I}s.prototype.once=function(S,H){return a(H),this.on(S,d(this,S,H)),this},s.prototype.prependOnceListener=function(S,H){return a(H),this.prependListener(S,d(this,S,H)),this},s.prototype.removeListener=function(S,H){var B,I,W,z,j;if(a(H),I=this._events,I===void 0)return this;if(B=I[S],B===void 0)return this;if(B===H||B.listener===H)--this._eventsCount===0?this._events=Object.create(null):(delete I[S],I.removeListener&&this.emit("removeListener",S,B.listener||H));else if(typeof B!="function"){for(W=-1,z=B.length-1;z>=0;z--)if(B[z]===H||B[z].listener===H){j=B[z].listener,W=z;break}if(W<0)return this;W===0?B.shift():y(B,W),B.length===1&&(I[S]=B[0]),I.removeListener!==void 0&&this.emit("removeListener",S,j||H)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(S){var H,B,I;if(B=this._events,B===void 0)return this;if(B.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):B[S]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete B[S]),this;if(arguments.length===0){var W=Object.keys(B),z;for(I=0;I<W.length;++I)z=W[I],z!=="removeListener"&&this.removeAllListeners(z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(H=B[S],typeof H=="function")this.removeListener(S,H);else if(H!==void 0)for(I=H.length-1;I>=0;I--)this.removeListener(S,H[I]);return this};function m(M,S,H){var B=M._events;if(B===void 0)return[];var I=B[S];return I===void 0?[]:typeof I=="function"?H?[I.listener||I]:[I]:H?E(I):g(I,I.length)}s.prototype.listeners=function(S){return m(this,S,!0)},s.prototype.rawListeners=function(S){return m(this,S,!1)},s.listenerCount=function(M,S){return typeof M.listenerCount=="function"?M.listenerCount(S):p.call(M,S)},s.prototype.listenerCount=p;function p(M){var S=this._events;if(S!==void 0){var H=S[M];if(typeof H=="function")return 1;if(H!==void 0)return H.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]};function g(M,S){for(var H=new Array(S),B=0;B<S;++B)H[B]=M[B];return H}function y(M,S){for(;S+1<M.length;S++)M[S]=M[S+1];M.pop()}function E(M){for(var S=new Array(M.length),H=0;H<S.length;++H)S[H]=M[H].listener||M[H];return S}function w(M,S){return new Promise(function(H,B){function I(z){M.removeListener(S,W),B(z)}function W(){typeof M.removeListener=="function"&&M.removeListener("error",I),H([].slice.call(arguments))}C(M,S,W,{once:!0}),S!=="error"&&_(M,I,{once:!0})})}function _(M,S,H){typeof M.on=="function"&&C(M,"error",S,H)}function C(M,S,H,B){if(typeof M.on=="function")B.once?M.once(S,H):M.on(S,H);else if(typeof M.addEventListener=="function")M.addEventListener(S,function I(W){B.once&&M.removeEventListener(S,I),H(W)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof M)}return E5}var x5=Rs();x5.once;x5.once=function(r,t){return new Promise((e,i)=>{function n(...o){s!==void 0&&r.removeListener("error",s),e(o)}let s;t!=="error"&&(s=o=>{r.removeListener(name,n),i(o)},r.once("error",s)),r.once(t,n)})};x5.on=function(r,t){let e=[],i=[],n=null,s=!1,o={async next(){let l=e.shift();if(l)return createIterResult(l,!1);if(n){let c=Promise.reject(n);return n=null,c}return s?createIterResult(void 0,!0):new Promise((c,d)=>i.push({resolve:c,reject:d}))},async return(){r.removeListener(t,a),r.removeListener("error",v),s=!0;for(let l of i)l.resolve(createIterResult(void 0,!0));return createIterResult(void 0,!0)},throw(l){n=l,r.removeListener(t,a),r.removeListener("error",v)},[Symbol.asyncIterator](){return this}};return r.on(t,a),r.on("error",v),o;function a(...l){let c=i.shift();c?c.resolve(createIterResult(l,!1)):e.push(l)}function v(l){s=!0;let c=i.shift();c?c.reject(l):n=l,o.return()}};var{EventEmitter:Wt,defaultMaxListeners:c9,init:d9,listenerCount:u9,on:f9,once:h9}=x5;import{Vec3 as Vt}from"vec3";x();R();T();k();function De(r){let t=r*2+1;if(t<=0)return[];let e=[],i=0,n=0,s=0,o=-1;for(let a=0;a<t*t;a++){if(Math.abs(i)<=t/2&&Math.abs(n)<=t/2&&e.push([i,n]),i===n||i<0&&i===-n||i>0&&i===1-n){let v=s;s=-o,o=v}i+=s,n+=o}return e}var ae=r=>[Math.floor(r.x/16),Math.floor(r.z/16)],ks=r=>[Math.floor(r.x/16),Math.floor(r.y/16),Math.floor(r.z/16)],Un=async(r,t,e,i=1)=>{for(let n=0;n<r.length;n+=i)t&&await new Promise(s=>setTimeout(s,t)),await e(r[n],n)},Le=class Le extends Wt{static restoreTransferred(t,e){let i=new Le;return e&&e.addEventListener("message",({data:n})=>{n.class===Le.restorerName&&n.type==="event"&&i.emit(n.eventName,...n.args)}),i}};f(Le,"restorerName","WorldViewWorker");var Nt=Le,jt=class extends Wt{constructor(e,i,n=new Vt(0,0,0)){super();this.world=e;this.viewDistance=i;f(this,"spiralNumber",0);f(this,"gotPanicLastTime",!1);f(this,"panicChunksReload",()=>{});f(this,"loadedChunks",{});f(this,"inLoading",!1);f(this,"chunkReceiveTimes",[]);f(this,"lastChunkReceiveTime",0);f(this,"lastChunkReceiveTimeAvg",0);f(this,"panicTimeout");f(this,"lastPos");f(this,"eventListeners",{});f(this,"debugChunksInfo",{});f(this,"waitingSpiralChunksLoad",{});f(this,"addWaitTime",1);f(this,"keepChunksDistance",0);f(this,"isPlayground",!1);f(this,"allowPositionUpdate",!0);f(this,"lastBiomeId",null);f(this,"lastPosCheck",null);this.lastPos=new Vt(0,0,0).update(n)}prepareForTransfer(e){if(e){let i=this.emit.bind(this);this.emit=(n,...s)=>{i(n,...s),e.postMessage({class:Nt.restorerName,type:"event",eventName:n,args:s})}}return{__restorer:Nt.restorerName}}setBlockStateId(e,i){let n=this.world.setBlockStateId(e,i);if(n&&typeof n.then=="function")throw new Error("setBlockStateId returned promise (not supported)");this.emit("blockUpdate",{pos:e,stateId:i})}updateViewDistance(e){this.viewDistance=e,this.emit("renderDistance",e)}async init(e,i){this.updateViewDistance(this.viewDistance),this.emit("chunkPosUpdate",{pos:e}),i?.time?.timeOfDay!==void 0&&this.emit("time",i.time.timeOfDay),i?.entity&&this.emit("playerEntity",i.entity),this.emitterGotConnected(i);let[n,s]=ae(e),o=De(this.viewDistance).map(([a,v])=>new Vt((n+a)*16,0,(s+v)*16));this.lastPos.update(e),await this._loadChunks(o,e)}chunkProgress(){if(this.panicTimeout&&clearTimeout(this.panicTimeout),this.chunkReceiveTimes.length>=5){let e=this.chunkReceiveTimes.reduce((n,s)=>n+s,0)/this.chunkReceiveTimes.length;this.lastChunkReceiveTimeAvg=e;let i=e*2+1e3;this.panicTimeout&&clearTimeout(this.panicTimeout),this.panicTimeout=setTimeout(()=>{!this.gotPanicLastTime&&this.inLoading&&(this.gotPanicLastTime=!0,this.panicChunksReload())},i)}}async _loadChunks(e,i){this.spiralNumber++;let{spiralNumber:n}=this;for(let o of Object.keys(this.waitingSpiralChunksLoad))this.waitingSpiralChunksLoad[o](!1),delete this.waitingSpiralChunksLoad[o];let s=!0;this.inLoading=!0,await Un(e,this.addWaitTime,async o=>{!s||this.loadedChunks[`${o.x},${o.z}`]||(this.world.getColumnAt(o)||(s=await new Promise(a=>{this.waitingSpiralChunksLoad[`${o.x},${o.z}`]=a})),s&&(await this.loadChunk(o,void 0,`spiral ${n} from ${i.x},${i.z}`),this.chunkProgress()))}),this.panicTimeout&&clearTimeout(this.panicTimeout),this.inLoading=!1,this.gotPanicLastTime=!1,this.chunkReceiveTimes=[],this.lastChunkReceiveTime=0}async loadChunk(e,i=!1,n="spiral"){var l,c;let[s,o]=ae(this.lastPos),a=Math.abs(s-Math.floor(e.x/16)),v=Math.abs(o-Math.floor(e.z/16));if(a<=this.viewDistance&&v<=this.viewDistance){let d=await this.world.getColumnAt(e.y!==void 0?e:new Vt(e.x,0,e.z));if(d){let m=d.toJson(),p={minY:d.minY??0,worldHeight:d.worldHeight??256};this.emit("loadChunk",{x:e.x,z:e.z,chunk:m,blockEntities:d.blockEntities,worldConfig:p,isLightUpdate:i}),this.loadedChunks[`${e.x},${e.z}`]=!0,(l=this.debugChunksInfo)[c=`${e.x},${e.z}`]??(l[c]={loads:[]}),this.debugChunksInfo[`${e.x},${e.z}`].loads.push({dataLength:m.length,reason:n,time:Date.now()})}else this.isPlayground&&this.emit("markAsLoaded",{x:e.x,z:e.z})}}unloadAllChunks(){for(let e of Object.keys(this.loadedChunks)){let[i,n]=e.split(",").map(Number);this.unloadChunk({x:i,z:n})}}unloadChunk(e){this.emit("unloadChunk",{x:e.x,z:e.z}),delete this.loadedChunks[`${e.x},${e.z}`],delete this.debugChunksInfo[`${e.x},${e.z}`]}emitterGotConnected(e){typeof globalThis.WorkerGlobalScope<"u"&&globalThis instanceof globalThis.WorkerGlobalScope||!e||this.emit("blockEntities",new Proxy({},{get(n,s,o){if(typeof s!="string")return;let[a,v,l]=s.split(",").map(Number);return e.world.getBlock(new Vt(a,v,l))?.entity}}))}updateBiome(e){try{if(!this.world.getBiome)return;let i=this.world.getBiome(e);i!==this.lastBiomeId&&(this.lastBiomeId=i,this.emit("biomeReset"))}catch{}}async updatePosition(e,i=!1){if(!this.allowPositionUpdate)return;let n=e.floored();if(!i&&this.lastPosCheck&&this.lastPosCheck.equals(n))return;this.lastPosCheck=n,this.updateBiome(e);let[s,o]=ae(this.lastPos),[a,v]=ae(e);if(s!==a||o!==v||i){this.emit("chunkPosUpdate",{pos:e});let l=[],c=i?this.viewDistance:this.viewDistance+this.keepChunksDistance;for(let m of Object.keys(this.loadedChunks)){let[p,g]=m.split(",").map(Number),y=new Vt(p,0,g),[E,w]=ae(y),_=Math.abs(a-E),C=Math.abs(v-w);(_>c||C>c)&&l.push(y)}for(let m of l)this.unloadChunk(m);let d=De(this.viewDistance).map(([m,p])=>{let g=new Vt((a+m)*16,0,(v+p)*16);if(!this.loadedChunks[`${g.x},${g.z}`])return g}).filter(m=>!!m);this.lastPos.update(e),this._loadChunks(d,e)}else this.emit("chunkPosUpdate",{pos:e}),this.lastPos.update(e)}};x();R();T();k();x();R();T();k();import Gn from"minecraft-data";import Ts from"mc-assets/dist/blocksAtlases.json";import Ms from"mc-assets/dist/itemsAtlases.json";import Ss from"mc-assets/dist/itemDefinitions.json";import Cs from"mc-assets/dist/blocksAtlasLatest.png";import Ps from"mc-assets/dist/blocksAtlasLegacy.png";import Bs from"mc-assets/dist/itemsAtlasLatest.png";import Is from"mc-assets/dist/itemsAtlasLegacy.png";import Hs from"mc-assets/dist/textureReplacements/christmas";import{AtlasParser as R5}from"mc-assets/dist/atlasParser";import zs from"mc-assets/dist/worldBlockProvider";import{ItemsRenderer as Os}from"mc-assets/dist/itemsRenderer";import{getLoadedItemDefinitionsStore as Ds}from"mc-assets";var ve=class{constructor(t){f(this,"sourceItemDefinitionsJson",Ss);f(this,"itemsDefinitionsStore",Ds(this.sourceItemDefinitionsJson));f(this,"allReady",!1);f(this,"itemsAtlasImage");f(this,"blocksAtlasImage");f(this,"blocksAtlasJson");f(this,"customBlockStates");f(this,"customModels");f(this,"customItemModelNames",{});f(this,"customTextures",{});f(this,"guiAtlas",null);f(this,"guiAtlasVersion",0);f(this,"itemsRenderer");f(this,"worldBlockProvider");f(this,"blockstatesModels",null);f(this,"version");f(this,"texturesVersion");f(this,"mcData");t&&(Object.assign(this,t),this.mcData=Gn(this.version))}prepareForTransfer(){let t={};for(let e in this)Object.prototype.hasOwnProperty.call(this,e)&&typeof this[e]!="function"&&(e==="itemsRenderer"||e==="worldBlockProvider"||e==="mcData"||(t[e]=this[e]));return t.customTextures={},t}},Ls="1.21.4",Et=class Et extends Wt{constructor(){super(...arguments);f(this,"sourceBlockStatesModels",null);f(this,"sourceBlocksAtlases",Ts);f(this,"sourceItemsAtlases",Ms);f(this,"currentResources");f(this,"itemsAtlasParser");f(this,"blocksAtlasParser");f(this,"currentConfig");f(this,"abortController",new AbortController);f(this,"_promiseAssetsReadyResolvers",Promise.withResolvers())}static restoreTransferred(e,i){let n=new Et,s=o=>{n.currentResources=new ve(o)};return s(e.currentResources),i&&i.addEventListener("message",({data:o})=>{o.class===Et.restorerName&&(o.type==="newResources"&&s(o.currentResources),o.type==="event"&&n.emit(o.eventName,...o.args))}),n}prepareForTransfer(e){if(e){let i=this.emit.bind(this);this.emit=(n,...s)=>{i(n,...s),e.postMessage({class:Et.restorerName,type:"event",eventName:n,args:s}),(n==="assetsTexturesUpdated"||n==="assetsInventoryReady")&&e.postMessage({class:Et.restorerName,type:"newResources",currentResources:this.currentResources?.prepareForTransfer()})}}return{__restorer:Et.restorerName,currentResources:this.currentResources?.prepareForTransfer()}}get promiseAssetsReady(){return this._promiseAssetsReadyResolvers.promise}async loadSourceData(e=this.currentConfig?.version){if(!e)throw new Error("No version loaded");this.sourceBlockStatesModels??(this.sourceBlockStatesModels=(await import("mc-assets/dist/blockStatesModels.json")).default)}resetResources(){this.currentResources=new ve}async updateAssetsData(e,i=!1){if(!this.currentConfig)throw new Error("No config loaded");this._promiseAssetsReadyResolvers=Promise.withResolvers();let n=new AbortController;if(await this.loadSourceData(this.currentConfig.version),n.signal.aborted)return;let s=this.currentResources??new ve;s.version=this.currentConfig.version,s.texturesVersion=this.currentConfig.texturesVersion??s.version,s.mcData=Gn(s.version),s.blockstatesModels={blockstates:{},models:{}},s.blockstatesModels.blockstates.latest={...this.sourceBlockStatesModels.blockstates.latest,...s.customBlockStates},s.blockstatesModels.models.latest={...this.sourceBlockStatesModels.models.latest,...s.customModels},await Promise.all([this.recreateBlockAtlas(s),this.recreateItemsAtlas(s)]),!n.signal.aborted&&(s.version&&s.blockstatesModels&&this.itemsAtlasParser&&this.blocksAtlasParser&&(s.itemsRenderer=new Os(s.version,s.blockstatesModels,this.itemsAtlasParser,this.blocksAtlasParser)),!n.signal.aborted&&(this.currentResources=s,s.allReady=!0,i||this.emit("assetsTexturesUpdated"),this.currentConfig.noInventoryGui?this._promiseAssetsReadyResolvers.resolve():(this.emit("assetsInventoryStarted"),this.generateGuiTextures().then(()=>{n.signal.aborted||(i||this.emit("assetsInventoryReady"),this._promiseAssetsReadyResolvers.resolve())}))))}async recreateBlockAtlas(e=this.currentResources){let i={},n=new Date;(n.getMonth()===11&&n.getDate()>=24||n.getMonth()===0&&n.getDate()<=6)&&Object.assign(i,Hs);let s=new R5(this.sourceBlocksAtlases,Cs,Ps),o=Object.keys(e.customTextures.blocks?.textures??{}),{atlas:a,canvas:v}=await s.makeNewAtlas(e.texturesVersion,l=>{if(this.currentConfig.includeOnlyBlocks&&!this.currentConfig.includeOnlyBlocks.includes(l))return!1;let c=e.customTextures.blocks?.textures[l];return i[l]??c},void 0,void 0,o,{needHorizontalIndexes:!!this.currentConfig.includeOnlyBlocks});this.blocksAtlasParser=new R5({latest:a},v.toDataURL()),e.blocksAtlasImage=await createImageBitmap(v),e.blocksAtlasJson=this.blocksAtlasParser.atlas.latest,e.worldBlockProvider=zs(e.blockstatesModels,this.blocksAtlasParser.atlas,Ls)}async recreateItemsAtlas(e=this.currentResources){let i=new R5(this.sourceItemsAtlases,Bs,Is),n=Object.keys(e.customTextures.items?.textures??{}),{atlas:s,canvas:o}=await i.makeNewAtlas(e.texturesVersion,a=>{let v=e.customTextures.items?.textures[a];if(v)return v},e.customTextures.items?.tileSize,void 0,n);this.itemsAtlasParser=new R5({latest:s},o.toDataURL()),e.itemsAtlasImage=await createImageBitmap(o)}async generateGuiTextures(){}async downloadDebugAtlas(e=!1){if(!this.currentResources)throw new Error("No resources loaded");let s=await(e?this.itemsAtlasParser:this.blocksAtlasParser).createDebugImage(!0),o=document.createElement("a");o.href=s,o.download=`atlas-debug-${e?"items":"blocks"}.png`,o.click()}destroy(){this.abortController.abort(),this.currentResources=void 0,this.abortController=new AbortController}};f(Et,"restorerName","ResourcesManager");var mt=Et;var Vn=class{constructor(t={},e=new mt){this.resourcesManager=e;f(this,"waitBackendLoadPromises",[]);f(this,"onWorldStart");f(this,"onBeforeWorldStart");f(this,"worldView");f(this,"config");f(this,"inWorldRenderingConfig");f(this,"backend");f(this,"backendLoader");f(this,"currentState");f(this,"currentDisplay",null);f(this,"playerState",{reactive:P1()});f(this,"rendererState");f(this,"nonReactiveState");f(this,"worldReady");f(this,"resolveWorldReady");f(this,"lastCamUpdate",0);this.config={...On,...t.config},this.inWorldRenderingConfig=Wn({...Oe,...t.rendererConfig});let i=Gt();this.rendererState=i.reactive,this.nonReactiveState=i.nonReactive,this.initWorldReadyPromise()}initWorldReadyPromise(){let{promise:t,resolve:e}=Promise.withResolvers();this.worldReady=t,this.resolveWorldReady=e}async loadBackend(t){this.backend&&this.disconnectBackend(),await Promise.all(this.waitBackendLoadPromises),this.waitBackendLoadPromises=[],this.backendLoader=t;let e={config:this.config,callbacks:{displayCriticalError:n=>{},setRendererSpecificSettings:(n,s)=>{},fireCustomEvent:(n,...s)=>{}},rendererSpecificSettings:{}},i=t(e);if(this.backend=await Promise.resolve(i),this.currentState)if(this.currentState.method==="startPanorama")this.startPanorama();else{let{method:n,args:s}=this.currentState;this.backend[n](...s)}}async startWorld(t,e,i=this.playerState.reactive,n){if(this.currentDisplay==="world")throw new Error("World already started");this.currentDisplay="world";let s=n??new Fs(0,64,0);this.worldView=new jt(t,e,s),this.worldView.isPlayground=this.inWorldRenderingConfig.isPlayground;let o={version:this.resourcesManager?.currentConfig?.version??"1.20.4",worldView:this.worldView,inWorldRenderingConfig:this.inWorldRenderingConfig,playerStateReactive:i,rendererState:this.rendererState,nonReactiveState:this.nonReactiveState,resourcesManager:this.resourcesManager};this.onBeforeWorldStart?.();let a;if(this.backend){let v=this.backend.startWorld(o);v&&typeof v.then=="function"&&(a=v)}return this.currentState={method:"startWorld",args:[o]},await a,this.resolveWorldReady(),this.onWorldStart?.(),!!a}startPanorama(){this.currentDisplay!=="menu"&&(this.backend&&(this.currentDisplay="menu",this.backend.startPanorama()),this.currentState={method:"startPanorama",args:[]})}resetBackend(t=!1){this.disconnectBackend(t),this.backendLoader&&this.loadBackend(this.backendLoader)}disconnectBackend(t=!1){t&&(this.currentState=void 0,this.currentDisplay=null,this.worldView=void 0),this.backend&&(this.backend.disconnect(),this.backend=void 0),this.currentDisplay=null,this.initWorldReadyPromise(),this.rendererState=Wn(Gt().reactive),this.nonReactiveState=Gt().nonReactive}updateCamera(t,e,i){this.backend?.updateCamera(t,e,i)}setRendering(t){this.backend?.setRendering(t)}async startWithBot(t,e){await this.startWorld(t.world,e),this.worldView&&typeof this.worldView.listenToBot=="function"&&this.worldView.listenToBot(t)}destroyAll(){this.disconnectBackend(!0),this.resourcesManager&&typeof this.resourcesManager.destroy=="function"&&this.resourcesManager.destroy()}get utils(){let t=this.backend;return{async waitingForChunks(){if(!t?.worldState?.allChunksLoaded)return new Promise(e=>{let i=setInterval(()=>{t?.worldState?.allChunksLoaded&&(clearInterval(i),e())},100)})}}}destroy(){this.disconnectBackend(!0)}};x();R();T();k();import{proxy as Us}from"valtio";var Nn=()=>Us({playerSkin:void 0,inWater:!1,waterBreathing:!1,backgroundColor:[0,0,0],ambientLight:0,directionalLight:0,eyeHeight:0,gameMode:void 0,lookingAtBlock:void 0,diggingBlock:void 0,movementState:"NOT_MOVING",onGround:!0,sneaking:!1,flying:!1,sprinting:!1,walkDist:0,prevWalkDist:0,bob:0,prevBob:0,itemUsageTicks:0,username:"",onlineMode:!1,lightingDisabled:!1,shouldHideHand:!1,heldItemMain:void 0,heldItemOff:void 0,perspective:"first_person",onFire:!1,cameraSpectatingEntity:void 0,team:void 0}),Gs=r=>({isSpectator(){return r.gameMode==="spectator"},isSpectatingEntity(){return r.cameraSpectatingEntity!==void 0&&r.gameMode==="spectator"},isThirdPerson(){return this.isSpectatingEntity()?!1:r.perspective==="third_person_back"||r.perspective==="third_person_front"}}),Ws=()=>({reactive:Nn()}),jn=(r,t,e)=>({...t,"minecraft:date":new Date});x();R();T();k();x();R();T();k();import*as h5 from"three";import{Vec3 as mv}from"vec3";x();R();T();k();import{proxy as Vs,getVersion as Qn,subscribe as Kn}from"valtio";import{Vec3 as Jn}from"vec3";function qn(r,t){let e=t??globalThis;return e.addEventListener("message",i=>{let{type:n,args:s,msgId:o}=i.data;if(r[n]){let a=r[n](...s);a instanceof Promise&&a.then(v=>{e.postMessage({type:"result",msgId:o,args:[v]})})}}),null}var Zn=(r,t=!0)=>{let e=0;return new Proxy({},{get(i,n){return n==="transfer"?(...s)=>new Proxy({},{get(o,a){return(...v)=>{r.postMessage({type:a,args:v},s)}}}):(...s)=>{let o=e++,a=t?s.filter(v=>v instanceof ArrayBuffer||v instanceof MessagePort||typeof ImageBitmap<"u"&&v instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&v instanceof OffscreenCanvas||typeof ImageData<"u"&&v instanceof ImageData):[];return r.postMessage({type:n,msgId:o,args:s},a),{then(v){let l=({data:c})=>{c.type==="result"&&c.msgId===o&&(v(c.args[0]),r.removeEventListener("message",l))};r.addEventListener("message",l)}}}}})};var Xn=(r,t,e,i)=>{try{e.postMessage({type:"sync",syncId:r,value:k5(t)}),Fe.toWorker++,globalThis.debugSyncMessagesOutgoing??(globalThis.debugSyncMessagesOutgoing=0),globalThis.debugSyncMessagesOutgoing++}catch{Ue(t)}},Fe={toWorker:0,fromWorker:0};typeof window<"u"&&setInterval(()=>{globalThis.debugWorkerSyncStats={...Fe},Fe.toWorker=0,Fe.fromWorker=0},1e3);var Ns=()=>Math.random().toString(36).slice(2,15)+Math.random().toString(36).slice(2,15),Yn=(r,t,e,i,n)=>{if(!r.__syncToWorker&&!r.__syncFromWorker&&!i)return;let s=Ns();if(r.__syncId=s,r.__syncToWorker||i){let o=()=>{Xn(s,t,e,`toWorker:${n}`)};i&&Kn(t,o);let a=r.__syncToWorkerInterval??0;a>0&&setInterval(o,a)}t.__syncFromWorker&&e.addEventListener("message",o=>{o.data.type==="sync"&&o.data.syncId===s&&(Fe.fromWorker++,Object.assign(t,o.data.value))})},k5=r=>{if(Qn(r)===void 0)return r;if(Array.isArray(r))return r.map(k5);if(typeof r=="object"&&r!==null){let t={};for(let e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=k5(r[e]));return t}return r},T5=(r,t,e=!0,i=!0,n=!1)=>{var a,v;let s=r,o={};for(let l in r)if(Object.prototype.hasOwnProperty.call(r,l)){if(e&&typeof r[l]=="function")continue;if(r[l]instanceof Date||r[l]instanceof RegExp||r[l]instanceof Map||r[l]instanceof WeakMap||r[l]instanceof WeakSet,r[l]instanceof Set){o[l]=[...r[l]],o[l].__restorer="Set";continue}if(r[l]instanceof Jn){o[l]={x:r[l].x,y:r[l].y,z:r[l].z},o[l].__restorer="Vec3";continue}if(o[l]=r[l],typeof r[l]=="object"&&r[l]!==null){if(r[l].prepareForTransfer){o[l]=r[l].prepareForTransfer(t);continue}let c=Qn(r[l])!==void 0;o[l]=c?k5(r[l]):r[l];let d=r[l].__syncToWorker!==!1&&!n&&c&&!r[l].__syncFromWorker;if((a=o[l]).__syncToWorker??(a.__syncToWorker=d),c&&((v=o[l]).__valtio??(v.__valtio=!0)),o[l].__syncToWorker&&c){Yn(o[l],s[l],t,!0,l);continue}Yn(o[l],s[l],t,!1,l),o[l]=T5(o[l],t,e,!1,c)}}return o},Ue=(r,t=[])=>{for(let e in r)if(Object.prototype.hasOwnProperty.call(r,e)){if(!r[e])continue;typeof r[e]=="object"&&r[e]!==null&&Ue(r[e],[...t,e]);try{structuredClone(r[e])}catch{}}},js=(r,t,e)=>{if(!r.__syncId)return;let i=r.__syncId;if(r.__syncToWorker&&t.addEventListener("message",n=>{n.data.type==="sync"&&n.data.syncId===i&&Object.assign(r,n.data.value)}),r.__syncFromWorker){let n=()=>{Xn(i,r,t,`fromWorker:${e}`)};r.__valtio&&Kn(r,n);let s=r.__syncFromWorkerInterval??0;s>0&&setInterval(n,s)}},Ys=[{restorerName:"Set",restoreTransferred(r,t){return new Set(r)}},{restorerName:"Vec3",restoreTransferred(r,t){return new Jn(r.x,r.y,r.z)}}];var M5=(r,t,e,i=!0)=>{let n=[...Ys,...t];for(let s in r)if(Object.prototype.hasOwnProperty.call(r,s)){if(!r[s])continue;if(typeof r[s]=="object"&&r[s]!==null&&M5(r[s],n,e,i),r[s].__restorer){let o=n.find(a=>a.restorerName?a.restorerName===r[s].__restorer:a.name===r[s].__restorer);if(o)r[s]=o.restoreTransferred(r[s],e);else{let a=new Error(`Restorer ${r[s].__restorer} not found`);if(typeof i=="function")i(a);else if(i)throw a}}r[s].__valtio&&(r[s]=Vs(r[s])),js(r[s],e,s)}return r};x();R();T();k();var S5=class{constructor(t){this.nonReactiveState=t;f(this,"events",[]);f(this,"frozenEvents",[]);f(this,"lastSecondEvents",[]);f(this,"currentFrameStartTime",null);f(this,"lastInteractionTime",0);f(this,"lastSecondUpdateTime",0);f(this,"timeWindowMs",5e3);f(this,"lastSecondWindowMs",1e3);f(this,"maxEvents",500);f(this,"lastSecondUpdateInterval",1e3);this.nonReactiveState.renderer||(this.nonReactiveState.renderer={timeline:{live:[],frozen:[],lastSecond:[]}}),this.nonReactiveState.renderer.timeline||(this.nonReactiveState.renderer.timeline={live:[],frozen:[],lastSecond:[]}),setInterval(()=>{this.updateLastSecondTimeline()},this.lastSecondUpdateInterval)}markFrameStart(){this.currentFrameStartTime=performance.now(),this.addEvent({type:"frameStart",timestamp:this.currentFrameStartTime})}markFrameEnd(){if(!this.currentFrameStartTime)return;let t=performance.now(),e=t-this.currentFrameStartTime;this.addEvent({type:"frameEnd",timestamp:t,duration:e}),this.currentFrameStartTime=null}markCameraUpdate(t){if(!t)return;let e=performance.now();this.lastInteractionTime=e,this.addEvent({type:"cameraUpdate",timestamp:e}),this.frozenEvents=[...this.events],this.trimEvents(this.frozenEvents),this.syncFrozenEvents()}markFrameDisplay(){this.addEvent({type:"frameDisplay",timestamp:performance.now()})}addEvent(t){this.events.push(t),this.lastSecondEvents.push(t),this.trimEvents(this.events),this.trimLastSecondEvents(),this.syncLiveEvents()}trimEvents(t){let i=performance.now()-this.timeWindowMs;for(;t.length>0&&t[0].timestamp<i;)t.shift();t.length>this.maxEvents&&t.splice(0,t.length-this.maxEvents)}trimLastSecondEvents(){let e=performance.now()-this.lastSecondWindowMs;for(;this.lastSecondEvents.length>0&&this.lastSecondEvents[0].timestamp<e;)this.lastSecondEvents.shift()}updateLastSecondTimeline(){let t=performance.now();t-this.lastSecondUpdateTime<this.lastSecondUpdateInterval||(this.lastSecondUpdateTime=t,this.trimLastSecondEvents(),this.syncLastSecondEvents())}syncLiveEvents(){this.nonReactiveState.renderer.timeline.live=[...this.events]}syncFrozenEvents(){this.nonReactiveState.renderer.timeline.frozen=[...this.frozenEvents]}syncLastSecondEvents(){this.nonReactiveState.renderer.timeline.lastSecond=[...this.lastSecondEvents]}clear(){this.events=[],this.frozenEvents=[],this.lastSecondEvents=[],this.syncLiveEvents(),this.syncFrozenEvents(),this.syncLastSecondEvents()}};x();R();T();k();import*as Y from"three";import{Vec3 as It}from"vec3";import q8 from"prismarine-chat";x();R();T();k();var k0=Object.freeze({Linear:Object.freeze({None:function(r){return r},In:function(r){return this.None(r)},Out:function(r){return this.None(r)},InOut:function(r){return this.None(r)}}),Quadratic:Object.freeze({In:function(r){return r*r},Out:function(r){return r*(2-r)},InOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)}}),Cubic:Object.freeze({In:function(r){return r*r*r},Out:function(r){return--r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)}}),Quartic:Object.freeze({In:function(r){return r*r*r*r},Out:function(r){return 1- --r*r*r*r},InOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)}}),Quintic:Object.freeze({In:function(r){return r*r*r*r*r},Out:function(r){return--r*r*r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)}}),Sinusoidal:Object.freeze({In:function(r){return 1-Math.sin((1-r)*Math.PI/2)},Out:function(r){return Math.sin(r*Math.PI/2)},InOut:function(r){return .5*(1-Math.sin(Math.PI*(.5-r)))}}),Exponential:Object.freeze({In:function(r){return r===0?0:Math.pow(1024,r-1)},Out:function(r){return r===1?1:1-Math.pow(2,-10*r)},InOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)}}),Circular:Object.freeze({In:function(r){return 1-Math.sqrt(1-r*r)},Out:function(r){return Math.sqrt(1- --r*r)},InOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)}}),Elastic:Object.freeze({In:function(r){return r===0?0:r===1?1:-Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI)},Out:function(r){return r===0?0:r===1?1:Math.pow(2,-10*r)*Math.sin((r-.1)*5*Math.PI)+1},InOut:function(r){return r===0?0:r===1?1:(r*=2,r<1?-.5*Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI):.5*Math.pow(2,-10*(r-1))*Math.sin((r-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(r){var t=1.70158;return r===1?1:r*r*((t+1)*r-t)},Out:function(r){var t=1.70158;return r===0?0:--r*r*((t+1)*r+t)+1},InOut:function(r){var t=2.5949095;return(r*=2)<1?.5*(r*r*((t+1)*r-t)):.5*((r-=2)*r*((t+1)*r+t)+2)}}),Bounce:Object.freeze({In:function(r){return 1-k0.Bounce.Out(1-r)},Out:function(r){return r<.36363636363636365?7.5625*r*r:r<.7272727272727273?7.5625*(r-=.5454545454545454)*r+.75:r<.9090909090909091?7.5625*(r-=.8181818181818182)*r+.9375:7.5625*(r-=.9545454545454546)*r+.984375},InOut:function(r){return r<.5?k0.Bounce.In(r*2)*.5:k0.Bounce.Out(r*2-1)*.5+.5}}),generatePow:function(r){return r===void 0&&(r=4),r=r<Number.EPSILON?Number.EPSILON:r,r=r>1e4?1e4:r,{In:function(t){return Math.pow(t,r)},Out:function(t){return 1-Math.pow(1-t,r)},InOut:function(t){return t<.5?Math.pow(t*2,r)/2:(1-Math.pow(2-t*2,r))/2+.5}}}}),Ge=function(){return performance.now()},ce=function(){function r(){this._tweens={},this._tweensAddedDuringUpdate={}}return r.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map(function(e){return t._tweens[e]})},r.prototype.removeAll=function(){this._tweens={}},r.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},r.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},r.prototype.update=function(t,e){t===void 0&&(t=Ge()),e===void 0&&(e=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var n=0;n<i.length;n++){var s=this._tweens[i[n]],o=!e;s&&s.update(t,o)===!1&&!e&&delete this._tweens[i[n]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},r}(),le={Linear:function(r,t){var e=r.length-1,i=e*t,n=Math.floor(i),s=le.Utils.Linear;return t<0?s(r[0],r[1],i):t>1?s(r[e],r[e-1],e-i):s(r[n],r[n+1>e?e:n+1],i-n)},Bezier:function(r,t){for(var e=0,i=r.length-1,n=Math.pow,s=le.Utils.Bernstein,o=0;o<=i;o++)e+=n(1-t,i-o)*n(t,o)*r[o]*s(i,o);return e},CatmullRom:function(r,t){var e=r.length-1,i=e*t,n=Math.floor(i),s=le.Utils.CatmullRom;return r[0]===r[e]?(t<0&&(n=Math.floor(i=e*(1+t))),s(r[(n-1+e)%e],r[n],r[(n+1)%e],r[(n+2)%e],i-n)):t<0?r[0]-(s(r[0],r[0],r[1],r[1],-i)-r[0]):t>1?r[e]-(s(r[e],r[e],r[e-1],r[e-1],i-e)-r[e]):s(r[n?n-1:0],r[n],r[e<n+1?e:n+1],r[e<n+2?e:n+2],i-n)},Utils:{Linear:function(r,t,e){return(t-r)*e+r},Bernstein:function(r,t){var e=le.Utils.Factorial;return e(r)/e(t)/e(r-t)},Factorial:function(){var r=[1];return function(t){var e=1;if(r[t])return r[t];for(var i=t;i>1;i--)e*=i;return r[t]=e,e}}(),CatmullRom:function(r,t,e,i,n){var s=(e-r)*.5,o=(i-t)*.5,a=n*n,v=n*a;return(2*t-2*e+s+o)*v+(-3*t+3*e-2*s-o)*a+s*n+t}}},$n=function(){function r(){}return r.nextId=function(){return r._nextId++},r._nextId=0,r}(),B1=new ce,S0=function(){function r(t,e){e===void 0&&(e=B1),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=k0.Linear.None,this._interpolationFunction=le.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=$n.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return r.prototype.getId=function(){return this._id},r.prototype.isPlaying=function(){return this._isPlaying},r.prototype.isPaused=function(){return this._isPaused},r.prototype.to=function(t,e){if(e===void 0&&(e=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=e,this},r.prototype.duration=function(t){return t===void 0&&(t=1e3),this._duration=t,this},r.prototype.dynamic=function(t){return t===void 0&&(t=!1),this._isDynamic=t,this},r.prototype.start=function(t,e){if(t===void 0&&(t=Ge()),e===void 0&&(e=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||e){if(this._propertiesAreSetUp=!0,!this._isDynamic){var n={};for(var s in this._valuesEnd)n[s]=this._valuesEnd[s];this._valuesEnd=n}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,e)}return this},r.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},r.prototype._setupProperties=function(t,e,i,n,s){for(var o in i){var a=t[o],v=Array.isArray(a),l=v?"array":typeof a,c=!v&&Array.isArray(i[o]);if(!(l==="undefined"||l==="function")){if(c){var d=i[o];if(d.length===0)continue;for(var m=[a],p=0,g=d.length;p<g;p+=1){var y=this._handleRelativeValue(a,d[p]);if(isNaN(y)){c=!1;break}m.push(y)}c&&(i[o]=m)}if((l==="object"||v)&&a&&!c){e[o]=v?[]:{};var E=a;for(var w in E)e[o][w]=E[w];n[o]=v?[]:{};var d=i[o];if(!this._isDynamic){var _={};for(var w in d)_[w]=d[w];i[o]=d=_}this._setupProperties(E,e[o],d,n[o],s)}else(typeof e[o]>"u"||s)&&(e[o]=a),v||(e[o]*=1),c?n[o]=i[o].slice().reverse():n[o]=e[o]||0}}},r.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},r.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},r.prototype.pause=function(t){return t===void 0&&(t=Ge()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this),this)},r.prototype.resume=function(t){return t===void 0&&(t=Ge()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},r.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},r.prototype.group=function(t){return t===void 0&&(t=B1),this._group=t,this},r.prototype.delay=function(t){return t===void 0&&(t=0),this._delayTime=t,this},r.prototype.repeat=function(t){return t===void 0&&(t=0),this._initialRepeat=t,this._repeat=t,this},r.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},r.prototype.yoyo=function(t){return t===void 0&&(t=!1),this._yoyo=t,this},r.prototype.easing=function(t){return t===void 0&&(t=k0.Linear.None),this._easingFunction=t,this},r.prototype.interpolation=function(t){return t===void 0&&(t=le.Linear),this._interpolationFunction=t,this},r.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},r.prototype.onStart=function(t){return this._onStartCallback=t,this},r.prototype.onEveryStart=function(t){return this._onEveryStartCallback=t,this},r.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},r.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},r.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},r.prototype.onStop=function(t){return this._onStopCallback=t,this},r.prototype.update=function(t,e){if(t===void 0&&(t=Ge()),e===void 0&&(e=!0),this._isPaused)return!0;var i,n,s=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>s)return!1;e&&this.start(t,!0)}if(this._goToEnd=!1,t<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0),n=(t-this._startTime)/this._duration,n=this._duration===0||n>1?1:n;var o=this._easingFunction(n);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,o),this._onUpdateCallback&&this._onUpdateCallback(this._object,n),n===1)if(this._repeat>0){isFinite(this._repeat)&&this._repeat--;for(i in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[i]=="string"&&(this._valuesStartRepeat[i]=this._valuesStartRepeat[i]+parseFloat(this._valuesEnd[i])),this._yoyo&&this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];return this._yoyo&&(this._reversed=!this._reversed),this._repeatDelayTime!==void 0?this._startTime=t+this._repeatDelayTime:this._startTime=t+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var a=0,v=this._chainedTweens.length;a<v;a++)this._chainedTweens[a].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},r.prototype._updateProperties=function(t,e,i,n){for(var s in i)if(e[s]!==void 0){var o=e[s]||0,a=i[s],v=Array.isArray(t[s]),l=Array.isArray(a),c=!v&&l;c?t[s]=this._interpolationFunction(a,n):typeof a=="object"&&a?this._updateProperties(t[s],o,a,n):(a=this._handleRelativeValue(o,a),typeof a=="number"&&(t[s]=o+(a-o)*n))}},r.prototype._handleRelativeValue=function(t,e){return typeof e!="string"?e:e.charAt(0)==="+"||e.charAt(0)==="-"?t+parseFloat(e):parseFloat(e)},r.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],i=this._valuesEnd[t];typeof i=="string"?this._valuesStartRepeat[t]=this._valuesStartRepeat[t]+parseFloat(i):this._valuesStartRepeat[t]=this._valuesEnd[t],this._valuesEnd[t]=e},r}();var oc=$n.nextId,at=B1,ac=at.getAll.bind(at),vc=at.removeAll.bind(at),lc=at.add.bind(at),cc=at.remove.bind(at),tr=at.update.bind(at);x();R();T();k();x();R();T();k();var Qs=()=>{if(typeof OffscreenCanvas>"u")return!1;try{let r=new OffscreenCanvas(1,1);return(r.getContext("webgl2")||r.getContext("webgl"))!==null}catch{return!1}},Ks=Qs(),L0=(r,t)=>{if(Ks)return new OffscreenCanvas(r,t);let e=document.createElement("canvas");return e.width=r,e.height=t,e};async function C5(r){let e=await(await fetch(r)).blob();return createImageBitmap(e)}var Js=(r,t)=>{try{return JSON.parse(r)}catch{return null}},qs={black:"#000000",dark_blue:"#0000AA",dark_green:"#00AA00",dark_aqua:"#00AAAA",dark_red:"#AA0000",dark_purple:"#AA00AA",gold:"#FFAA00",gray:"#AAAAAA",dark_gray:"#555555",blue:"#5555FF",green:"#55FF55",aqua:"#55FFFF",red:"#FF5555",light_purple:"#FF55FF",yellow:"#FFFF55",white:"#FFFFFF"},P5=(r,t,e,i=s=>{},n=(s,o)=>L0(s,o))=>{let a=[16,9],v=a[0]-a[1],l=v/16,c="front_text"in r?r.front_text.messages:[r.Text1,r.Text2,r.Text3,r.Text4];if(!c.some(g=>g!=="null"))return;let d=n(16*40,v*40),m=d.getContext("2d");i(m);let p=("front_text"in r?r.front_text.color:r.Color)||"black";for(let[g,y]of c.slice(0,4).entries())y!=="null"&&I1(y,e,d,64,p,64*(g+1)+(t?0:-8));return d},I1=(r,t,e,i,n,s=0)=>{let o=!1,a=typeof r=="string"&&(r?.startsWith("{")||r?.startsWith('"'))?Js(r??'""',"sign text"):r;if(!a||typeof a!="object"&&typeof a!="string")return;let v=e.getContext("2d");if(!v)throw new Error("Could not get 2d context");v.imageSmoothingEnabled=!1,v.font=`${i}px mojangles`;let l=new t(a),c=[],d=!1,m="",p=s,g=[],y=(C,M)=>{C.text!==null&&C.text!==void 0&&C.text;let S=C.text===null||C.text===void 0?void 0:String(C.text),H={color:C.color??M?.color,underlined:C.underlined??M?.underlined,strikethrough:C.strikethrough??M?.strikethrough,bold:C.bold??M?.bold,italic:C.italic??M?.italic};if(d=d||H.underlined||H.strikethrough||!1,S?.includes(`
|
|
13
|
+
`,"\\n")).join("")))},{name:"STRING$ebnf$2",symbols:[/[^\"\'}\]:;,\s]/]},{name:"STRING$ebnf$2",symbols:["STRING$ebnf$2",/[^\"\'}\]:;,\s]/],postprocess:function(l){return l[0].concat([l[1]])}},{name:"STRING",symbols:["STRING$ebnf$2"],postprocess:v=>t(v[0].join(""))}],ParserStart:"MAIN"};typeof V5<"u"&&typeof V5.exports<"u"?V5.exports=a:window.grammar=a})()});var c2=Z0((Sh,kr)=>{x();R();T();k();var _r=yr(),bo=wr();function xr(r){function t(e,i){return i==="compound"?Object.keys(e).reduce(function(n,s){return n[s]=xr(e[s]),n},{}):i==="list"?Array.isArray(e.value)?e.value.map(function(n){return t(n,e.type)}):[]:e}return t(r.value,r.type)}function N5({value:r,type:t}){if(t==="compound"){let i=[],n=Object.entries(r);for(let s=0;s<n.length;s++){let o=n[s][0],a=N5(n[s][1]);o==="string"&&(a=Ar(a)),i.push(`${o}:${a}`)}return`{${i.join(",")}}`}else{if(t==="list")return Array.isArray(r.value)?`[${Er(r)}]`:"[]";if(t==="byteArray"||t==="intArray"||t==="longArray"){let i=wo(t),n=Er(r);return`[${i}${n}]`}}let e=r+_o(r,t);return t==="string"&&(e=Ar(e)),e}function Ar(r){return r=r.replace(/"/g,'\\"'),(/'|{|}|\[|\]|:|;|,|\(|\)|§|=/g.test(r)||r==="")&&(r=`"${r}"`),r}function Er({value:r,type:t}){let e=yo(r),i=[];for(let n=0;n<r.length;n++){let s=r[n];s!==void 0&&(s=N5({value:s,type:t}),e?i.push(`${n}:${s}`):i.push(s))}return i.join(",")}function yo(r){for(let t=0;t<r.length;t++)if(r[t]===void 0)return!0;return!1}var wo=r=>r.charAt(0).toUpperCase()+";";function _o(r,t){return t==="double"?r>>0===r?"d":"":{int:"",byte:"b",short:"s",float:"f",long:"l",string:""}[t]}function Ao(r){return N5(Rr(r))}function Rr(r){try{let t=new _r.Parser(_r.Grammar.fromCompiled(bo));return t.feed(r),t.results[0]}catch(t){throw t.message=`Error parsing text '${r}'`,t}}kr.exports={parse:Rr,simplify:xr,stringify:N5,normalize:Ao}});var Pr={};b5(Pr,{camelCase:()=>To,capitalCase:()=>u2,constantCase:()=>Co,dotCase:()=>Po,kebabCase:()=>Bo,noCase:()=>Qe,pascalCase:()=>Mo,pascalSnakeCase:()=>So,pathCase:()=>Io,sentenceCase:()=>Ho,snakeCase:()=>f2,split:()=>d2,splitSeparateNumbers:()=>Sr,trainCase:()=>zo});function d2(r){let t=r.trim();t=t.replace(Eo,Tr).replace(xo,Tr),t=t.replace(ko,"\0");let e=0,i=t.length;for(;t.charAt(e)==="\0";)e++;if(e===i)return[];for(;t.charAt(i-1)==="\0";)i--;return t.slice(e,i).split(/\0/g)}function Sr(r){let t=d2(r);for(let e=0;e<t.length;e++){let i=t[e],n=Ro.exec(i);if(n){let s=n.index+(n[1]??n[2]).length;t.splice(e,1,i.slice(0,s),i.slice(s))}}return t}function Qe(r,t){let[e,i,n]=he(r,t);return e+i.map(Ke(t?.locale)).join(t?.delimiter??" ")+n}function To(r,t){let[e,i,n]=he(r,t),s=Ke(t?.locale),o=Je(t?.locale),a=t?.mergeAmbiguousCharacters?j5(s,o):Cr(s,o);return e+i.map((v,l)=>l===0?s(v):a(v,l)).join(t?.delimiter??"")+n}function Mo(r,t){let[e,i,n]=he(r,t),s=Ke(t?.locale),o=Je(t?.locale),a=t?.mergeAmbiguousCharacters?j5(s,o):Cr(s,o);return e+i.map(a).join(t?.delimiter??"")+n}function So(r,t){return u2(r,{delimiter:"_",...t})}function u2(r,t){let[e,i,n]=he(r,t),s=Ke(t?.locale),o=Je(t?.locale);return e+i.map(j5(s,o)).join(t?.delimiter??" ")+n}function Co(r,t){let[e,i,n]=he(r,t);return e+i.map(Je(t?.locale)).join(t?.delimiter??"_")+n}function Po(r,t){return Qe(r,{delimiter:".",...t})}function Bo(r,t){return Qe(r,{delimiter:"-",...t})}function Io(r,t){return Qe(r,{delimiter:"/",...t})}function Ho(r,t){let[e,i,n]=he(r,t),s=Ke(t?.locale),o=Je(t?.locale),a=j5(s,o);return e+i.map((v,l)=>l===0?a(v):s(v)).join(t?.delimiter??" ")+n}function f2(r,t){return Qe(r,{delimiter:"_",...t})}function zo(r,t){return u2(r,{delimiter:"-",...t})}function Ke(r){return r===!1?t=>t.toLowerCase():t=>t.toLocaleLowerCase(r)}function Je(r){return r===!1?t=>t.toUpperCase():t=>t.toLocaleUpperCase(r)}function j5(r,t){return e=>`${t(e[0])}${r(e.slice(1))}`}function Cr(r,t){return(e,i)=>{let n=e[0];return(i>0&&n>="0"&&n<="9"?"_"+n:t(n))+r(e.slice(1))}}function he(r,t={}){let e=t.split??(t.separateNumbers?Sr:d2),i=t.prefixCharacters??Mr,n=t.suffixCharacters??Mr,s=0,o=r.length;for(;s<r.length;){let a=r.charAt(s);if(!i.includes(a))break;s++}for(;o>s;){let a=o-1,v=r.charAt(a);if(!n.includes(v))break;o=a}return[r.slice(0,s),e(r.slice(s,o)),r.slice(o)]}var Eo,xo,Ro,ko,Tr,Mr,h2=ut(()=>{x();R();T();k();Eo=/([\p{Ll}\d])(\p{Lu})/gu,xo=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,Ro=/(\d)\p{Ll}|(\p{L})\d/u,ko=/[^\p{L}\d]+/giu,Tr="$1\0$2",Mr=""});var Br=Z0((Lh,Oo)=>{Oo.exports={version:"1.21.4",attackable:["acacia_boat","acacia_chest_boat","allay","armadillo","armor_stand","axolotl","bamboo_chest_raft","bamboo_raft","bat","bee","birch_boat","birch_chest_boat","blaze","bogged","breeze","camel","cat","cave_spider","cherry_boat","cherry_chest_boat","chest_minecart","chicken","cod","command_block_minecart","cow","creaking","creeper","dark_oak_boat","dark_oak_chest_boat","dolphin","donkey","drowned","elder_guardian","end_crystal","ender_dragon","enderman","endermite","evoker","falling_block","fox","frog","furnace_minecart","ghast","giant","glow_item_frame","glow_squid","goat","guardian","hoglin","hopper_minecart","horse","husk","illusioner","iron_golem","item_frame","jungle_boat","jungle_chest_boat","leash_knot","llama","magma_cube","mangrove_boat","mangrove_chest_boat","minecart","mooshroom","mule","oak_boat","oak_chest_boat","ocelot","painting","pale_oak_boat","pale_oak_chest_boat","panda","parrot","phantom","pig","piglin","piglin_brute","pillager","player","polar_bear","pufferfish","rabbit","ravager","salmon","sheep","shulker","shulker_bullet","silverfish","skeleton","skeleton_horse","slime","sniffer","snow_golem","spawner_minecart","spider","spruce_boat","spruce_chest_boat","squid","stray","strider","tadpole","tnt","tnt_minecart","trader_llama","tropical_fish","turtle","vex","villager","vindicator","wandering_trader","warden","wind_charge","witch","wither","wither_skeleton","wolf","zoglin","zombie","zombie_horse","zombie_villager","zombified_piglin"],notAttackable:["area_effect_cloud","arrow","block_display","breeze_wind_charge","dragon_fireball","egg","ender_pearl","evoker_fangs","experience_bottle","experience_orb","eye_of_ender","fireball","firework_rocket","fishing_bobber","interaction","item","item_display","lightning_bolt","llama_spit","marker","ominous_item_spawner","potion","small_fireball","snowball","spectral_arrow","text_display","trident","wither_skull"],entityRenames:{Boat:"oak_boat",EnderCrystal:"end_crystal",EntityHorse:"horse",EyeOfEnderSignal:"eye_of_ender",FallingSand:"falling_block",FireworksRocketEntity:"firework_rocket","Fishing Float":"fishing_bobber","Fishing Hook":"fishing_bobber",LavaSlime:"magma_cube",MinecartRideable:"minecart",Mob:!1,Monster:!1,MushroomCow:"mooshroom",Ozelot:"ocelot",PigZombie:"zombified_piglin",PrimedTnt:"tnt",SnowMan:"snow_golem",ThrownEgg:"egg",ThrownEnderpearl:"ender_pearl",ThrownExpBottle:"experience_bottle",ThrownPotion:"potion",VillagerGolem:"iron_golem",WitherBoss:"wither",XPOrb:"experience_orb",activated_tnt:"tnt",armorstand:"armor_stand",boat:"oak_boat",chest_boat:"oak_chest_boat",commandblock_minecart:"command_block_minecart",creaking_transient:"creaking",ender_crystal:"end_crystal",endercrystal:"end_crystal",evocation_fangs:"evoker_fangs",evocation_illager:"evoker",eye_of_ender_signal:"eye_of_ender",falling_objects:"falling_block",firecharge:"fireball",fireworks_rocket:"firework_rocket",fishing_hook:"fishing_bobber",illusion_illager:"illusioner",item_frames:"item_frame",item_stack:"item",snowman:"snow_golem",thrown_enderpearl:"ender_pearl","thrown_exp bottle":"experience_bottle",thrown_exp_bottle:"experience_bottle",thrown_potion:"potion",tipped_arrow:"arrow",villager_golem:"iron_golem",vindication_illager:"vindicator",xp_bottle:"experience_bottle",xp_orb:"experience_orb",zombie_pigman:"zombified_piglin"}}});var Hr=Z0((Fh,Ir)=>{x();R();T();k();var me=1e3,pe=me*60,ge=pe*60,Jt=ge*24,Do=Jt*7,Lo=Jt*365.25;Ir.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Fo(r);if(e==="number"&&isFinite(r))return t.long?Go(r):Uo(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Fo(r){if(r=String(r),!(r.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(t){var e=parseFloat(t[1]),i=(t[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return e*Lo;case"weeks":case"week":case"w":return e*Do;case"days":case"day":case"d":return e*Jt;case"hours":case"hour":case"hrs":case"hr":case"h":return e*ge;case"minutes":case"minute":case"mins":case"min":case"m":return e*pe;case"seconds":case"second":case"secs":case"sec":case"s":return e*me;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Uo(r){var t=Math.abs(r);return t>=Jt?Math.round(r/Jt)+"d":t>=ge?Math.round(r/ge)+"h":t>=pe?Math.round(r/pe)+"m":t>=me?Math.round(r/me)+"s":r+"ms"}function Go(r){var t=Math.abs(r);return t>=Jt?Y5(r,t,Jt,"day"):t>=ge?Y5(r,t,ge,"hour"):t>=pe?Y5(r,t,pe,"minute"):t>=me?Y5(r,t,me,"second"):r+" ms"}function Y5(r,t,e,i){var n=t>=e*1.5;return Math.round(r/e)+" "+i+(n?"s":"")}});var Or=Z0((Nh,zr)=>{x();R();T();k();function Wo(r){e.debug=e,e.default=e,e.coerce=v,e.disable=o,e.enable=n,e.enabled=a,e.humanize=Hr(),e.destroy=l,Object.keys(r).forEach(c=>{e[c]=r[c]}),e.names=[],e.skips=[],e.formatters={};function t(c){let d=0;for(let m=0;m<c.length;m++)d=(d<<5)-d+c.charCodeAt(m),d|=0;return e.colors[Math.abs(d)%e.colors.length]}e.selectColor=t;function e(c){let d,m=null,p,g;function y(...E){if(!y.enabled)return;let w=y,_=Number(new Date),C=_-(d||_);w.diff=C,w.prev=d,w.curr=_,d=_,E[0]=e.coerce(E[0]),typeof E[0]!="string"&&E.unshift("%O");let M=0;E[0]=E[0].replace(/%([a-zA-Z%])/g,(H,B)=>{if(H==="%%")return"%";M++;let I=e.formatters[B];if(typeof I=="function"){let W=E[M];H=I.call(w,W),E.splice(M,1),M--}return H}),e.formatArgs.call(w,E),(w.log||e.log).apply(w,E)}return y.namespace=c,y.useColors=e.useColors(),y.color=e.selectColor(c),y.extend=i,y.destroy=e.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(p!==e.namespaces&&(p=e.namespaces,g=e.enabled(c)),g),set:E=>{m=E}}),typeof e.init=="function"&&e.init(y),y}function i(c,d){let m=e(this.namespace+(typeof d>"u"?":":d)+c);return m.log=this.log,m}function n(c){e.save(c),e.namespaces=c,e.names=[],e.skips=[];let d=(typeof c=="string"?c:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let m of d)m[0]==="-"?e.skips.push(m.slice(1)):e.names.push(m)}function s(c,d){let m=0,p=0,g=-1,y=0;for(;m<c.length;)if(p<d.length&&(d[p]===c[m]||d[p]==="*"))d[p]==="*"?(g=p,y=m,p++):(m++,p++);else if(g!==-1)p=g+1,y++,m=y;else return!1;for(;p<d.length&&d[p]==="*";)p++;return p===d.length}function o(){let c=[...e.names,...e.skips.map(d=>"-"+d)].join(",");return e.enable(""),c}function a(c){for(let d of e.skips)if(s(c,d))return!1;for(let d of e.names)if(s(c,d))return!0;return!1}function v(c){return c instanceof Error?c.stack||c.message:c}function l(){}return e.enable(e.load()),e}zr.exports=Wo});var Dr=Z0((J0,Q5)=>{x();R();T();k();J0.formatArgs=No;J0.save=jo;J0.load=Yo;J0.useColors=Vo;J0.storage=Qo();J0.destroy=(()=>{let r=!1;return()=>{r||(r=!0)}})();J0.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Vo(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let r;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(r=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(r[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function No(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Q5.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,i=0;r[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(e++,n==="%c"&&(i=e))}),r.splice(i,0,t)}J0.log=console.debug||console.log||(()=>{});function jo(r){try{r?J0.storage.setItem("debug",r):J0.storage.removeItem("debug")}catch{}}function Yo(){let r;try{r=J0.storage.getItem("debug")||J0.storage.getItem("DEBUG")}catch{}return!r&&typeof D<"u"&&"env"in D&&(r=D.env.DEBUG),r}function Qo(){try{return localStorage}catch{}}Q5.exports=Or()(J0);var{formatters:Ko}=Q5.exports;Ko.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Lr=Z0(be=>{"use strict";x();R();T();k();var Jo=be&&be.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(be,"__esModule",{value:!0});be.debug=void 0;var qo=Jo(Dr());be.debug=(0,qo.default)("mineflayer-mouse")});var Wr=Z0(qt=>{"use strict";x();R();T();k();var Zo=qt&&qt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(qt,"__esModule",{value:!0});qt.isEntityAttackable=void 0;qt.isArmorStandAttackable=Gr;var Fr=(h2(),ws(Pr)),qe=Zo(Br()),Xo=Lr(),Ur=Object.fromEntries([...qe.default.attackable,...qe.default.notAttackable].map(r=>[r,!0])),$o=qe.default.attackable,ta=(r,t)=>{if(!t.name)throw new Error("Entity has no name");let e=r.entitiesByName[t.name],n=qe.default.entityRenames[t.name]||qe.default.entityRenames[(0,Fr.snakeCase)(t.name)]||t.name;if(!Ur[n]&&(n=(0,Fr.snakeCase)(n),!Ur[n]))return(0,Xo.debug)(`Cannot find entity ${n} in entityData.json`),!1;let s=ea[n];return s?s(t,e):$o.includes(n)};qt.isEntityAttackable=ta;var ea={armor_stand:Gr};function Gr(r,t){let e=Number(r.metadata?.[t.metadataKeys?.indexOf("client_flags")??14]??0),i=(e&16)!==0,n=(e&8)!==0,s=(e&4)!==0,o=(e&1)!==0;return!i}});var E6=Z0((g_,w8)=>{w8.exports={version:"1.20.4","1.8":{blocks:[["wood_planks","planks"],["large_flowers","double_plant"]]},"1.12":{items:[["totem","totem_of_undying"]]},"1.13":{blocks:[["grass","grass_block"],["planks","oak_planks"],["planks","spruce_planks"],["planks","birch_planks"],["planks","jungle_planks"],["planks","acacia_planks"],["planks","dark_oak_planks"],["sapling","oak_sapling"],["sapling","spruce_sapling"],["sapling","birch_sapling"],["sapling","jungle_sapling"],["sapling","acacia_sapling"],["sapling","dark_oak_sapling"],["sand","red_sand"],["log","oak_log"],["log","spruce_log"],["log","birch_log"],["log","jungle_log"],["log","oak_wood"],["log","spruce_wood"],["log","birch_wood"],["log","jungle_wood"],["leaves","oak_leaves"],["leaves","spruce_leaves"],["leaves","birch_leaves"],["leaves","jungle_leaves"],["sponge","wet_sponge"],["sandstone","chiseled_sandstone"],["sandstone","cut_sandstone"],["noteblock","note_block"],["bed","red_bed"],["golden_rail","powered_rail"],["web","cobweb"],["tallgrass","dead_bush"],["tallgrass","grass"],["tallgrass","fern"],["deadbush","dead_bush"],["wool","white_wool"],["wool","orange_wool"],["wool","magenta_wool"],["wool","light_blue_wool"],["wool","yellow_wool"],["wool","lime_wool"],["wool","pink_wool"],["wool","gray_wool"],["wool","light_gray_wool"],["wool","cyan_wool"],["wool","purple_wool"],["wool","blue_wool"],["wool","brown_wool"],["wool","green_wool"],["wool","red_wool"],["wool","black_wool"],["piston_extension","moving_piston"],["yellow_flower","dandelion"],["red_flower","poppy"],["red_flower","blue_orchid"],["red_flower","allium"],["red_flower","azure_bluet"],["red_flower","red_tulip"],["red_flower","orange_tulip"],["red_flower","white_tulip"],["red_flower","pink_tulip"],["red_flower","oxeye_daisy"],["double_stone_slab","stone_slab"],["double_stone_slab","sandstone_slab"],["double_stone_slab","petrified_oak_slab"],["double_stone_slab","cobblestone_slab"],["double_stone_slab","brick_slab"],["double_stone_slab","stone_brick_slab"],["double_stone_slab","nether_brick_slab"],["double_stone_slab","quartz_slab"],["double_stone_slab","smooth_stone"],["double_stone_slab","smooth_sandstone"],["double_stone_slab","smooth_quartz"],["stone_slab","sandstone_slab"],["stone_slab","petrified_oak_slab"],["stone_slab","cobblestone_slab"],["stone_slab","brick_slab"],["stone_slab","stone_brick_slab"],["stone_slab","nether_brick_slab"],["stone_slab","quartz_slab"],["brick_block","bricks"],["mob_spawner","spawner"],["lit_furnace","furnace"],["standing_sign","sign"],["wooden_door","oak_door"],["stone_stairs","cobblestone_stairs"],["wooden_pressure_plate","oak_pressure_plate"],["lit_redstone_ore","redstone_ore"],["unlit_redstone_torch","redstone_wall_torch"],["unlit_redstone_torch","redstone_torch"],["redstone_torch","redstone_wall_torch"],["snow_layer","snow"],["snow","snow_block"],["reeds","sugar_cane"],["fence","oak_fence"],["pumpkin","carved_pumpkin"],["portal","nether_portal"],["lit_pumpkin","jack_o_lantern"],["unpowered_repeater","repeater"],["powered_repeater","repeater"],["stained_glass","white_stained_glass"],["stained_glass","orange_stained_glass"],["stained_glass","magenta_stained_glass"],["stained_glass","light_blue_stained_glass"],["stained_glass","yellow_stained_glass"],["stained_glass","lime_stained_glass"],["stained_glass","pink_stained_glass"],["stained_glass","gray_stained_glass"],["stained_glass","light_gray_stained_glass"],["stained_glass","cyan_stained_glass"],["stained_glass","purple_stained_glass"],["stained_glass","blue_stained_glass"],["stained_glass","brown_stained_glass"],["stained_glass","green_stained_glass"],["stained_glass","red_stained_glass"],["stained_glass","black_stained_glass"],["trapdoor","oak_trapdoor"],["monster_egg","infested_stone"],["monster_egg","infested_cobblestone"],["monster_egg","infested_stone_bricks"],["monster_egg","infested_mossy_stone_bricks"],["monster_egg","infested_cracked_stone_bricks"],["monster_egg","infested_chiseled_stone_bricks"],["stonebrick","stone_bricks"],["stonebrick","mossy_stone_bricks"],["stonebrick","cracked_stone_bricks"],["stonebrick","chiseled_stone_bricks"],["brown_mushroom_block","mushroom_stem"],["red_mushroom_block","mushroom_stem"],["melon_block","melon"],["fence_gate","oak_fence_gate"],["waterlily","lily_pad"],["nether_brick","nether_bricks"],["lit_redstone_lamp","redstone_lamp"],["double_wooden_slab","oak_slab"],["double_wooden_slab","spruce_slab"],["double_wooden_slab","birch_slab"],["double_wooden_slab","jungle_slab"],["double_wooden_slab","acacia_slab"],["double_wooden_slab","dark_oak_slab"],["wooden_slab","oak_slab"],["wooden_slab","spruce_slab"],["wooden_slab","birch_slab"],["wooden_slab","jungle_slab"],["wooden_slab","acacia_slab"],["wooden_slab","dark_oak_slab"],["cobblestone_wall","mossy_cobblestone_wall"],["flower_pot","potted_poppy"],["flower_pot","potted_dandelion"],["flower_pot","potted_oak_sapling"],["flower_pot","potted_spruce_sapling"],["flower_pot","potted_birch_sapling"],["flower_pot","potted_jungle_sapling"],["flower_pot","potted_red_mushroom"],["flower_pot","potted_brown_mushroom"],["flower_pot","potted_cactus"],["flower_pot","potted_dead_bush"],["flower_pot","potted_fern"],["flower_pot","potted_acacia_sapling"],["flower_pot","potted_dark_oak_sapling"],["flower_pot","potted_blue_orchid"],["flower_pot","potted_allium"],["wooden_button","oak_button"],["skull","skeleton_skull"],["skull","skeleton_wall_skull"],["anvil","chipped_anvil"],["anvil","damaged_anvil"],["unpowered_comparator","comparator"],["powered_comparator","comparator"],["quartz_ore","nether_quartz_ore"],["quartz_block","chiseled_quartz_block"],["quartz_block","quartz_pillar"],["stained_hardened_clay","white_terracotta"],["stained_hardened_clay","orange_terracotta"],["stained_hardened_clay","magenta_terracotta"],["stained_hardened_clay","light_blue_terracotta"],["stained_hardened_clay","yellow_terracotta"],["stained_hardened_clay","lime_terracotta"],["stained_hardened_clay","pink_terracotta"],["stained_hardened_clay","gray_terracotta"],["stained_hardened_clay","light_gray_terracotta"],["stained_hardened_clay","cyan_terracotta"],["stained_hardened_clay","purple_terracotta"],["stained_hardened_clay","blue_terracotta"],["stained_hardened_clay","brown_terracotta"],["stained_hardened_clay","green_terracotta"],["stained_hardened_clay","red_terracotta"],["stained_hardened_clay","black_terracotta"],["stained_glass_pane","white_stained_glass_pane"],["stained_glass_pane","orange_stained_glass_pane"],["stained_glass_pane","magenta_stained_glass_pane"],["stained_glass_pane","light_blue_stained_glass_pane"],["stained_glass_pane","yellow_stained_glass_pane"],["stained_glass_pane","lime_stained_glass_pane"],["stained_glass_pane","pink_stained_glass_pane"],["stained_glass_pane","gray_stained_glass_pane"],["stained_glass_pane","light_gray_stained_glass_pane"],["stained_glass_pane","cyan_stained_glass_pane"],["stained_glass_pane","purple_stained_glass_pane"],["stained_glass_pane","blue_stained_glass_pane"],["stained_glass_pane","brown_stained_glass_pane"],["stained_glass_pane","green_stained_glass_pane"],["stained_glass_pane","red_stained_glass_pane"],["stained_glass_pane","black_stained_glass_pane"],["leaves2","acacia_leaves"],["leaves2","dark_oak_leaves"],["log2","acacia_log"],["log2","dark_oak_log"],["log2","acacia_wood"],["log2","dark_oak_wood"],["slime","slime_block"],["prismarine","prismarine_bricks"],["prismarine","dark_prismarine"],["carpet","white_carpet"],["carpet","orange_carpet"],["carpet","magenta_carpet"],["carpet","light_blue_carpet"],["carpet","yellow_carpet"],["carpet","lime_carpet"],["carpet","pink_carpet"],["carpet","gray_carpet"],["carpet","light_gray_carpet"],["carpet","cyan_carpet"],["carpet","purple_carpet"],["carpet","blue_carpet"],["carpet","brown_carpet"],["carpet","green_carpet"],["carpet","red_carpet"],["carpet","black_carpet"],["hardened_clay","terracotta"],["double_plant","sunflower"],["double_plant","lilac"],["double_plant","tall_grass"],["double_plant","large_fern"],["double_plant","rose_bush"],["double_plant","peony"],["standing_banner","white_banner"],["wall_banner","white_wall_banner"],["daylight_detector_inverted","daylight_detector"],["red_sandstone","chiseled_red_sandstone"],["red_sandstone","cut_red_sandstone"],["double_stone_slab2","red_sandstone_slab"],["double_stone_slab2","smooth_red_sandstone"],["stone_slab2","red_sandstone_slab"],["purpur_double_slab","purpur_slab"],["end_bricks","end_stone_bricks"],["magma","magma_block"],["red_nether_brick","red_nether_bricks"],["concrete","white_concrete"],["concrete","orange_concrete"],["concrete","magenta_concrete"],["concrete","light_blue_concrete"],["concrete","yellow_concrete"],["concrete","lime_concrete"],["concrete","pink_concrete"],["concrete","gray_concrete"],["concrete","light_gray_concrete"],["concrete","cyan_concrete"],["concrete","purple_concrete"],["concrete","blue_concrete"],["concrete","brown_concrete"],["concrete","green_concrete"],["concrete","red_concrete"],["concrete","black_concrete"],["concrete_powder","white_concrete_powder"],["concrete_powder","orange_concrete_powder"],["concrete_powder","magenta_concrete_powder"],["concrete_powder","light_blue_concrete_powder"],["concrete_powder","yellow_concrete_powder"],["concrete_powder","lime_concrete_powder"],["concrete_powder","pink_concrete_powder"],["concrete_powder","gray_concrete_powder"],["concrete_powder","light_gray_concrete_powder"],["concrete_powder","cyan_concrete_powder"],["concrete_powder","purple_concrete_powder"],["concrete_powder","blue_concrete_powder"],["concrete_powder","brown_concrete_powder"],["concrete_powder","green_concrete_powder"],["concrete_powder","red_concrete_powder"],["concrete_powder","black_concrete_powder"]],items:[["stone","granite"],["stone","polished_granite"],["stone","diorite"],["stone","polished_diorite"],["stone","andesite"],["stone","polished_andesite"],["grass","grass_block"],["dirt","coarse_dirt"],["dirt","podzol"],["planks","oak_planks"],["planks","spruce_planks"],["planks","birch_planks"],["planks","jungle_planks"],["planks","acacia_planks"],["planks","dark_oak_planks"],["sapling","oak_sapling"],["sapling","spruce_sapling"],["sapling","birch_sapling"],["sapling","jungle_sapling"],["sapling","acacia_sapling"],["sapling","dark_oak_sapling"],["sand","red_sand"],["log","oak_log"],["log","spruce_log"],["log","birch_log"],["log","jungle_log"],["leaves","oak_leaves"],["leaves","spruce_leaves"],["leaves","birch_leaves"],["leaves","jungle_leaves"],["sponge","wet_sponge"],["sandstone","chiseled_sandstone"],["sandstone","cut_sandstone"],["noteblock","note_block"],["golden_rail","powered_rail"],["web","cobweb"],["tallgrass","grass"],["tallgrass","fern"],["deadbush","dead_bush"],["wool","white_wool"],["wool","orange_wool"],["wool","magenta_wool"],["wool","light_blue_wool"],["wool","yellow_wool"],["wool","lime_wool"],["wool","pink_wool"],["wool","gray_wool"],["wool","light_gray_wool"],["wool","cyan_wool"],["wool","purple_wool"],["wool","blue_wool"],["wool","brown_wool"],["wool","green_wool"],["wool","red_wool"],["wool","black_wool"],["yellow_flower","dandelion"],["red_flower","poppy"],["red_flower","blue_orchid"],["red_flower","allium"],["red_flower","azure_bluet"],["red_flower","red_tulip"],["red_flower","orange_tulip"],["red_flower","white_tulip"],["red_flower","pink_tulip"],["red_flower","oxeye_daisy"],["stone_slab","sandstone_slab"],["stone_slab","cobblestone_slab"],["stone_slab","brick_slab"],["stone_slab","stone_brick_slab"],["stone_slab","nether_brick_slab"],["stone_slab","quartz_slab"],["brick_block","bricks"],["mob_spawner","spawner"],["stone_stairs","cobblestone_stairs"],["wooden_pressure_plate","oak_pressure_plate"],["snow_layer","snow"],["snow","snow_block"],["fence","oak_fence"],["pumpkin","carved_pumpkin"],["lit_pumpkin","jack_o_lantern"],["stained_glass","white_stained_glass"],["stained_glass","orange_stained_glass"],["stained_glass","magenta_stained_glass"],["stained_glass","light_blue_stained_glass"],["stained_glass","yellow_stained_glass"],["stained_glass","lime_stained_glass"],["stained_glass","pink_stained_glass"],["stained_glass","gray_stained_glass"],["stained_glass","light_gray_stained_glass"],["stained_glass","cyan_stained_glass"],["stained_glass","purple_stained_glass"],["stained_glass","blue_stained_glass"],["stained_glass","brown_stained_glass"],["stained_glass","green_stained_glass"],["stained_glass","red_stained_glass"],["stained_glass","black_stained_glass"],["trapdoor","oak_trapdoor"],["monster_egg","infested_stone"],["monster_egg","infested_cobblestone"],["monster_egg","infested_stone_bricks"],["monster_egg","infested_mossy_stone_bricks"],["monster_egg","infested_cracked_stone_bricks"],["monster_egg","infested_chiseled_stone_bricks"],["stonebrick","stone_bricks"],["stonebrick","mossy_stone_bricks"],["stonebrick","cracked_stone_bricks"],["stonebrick","chiseled_stone_bricks"],["melon_block","melon"],["fence_gate","oak_fence_gate"],["waterlily","lily_pad"],["nether_brick","nether_bricks"],["wooden_slab","oak_slab"],["wooden_slab","spruce_slab"],["wooden_slab","birch_slab"],["wooden_slab","jungle_slab"],["wooden_slab","acacia_slab"],["wooden_slab","dark_oak_slab"],["cobblestone_wall","mossy_cobblestone_wall"],["wooden_button","oak_button"],["anvil","chipped_anvil"],["anvil","damaged_anvil"],["quartz_ore","nether_quartz_ore"],["quartz_block","chiseled_quartz_block"],["quartz_block","quartz_pillar"],["stained_hardened_clay","white_terracotta"],["stained_hardened_clay","orange_terracotta"],["stained_hardened_clay","magenta_terracotta"],["stained_hardened_clay","light_blue_terracotta"],["stained_hardened_clay","yellow_terracotta"],["stained_hardened_clay","lime_terracotta"],["stained_hardened_clay","pink_terracotta"],["stained_hardened_clay","gray_terracotta"],["stained_hardened_clay","light_gray_terracotta"],["stained_hardened_clay","cyan_terracotta"],["stained_hardened_clay","purple_terracotta"],["stained_hardened_clay","blue_terracotta"],["stained_hardened_clay","brown_terracotta"],["stained_hardened_clay","green_terracotta"],["stained_hardened_clay","red_terracotta"],["stained_hardened_clay","black_terracotta"],["stained_glass_pane","white_stained_glass_pane"],["stained_glass_pane","orange_stained_glass_pane"],["stained_glass_pane","magenta_stained_glass_pane"],["stained_glass_pane","light_blue_stained_glass_pane"],["stained_glass_pane","yellow_stained_glass_pane"],["stained_glass_pane","lime_stained_glass_pane"],["stained_glass_pane","pink_stained_glass_pane"],["stained_glass_pane","gray_stained_glass_pane"],["stained_glass_pane","light_gray_stained_glass_pane"],["stained_glass_pane","cyan_stained_glass_pane"],["stained_glass_pane","purple_stained_glass_pane"],["stained_glass_pane","blue_stained_glass_pane"],["stained_glass_pane","brown_stained_glass_pane"],["stained_glass_pane","green_stained_glass_pane"],["stained_glass_pane","red_stained_glass_pane"],["stained_glass_pane","black_stained_glass_pane"],["leaves2","acacia_leaves"],["leaves2","dark_oak_leaves"],["log2","acacia_log"],["log2","dark_oak_log"],["slime","slime_block"],["prismarine","prismarine_bricks"],["prismarine","dark_prismarine"],["carpet","white_carpet"],["carpet","orange_carpet"],["carpet","magenta_carpet"],["carpet","light_blue_carpet"],["carpet","yellow_carpet"],["carpet","lime_carpet"],["carpet","pink_carpet"],["carpet","gray_carpet"],["carpet","light_gray_carpet"],["carpet","cyan_carpet"],["carpet","purple_carpet"],["carpet","blue_carpet"],["carpet","brown_carpet"],["carpet","green_carpet"],["carpet","red_carpet"],["carpet","black_carpet"],["hardened_clay","terracotta"],["double_plant","sunflower"],["double_plant","lilac"],["double_plant","tall_grass"],["double_plant","large_fern"],["double_plant","rose_bush"],["double_plant","peony"],["red_sandstone","chiseled_red_sandstone"],["red_sandstone","cut_red_sandstone"],["stone_slab2","red_sandstone_slab"],["end_bricks","end_stone_bricks"],["magma","magma_block"],["red_nether_brick","red_nether_bricks"],["silver_shulker_box","light_gray_shulker_box"],["silver_glazed_terracotta","light_gray_glazed_terracotta"],["concrete","white_concrete"],["concrete","orange_concrete"],["concrete","magenta_concrete"],["concrete","light_blue_concrete"],["concrete","yellow_concrete"],["concrete","lime_concrete"],["concrete","pink_concrete"],["concrete","gray_concrete"],["concrete","light_gray_concrete"],["concrete","cyan_concrete"],["concrete","purple_concrete"],["concrete","blue_concrete"],["concrete","brown_concrete"],["concrete","green_concrete"],["concrete","red_concrete"],["concrete","black_concrete"],["concrete_powder","white_concrete_powder"],["concrete_powder","orange_concrete_powder"],["concrete_powder","magenta_concrete_powder"],["concrete_powder","light_blue_concrete_powder"],["concrete_powder","yellow_concrete_powder"],["concrete_powder","lime_concrete_powder"],["concrete_powder","pink_concrete_powder"],["concrete_powder","gray_concrete_powder"],["concrete_powder","light_gray_concrete_powder"],["concrete_powder","cyan_concrete_powder"],["concrete_powder","purple_concrete_powder"],["concrete_powder","blue_concrete_powder"],["concrete_powder","brown_concrete_powder"],["concrete_powder","green_concrete_powder"],["concrete_powder","red_concrete_powder"],["concrete_powder","black_concrete_powder"],["coal","charcoal"],["golden_apple","enchanted_golden_apple"],["wooden_door","oak_door"],["boat","oak_boat"],["reeds","sugar_cane"],["fish","cod"],["fish","salmon"],["fish","tropical_fish"],["fish","pufferfish"],["cooked_fish","cooked_cod"],["cooked_fish","cooked_salmon"],["dye","ink_sac"],["dye","rose_red"],["dye","cactus_green"],["dye","cocoa_beans"],["dye","lapis_lazuli"],["dye","purple_dye"],["dye","cyan_dye"],["dye","light_gray_dye"],["dye","gray_dye"],["dye","pink_dye"],["dye","lime_dye"],["dye","dandelion_yellow"],["dye","light_blue_dye"],["dye","magenta_dye"],["dye","orange_dye"],["dye","bone_meal"],["bed","white_bed"],["bed","orange_bed"],["bed","magenta_bed"],["bed","light_blue_bed"],["bed","yellow_bed"],["bed","lime_bed"],["bed","pink_bed"],["bed","gray_bed"],["bed","light_gray_bed"],["bed","cyan_bed"],["bed","purple_bed"],["bed","blue_bed"],["bed","brown_bed"],["bed","green_bed"],["bed","red_bed"],["bed","black_bed"],["melon","melon_slice"],["speckled_melon","glistering_melon_slice"],["spawn_egg","pig_spawn_egg"],["skull","skeleton_skull"],["skull","wither_skeleton_skull"],["skull","zombie_head"],["skull","player_head"],["skull","creeper_head"],["skull","dragon_head"],["fireworks","firework_rocket"],["firework_charge","firework_star"],["netherbrick","nether_brick"],["banner","black_banner"],["banner","red_banner"],["banner","green_banner"],["banner","brown_banner"],["banner","blue_banner"],["banner","purple_banner"],["banner","cyan_banner"],["banner","light_gray_banner"],["banner","gray_banner"],["banner","pink_banner"],["banner","lime_banner"],["banner","yellow_banner"],["banner","light_blue_banner"],["banner","magenta_banner"],["banner","orange_banner"],["banner","white_banner"],["chorus_fruit_popped","popped_chorus_fruit"],["record_13","music_disc_13"],["record_cat","music_disc_cat"],["record_blocks","music_disc_blocks"],["record_chirp","music_disc_chirp"],["record_far","music_disc_far"],["record_mall","music_disc_mall"],["record_mellohi","music_disc_mellohi"],["record_stal","music_disc_stal"],["record_strad","music_disc_strad"],["record_ward","music_disc_ward"],["record_11","music_disc_11"],["record_wait","music_disc_wait"]]},"1.14":{blocks:[["sign","oak_sign"],["wall_sign","oak_wall_sign"]],items:[["sign","oak_sign"],["rose_red","red_dye"],["cactus_green","green_dye"],["dandelion_yellow","yellow_dye"]]},"1.15.2":{blocks:[],items:[]},"1.16.1":{blocks:[],items:[["zombie_pigman_spawn_egg","zombified_piglin_spawn_egg"]]},"1.16.2":{blocks:[],items:[]},"1.17":{blocks:[["grass_path","dirt_path"]],items:[["grass_path","dirt_path"]]},"1.18":{blocks:[],items:[]},"1.19":{blocks:[],items:[]},"1.19.3":{blocks:[],items:[]},"1.19.4":{blocks:[],items:[]},"1.20":{blocks:[],items:[["pottery_shard_archer","archer_pottery_sherd"],["pottery_shard_prize","prize_pottery_sherd"],["pottery_shard_arms_up","arms_up_pottery_sherd"],["pottery_shard_skull","skull_pottery_sherd"]]},"1.16":{items:[["zombie_pigman_spawn_egg","zombified_piglin_spawn_egg"]]},"1.20.3":{blocks:[["grass","short_grass"]],items:[["grass","short_grass"]]}}});var x6=Z0(o1=>{"use strict";x();R();T();k();Object.defineProperty(o1,"__esModule",{value:!0});o1.versionToNumber=void 0;var _8=r=>{let[t,e="0",i="0"]=r.split(".");return+`${t.padStart(2,"0")}${parseInt(e).toString().padStart(2,"0")}${parseInt(i).toString().padStart(2,"0")}`};o1.versionToNumber=_8});var k6=Z0(xe=>{"use strict";x();R();T();k();var A8=xe&&xe.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(xe,"__esModule",{value:!0});xe.getRenamedData=void 0;var R6=A8(E6()),Ct=x6(),E8=(r,t,e,i)=>{let n=(0,Ct.versionToNumber)(e),s=(0,Ct.versionToNumber)(i),o=n<s?1:-1,a=o>0?1:0,v=t,l=Object.keys(R6.default).sort((m,p)=>o*((0,Ct.versionToNumber)(m)-(0,Ct.versionToNumber)(p))),c=o>0?s:n,d=o>0?n:s;for(let m of l.filter(p=>(0,Ct.versionToNumber)(p)<=c&&(0,Ct.versionToNumber)(p)>=d)){if(o>0&&(0,Ct.versionToNumber)(m)>=c||o<0&&(0,Ct.versionToNumber)(m)<=d)break;let p=R6.default[m][r];if(p)for(let g of p){let y=g[a],E=g[1-a];if(Array.isArray(v))v.includes(E)&&(v=v.map(w=>w===E?y:w));else if(v===E){v=y;break}}}return v};xe.getRenamedData=E8});var D6={};b5(D6,{applyWorldGeometryExport:()=>I8,createMeshesFromExport:()=>z6,downloadWorldGeometry:()=>V2,exportWorldGeometry:()=>H6,loadTextureFromDataUrl:()=>O6,loadWorldGeometryFromUrl:()=>P8});import*as R0 from"three";function H6(r,t,e,i=!1){let n=[];for(let[o,a]of Object.entries(r.sectionObjects)){let v=a.children.find(E=>E.name==="mesh");if(!v?.geometry)continue;let{geometry:l}=v,c=l.getAttribute("position"),d=l.getAttribute("normal"),m=l.getAttribute("color"),p=l.getAttribute("uv"),g=l.index;if(!c||!g)continue;let y=r.sceneOrigin.getWorldPosition(v);n.push({key:o,position:{x:y?.x??r.sceneOrigin.toWorldX(v.position.x),y:y?.y??r.sceneOrigin.toWorldY(v.position.y),z:y?.z??r.sceneOrigin.toWorldZ(v.position.z)},geometry:{positions:[...c.array],normals:d?[...d.array]:[],colors:m?[...m.array]:[],uvs:p?[...p.array]:[],indices:[...g.array]}})}let s={version:r.version??"unknown",exportedAt:new Date().toISOString(),camera:{position:t,rotation:e},sections:n};if(i&&r.material.map){let o=document.createElement("canvas"),a=r.material.map,{image:v}=a;v&&(o.width=v.width,o.height=v.height,o.getContext("2d").drawImage(v,0,0),s.textureAtlasDataUrl=o.toDataURL("image/png"))}return s}function V2(r,t,e,i="world-geometry.json",n=!1){let s=H6(r,t,e,n),o=JSON.stringify(s),a=new Blob([o],{type:"application/json"}),v=URL.createObjectURL(a),l=document.createElement("a");l.href=v,l.download=i,l.click(),URL.revokeObjectURL(v)}async function P8(r){let t=await fetch(r);if(!t.ok)throw new Error(`Failed to fetch world geometry: ${t.statusText}`);return t.json()}function z6(r,t){let e=[];for(let i of r.sections){let n=new R0.BufferGeometry;n.setAttribute("position",new R0.Float32BufferAttribute(i.geometry.positions,3)),i.geometry.normals.length&&n.setAttribute("normal",new R0.Float32BufferAttribute(i.geometry.normals,3)),i.geometry.colors.length&&n.setAttribute("color",new R0.Float32BufferAttribute(i.geometry.colors,3)),i.geometry.uvs.length&&n.setAttribute("uv",new R0.Float32BufferAttribute(i.geometry.uvs,2));let o=Math.max(...i.geometry.indices)>65535?Uint32Array:Uint16Array;n.setIndex(new R0.BufferAttribute(new o(i.geometry.indices),1));let a=new R0.Mesh(n,t);a.position.set(i.position.x,i.position.y,i.position.z),a.name="mesh";let v=new R0.Group;v.name="chunk",v.add(a),e.push(v)}return e}async function O6(r){return new Promise((t,e)=>{let i=new Image;i.onload=()=>{let n=new R0.Texture(i);n.magFilter=R0.NearestFilter,n.minFilter=R0.NearestFilter,n.needsUpdate=!0,n.flipY=!1,t(n)},i.onerror=e,i.src=r})}async function I8(r,t){let{scene:e,renderUpdateEmitter:i,material:n}=r,s=e.getObjectByName(I6);s&&(e.remove(s),B8(s));let o=!!t.textureAtlasDataUrl,a;if(o&&t.textureAtlasDataUrl){let c=await O6(t.textureAtlasDataUrl);a=new R0.MeshLambertMaterial({map:c,vertexColors:!0,transparent:!0,alphaTest:.1}),a.name="geometry-export-material"}else a=n;let v=z6(t,a),l=new R0.Group;l.name=I6,o&&(l.userData.geometryExportMaterial=a);for(let c of v)l.add(c);return e.add(l),i.emit("update"),v.length}var I6,B8,N2=ut(()=>{"use strict";x();R();T();k();I6="geometry-export-root";B8=r=>{r.traverse(e=>{e.isMesh&&e.geometry?.dispose()});let t=r.userData?.geometryExportMaterial;t&&(t.map?.dispose?.(),t.dispose?.())}});x();R();T();k();x();R();T();k();x();R();T();k();x();R();T();k();import{proxy as zn}from"valtio";var Oe={paused:!1,showChunkBorders:!1,enableDebugOverlay:!0,debugModelVariant:void 0,futuristicReveal:!1,wasmMesher:!1,mesherWorkers:1,addChunksBatchWaitTime:200,_experimentalSmoothChunkLoading:!0,_renderByChunks:!1,autoLowerRenderDistance:!1,shadingTheme:"high-contrast",cardinalLight:"default",dayCycle:!0,smoothLighting:!0,enableLighting:!0,starfield:!0,defaultSkybox:!0,renderEntities:!0,extraBlockRenderers:!0,foreground:!0,fov:75,volume:1,showHand:!1,viewBobbing:!1,handRenderer:"vanilla",renderEars:!0,highlightBlockColor:"blue",fetchPlayerSkins:!0,skinTexturesProxy:void 0,vrSupport:!0,vrPageGameRendering:!0,clipWorldBelowY:void 0,isPlayground:!1,instantCameraUpdate:!1,isRaining:!1,moduleStates:{}},On={fpsLimit:void 0,powerPreference:void 0,sceneBackground:"lightblue",timeoutRendering:!1},Kv=(r={})=>zn({...Oe,...r}),Gt=()=>({reactive:zn({world:{chunksLoaded:new Set,heightmaps:new Map,allChunksLoaded:!1,mesherWork:!1,intersectMedia:null},renderer:"...",preventEscapeMenu:!1}),nonReactive:{fps:0,worstRenderTime:0,avgRenderTime:0,world:{chunksLoaded:new Set,chunksTotalNumber:0},renderer:{timeline:{live:[],frozen:[],lastSecond:[]}}}});x();R();T();k();import{proxy as xs}from"valtio";var P1=()=>xs({playerSkin:void 0,inWater:!1,waterBreathing:!1,backgroundColor:[0,0,0],ambientLight:0,directionalLight:0,eyeHeight:0,gameMode:void 0,lookingAtBlock:void 0,diggingBlock:void 0,movementState:"NOT_MOVING",onGround:!0,sneaking:!1,flying:!1,sprinting:!1,walkDist:0,prevWalkDist:0,bob:0,prevBob:0,itemUsageTicks:0,username:"",onlineMode:!1,cardinalLight:"default",lightingDisabled:!1,shouldHideHand:!1,heldItemMain:void 0,heldItemOff:void 0,perspective:"first_person",onFire:!1,cameraSpectatingEntity:void 0,team:void 0}),Dn=r=>({isSpectator(){return r.gameMode==="spectator"},isSpectatingEntity(){return r.cameraSpectatingEntity!==void 0&&r.gameMode==="spectator"},isThirdPerson(){return this.isSpectatingEntity()?!1:r.perspective==="third_person_back"||r.perspective==="third_person_front"}}),Ln=()=>({reactive:P1()});x();R();T();k();import{Vec3 as Fs}from"vec3";import{proxy as Wn}from"valtio";x();R();T();k();x();R();T();k();x();R();T();k();x();R();T();k();var E5={},Fn=!1;function Rs(){if(Fn)return E5;Fn=!0;var r=typeof Reflect=="object"?Reflect:null,t=r&&typeof r.apply=="function"?r.apply:function(S,H,B){return Function.prototype.apply.call(S,H,B)},e;r&&typeof r.ownKeys=="function"?e=r.ownKeys:Object.getOwnPropertySymbols?e=function(S){return Object.getOwnPropertyNames(S).concat(Object.getOwnPropertySymbols(S))}:e=function(S){return Object.getOwnPropertyNames(S)};function i(M){}var n=Number.isNaN||function(S){return S!==S};function s(){s.init.call(this)}E5=s,E5.once=w,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(M){if(typeof M!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof M)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(M){if(typeof M!="number"||M<0||n(M))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+M+".");o=M}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(S){if(typeof S!="number"||S<0||n(S))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+S+".");return this._maxListeners=S,this};function v(M){return M._maxListeners===void 0?s.defaultMaxListeners:M._maxListeners}s.prototype.getMaxListeners=function(){return v(this)},s.prototype.emit=function(S){for(var H=[],B=1;B<arguments.length;B++)H.push(arguments[B]);var I=S==="error",W=this._events;if(W!==void 0)I=I&&W.error===void 0;else if(!I)return!1;if(I){var z;if(H.length>0&&(z=H[0]),z instanceof Error)throw z;var j=new Error("Unhandled error."+(z?" ("+z.message+")":""));throw j.context=z,j}var q=W[S];if(q===void 0)return!1;if(typeof q=="function")t(q,this,H);else for(var e0=q.length,N=g(q,e0),B=0;B<e0;++B)t(N[B],this,H);return!0};function l(M,S,H,B){var I,W,z;if(a(H),W=M._events,W===void 0?(W=M._events=Object.create(null),M._eventsCount=0):(W.newListener!==void 0&&(M.emit("newListener",S,H.listener?H.listener:H),W=M._events),z=W[S]),z===void 0)z=W[S]=H,++M._eventsCount;else if(typeof z=="function"?z=W[S]=B?[H,z]:[z,H]:B?z.unshift(H):z.push(H),I=v(M),I>0&&z.length>I&&!z.warned){z.warned=!0;var j=new Error("Possible EventEmitter memory leak detected. "+z.length+" "+String(S)+" listeners added. Use emitter.setMaxListeners() to increase limit");j.name="MaxListenersExceededWarning",j.emitter=M,j.type=S,j.count=z.length}return M}s.prototype.addListener=function(S,H){return l(this,S,H,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(S,H){return l(this,S,H,!0)};function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(M,S,H){var B={fired:!1,wrapFn:void 0,target:M,type:S,listener:H},I=c.bind(B);return I.listener=H,B.wrapFn=I,I}s.prototype.once=function(S,H){return a(H),this.on(S,d(this,S,H)),this},s.prototype.prependOnceListener=function(S,H){return a(H),this.prependListener(S,d(this,S,H)),this},s.prototype.removeListener=function(S,H){var B,I,W,z,j;if(a(H),I=this._events,I===void 0)return this;if(B=I[S],B===void 0)return this;if(B===H||B.listener===H)--this._eventsCount===0?this._events=Object.create(null):(delete I[S],I.removeListener&&this.emit("removeListener",S,B.listener||H));else if(typeof B!="function"){for(W=-1,z=B.length-1;z>=0;z--)if(B[z]===H||B[z].listener===H){j=B[z].listener,W=z;break}if(W<0)return this;W===0?B.shift():y(B,W),B.length===1&&(I[S]=B[0]),I.removeListener!==void 0&&this.emit("removeListener",S,j||H)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(S){var H,B,I;if(B=this._events,B===void 0)return this;if(B.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):B[S]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete B[S]),this;if(arguments.length===0){var W=Object.keys(B),z;for(I=0;I<W.length;++I)z=W[I],z!=="removeListener"&&this.removeAllListeners(z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(H=B[S],typeof H=="function")this.removeListener(S,H);else if(H!==void 0)for(I=H.length-1;I>=0;I--)this.removeListener(S,H[I]);return this};function m(M,S,H){var B=M._events;if(B===void 0)return[];var I=B[S];return I===void 0?[]:typeof I=="function"?H?[I.listener||I]:[I]:H?E(I):g(I,I.length)}s.prototype.listeners=function(S){return m(this,S,!0)},s.prototype.rawListeners=function(S){return m(this,S,!1)},s.listenerCount=function(M,S){return typeof M.listenerCount=="function"?M.listenerCount(S):p.call(M,S)},s.prototype.listenerCount=p;function p(M){var S=this._events;if(S!==void 0){var H=S[M];if(typeof H=="function")return 1;if(H!==void 0)return H.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]};function g(M,S){for(var H=new Array(S),B=0;B<S;++B)H[B]=M[B];return H}function y(M,S){for(;S+1<M.length;S++)M[S]=M[S+1];M.pop()}function E(M){for(var S=new Array(M.length),H=0;H<S.length;++H)S[H]=M[H].listener||M[H];return S}function w(M,S){return new Promise(function(H,B){function I(z){M.removeListener(S,W),B(z)}function W(){typeof M.removeListener=="function"&&M.removeListener("error",I),H([].slice.call(arguments))}C(M,S,W,{once:!0}),S!=="error"&&_(M,I,{once:!0})})}function _(M,S,H){typeof M.on=="function"&&C(M,"error",S,H)}function C(M,S,H,B){if(typeof M.on=="function")B.once?M.once(S,H):M.on(S,H);else if(typeof M.addEventListener=="function")M.addEventListener(S,function I(W){B.once&&M.removeEventListener(S,I),H(W)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof M)}return E5}var x5=Rs();x5.once;x5.once=function(r,t){return new Promise((e,i)=>{function n(...o){s!==void 0&&r.removeListener("error",s),e(o)}let s;t!=="error"&&(s=o=>{r.removeListener(name,n),i(o)},r.once("error",s)),r.once(t,n)})};x5.on=function(r,t){let e=[],i=[],n=null,s=!1,o={async next(){let l=e.shift();if(l)return createIterResult(l,!1);if(n){let c=Promise.reject(n);return n=null,c}return s?createIterResult(void 0,!0):new Promise((c,d)=>i.push({resolve:c,reject:d}))},async return(){r.removeListener(t,a),r.removeListener("error",v),s=!0;for(let l of i)l.resolve(createIterResult(void 0,!0));return createIterResult(void 0,!0)},throw(l){n=l,r.removeListener(t,a),r.removeListener("error",v)},[Symbol.asyncIterator](){return this}};return r.on(t,a),r.on("error",v),o;function a(...l){let c=i.shift();c?c.resolve(createIterResult(l,!1)):e.push(l)}function v(l){s=!0;let c=i.shift();c?c.reject(l):n=l,o.return()}};var{EventEmitter:Wt,defaultMaxListeners:c9,init:d9,listenerCount:u9,on:f9,once:h9}=x5;import{Vec3 as Vt}from"vec3";x();R();T();k();function De(r){let t=r*2+1;if(t<=0)return[];let e=[],i=0,n=0,s=0,o=-1;for(let a=0;a<t*t;a++){if(Math.abs(i)<=t/2&&Math.abs(n)<=t/2&&e.push([i,n]),i===n||i<0&&i===-n||i>0&&i===1-n){let v=s;s=-o,o=v}i+=s,n+=o}return e}var ae=r=>[Math.floor(r.x/16),Math.floor(r.z/16)],ks=r=>[Math.floor(r.x/16),Math.floor(r.y/16),Math.floor(r.z/16)],Un=async(r,t,e,i=1)=>{for(let n=0;n<r.length;n+=i)t&&await new Promise(s=>setTimeout(s,t)),await e(r[n],n)},Le=class Le extends Wt{static restoreTransferred(t,e){let i=new Le;return e&&e.addEventListener("message",({data:n})=>{n.class===Le.restorerName&&n.type==="event"&&i.emit(n.eventName,...n.args)}),i}};f(Le,"restorerName","WorldViewWorker");var Nt=Le,jt=class extends Wt{constructor(e,i,n=new Vt(0,0,0)){super();this.world=e;this.viewDistance=i;f(this,"spiralNumber",0);f(this,"gotPanicLastTime",!1);f(this,"panicChunksReload",()=>{});f(this,"loadedChunks",{});f(this,"inLoading",!1);f(this,"chunkReceiveTimes",[]);f(this,"lastChunkReceiveTime",0);f(this,"lastChunkReceiveTimeAvg",0);f(this,"panicTimeout");f(this,"lastPos");f(this,"eventListeners",{});f(this,"debugChunksInfo",{});f(this,"waitingSpiralChunksLoad",{});f(this,"addWaitTime",1);f(this,"keepChunksDistance",0);f(this,"isPlayground",!1);f(this,"allowPositionUpdate",!0);f(this,"lastBiomeId",null);f(this,"lastPosCheck",null);this.lastPos=new Vt(0,0,0).update(n)}prepareForTransfer(e){if(e){let i=this.emit.bind(this);this.emit=(n,...s)=>{i(n,...s),e.postMessage({class:Nt.restorerName,type:"event",eventName:n,args:s})}}return{__restorer:Nt.restorerName}}setBlockStateId(e,i){let n=this.world.setBlockStateId(e,i);if(n&&typeof n.then=="function")throw new Error("setBlockStateId returned promise (not supported)");this.emit("blockUpdate",{pos:e,stateId:i})}updateViewDistance(e){this.viewDistance=e,this.emit("renderDistance",e)}async init(e,i){this.updateViewDistance(this.viewDistance),this.emit("chunkPosUpdate",{pos:e}),i?.time?.timeOfDay!==void 0&&this.emit("time",i.time.timeOfDay),i?.entity&&this.emit("playerEntity",i.entity),this.emitterGotConnected(i);let[n,s]=ae(e),o=De(this.viewDistance).map(([a,v])=>new Vt((n+a)*16,0,(s+v)*16));this.lastPos.update(e),await this._loadChunks(o,e)}chunkProgress(){if(this.panicTimeout&&clearTimeout(this.panicTimeout),this.chunkReceiveTimes.length>=5){let e=this.chunkReceiveTimes.reduce((n,s)=>n+s,0)/this.chunkReceiveTimes.length;this.lastChunkReceiveTimeAvg=e;let i=e*2+1e3;this.panicTimeout&&clearTimeout(this.panicTimeout),this.panicTimeout=setTimeout(()=>{!this.gotPanicLastTime&&this.inLoading&&(this.gotPanicLastTime=!0,this.panicChunksReload())},i)}}async _loadChunks(e,i){this.spiralNumber++;let{spiralNumber:n}=this;for(let o of Object.keys(this.waitingSpiralChunksLoad))this.waitingSpiralChunksLoad[o](!1),delete this.waitingSpiralChunksLoad[o];let s=!0;this.inLoading=!0,await Un(e,this.addWaitTime,async o=>{!s||this.loadedChunks[`${o.x},${o.z}`]||(this.world.getColumnAt(o)||(s=await new Promise(a=>{this.waitingSpiralChunksLoad[`${o.x},${o.z}`]=a})),s&&(await this.loadChunk(o,void 0,`spiral ${n} from ${i.x},${i.z}`),this.chunkProgress()))}),this.panicTimeout&&clearTimeout(this.panicTimeout),this.inLoading=!1,this.gotPanicLastTime=!1,this.chunkReceiveTimes=[],this.lastChunkReceiveTime=0}async loadChunk(e,i=!1,n="spiral"){var l,c;let[s,o]=ae(this.lastPos),a=Math.abs(s-Math.floor(e.x/16)),v=Math.abs(o-Math.floor(e.z/16));if(a<=this.viewDistance&&v<=this.viewDistance){let d=await this.world.getColumnAt(e.y!==void 0?e:new Vt(e.x,0,e.z));if(d){let m=d.toJson(),p={minY:d.minY??0,worldHeight:d.worldHeight??256};this.emit("loadChunk",{x:e.x,z:e.z,chunk:m,blockEntities:d.blockEntities,worldConfig:p,isLightUpdate:i}),this.loadedChunks[`${e.x},${e.z}`]=!0,(l=this.debugChunksInfo)[c=`${e.x},${e.z}`]??(l[c]={loads:[]}),this.debugChunksInfo[`${e.x},${e.z}`].loads.push({dataLength:m.length,reason:n,time:Date.now()})}else this.isPlayground&&this.emit("markAsLoaded",{x:e.x,z:e.z})}}unloadAllChunks(){for(let e of Object.keys(this.loadedChunks)){let[i,n]=e.split(",").map(Number);this.unloadChunk({x:i,z:n})}}unloadChunk(e){this.emit("unloadChunk",{x:e.x,z:e.z}),delete this.loadedChunks[`${e.x},${e.z}`],delete this.debugChunksInfo[`${e.x},${e.z}`]}emitterGotConnected(e){typeof globalThis.WorkerGlobalScope<"u"&&globalThis instanceof globalThis.WorkerGlobalScope||!e||this.emit("blockEntities",new Proxy({},{get(n,s,o){if(typeof s!="string")return;let[a,v,l]=s.split(",").map(Number);return e.world.getBlock(new Vt(a,v,l))?.entity}}))}updateBiome(e){try{if(!this.world.getBiome)return;let i=this.world.getBiome(e);i!==this.lastBiomeId&&(this.lastBiomeId=i,this.emit("biomeReset"))}catch{}}async updatePosition(e,i=!1){if(!this.allowPositionUpdate)return;let n=e.floored();if(!i&&this.lastPosCheck&&this.lastPosCheck.equals(n))return;this.lastPosCheck=n,this.updateBiome(e);let[s,o]=ae(this.lastPos),[a,v]=ae(e);if(s!==a||o!==v||i){this.emit("chunkPosUpdate",{pos:e});let l=[],c=i?this.viewDistance:this.viewDistance+this.keepChunksDistance;for(let m of Object.keys(this.loadedChunks)){let[p,g]=m.split(",").map(Number),y=new Vt(p,0,g),[E,w]=ae(y),_=Math.abs(a-E),C=Math.abs(v-w);(_>c||C>c)&&l.push(y)}for(let m of l)this.unloadChunk(m);let d=De(this.viewDistance).map(([m,p])=>{let g=new Vt((a+m)*16,0,(v+p)*16);if(!this.loadedChunks[`${g.x},${g.z}`])return g}).filter(m=>!!m);this.lastPos.update(e),this._loadChunks(d,e)}else this.emit("chunkPosUpdate",{pos:e}),this.lastPos.update(e)}};x();R();T();k();x();R();T();k();import Gn from"minecraft-data";import Ts from"mc-assets/dist/blocksAtlases.json";import Ms from"mc-assets/dist/itemsAtlases.json";import Ss from"mc-assets/dist/itemDefinitions.json";import Cs from"mc-assets/dist/blocksAtlasLatest.png";import Ps from"mc-assets/dist/blocksAtlasLegacy.png";import Bs from"mc-assets/dist/itemsAtlasLatest.png";import Is from"mc-assets/dist/itemsAtlasLegacy.png";import Hs from"mc-assets/dist/textureReplacements/christmas";import{AtlasParser as R5}from"mc-assets/dist/atlasParser";import zs from"mc-assets/dist/worldBlockProvider";import{ItemsRenderer as Os}from"mc-assets/dist/itemsRenderer";import{getLoadedItemDefinitionsStore as Ds}from"mc-assets";var ve=class{constructor(t){f(this,"sourceItemDefinitionsJson",Ss);f(this,"itemsDefinitionsStore",Ds(this.sourceItemDefinitionsJson));f(this,"allReady",!1);f(this,"itemsAtlasImage");f(this,"blocksAtlasImage");f(this,"blocksAtlasJson");f(this,"customBlockStates");f(this,"customModels");f(this,"customItemModelNames",{});f(this,"customTextures",{});f(this,"guiAtlas",null);f(this,"guiAtlasVersion",0);f(this,"itemsRenderer");f(this,"worldBlockProvider");f(this,"blockstatesModels",null);f(this,"version");f(this,"texturesVersion");f(this,"mcData");t&&(Object.assign(this,t),this.mcData=Gn(this.version))}prepareForTransfer(){let t={};for(let e in this)Object.prototype.hasOwnProperty.call(this,e)&&typeof this[e]!="function"&&(e==="itemsRenderer"||e==="worldBlockProvider"||e==="mcData"||(t[e]=this[e]));return t.customTextures={},t}},Ls="1.21.4",Et=class Et extends Wt{constructor(){super(...arguments);f(this,"sourceBlockStatesModels",null);f(this,"sourceBlocksAtlases",Ts);f(this,"sourceItemsAtlases",Ms);f(this,"currentResources");f(this,"itemsAtlasParser");f(this,"blocksAtlasParser");f(this,"currentConfig");f(this,"abortController",new AbortController);f(this,"_promiseAssetsReadyResolvers",Promise.withResolvers())}static restoreTransferred(e,i){let n=new Et,s=o=>{n.currentResources=new ve(o)};return s(e.currentResources),i&&i.addEventListener("message",({data:o})=>{o.class===Et.restorerName&&(o.type==="newResources"&&s(o.currentResources),o.type==="event"&&n.emit(o.eventName,...o.args))}),n}prepareForTransfer(e){if(e){let i=this.emit.bind(this);this.emit=(n,...s)=>{i(n,...s),e.postMessage({class:Et.restorerName,type:"event",eventName:n,args:s}),(n==="assetsTexturesUpdated"||n==="assetsInventoryReady")&&e.postMessage({class:Et.restorerName,type:"newResources",currentResources:this.currentResources?.prepareForTransfer()})}}return{__restorer:Et.restorerName,currentResources:this.currentResources?.prepareForTransfer()}}get promiseAssetsReady(){return this._promiseAssetsReadyResolvers.promise}async loadSourceData(e=this.currentConfig?.version){if(!e)throw new Error("No version loaded");this.sourceBlockStatesModels??(this.sourceBlockStatesModels=(await import("mc-assets/dist/blockStatesModels.json")).default)}resetResources(){this.currentResources=new ve}async updateAssetsData(e,i=!1){if(!this.currentConfig)throw new Error("No config loaded");this._promiseAssetsReadyResolvers=Promise.withResolvers();let n=new AbortController;if(await this.loadSourceData(this.currentConfig.version),n.signal.aborted)return;let s=this.currentResources??new ve;s.version=this.currentConfig.version,s.texturesVersion=this.currentConfig.texturesVersion??s.version,s.mcData=Gn(s.version),s.blockstatesModels={blockstates:{},models:{}},s.blockstatesModels.blockstates.latest={...this.sourceBlockStatesModels.blockstates.latest,...s.customBlockStates},s.blockstatesModels.models.latest={...this.sourceBlockStatesModels.models.latest,...s.customModels},await Promise.all([this.recreateBlockAtlas(s),this.recreateItemsAtlas(s)]),!n.signal.aborted&&(s.version&&s.blockstatesModels&&this.itemsAtlasParser&&this.blocksAtlasParser&&(s.itemsRenderer=new Os(s.version,s.blockstatesModels,this.itemsAtlasParser,this.blocksAtlasParser)),!n.signal.aborted&&(this.currentResources=s,s.allReady=!0,i||this.emit("assetsTexturesUpdated"),this.currentConfig.noInventoryGui?this._promiseAssetsReadyResolvers.resolve():(this.emit("assetsInventoryStarted"),this.generateGuiTextures().then(()=>{n.signal.aborted||(i||this.emit("assetsInventoryReady"),this._promiseAssetsReadyResolvers.resolve())}))))}async recreateBlockAtlas(e=this.currentResources){let i={},n=new Date;(n.getMonth()===11&&n.getDate()>=24||n.getMonth()===0&&n.getDate()<=6)&&Object.assign(i,Hs);let s=new R5(this.sourceBlocksAtlases,Cs,Ps),o=Object.keys(e.customTextures.blocks?.textures??{}),{atlas:a,canvas:v}=await s.makeNewAtlas(e.texturesVersion,l=>{if(this.currentConfig.includeOnlyBlocks&&!this.currentConfig.includeOnlyBlocks.includes(l))return!1;let c=e.customTextures.blocks?.textures[l];return i[l]??c},void 0,void 0,o,{needHorizontalIndexes:!!this.currentConfig.includeOnlyBlocks});this.blocksAtlasParser=new R5({latest:a},v.toDataURL()),e.blocksAtlasImage=await createImageBitmap(v),e.blocksAtlasJson=this.blocksAtlasParser.atlas.latest,e.worldBlockProvider=zs(e.blockstatesModels,this.blocksAtlasParser.atlas,Ls)}async recreateItemsAtlas(e=this.currentResources){let i=new R5(this.sourceItemsAtlases,Bs,Is),n=Object.keys(e.customTextures.items?.textures??{}),{atlas:s,canvas:o}=await i.makeNewAtlas(e.texturesVersion,a=>{let v=e.customTextures.items?.textures[a];if(v)return v},e.customTextures.items?.tileSize,void 0,n);this.itemsAtlasParser=new R5({latest:s},o.toDataURL()),e.itemsAtlasImage=await createImageBitmap(o)}async generateGuiTextures(){}async downloadDebugAtlas(e=!1){if(!this.currentResources)throw new Error("No resources loaded");let s=await(e?this.itemsAtlasParser:this.blocksAtlasParser).createDebugImage(!0),o=document.createElement("a");o.href=s,o.download=`atlas-debug-${e?"items":"blocks"}.png`,o.click()}destroy(){this.abortController.abort(),this.currentResources=void 0,this.abortController=new AbortController}};f(Et,"restorerName","ResourcesManager");var mt=Et;var Vn=class{constructor(t={},e=new mt){this.resourcesManager=e;f(this,"waitBackendLoadPromises",[]);f(this,"onWorldStart");f(this,"onBeforeWorldStart");f(this,"worldView");f(this,"config");f(this,"inWorldRenderingConfig");f(this,"backend");f(this,"backendLoader");f(this,"currentState");f(this,"currentDisplay",null);f(this,"playerState",{reactive:P1()});f(this,"rendererState");f(this,"nonReactiveState");f(this,"worldReady");f(this,"resolveWorldReady");f(this,"lastCamUpdate",0);this.config={...On,...t.config},this.inWorldRenderingConfig=Wn({...Oe,...t.rendererConfig});let i=Gt();this.rendererState=i.reactive,this.nonReactiveState=i.nonReactive,this.initWorldReadyPromise()}initWorldReadyPromise(){let{promise:t,resolve:e}=Promise.withResolvers();this.worldReady=t,this.resolveWorldReady=e}async loadBackend(t){this.backend&&this.disconnectBackend(),await Promise.all(this.waitBackendLoadPromises),this.waitBackendLoadPromises=[],this.backendLoader=t;let e={config:this.config,callbacks:{displayCriticalError:n=>{},setRendererSpecificSettings:(n,s)=>{},fireCustomEvent:(n,...s)=>{}},rendererSpecificSettings:{}},i=t(e);if(this.backend=await Promise.resolve(i),this.currentState)if(this.currentState.method==="startPanorama")this.startPanorama();else{let{method:n,args:s}=this.currentState;this.backend[n](...s)}}async startWorld(t,e,i=this.playerState.reactive,n){if(this.currentDisplay==="world")throw new Error("World already started");this.currentDisplay="world";let s=n??new Fs(0,64,0);this.worldView=new jt(t,e,s),this.worldView.isPlayground=this.inWorldRenderingConfig.isPlayground;let o={version:this.resourcesManager?.currentConfig?.version??"1.20.4",worldView:this.worldView,inWorldRenderingConfig:this.inWorldRenderingConfig,playerStateReactive:i,rendererState:this.rendererState,nonReactiveState:this.nonReactiveState,resourcesManager:this.resourcesManager};this.onBeforeWorldStart?.();let a;if(this.backend){let v=this.backend.startWorld(o);v&&typeof v.then=="function"&&(a=v)}return this.currentState={method:"startWorld",args:[o]},await a,this.resolveWorldReady(),this.onWorldStart?.(),!!a}startPanorama(){this.currentDisplay!=="menu"&&(this.backend&&(this.currentDisplay="menu",this.backend.startPanorama()),this.currentState={method:"startPanorama",args:[]})}resetBackend(t=!1){this.disconnectBackend(t),this.backendLoader&&this.loadBackend(this.backendLoader)}disconnectBackend(t=!1){t&&(this.currentState=void 0,this.currentDisplay=null,this.worldView=void 0),this.backend&&(this.backend.disconnect(),this.backend=void 0),this.currentDisplay=null,this.initWorldReadyPromise(),this.rendererState=Wn(Gt().reactive),this.nonReactiveState=Gt().nonReactive}updateCamera(t,e,i){this.backend?.updateCamera(t,e,i)}setRendering(t){this.backend?.setRendering(t)}async startWithBot(t,e){await this.startWorld(t.world,e),this.worldView&&typeof this.worldView.listenToBot=="function"&&this.worldView.listenToBot(t)}destroyAll(){this.disconnectBackend(!0),this.resourcesManager&&typeof this.resourcesManager.destroy=="function"&&this.resourcesManager.destroy()}get utils(){let t=this.backend;return{async waitingForChunks(){if(!t?.worldState?.allChunksLoaded)return new Promise(e=>{let i=setInterval(()=>{t?.worldState?.allChunksLoaded&&(clearInterval(i),e())},100)})}}}destroy(){this.disconnectBackend(!0)}};x();R();T();k();import{proxy as Us}from"valtio";var Nn=()=>Us({playerSkin:void 0,inWater:!1,waterBreathing:!1,backgroundColor:[0,0,0],ambientLight:0,directionalLight:0,eyeHeight:0,gameMode:void 0,lookingAtBlock:void 0,diggingBlock:void 0,movementState:"NOT_MOVING",onGround:!0,sneaking:!1,flying:!1,sprinting:!1,walkDist:0,prevWalkDist:0,bob:0,prevBob:0,itemUsageTicks:0,username:"",onlineMode:!1,cardinalLight:"default",lightingDisabled:!1,shouldHideHand:!1,heldItemMain:void 0,heldItemOff:void 0,perspective:"first_person",onFire:!1,cameraSpectatingEntity:void 0,team:void 0}),Gs=r=>({isSpectator(){return r.gameMode==="spectator"},isSpectatingEntity(){return r.cameraSpectatingEntity!==void 0&&r.gameMode==="spectator"},isThirdPerson(){return this.isSpectatingEntity()?!1:r.perspective==="third_person_back"||r.perspective==="third_person_front"}}),Ws=()=>({reactive:Nn()}),jn=(r,t,e)=>({...t,"minecraft:date":new Date});x();R();T();k();x();R();T();k();import*as h5 from"three";import{Vec3 as mv}from"vec3";x();R();T();k();import{proxy as Vs,getVersion as Qn,subscribe as Kn}from"valtio";import{Vec3 as Jn}from"vec3";function qn(r,t){let e=t??globalThis;return e.addEventListener("message",i=>{let{type:n,args:s,msgId:o}=i.data;if(r[n]){let a=r[n](...s);a instanceof Promise&&a.then(v=>{e.postMessage({type:"result",msgId:o,args:[v]})})}}),null}var Zn=(r,t=!0)=>{let e=0;return new Proxy({},{get(i,n){return n==="transfer"?(...s)=>new Proxy({},{get(o,a){return(...v)=>{r.postMessage({type:a,args:v},s)}}}):(...s)=>{let o=e++,a=t?s.filter(v=>v instanceof ArrayBuffer||v instanceof MessagePort||typeof ImageBitmap<"u"&&v instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&v instanceof OffscreenCanvas||typeof ImageData<"u"&&v instanceof ImageData):[];return r.postMessage({type:n,msgId:o,args:s},a),{then(v){let l=({data:c})=>{c.type==="result"&&c.msgId===o&&(v(c.args[0]),r.removeEventListener("message",l))};r.addEventListener("message",l)}}}}})};var Xn=(r,t,e,i)=>{try{e.postMessage({type:"sync",syncId:r,value:k5(t)}),Fe.toWorker++,globalThis.debugSyncMessagesOutgoing??(globalThis.debugSyncMessagesOutgoing=0),globalThis.debugSyncMessagesOutgoing++}catch{Ue(t)}},Fe={toWorker:0,fromWorker:0};typeof window<"u"&&setInterval(()=>{globalThis.debugWorkerSyncStats={...Fe},Fe.toWorker=0,Fe.fromWorker=0},1e3);var Ns=()=>Math.random().toString(36).slice(2,15)+Math.random().toString(36).slice(2,15),Yn=(r,t,e,i,n)=>{if(!r.__syncToWorker&&!r.__syncFromWorker&&!i)return;let s=Ns();if(r.__syncId=s,r.__syncToWorker||i){let o=()=>{Xn(s,t,e,`toWorker:${n}`)};i&&Kn(t,o);let a=r.__syncToWorkerInterval??0;a>0&&setInterval(o,a)}t.__syncFromWorker&&e.addEventListener("message",o=>{o.data.type==="sync"&&o.data.syncId===s&&(Fe.fromWorker++,Object.assign(t,o.data.value))})},k5=r=>{if(Qn(r)===void 0)return r;if(Array.isArray(r))return r.map(k5);if(typeof r=="object"&&r!==null){let t={};for(let e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=k5(r[e]));return t}return r},T5=(r,t,e=!0,i=!0,n=!1)=>{var a,v;let s=r,o={};for(let l in r)if(Object.prototype.hasOwnProperty.call(r,l)){if(e&&typeof r[l]=="function")continue;if(r[l]instanceof Date||r[l]instanceof RegExp||r[l]instanceof Map||r[l]instanceof WeakMap||r[l]instanceof WeakSet,r[l]instanceof Set){o[l]=[...r[l]],o[l].__restorer="Set";continue}if(r[l]instanceof Jn){o[l]={x:r[l].x,y:r[l].y,z:r[l].z},o[l].__restorer="Vec3";continue}if(o[l]=r[l],typeof r[l]=="object"&&r[l]!==null){if(r[l].prepareForTransfer){o[l]=r[l].prepareForTransfer(t);continue}let c=Qn(r[l])!==void 0;o[l]=c?k5(r[l]):r[l];let d=r[l].__syncToWorker!==!1&&!n&&c&&!r[l].__syncFromWorker;if((a=o[l]).__syncToWorker??(a.__syncToWorker=d),c&&((v=o[l]).__valtio??(v.__valtio=!0)),o[l].__syncToWorker&&c){Yn(o[l],s[l],t,!0,l);continue}Yn(o[l],s[l],t,!1,l),o[l]=T5(o[l],t,e,!1,c)}}return o},Ue=(r,t=[])=>{for(let e in r)if(Object.prototype.hasOwnProperty.call(r,e)){if(!r[e])continue;typeof r[e]=="object"&&r[e]!==null&&Ue(r[e],[...t,e]);try{structuredClone(r[e])}catch{}}},js=(r,t,e)=>{if(!r.__syncId)return;let i=r.__syncId;if(r.__syncToWorker&&t.addEventListener("message",n=>{n.data.type==="sync"&&n.data.syncId===i&&Object.assign(r,n.data.value)}),r.__syncFromWorker){let n=()=>{Xn(i,r,t,`fromWorker:${e}`)};r.__valtio&&Kn(r,n);let s=r.__syncFromWorkerInterval??0;s>0&&setInterval(n,s)}},Ys=[{restorerName:"Set",restoreTransferred(r,t){return new Set(r)}},{restorerName:"Vec3",restoreTransferred(r,t){return new Jn(r.x,r.y,r.z)}}];var M5=(r,t,e,i=!0)=>{let n=[...Ys,...t];for(let s in r)if(Object.prototype.hasOwnProperty.call(r,s)){if(!r[s])continue;if(typeof r[s]=="object"&&r[s]!==null&&M5(r[s],n,e,i),r[s].__restorer){let o=n.find(a=>a.restorerName?a.restorerName===r[s].__restorer:a.name===r[s].__restorer);if(o)r[s]=o.restoreTransferred(r[s],e);else{let a=new Error(`Restorer ${r[s].__restorer} not found`);if(typeof i=="function")i(a);else if(i)throw a}}r[s].__valtio&&(r[s]=Vs(r[s])),js(r[s],e,s)}return r};x();R();T();k();var S5=class{constructor(t){this.nonReactiveState=t;f(this,"events",[]);f(this,"frozenEvents",[]);f(this,"lastSecondEvents",[]);f(this,"currentFrameStartTime",null);f(this,"lastInteractionTime",0);f(this,"lastSecondUpdateTime",0);f(this,"timeWindowMs",5e3);f(this,"lastSecondWindowMs",1e3);f(this,"maxEvents",500);f(this,"lastSecondUpdateInterval",1e3);this.nonReactiveState.renderer||(this.nonReactiveState.renderer={timeline:{live:[],frozen:[],lastSecond:[]}}),this.nonReactiveState.renderer.timeline||(this.nonReactiveState.renderer.timeline={live:[],frozen:[],lastSecond:[]}),setInterval(()=>{this.updateLastSecondTimeline()},this.lastSecondUpdateInterval)}markFrameStart(){this.currentFrameStartTime=performance.now(),this.addEvent({type:"frameStart",timestamp:this.currentFrameStartTime})}markFrameEnd(){if(!this.currentFrameStartTime)return;let t=performance.now(),e=t-this.currentFrameStartTime;this.addEvent({type:"frameEnd",timestamp:t,duration:e}),this.currentFrameStartTime=null}markCameraUpdate(t){if(!t)return;let e=performance.now();this.lastInteractionTime=e,this.addEvent({type:"cameraUpdate",timestamp:e}),this.frozenEvents=[...this.events],this.trimEvents(this.frozenEvents),this.syncFrozenEvents()}markFrameDisplay(){this.addEvent({type:"frameDisplay",timestamp:performance.now()})}addEvent(t){this.events.push(t),this.lastSecondEvents.push(t),this.trimEvents(this.events),this.trimLastSecondEvents(),this.syncLiveEvents()}trimEvents(t){let i=performance.now()-this.timeWindowMs;for(;t.length>0&&t[0].timestamp<i;)t.shift();t.length>this.maxEvents&&t.splice(0,t.length-this.maxEvents)}trimLastSecondEvents(){let e=performance.now()-this.lastSecondWindowMs;for(;this.lastSecondEvents.length>0&&this.lastSecondEvents[0].timestamp<e;)this.lastSecondEvents.shift()}updateLastSecondTimeline(){let t=performance.now();t-this.lastSecondUpdateTime<this.lastSecondUpdateInterval||(this.lastSecondUpdateTime=t,this.trimLastSecondEvents(),this.syncLastSecondEvents())}syncLiveEvents(){this.nonReactiveState.renderer.timeline.live=[...this.events]}syncFrozenEvents(){this.nonReactiveState.renderer.timeline.frozen=[...this.frozenEvents]}syncLastSecondEvents(){this.nonReactiveState.renderer.timeline.lastSecond=[...this.lastSecondEvents]}clear(){this.events=[],this.frozenEvents=[],this.lastSecondEvents=[],this.syncLiveEvents(),this.syncFrozenEvents(),this.syncLastSecondEvents()}};x();R();T();k();import*as Y from"three";import{Vec3 as It}from"vec3";import q8 from"prismarine-chat";x();R();T();k();var k0=Object.freeze({Linear:Object.freeze({None:function(r){return r},In:function(r){return this.None(r)},Out:function(r){return this.None(r)},InOut:function(r){return this.None(r)}}),Quadratic:Object.freeze({In:function(r){return r*r},Out:function(r){return r*(2-r)},InOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)}}),Cubic:Object.freeze({In:function(r){return r*r*r},Out:function(r){return--r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)}}),Quartic:Object.freeze({In:function(r){return r*r*r*r},Out:function(r){return 1- --r*r*r*r},InOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)}}),Quintic:Object.freeze({In:function(r){return r*r*r*r*r},Out:function(r){return--r*r*r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)}}),Sinusoidal:Object.freeze({In:function(r){return 1-Math.sin((1-r)*Math.PI/2)},Out:function(r){return Math.sin(r*Math.PI/2)},InOut:function(r){return .5*(1-Math.sin(Math.PI*(.5-r)))}}),Exponential:Object.freeze({In:function(r){return r===0?0:Math.pow(1024,r-1)},Out:function(r){return r===1?1:1-Math.pow(2,-10*r)},InOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)}}),Circular:Object.freeze({In:function(r){return 1-Math.sqrt(1-r*r)},Out:function(r){return Math.sqrt(1- --r*r)},InOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)}}),Elastic:Object.freeze({In:function(r){return r===0?0:r===1?1:-Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI)},Out:function(r){return r===0?0:r===1?1:Math.pow(2,-10*r)*Math.sin((r-.1)*5*Math.PI)+1},InOut:function(r){return r===0?0:r===1?1:(r*=2,r<1?-.5*Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI):.5*Math.pow(2,-10*(r-1))*Math.sin((r-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(r){var t=1.70158;return r===1?1:r*r*((t+1)*r-t)},Out:function(r){var t=1.70158;return r===0?0:--r*r*((t+1)*r+t)+1},InOut:function(r){var t=2.5949095;return(r*=2)<1?.5*(r*r*((t+1)*r-t)):.5*((r-=2)*r*((t+1)*r+t)+2)}}),Bounce:Object.freeze({In:function(r){return 1-k0.Bounce.Out(1-r)},Out:function(r){return r<.36363636363636365?7.5625*r*r:r<.7272727272727273?7.5625*(r-=.5454545454545454)*r+.75:r<.9090909090909091?7.5625*(r-=.8181818181818182)*r+.9375:7.5625*(r-=.9545454545454546)*r+.984375},InOut:function(r){return r<.5?k0.Bounce.In(r*2)*.5:k0.Bounce.Out(r*2-1)*.5+.5}}),generatePow:function(r){return r===void 0&&(r=4),r=r<Number.EPSILON?Number.EPSILON:r,r=r>1e4?1e4:r,{In:function(t){return Math.pow(t,r)},Out:function(t){return 1-Math.pow(1-t,r)},InOut:function(t){return t<.5?Math.pow(t*2,r)/2:(1-Math.pow(2-t*2,r))/2+.5}}}}),Ge=function(){return performance.now()},ce=function(){function r(){this._tweens={},this._tweensAddedDuringUpdate={}}return r.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map(function(e){return t._tweens[e]})},r.prototype.removeAll=function(){this._tweens={}},r.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},r.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},r.prototype.update=function(t,e){t===void 0&&(t=Ge()),e===void 0&&(e=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var n=0;n<i.length;n++){var s=this._tweens[i[n]],o=!e;s&&s.update(t,o)===!1&&!e&&delete this._tweens[i[n]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},r}(),le={Linear:function(r,t){var e=r.length-1,i=e*t,n=Math.floor(i),s=le.Utils.Linear;return t<0?s(r[0],r[1],i):t>1?s(r[e],r[e-1],e-i):s(r[n],r[n+1>e?e:n+1],i-n)},Bezier:function(r,t){for(var e=0,i=r.length-1,n=Math.pow,s=le.Utils.Bernstein,o=0;o<=i;o++)e+=n(1-t,i-o)*n(t,o)*r[o]*s(i,o);return e},CatmullRom:function(r,t){var e=r.length-1,i=e*t,n=Math.floor(i),s=le.Utils.CatmullRom;return r[0]===r[e]?(t<0&&(n=Math.floor(i=e*(1+t))),s(r[(n-1+e)%e],r[n],r[(n+1)%e],r[(n+2)%e],i-n)):t<0?r[0]-(s(r[0],r[0],r[1],r[1],-i)-r[0]):t>1?r[e]-(s(r[e],r[e],r[e-1],r[e-1],i-e)-r[e]):s(r[n?n-1:0],r[n],r[e<n+1?e:n+1],r[e<n+2?e:n+2],i-n)},Utils:{Linear:function(r,t,e){return(t-r)*e+r},Bernstein:function(r,t){var e=le.Utils.Factorial;return e(r)/e(t)/e(r-t)},Factorial:function(){var r=[1];return function(t){var e=1;if(r[t])return r[t];for(var i=t;i>1;i--)e*=i;return r[t]=e,e}}(),CatmullRom:function(r,t,e,i,n){var s=(e-r)*.5,o=(i-t)*.5,a=n*n,v=n*a;return(2*t-2*e+s+o)*v+(-3*t+3*e-2*s-o)*a+s*n+t}}},$n=function(){function r(){}return r.nextId=function(){return r._nextId++},r._nextId=0,r}(),B1=new ce,S0=function(){function r(t,e){e===void 0&&(e=B1),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=k0.Linear.None,this._interpolationFunction=le.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=$n.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return r.prototype.getId=function(){return this._id},r.prototype.isPlaying=function(){return this._isPlaying},r.prototype.isPaused=function(){return this._isPaused},r.prototype.to=function(t,e){if(e===void 0&&(e=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=e,this},r.prototype.duration=function(t){return t===void 0&&(t=1e3),this._duration=t,this},r.prototype.dynamic=function(t){return t===void 0&&(t=!1),this._isDynamic=t,this},r.prototype.start=function(t,e){if(t===void 0&&(t=Ge()),e===void 0&&(e=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||e){if(this._propertiesAreSetUp=!0,!this._isDynamic){var n={};for(var s in this._valuesEnd)n[s]=this._valuesEnd[s];this._valuesEnd=n}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,e)}return this},r.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},r.prototype._setupProperties=function(t,e,i,n,s){for(var o in i){var a=t[o],v=Array.isArray(a),l=v?"array":typeof a,c=!v&&Array.isArray(i[o]);if(!(l==="undefined"||l==="function")){if(c){var d=i[o];if(d.length===0)continue;for(var m=[a],p=0,g=d.length;p<g;p+=1){var y=this._handleRelativeValue(a,d[p]);if(isNaN(y)){c=!1;break}m.push(y)}c&&(i[o]=m)}if((l==="object"||v)&&a&&!c){e[o]=v?[]:{};var E=a;for(var w in E)e[o][w]=E[w];n[o]=v?[]:{};var d=i[o];if(!this._isDynamic){var _={};for(var w in d)_[w]=d[w];i[o]=d=_}this._setupProperties(E,e[o],d,n[o],s)}else(typeof e[o]>"u"||s)&&(e[o]=a),v||(e[o]*=1),c?n[o]=i[o].slice().reverse():n[o]=e[o]||0}}},r.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},r.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},r.prototype.pause=function(t){return t===void 0&&(t=Ge()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this),this)},r.prototype.resume=function(t){return t===void 0&&(t=Ge()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},r.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},r.prototype.group=function(t){return t===void 0&&(t=B1),this._group=t,this},r.prototype.delay=function(t){return t===void 0&&(t=0),this._delayTime=t,this},r.prototype.repeat=function(t){return t===void 0&&(t=0),this._initialRepeat=t,this._repeat=t,this},r.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},r.prototype.yoyo=function(t){return t===void 0&&(t=!1),this._yoyo=t,this},r.prototype.easing=function(t){return t===void 0&&(t=k0.Linear.None),this._easingFunction=t,this},r.prototype.interpolation=function(t){return t===void 0&&(t=le.Linear),this._interpolationFunction=t,this},r.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},r.prototype.onStart=function(t){return this._onStartCallback=t,this},r.prototype.onEveryStart=function(t){return this._onEveryStartCallback=t,this},r.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},r.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},r.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},r.prototype.onStop=function(t){return this._onStopCallback=t,this},r.prototype.update=function(t,e){if(t===void 0&&(t=Ge()),e===void 0&&(e=!0),this._isPaused)return!0;var i,n,s=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>s)return!1;e&&this.start(t,!0)}if(this._goToEnd=!1,t<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0),n=(t-this._startTime)/this._duration,n=this._duration===0||n>1?1:n;var o=this._easingFunction(n);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,o),this._onUpdateCallback&&this._onUpdateCallback(this._object,n),n===1)if(this._repeat>0){isFinite(this._repeat)&&this._repeat--;for(i in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[i]=="string"&&(this._valuesStartRepeat[i]=this._valuesStartRepeat[i]+parseFloat(this._valuesEnd[i])),this._yoyo&&this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];return this._yoyo&&(this._reversed=!this._reversed),this._repeatDelayTime!==void 0?this._startTime=t+this._repeatDelayTime:this._startTime=t+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var a=0,v=this._chainedTweens.length;a<v;a++)this._chainedTweens[a].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},r.prototype._updateProperties=function(t,e,i,n){for(var s in i)if(e[s]!==void 0){var o=e[s]||0,a=i[s],v=Array.isArray(t[s]),l=Array.isArray(a),c=!v&&l;c?t[s]=this._interpolationFunction(a,n):typeof a=="object"&&a?this._updateProperties(t[s],o,a,n):(a=this._handleRelativeValue(o,a),typeof a=="number"&&(t[s]=o+(a-o)*n))}},r.prototype._handleRelativeValue=function(t,e){return typeof e!="string"?e:e.charAt(0)==="+"||e.charAt(0)==="-"?t+parseFloat(e):parseFloat(e)},r.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],i=this._valuesEnd[t];typeof i=="string"?this._valuesStartRepeat[t]=this._valuesStartRepeat[t]+parseFloat(i):this._valuesStartRepeat[t]=this._valuesEnd[t],this._valuesEnd[t]=e},r}();var oc=$n.nextId,at=B1,ac=at.getAll.bind(at),vc=at.removeAll.bind(at),lc=at.add.bind(at),cc=at.remove.bind(at),tr=at.update.bind(at);x();R();T();k();x();R();T();k();var Qs=()=>{if(typeof OffscreenCanvas>"u")return!1;try{let r=new OffscreenCanvas(1,1);return(r.getContext("webgl2")||r.getContext("webgl"))!==null}catch{return!1}},Ks=Qs(),L0=(r,t)=>{if(Ks)return new OffscreenCanvas(r,t);let e=document.createElement("canvas");return e.width=r,e.height=t,e};async function C5(r){let e=await(await fetch(r)).blob();return createImageBitmap(e)}var Js=(r,t)=>{try{return JSON.parse(r)}catch{return null}},qs={black:"#000000",dark_blue:"#0000AA",dark_green:"#00AA00",dark_aqua:"#00AAAA",dark_red:"#AA0000",dark_purple:"#AA00AA",gold:"#FFAA00",gray:"#AAAAAA",dark_gray:"#555555",blue:"#5555FF",green:"#55FF55",aqua:"#55FFFF",red:"#FF5555",light_purple:"#FF55FF",yellow:"#FFFF55",white:"#FFFFFF"},P5=(r,t,e,i=s=>{},n=(s,o)=>L0(s,o))=>{let a=[16,9],v=a[0]-a[1],l=v/16,c="front_text"in r?r.front_text.messages:[r.Text1,r.Text2,r.Text3,r.Text4];if(!c.some(g=>g!=="null"))return;let d=n(16*40,v*40),m=d.getContext("2d");i(m);let p=("front_text"in r?r.front_text.color:r.Color)||"black";for(let[g,y]of c.slice(0,4).entries())y!=="null"&&I1(y,e,d,64,p,64*(g+1)+(t?0:-8));return d},I1=(r,t,e,i,n,s=0)=>{let o=!1,a=typeof r=="string"&&(r?.startsWith("{")||r?.startsWith('"'))?Js(r??'""',"sign text"):r;if(!a||typeof a!="object"&&typeof a!="string")return;let v=e.getContext("2d");if(!v)throw new Error("Could not get 2d context");v.imageSmoothingEnabled=!1,v.font=`${i}px mojangles`;let l=new t(a),c=[],d=!1,m="",p=s,g=[],y=(C,M)=>{C.text!==null&&C.text!==void 0&&C.text;let S=C.text===null||C.text===void 0?void 0:String(C.text),H={color:C.color??M?.color,underlined:C.underlined??M?.underlined,strikethrough:C.strikethrough??M?.strikethrough,bold:C.bold??M?.bold,italic:C.italic??M?.italic};if(d=d||H.underlined||H.strikethrough||!1,S?.includes(`
|
|
14
14
|
`))for(let B of S.split(`
|
|
15
|
-
`))E(B,H),p+=i,m="";else S&&E(S,H);if(C.extra)for(let B of C.extra)y(B,H)},E=(C,M)=>{o||(o=C.trim()!==""),m+=C,g[p]=v.measureText(m).width;let S=M.color??n;S.startsWith("#")||(S=qs[S.toLowerCase()]||S),c.push({fontStyle:`${M.bold?"bold":""} ${M.italic?"italic":""}`,fillStyle:S,underlineStyle:M.underlined??!1,strikeStyle:M.strikethrough??!1,offset:p,text:C})};if(y(l),!d&&!l.toString().trim())return;let w=0,_=0;for(let{fillStyle:C,fontStyle:M,underlineStyle:S,strikeStyle:H,offset:B,text:I}of c){_!==B&&(w=0),_=B,v.fillStyle=C,v.textRendering="optimizeLegibility",v.font=`${M} ${i}px mojangles`;let W=g[B]??v.measureText(I).width,z=(e.width-W)/2+w;v.fillText(I,z,B),H&&(v.lineWidth=i/8,v.strokeStyle=C,v.beginPath(),v.moveTo(z,B-v.lineWidth*2.5),v.lineTo(z+v.measureText(I).width,B-v.lineWidth*2.5),v.stroke()),S&&(v.lineWidth=i/8,v.strokeStyle=C,v.beginPath(),v.moveTo(z,B+v.lineWidth),v.lineTo(z+v.measureText(I).width,B+v.lineWidth),v.stroke()),w+=v.measureText(I).width}return o};x();R();T();k();function de(r){let t=Math.floor(r.x/16),e=Math.floor(r.z/16);return[t,e]}function H1(r){let t=Math.floor(r.x/16),e=Math.floor(r.y/16),i=Math.floor(r.z/16);return[t,e,i]}x();R();T();k();import{Vec3 as Qt}from"vec3";import{subscribeKey as q1}from"valtio/utils";import{proxy as ao,subscribe as vo}from"valtio";x();R();T();k();var We={blocks:"blocksArray",blockCollisionShapes:"blockCollisionShapes",biomes:"biomesArray"};x();R();T();k();var Ve=!1,er=16;var ir=(r,t)=>t?`${r}:${t}`:String(r);x();R();T();k();x();R();T();k();var D1=He(nr(),1);import*as H5 from"three";x();R();T();k();x();R();T();k();var B5=class{constructor(t,e,i){this.name=t,this.fg=e,this.bg=i,this.PR=Math.round(window.devicePixelRatio||1),this.WIDTH=90*this.PR,this.HEIGHT=48*this.PR,this.TEXT_X=3*this.PR,this.TEXT_Y=2*this.PR,this.GRAPH_X=3*this.PR,this.GRAPH_Y=15*this.PR,this.GRAPH_WIDTH=84*this.PR,this.GRAPH_HEIGHT=30*this.PR,this.canvas=document.createElement("canvas"),this.canvas.width=90*this.PR,this.canvas.height=48*this.PR,this.canvas.style.width="90px",this.canvas.style.position="absolute",this.canvas.style.height="48px",this.canvas.style.cssText="width:90px;height:48px",this.context=this.canvas.getContext("2d"),this.context&&(this.context.font="bold "+9*this.PR+"px Helvetica,Arial,sans-serif",this.context.textBaseline="top",this.context.fillStyle=this.bg,this.context.fillRect(0,0,this.WIDTH,this.HEIGHT),this.context.fillStyle=this.fg,this.context.fillText(this.name,this.TEXT_X,this.TEXT_Y),this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT))}update(t,e,i,n,s=0){let o=1/0,a=0;this.context&&(o=Math.min(o,t),a=Math.max(i,t),n=Math.max(n,e),this.context.fillStyle=this.bg,this.context.globalAlpha=1,this.context.fillRect(0,0,this.WIDTH,this.GRAPH_Y),this.context.fillStyle=this.fg,this.context.fillText(t.toFixed(s)+" "+this.name+" ("+o.toFixed(s)+"-"+parseFloat(a.toFixed(s))+")",this.TEXT_X,this.TEXT_Y),this.context.drawImage(this.canvas,this.GRAPH_X+this.PR,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT,this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT),this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y,this.PR,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y,this.PR,(1-e/n)*this.GRAPH_HEIGHT))}};var rr=class I5{constructor({logsPerSecond:t=20,samplesLog:e=100,samplesGraph:i=10,precision:n=2,minimal:s=!1,horizontal:o=!0,mode:a=0}={}){this.mode=a,this.horizontal=o,this.container=document.createElement("div"),this.container.style.cssText="position:fixed;top:0;left:0;opacity:0.9;z-index:10000;",s&&(this.container.style.cssText+="cursor:pointer"),this.gl=null,this.query=null,this.minimal=s,this.beginTime=(performance||Date).now(),this.prevTime=this.beginTime,this.prevCpuTime=this.beginTime,this.frames=0,this.averageCpu={logs:[],graph:[]},this.averageGpu={logs:[],graph:[]},this.queryCreated=!1,this.fpsPanel=this.addPanel(new I5.Panel("FPS","#0ff","#002"),0),this.msPanel=this.addPanel(new I5.Panel("CPU","#0f0","#020"),1),this.gpuPanel=null,this.samplesLog=e,this.samplesGraph=i,this.precision=n,this.logsPerSecond=t,this.minimal?(this.container.addEventListener("click",v=>{v.preventDefault(),this.showPanel(++this.mode%this.container.children.length)},!1),this.mode=a,this.showPanel(this.mode)):window.addEventListener("resize",()=>{this.resizePanel(this.fpsPanel,0),this.resizePanel(this.msPanel,1),this.gpuPanel&&this.resizePanel(this.gpuPanel,2)})}resizePanel(t,e){t.canvas.style.position="absolute",this.minimal?t.canvas.style.display="none":(t.canvas.style.display="block",this.horizontal?(t.canvas.style.top="0px",t.canvas.style.left=e*t.WIDTH/t.PR+"px"):(t.canvas.style.left="0px",t.canvas.style.top=e*t.HEIGHT/t.PR+"px"))}addPanel(t,e){return t.canvas&&(this.container.appendChild(t.canvas),this.resizePanel(t,e)),t}showPanel(t){for(let e=0;e<this.container.children.length;e++){let i=this.container.children[e];i.style.display=e===t?"block":"none"}this.mode=t}init(t){if(t){if(t instanceof WebGL2RenderingContext)this.gl=t;else if(t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas){if(this.gl=t.getContext("webgl2"),!this.gl)return}else return;this.ext=this.gl.getExtension("EXT_disjoint_timer_query_webgl2"),this.ext&&(this.gpuPanel=this.addPanel(new I5.Panel("GPU","#ff0","#220"),2))}}begin(){if(this.beginProfiling("cpu-started"),!(!this.gl||!this.ext)){if(this.query){let t=this.gl.getQueryParameter(this.query,this.gl.QUERY_RESULT_AVAILABLE);if(this.disjoint=this.gl.getParameter(this.ext.GPU_DISJOINT_EXT),t&&!this.disjoint){this.ns=this.gl.getQueryParameter(this.query,this.gl.QUERY_RESULT);let e=this.ns*1e-6;(t||this.disjoint)&&(this.gl.deleteQuery(this.query),this.query=null),t&&this.addToAverage(e,this.averageGpu)}}this.query||(this.queryCreated=!0,this.query=this.gl.createQuery(),this.query&&this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,this.query))}}end(){this.beginTime=this.endInternal(),this.endProfiling("cpu-started","cpu-finished","cpu-duration",this.averageCpu),!(!this.gl||!this.ext)&&this.queryCreated&&this.gl.getQuery(this.ext.TIME_ELAPSED_EXT,this.gl.CURRENT_QUERY)&&this.gl.endQuery(this.ext.TIME_ELAPSED_EXT)}endInternal(){this.frames++;let t=(performance||Date).now();if(t>=this.prevCpuTime+1e3/this.logsPerSecond&&(this.updatePanel(this.msPanel,this.averageCpu),this.updatePanel(this.gpuPanel,this.averageGpu),this.prevCpuTime=t),t>=this.prevTime+1e3){let e=this.frames*1e3/(t-this.prevTime);this.fpsPanel.update(e,e,100,100,0),this.prevTime=t,this.frames=0}return t}addToAverage(t,e){e.logs.push(t),e.logs.length>this.samplesLog&&e.logs.shift(),e.graph.push(t),e.graph.length>this.samplesGraph&&e.graph.shift()}beginProfiling(t){window.performance&&window.performance.mark(t)}endProfiling(t,e,i,n){if(window.performance&&e){window.performance.mark(e);let s=performance.measure(i,t,e);this.addToAverage(s.duration,n)}}updatePanel(t,e){if(e.logs.length>0){let i=0,n=.01;for(let a=0;a<e.logs.length;a++)i+=e.logs[a],e.logs[a]>n&&(n=e.logs[a]);let s=0,o=.01;for(let a=0;a<e.graph.length;a++)s+=e.graph[a],e.graph[a]>o&&(o=e.graph[a]);t&&t.update(i/Math.min(e.logs.length,this.samplesLog),s/Math.min(e.graph.length,this.samplesGraph),n,o,this.precision)}}};rr.Panel=B5;var sr=rr;var _0=typeof globalThis.WorkerGlobalScope<"u"&&globalThis instanceof globalThis.WorkerGlobalScope,L1=class{constructor(t,e=0){this.canvas=t;f(this,"stats");f(this,"stats2");f(this,"statsGl");f(this,"total",0);f(this,"denseMode");this.stats=new D1.default,this.stats2=new D1.default,this.statsGl=new sr({minimal:!0}),this.stats2.showPanel(2),this.denseMode=typeof D<"u"&&!0||typeof window<"u"&&window.innerHeight<500,this.initStats(),this.setVisibility(e)}addStat(t,e=80){t.style.position="absolute",this.denseMode&&(t.style.height="12px"),t.style.overflow="hidden",t.style.left="",t.style.top="0",t.style.right=`${this.total}px`,t.style.width="80px",t.style.zIndex="1",t.style.opacity="0.8";let i=document.getElementById("corner-indicator-stats"),n=i??document.body;i&&(t.style.position="relative"),n.appendChild(t),this.total+=e}initStats(){let t=this.stats2.dom.children.length===3;this.addStat(this.stats.dom),t&&this.addStat(this.stats2.dom),this.statsGl.init(this.canvas),this.statsGl.container.style.display="flex",this.statsGl.container.style.justifyContent="flex-end";let e=0;for(let i of this.statsGl.container.children){let n=i;e++===0&&(n.style.display="none"),n.style.position=""}}setVisibility(t){t>0?(this.stats.dom.style.display="block",this.stats2.dom.style.display=t>=2?"block":"none",this.statsGl.container.style.display=t>=2?"block":"none"):(this.stats.dom.style.display="none",this.stats2.dom.style.display="none",this.statsGl.container.style.display="none")}markStart(){this.stats.begin(),this.stats2.begin(),this.statsGl.begin()}markEnd(){this.stats.end(),this.stats2.end(),this.statsGl.end()}dispose(){this.stats.dom.remove(),this.stats2.dom.remove(),this.statsGl.container.remove()}},Ne=class{constructor(t,e,i){this.initOptions=t;this.externalCanvas=e;f(this,"canvas");f(this,"renderer");f(this,"animationFrameId");f(this,"timeoutId");f(this,"lastRenderTime",0);f(this,"previousCanvasWidth",0);f(this,"previousCanvasHeight",0);f(this,"currentWidth",0);f(this,"currentHeight",0);f(this,"pendingResize",!1);f(this,"renderedFps",0);f(this,"fpsInterval");f(this,"stats");f(this,"paused",!1);f(this,"disconnected",!1);f(this,"preRender",()=>{});f(this,"render",t=>{});f(this,"postRender",()=>{});f(this,"sizeChanged",()=>{});f(this,"droppedFpsPercentage",0);f(this,"config");f(this,"onRender",[]);f(this,"inWorldRenderingConfig");f(this,"nonReactiveState");this.config=t.config,e?this.canvas=e:this.addToPage();try{this.renderer=new H5.WebGLRenderer({canvas:this.canvas,preserveDrawingBuffer:!0,logarithmicDepthBuffer:!0,powerPreference:this.config.powerPreference})}catch(s){throw t.callbacks.displayCriticalError(new Error(`Failed to create WebGL context, not possible to render (restart browser): ${s.message}`)),s}this.renderer.useLegacyLights=!0,this.renderer.outputColorSpace=H5.LinearSRGBColorSpace,e||(this.updatePixelRatio(),this.setupResizeListener()),this.sizeUpdated(),this.previousCanvasWidth=this.canvas.width,this.previousCanvasHeight=this.canvas.height;let n="WebGL2RenderingContext"in globalThis;!e&&n&&!_0&&(this.stats=new L1(this.canvas,this.config.statsVisible)),this.setupFpsTracking(),this.startRenderLoop()}setupResizeListener(){if(typeof window>"u")return;let t,e=()=>{t&&clearTimeout(t),t=setTimeout(()=>{this.pendingResize=!0},16)};window.addEventListener("resize",e,{passive:!0})}updatePixelRatio(){if(typeof window>"u")return;let t=window.devicePixelRatio||1;this.renderer.capabilities.isWebGL2||(t=1),this.renderer.setPixelRatio(t)}sizeUpdated(){this.renderer.setSize(this.currentWidth,this.currentHeight,!1)}addToPage(){this.canvas=or(),this.updateCanvasSize()}updateSizeExternal(t,e,i){this.currentWidth=t,this.currentHeight=e,this.renderer.setPixelRatio(i),this.sizeUpdated()}updateCanvasSize(){if(this.externalCanvas||typeof document>"u")return;let t=document.body.offsetWidth,e=document.body.offsetHeight;this.currentWidth!==t&&(this.currentWidth=t),this.currentHeight!==e&&(this.currentHeight=e)}setupFpsTracking(){let t=0;this.fpsInterval=setInterval(()=>{t>0&&(this.droppedFpsPercentage=this.renderedFps/t),t=Math.max(this.renderedFps,t),this.nonReactiveState&&(this.nonReactiveState.fps=this.renderedFps),this.renderedFps=0},1e3)}startRenderLoop(){let t=()=>{if(this.disconnected)return;if(this.config.timeoutRendering){let n=1e3/(this.config.fpsLimit?Math.min(this.config.fpsLimit,60):60);this.timeoutId=setTimeout(t,n)}else this.animationFrameId=requestAnimationFrame(t);if(this.paused||this.renderer.xr.isPresenting&&!this.inWorldRenderingConfig?.vrPageGameRendering)return;if(!this.config.timeoutRendering&&this.config.fpsLimit){let i=performance.now(),n=i-this.lastRenderTime,s=1e3/this.config.fpsLimit;if(n<s)return;this.lastRenderTime=i-n%s}let e=!1;this.pendingResize&&(this.updateCanvasSize(),this.pendingResize=!1),(this.previousCanvasWidth!==this.currentWidth||this.previousCanvasHeight!==this.currentHeight)&&(this.previousCanvasWidth=this.currentWidth,this.previousCanvasHeight=this.currentHeight,this.sizeUpdated(),e=!0),this.frameRender(e),this.config.statsVisible!==void 0&&this.stats?.setVisibility(this.config.statsVisible)};t()}frameRender(t){this.preRender(),this.stats?.markStart(),tr(),globalThis.freezeRender||this.render(t);for(let e of this.onRender)e(t);this.renderedFps++,this.stats?.markEnd(),this.postRender()}setPaused(t){this.paused=t}dispose(){this.disconnected=!0,this.animationFrameId&&cancelAnimationFrame(this.animationFrameId),this.timeoutId&&clearTimeout(this.timeoutId),this.canvas instanceof HTMLCanvasElement&&this.canvas.remove(),clearInterval(this.fpsInterval),this.stats?.dispose(),this.renderer.dispose()}};function or(){let r=document.createElement("canvas");return r.id="viewer-canvas",document.body.appendChild(r),r}var F1=()=>{let r=or(),t=r.transferControlToOffscreen(),e=!1,i=(o,a)=>{},n={width:0,height:0},s=()=>{e||((n.width!==window.innerWidth||n.height!==window.innerHeight)&&(i(window.innerWidth,window.innerHeight),n={width:window.innerWidth,height:window.innerHeight}),requestAnimationFrame(s))};return requestAnimationFrame(s),{canvas:t,destroy(){e=!0,r.remove()},onSizeChanged(o){i=o},get size(){return{width:window.innerWidth,height:window.innerHeight}}}};var ar=0,pt={},U1=40,ue=(r,t=80,e=ar,i=U1)=>{if(_0)return{updateText(){},setVisibility(){}};let n=document.createElement("div");return n.style.position="fixed",n.style.top=`${i??U1}px`,n.style.right=`${e}px`,n.style.backgroundColor="rgba(0, 0, 0, 0.7)",n.style.color="white",n.style.padding="2px",n.style.fontFamily="monospace",n.style.fontSize="12px",n.style.zIndex="100",n.style.pointerEvents="none",document.body.appendChild(n),pt[r]=n,i===void 0&&e===ar&&(U1+=20),{updateText(s){n.innerText!==s&&(n.innerText=s)},setVisibility(s){n.style.display=s?"block":"none"}}};var G1=(r,t)=>{_0||!pt[r]||(pt[r].innerText=t)},vr=r=>{if(!_0)for(let t in pt)pt[t].style.display=r?"block":"none"},lr=()=>{if(!_0)for(let r in pt)Zs(r)},Zs=r=>{_0||!pt[r]||(pt[r].remove(),delete pt[r])};x();R();T();k();x();R();T();k();x();R();T();k();x();R();T();k();function W1(r,t,e,i,n){let s=r.getImageData(t,e,i,n);for(let o=0;o<i;o++)for(let a=0;a<n;a++){let v=(o+a*i)*4;if(s.data[v+3]!==255)return!0}return!1}function z5(r){return r/64}function cr(r,t,e){if(e){if(W1(r,0,0,t,t))return}else if(W1(r,0,0,t,t/2))return;let i=z5(t),n=(s,o,a,v)=>r.clearRect(s*i,o*i,a*i,v*i);n(40,0,8,8),n(48,0,8,8),n(32,8,8,8),n(40,8,8,8),n(48,8,8,8),n(56,8,8,8),e&&(n(4,32,4,4),n(8,32,4,4),n(0,36,4,12),n(4,36,4,12),n(8,36,4,12),n(12,36,4,12),n(20,32,8,4),n(28,32,8,4),n(16,36,4,12),n(20,36,8,12),n(28,36,4,12),n(32,36,8,12),n(44,32,4,4),n(48,32,4,4),n(40,36,4,12),n(44,36,4,12),n(48,36,4,12),n(52,36,12,12),n(4,48,4,4),n(8,48,4,4),n(0,52,4,12),n(4,52,4,12),n(8,52,4,12),n(12,52,4,12),n(52,48,4,4),n(56,48,4,4),n(48,52,4,12),n(52,52,4,12),n(56,52,4,12),n(60,52,4,12))}function Xs(r,t){r.save(),r.scale(-1,1);let e=z5(t),i=(n,s,o,a,v,l)=>r.drawImage(r.canvas,n*e,s*e,o*e,a*e,-v*e,l*e,-o*e,a*e);i(4,16,4,4,20,48),i(8,16,4,4,24,48),i(0,20,4,12,24,52),i(4,20,4,12,20,52),i(8,20,4,12,16,52),i(12,20,4,12,28,52),i(44,16,4,4,36,48),i(48,16,4,4,40,48),i(40,20,4,12,40,52),i(44,20,4,12,36,52),i(48,20,4,12,32,52),i(52,20,4,12,44,52),r.restore()}function V1(r,t){let e=!1;if(t.width!==t.height)if(t.width===2*t.height)e=!0;else throw new Error(`Bad skin size: ${t.width}x${t.height}`);let i=r.getContext("2d",{willReadFrequently:!0});if(e){let n=t.width;r.width=n,r.height=n,i.clearRect(0,0,n,n),i.drawImage(t,0,0,n,n/2),Xs(i,n),cr(i,r.width,!1)}else r.width=t.width,r.height=t.height,i.clearRect(0,0,t.width,t.height),i.drawImage(t,0,0,r.width,r.height),cr(i,r.width,!0)}function $s(r){if(r.width===2*r.height)return r.width/64;if(r.width*17===r.height*22)return r.width/22;if(r.width*11===r.height*23)return r.width/46;throw new Error(`Bad cape size: ${r.width}x${r.height}`)}function N1(r,t){let e=$s(t);r.width=64*e,r.height=32*e;let i=r.getContext("2d",{willReadFrequently:!0});i.clearRect(0,0,r.width,r.height),i.drawImage(t,0,0,t.width,t.height)}function to(r,t,e,i,n){let s=r.getImageData(t,e,i,n);for(let o=0;o<i;o++)for(let a=0;a<n;a++){let v=(o+a*i)*4;if(!(s.data[v+0]===0&&s.data[v+1]===0&&s.data[v+2]===0&&s.data[v+3]===255))return!1}return!0}function eo(r,t,e,i,n){let s=r.getImageData(t,e,i,n);for(let o=0;o<i;o++)for(let a=0;a<n;a++){let v=(o+a*i)*4;if(!(s.data[v+0]===255&&s.data[v+1]===255&&s.data[v+2]===255&&s.data[v+3]===255))return!1}return!0}function j1(r){let t=z5(r.width),e=r.getContext("2d",{willReadFrequently:!0}),i=(a,v,l,c)=>W1(e,a*t,v*t,l*t,c*t),n=(a,v,l,c)=>to(e,a*t,v*t,l*t,c*t),s=(a,v,l,c)=>eo(e,a*t,v*t,l*t,c*t);return i(50,16,2,4)||i(54,20,2,12)||i(42,48,2,4)||i(46,52,2,12)||n(50,16,2,4)&&n(54,20,2,12)&&n(42,48,2,4)&&n(46,52,2,12)||s(50,16,2,4)&&s(54,20,2,12)&&s(42,48,2,4)&&s(46,52,2,12)?"slim":"default"}function Y1(r,t){if(t.width!==t.height&&t.width!==2*t.height)throw new Error(`Bad skin size: ${t.width}x${t.height}`);let e=z5(t.width),i=14*e,n=7*e;r.width=i,r.height=n;let s=r.getContext("2d",{willReadFrequently:!0});s.clearRect(0,0,i,n),s.drawImage(t,24*e,0,i,n,0,0,i,n)}x();R();T();k();import io from"mc-assets/dist/other-textures/latest/entity/player/wide/steve.png";x();R();T();k();import*as gt from"three";var A0=(r,t=!1)=>{r instanceof gt.Mesh&&(r.geometry?.dispose?.(),r.material?.dispose?.()),r.children&&r.children.forEach(e=>A0(e,t)),t&&r instanceof gt.Mesh&&r.material?.map?.dispose?.()},Q1={},dr={},O5=r=>{let t=new gt.Texture,e=C5(r).then(i=>{let n=new OffscreenCanvas(i.width,i.height);return n.getContext("2d").drawImage(i,0,0),t.source.data=n,t.needsUpdate=!0,t});return{texture:t,promise:e}},Rt=async r=>O5(r).texture,K1=r=>{let t=L0(r.width,r.height);t.getContext("2d").drawImage(r,0,0);let i=new gt.Texture(t);return i.magFilter=gt.NearestFilter,i.minFilter=gt.NearestFilter,i};async function D5(r,t,e){if(!Q1[r]){let{promise:n,resolve:s}=Promise.withResolvers(),o=O5(r);Q1[r]=o.texture,o.promise.then(s),dr[r]=n}t(Q1[r]),dr[r].then(()=>{e?.()})}var vt=io,Kd=Rt(vt),ur={apiEnabled:!0},fr=r=>{Object.assign(ur,r)};async function kt(r,t){if(!ur.apiEnabled||t==="cape")return;let e=`https://playerdb.co/api/player/minecraft/${r}`,i=await fetch(e);return i.ok?(await i.json()).data.player.skin_texture:void 0}async function Yt(r){r.startsWith("data:")||(r=await no(r.replace("http://","https://")));let t=await C5(r),e=L0(64,64);return V1(e,t),{canvas:e,image:t}}var no=async r=>{let e=await(await fetch(r,{})).arrayBuffer();return`data:image/png;base64,${L.from(e).toString("base64")}`};x();R();T();k();var ro=r=>{let t=r%24e3/24e3-.25;return t<0&&(t+=1),t>1&&(t-=1),t+(1-Math.cos(t*Math.PI))/2},so=r=>{let t=(r%24e3+24e3)%24e3,e=ro(t),n=Math.cos(e*Math.PI*2)*.5+.5,s=Math.round(4+n*11);return Math.max(4,Math.min(15,s))},J1=r=>{let t=(r%24e3+24e3)%24e3;if(t>=0&&t<12e3)return 15;if(t>=12e3&&t<13e3){let e=(t-12e3)/1e3;return Math.round(15-e*11)}else{if(t>=13e3&&t<23e3)return 4;{let e=(t-23e3)/1e3;return Math.round(4+e*11)}}},oo=()=>{let r=[{ticks:0,label:"6:00 AM (sunrise)"},{ticks:6e3,label:"12:00 PM (noon)"},{ticks:12e3,label:"6:00 PM (sunset starts)"},{ticks:12500,label:"6:30 PM (sunset mid)"},{ticks:13e3,label:"7:00 PM (night begins)"},{ticks:18e3,label:"12:00 AM (midnight)"},{ticks:19e3,label:"1:00 AM"},{ticks:23e3,label:"5:00 AM (dawn begins)"},{ticks:23500,label:"5:30 AM (dawn mid)"}];for(let{ticks:t,label:e}of r){let i=so(t),n=J1(t)}};typeof window<"u"&&(window.debugSkyLight=oo);function lo(r,t){return(r%t+t)%t}var Kt=class Kt{constructor(t,e,i){this.resourcesManager=t;this.displayOptions=e;this.initOptions=i;f(this,"worldReadyResolvers",Promise.withResolvers());f(this,"worldReadyPromise",this.worldReadyResolvers.promise);f(this,"timeOfTheDay",0);f(this,"worldSizeParams",{minY:0,worldHeight:256});f(this,"reactiveDebugParams",ao({stopRendering:!1,chunksRenderAboveOverride:void 0,chunksRenderAboveEnabled:!1,chunksRenderBelowOverride:void 0,chunksRenderBelowEnabled:!1,chunksRenderDistanceOverride:void 0,chunksRenderDistanceEnabled:!1,disableEntities:!1}));f(this,"active",!1);f(this,"loadedChunks",{});f(this,"finishedChunks",{});f(this,"finishedSections",{});f(this,"sectionsWaiting",new Map);f(this,"queuedChunks",new Set);f(this,"queuedFunctions",[]);f(this,"renderUpdateEmitter",new Wt);f(this,"customTexturesDataUrl");f(this,"workers",[]);f(this,"viewerChunkPosition");f(this,"lastCamUpdate",0);f(this,"droppedFpsPercentage",0);f(this,"initialChunkLoadWasStartedIn");f(this,"initialChunksLoad",!0);f(this,"enableChunksLoadDelay",!1);f(this,"texturesVersion");f(this,"viewDistance",-1);f(this,"onRenderDistanceChanged");f(this,"chunksLength",0);f(this,"allChunksFinished",!1);f(this,"messageQueue",[]);f(this,"isProcessingQueue",!1);f(this,"ONMESSAGE_TIME_LIMIT",30);f(this,"handleResize",()=>{});f(this,"highestBlocksByChunks",new Map);f(this,"blockEntities",{});f(this,"workersProcessAverageTime",0);f(this,"workersProcessAverageTimeCount",0);f(this,"maxWorkersProcessTime",0);f(this,"geometryReceiveCount",{});f(this,"allLoadedIn");f(this,"onWorldSwitched",[]);f(this,"renderTimeMax",0);f(this,"renderTimeAvg",0);f(this,"renderTimeAvgCount",0);f(this,"edgeChunks",{});f(this,"lastAddChunk",null);f(this,"neighborChunkUpdates",!0);f(this,"lastChunkDistance",0);f(this,"debugStopGeometryUpdate",!1);f(this,"protocolCustomBlocks",new Map);f(this,"heightmapDebounceTimers",new Map);f(this,"sectionDirtyCount",new Map);f(this,"sectionDirtyTimers",new Map);f(this,"sectionDirtyPendingArgs",new Map);f(this,"blockStateModelInfo",new Map);f(this,"worldBlockProvider");f(this,"soundSystem");f(this,"worldRendererConfig");f(this,"playerStateReactive");f(this,"playerStateUtils");f(this,"reactiveState");f(this,"mesherLogReader");f(this,"forceCallFromMesherReplayer",!1);f(this,"stopMesherMessagesProcessing",!1);f(this,"abortController",new AbortController);f(this,"lastRendered",0);f(this,"renderingActive",!0);f(this,"geometryReceiveCountPerSec",0);f(this,"mesherLogger",{contents:[],active:new URL(location.href).searchParams.get("mesherlog")==="true"});f(this,"currentRenderedFrames",0);f(this,"fpsAverage",0);f(this,"lastFps",0);f(this,"fpsWorst");f(this,"fpsSamples",0);f(this,"backendInfoReport","-");f(this,"chunksFullInfo","-");f(this,"workerCustomHandleTime",0);f(this,"queueAwaited",!1);f(this,"toWorkerMessagesQueue",{});this.snapshotInitialValues(),this.worldRendererConfig=e.inWorldRenderingConfig,this.playerStateReactive=e.playerStateReactive,this.playerStateUtils=Dn(this.playerStateReactive),this.reactiveState=e.rendererState,this.renderUpdateEmitter.on("update",()=>{let o=Object.keys(this.finishedChunks).length;G1("loaded-chunks",`${o}/${this.chunksLength} chunks (${this.lastChunkDistance}/${this.viewDistance})`)}),ue("downloaded-chunks",100,140,20),this.connect(this.displayOptions.worldView);let n=setInterval(()=>{this.geometryReceiveCountPerSec=Object.values(this.geometryReceiveCount).reduce((o,a)=>o+a,0),this.geometryReceiveCount={},vr(this.displayAdvancedStats),this.updateChunksStats()},500),s=setInterval(()=>{this.fpsUpdate()},1e3);this.abortController.signal.addEventListener("abort",()=>{clearInterval(n),clearInterval(s)})}anyModuleRequiresHeightmap(){return!1}get version(){return this.displayOptions.version}get displayAdvancedStats(){return(this.initOptions.config.statsVisible??0)>1}fpsUpdate(){this.fpsSamples++,this.fpsAverage=(this.fpsAverage*(this.fpsSamples-1)+this.currentRenderedFrames)/this.fpsSamples,this.fpsWorst===void 0?this.fpsWorst=this.currentRenderedFrames:this.fpsWorst=Math.min(this.fpsWorst,this.currentRenderedFrames),this.lastFps=this.currentRenderedFrames,this.displayOptions.nonReactiveState.fps=this.currentRenderedFrames,this.displayOptions.nonReactiveState.worstRenderTime=this.renderTimeMax,this.displayOptions.nonReactiveState.avgRenderTime=this.renderTimeAvg,this.currentRenderedFrames=0}logWorkerWork(t){this.mesherLogger.active&&this.mesherLogger.contents.push(typeof t=="function"?t():t)}async init(){if(this.active)throw new Error("WorldRendererCommon is already initialized");await Promise.all([this.resetWorkers(),(async()=>{this.resourcesManager.currentResources?.allReady&&await this.updateAssetsData()})()]),this.resourcesManager.on("assetsTexturesUpdated",async()=>{this.active&&await this.updateAssetsData()}),this.watchReactivePlayerState(),this.watchReactiveConfig(),this.worldReadyResolvers.resolve()}snapshotInitialValues(){}wasChunkSentToWorker(t){return this.loadedChunks[t]}async getHighestBlocks(t){return this.highestBlocksByChunks.get(t)}updateCustomBlock(t,e,i){if(this.protocolCustomBlocks.set(t,{...this.protocolCustomBlocks.get(t),[e]:i}),this.logWorkerWork(()=>`-> updateCustomBlock ${t} ${e} ${i} ${this.wasChunkSentToWorker(t)}`),this.wasChunkSentToWorker(t)){let[n,s,o]=e.split(",").map(Number);this.setBlockStateId(new Qt(n,s,o),void 0)}}async getBlockInfo(t,e){let n=`${Math.floor(t.x/16)*16},${Math.floor(t.z/16)*16}`,s=this.protocolCustomBlocks.get(n)?.[`${t.x},${t.y},${t.z}`],o=ir(e,s),a=this.blockStateModelInfo.get(o);return{customBlockName:s,modelInfo:a}}initWorkers(t=this.worldRendererConfig.mesherWorkers){for(let e=0;e<t+0;e++){let i=co(n=>{Array.isArray(n)?this.messageQueue.push(...n):this.messageQueue.push(n),this.processMessageQueue("worker")},this.worldRendererConfig.wasmMesher?"mesherWasm.js":"mesher.js");this.workers.push(i)}}onReactivePlayerStateUpdated(t,e,i=!0){return i&&e(this.playerStateReactive[t]),q1(this.playerStateReactive,t,e)}onReactiveConfigUpdated(t,e){e(this.worldRendererConfig[t]),t==="*"?vo(this.worldRendererConfig,e):q1(this.worldRendererConfig,t,e)}onReactiveDebugUpdated(t,e){e(this.reactiveDebugParams[t]),q1(this.reactiveDebugParams,t,e)}watchReactivePlayerState(){this.onReactivePlayerStateUpdated("backgroundColor",t=>{this.changeBackgroundColor(t)})}watchReactiveConfig(){this.onReactiveConfigUpdated("fetchPlayerSkins",t=>{fr({apiEnabled:t})})}async processMessageQueue(t){if(this.isProcessingQueue||this.messageQueue.length===0)return;if(this.logWorkerWork(`# ${t} processing queue`),this.lastRendered&&performance.now()-this.lastRendered>this.ONMESSAGE_TIME_LIMIT&&this.worldRendererConfig._experimentalSmoothChunkLoading&&this.renderingActive){let n=performance.now();await new Promise(s=>{requestAnimationFrame(s)}),this.logWorkerWork(`# processing got delayed by ${performance.now()-n}ms`)}this.isProcessingQueue=!0;let e=performance.now(),i=0;for(;this.messageQueue.length>0;){let n=this.stopMesherMessagesProcessing;if(!n){let s=this.messageQueue.shift();this.handleMessage(s),i++}if(n||performance.now()-e>this.ONMESSAGE_TIME_LIMIT&&this.renderingActive&&this.worldRendererConfig._experimentalSmoothChunkLoading){if(this.messageQueue.length>0){requestAnimationFrame(async()=>{this.isProcessingQueue=!1,this.processMessageQueue("queue-delay")});return}break}}this.isProcessingQueue=!1}handleMessage(t){var i,n;let e=t;if(this.active){if(this.mesherLogReader?.workerMessageReceived(e.type,e),e.type!=="geometry"||!this.debugStopGeometryUpdate){let s=performance.now();this.handleWorkerMessage(e),this.workerCustomHandleTime+=performance.now()-s}if(e.type==="geometry"){this.logWorkerWork(()=>`-> ${e.workerIndex} geometry ${e.key} ${JSON.stringify({dataSize:JSON.stringify(e).length})}`),(i=this.geometryReceiveCount)[n=e.workerIndex]??(i[n]=0),this.geometryReceiveCount[e.workerIndex]++;let s=e.key.split(",").map(Number);this.lastChunkDistance=Math.max(...this.getDistance(new Qt(s[0],0,s[2])))}if(e.type==="sectionFinished"){if(this.logWorkerWork(`<- ${e.workerIndex} sectionFinished ${e.key} ${JSON.stringify({processTime:e.processTime})}`),!this.sectionsWaiting.has(e.key))throw new Error(`sectionFinished event for non-outstanding section ${e.key}`);this.sectionsWaiting.set(e.key,this.sectionsWaiting.get(e.key)-1),this.sectionsWaiting.get(e.key)===0&&(this.sectionsWaiting.delete(e.key),this.finishedSections[e.key]=!0);let s=e.key.split(",").map(Number),o=`${s[0]},${s[2]}`;if(this.loadedChunks[o]){let a=!0,v=this.getSectionHeight();if(Ve){let l=this.worldMinYRender;this.finishedSections[`${s[0]},${l},${s[2]}`]||(a=!1)}else for(let l=this.worldMinYRender;l<this.worldSizeParams.worldHeight;l+=v)if(!this.finishedSections[`${s[0]},${l},${s[2]}`]){a=!1;break}if(a){this.finishedChunks[o]=!0;let l=16;this.reactiveState.world.chunksLoaded.add(`${Math.floor(s[0]/l)},${Math.floor(s[2]/l)}`),this.renderUpdateEmitter.emit("chunkFinished",`${s[0]},${s[2]}`),this.checkAllFinished()}}this.renderUpdateEmitter.emit("update"),e.processTime&&(this.workersProcessAverageTimeCount++,this.workersProcessAverageTime=(this.workersProcessAverageTime*(this.workersProcessAverageTimeCount-1)+e.processTime)/this.workersProcessAverageTimeCount,this.maxWorkersProcessTime=Math.max(this.maxWorkersProcessTime,e.processTime))}if(e.type==="blockStateModelInfo")for(let[s,o]of Object.entries(e.info))this.blockStateModelInfo.set(s,o);e.type==="heightmap"&&this.reactiveState.world.heightmaps.set(e.key,new Int16Array(e.heightmap))}}downloadMesherLog(){let t=document.createElement("a");t.href="data:text/plain;charset=utf-8,"+encodeURIComponent(this.mesherLogger.contents.join(`
|
|
16
|
-
`)),t.download="mesher.log",t.click()}checkAllFinished(){this.sectionsWaiting.size===0&&(this.reactiveState.world.mesherWork=!1),Object.keys(this.finishedChunks).length>=this.chunksLength&&(this.allChunksLoaded?.(),this.allChunksFinished=!0,this.allLoadedIn??(this.allLoadedIn=Date.now()-this.initialChunkLoadWasStartedIn)),this.updateChunksStats()}changeHandSwingingState(t,e){}updateViewerPosition(t){this.viewerChunkPosition=t;for(let[e,i]of Object.entries(this.loadedChunks))i&&this.updatePosDataChunk?.(e)}sendWorkers(t){for(let e of this.workers)e.postMessage(t)}getDistance(t){let[e,i]=de(this.viewerChunkPosition),n=16,s=Math.abs(e-Math.floor(t.x/n)),o=Math.abs(i-Math.floor(t.z/n));return[s,o]}resetWorld(){for(let t of this.workers)t.terminate();this.workers=[]}async resetWorkers(){this.resetWorld(),typeof document<"u"&&document?.readyState==="loading"&&await new Promise(t=>{document.addEventListener("DOMContentLoaded",t)}),this.initWorkers(),this.active=!0,this.sendMesherMcData()}getMesherConfig(){let t=this.timeOfTheDay,e=t<0||t>24e3?15:J1(t);return{version:this.version,enableLighting:this.worldRendererConfig.enableLighting,skyLight:e,smoothLighting:this.worldRendererConfig.smoothLighting,outputFormat:this.outputFormat,debugModelVariant:this.worldRendererConfig.debugModelVariant,clipWorldBelowY:this.worldRendererConfig.clipWorldBelowY,disableBlockEntityTextures:!this.worldRendererConfig.extraBlockRenderers,worldMinY:this.worldMinYRender,worldMaxY:this.worldMinYRender+this.worldSizeParams.worldHeight}}sendMesherMcData(){let t=this.resourcesManager.currentResources.mcData;Z1(this.workers,this.version,We,t),this.logWorkerWork("# mcData sent")}async updateAssetsData(){let t=this.resourcesManager.currentResources;if(this.workers.length===0)throw new Error("workers not initialized yet");for(let[e,i]of this.workers.entries()){let{blockstatesModels:n}=t;i.postMessage({type:"mesherData",workerIndex:e,blocksAtlas:{latest:t.blocksAtlasJson},blockstatesModels:n,config:this.getMesherConfig()})}this.logWorkerWork("# mesherData sent")}getSectionHeight(){return Ve?this.worldSizeParams.worldHeight:er}get worldMinYRender(){let t=this.getSectionHeight();return Math.floor(Math.max(this.worldSizeParams.minY,this.worldRendererConfig.clipWorldBelowY??-1/0)/t)*t}updateChunksStats(){let t=Object.keys(this.finishedChunks);this.displayOptions.nonReactiveState.world.chunksLoaded=new Set(t),this.displayOptions.nonReactiveState.world.chunksTotalNumber=this.chunksLength,this.reactiveState.world.allChunksLoaded=this.allChunksFinished;let e=`Q: ${this.messageQueue.length} ${Object.keys(this.loadedChunks).length}/${Object.keys(this.finishedChunks).length}/${this.chunksLength} chunks (${this.workers.length}:${this.workersProcessAverageTime.toFixed(0)}ms/${this.geometryReceiveCountPerSec}ss/${this.allLoadedIn?.toFixed(1)??"-"}s)`;this.chunksFullInfo=e,G1("downloaded-chunks",e)}addColumn(t,e,i,n){if(!this.active)return;if(this.workers.length===0)throw new Error("workers not initialized yet");this.initialChunksLoad=!1,this.initialChunkLoadWasStartedIn??(this.initialChunkLoadWasStartedIn=Date.now()),this.loadedChunks[`${t},${e}`]=!0,this.updateChunksStats();let s=`${t},${e}`,o=this.protocolCustomBlocks.get(s);for(let l of this.workers)l.postMessage({type:"chunk",x:t,z:e,chunk:i,customBlockModels:o||void 0});this.workers[0].postMessage({type:"getHeightmap",x:t,z:e}),this.logWorkerWork(()=>`-> chunk ${JSON.stringify({x:t,z:e,chunkLength:i.length,customBlockModelsLength:o?Object.keys(o).length:0})}`),this.mesherLogReader?.chunkReceived(t,e,i.length);let a=this.getSectionHeight(),v=16;if(Ve){let l=new Qt(t,this.worldMinYRender,e);this.setSectionDirty(l),this.neighborChunkUpdates&&(!n||this.worldRendererConfig.smoothLighting)&&(this.setSectionDirty(l.offset(-v,0,0)),this.setSectionDirty(l.offset(v,0,0)),this.setSectionDirty(l.offset(0,0,-v)),this.setSectionDirty(l.offset(0,0,v)))}else for(let l=this.worldMinYRender;l<this.worldSizeParams.worldHeight;l+=a){let c=new Qt(t,l,e);this.setSectionDirty(c),this.neighborChunkUpdates&&(!n||this.worldRendererConfig.smoothLighting)&&(this.setSectionDirty(c.offset(-v,0,0)),this.setSectionDirty(c.offset(v,0,0)),this.setSectionDirty(c.offset(0,0,-v)),this.setSectionDirty(c.offset(0,0,v)))}}markAsLoaded(t,e){this.loadedChunks[`${t},${e}`]=!0,this.finishedChunks[`${t},${e}`]=!0,this.logWorkerWork(`-> markAsLoaded ${JSON.stringify({x:t,z:e})}`),this.checkAllFinished()}removeColumn(t,e){delete this.loadedChunks[`${t},${e}`];let i=`${t},${e}`,n=this.heightmapDebounceTimers.get(i);n&&(clearTimeout(n),this.heightmapDebounceTimers.delete(i));for(let[o,a]of this.sectionDirtyTimers)o.startsWith(`${t},`)&&o.endsWith(`,${e}`)&&(clearTimeout(a),this.sectionDirtyTimers.delete(o),this.sectionDirtyCount.delete(o),this.sectionDirtyPendingArgs.delete(o));for(let o of this.workers)o.postMessage({type:"unloadChunk",x:t,z:e});this.logWorkerWork(`-> unloadChunk ${JSON.stringify({x:t,z:e})}`),delete this.finishedChunks[`${t},${e}`],this.allChunksFinished=Object.keys(this.finishedChunks).length===this.chunksLength,Object.keys(this.finishedChunks).length===0&&(this.allLoadedIn=void 0,this.initialChunkLoadWasStartedIn=void 0);let s=this.getSectionHeight();if(Ve){let o=this.worldMinYRender;this.setSectionDirty(new Qt(t,o,e),!1),delete this.finishedSections[`${t},${o},${e}`]}else for(let o=this.worldSizeParams.minY;o<this.worldSizeParams.worldHeight;o+=s)this.setSectionDirty(new Qt(t,o,e),!1),delete this.finishedSections[`${t},${o},${e}`];this.highestBlocksByChunks.delete(`${t},${e}`),this.reactiveState.world.heightmaps.delete(`${Math.floor(t/16)},${Math.floor(e/16)}`),this.updateChunksStats(),Object.keys(this.loadedChunks).length===0&&(this.mesherLogger.contents=[],this.logWorkerWork("# all chunks unloaded. New log started"),this.mesherLogReader?.maybeStartReplay())}setBlockStateId(t,e,i=!0){(async()=>{let o=Math.floor(t.x/16)*16,a=Math.floor(t.z/16)*16;this.queuedChunks.has(`${o},${a}`)&&await new Promise(v=>{this.queuedFunctions.push(()=>{v()})}),this.loadedChunks[`${o},${a}`],this.setBlockStateIdInner(t,e,i)})()}updateEntity(t,e=!1){}lightUpdate(t,e){}connect(t){let e=t;e.on("entity",n=>{this.updateEntity(n,!1)}),e.on("entityMoved",n=>{this.updateEntity(n,!0)}),e.on("playerEntity",n=>{this.updatePlayerEntity?.(n)});let i=null;e.on("loadChunk",({x:n,z:s,chunk:o,worldConfig:a,isLightUpdate:v})=>{this.worldSizeParams=a,this.queuedChunks.add(`${n},${s}`);let l=[n,s,o,v];i||(i={data:[],timeout:setTimeout(()=>{for(let c of i.data)this.queuedChunks.delete(`${c[0]},${c[1]}`),this.addColumn(...c);for(let c of this.queuedFunctions)c();this.queuedFunctions=[],i=null},this.worldRendererConfig.addChunksBatchWaitTime)}),i.data.push(l)}),e.on("blockEntities",n=>{this.blockEntities=n}),e.on("unloadChunk",({x:n,z:s})=>{this.removeColumn(n,s)}),e.on("blockUpdate",({pos:n,stateId:s})=>{this.setBlockStateId(new Qt(n.x,n.y,n.z),s)}),e.on("chunkPosUpdate",({pos:n})=>{this.updateViewerPosition(n)}),e.on("end",()=>{this.worldStop?.()}),e.on("renderDistance",n=>{this.viewDistance=n,this.chunksLength=n===0?1:De(n).length,this.allChunksFinished=Object.keys(this.finishedChunks).length===this.chunksLength,this.onRenderDistanceChanged?.(n)}),e.on("markAsLoaded",({x:n,z:s})=>{this.markAsLoaded(n,s)}),e.on("updateLight",({pos:n})=>{this.lightUpdate(n.x,n.z)}),e.on("onWorldSwitch",()=>{for(let n of this.onWorldSwitched)try{n()}catch(s){setTimeout(()=>{throw s},0)}}),e.on("time",n=>{this.worldRendererConfig.dayCycle&&(this.timeUpdated?.(n),this.timeOfTheDay=n)}),e.on("biomeUpdate",({biome:n})=>{this.biomeUpdated?.(n)}),e.on("biomeReset",()=>{this.biomeReset?.()})}setBlockStateIdInner(t,e,i=!0){let s=`${Math.floor(t.x/16)*16},${Math.floor(t.z/16)*16}`,o=`${t.x},${t.y},${t.z}`,a=this.protocolCustomBlocks.get(s)||{};for(let v of this.workers)v.postMessage({type:"blockUpdate",pos:t,stateId:e,customBlockModels:a});if(this.anyModuleRequiresHeightmap()){let v=Math.floor(t.x/16)*16,l=Math.floor(t.z/16)*16,c=`${v},${l}`,d=this.heightmapDebounceTimers.get(c);d&&clearTimeout(d),this.heightmapDebounceTimers.set(c,setTimeout(()=>{this.heightmapDebounceTimers.delete(c),this.workers[0]?.postMessage({type:"getHeightmap",x:v,z:l})},100))}if(this.logWorkerWork(`-> blockUpdate ${JSON.stringify({pos:t,stateId:e,customBlockModels:a})}`),this.setSectionDirty(t,!0,!0),this.neighborChunkUpdates){let l=this.getSectionHeight();t.x&15||this.setSectionDirty(t.offset(-16,0,0),!0,!0),(t.x&15)===15&&this.setSectionDirty(t.offset(16,0,0),!0,!0),t.y&l-1||this.setSectionDirty(t.offset(0,-l,0),!0,!0),(t.y&l-1)===l-1&&this.setSectionDirty(t.offset(0,l,0),!0,!0),t.z&15||this.setSectionDirty(t.offset(0,0,-16),!0,!0),(t.z&15)===15&&this.setSectionDirty(t.offset(0,0,16),!0,!0),i&&(!(t.x&15)&&!(t.z&15)&&this.setSectionDirty(t.offset(-16,0,-16),!0,!0),(t.x&15)===15&&!(t.z&15)&&this.setSectionDirty(t.offset(16,0,-16),!0,!0),!(t.x&15)&&(t.z&15)===15&&this.setSectionDirty(t.offset(-16,0,16),!0,!0),(t.x&15)===15&&(t.z&15)===15&&this.setSectionDirty(t.offset(16,0,16),!0,!0),!(t.x&15)&&!(t.y&l-1)&&this.setSectionDirty(t.offset(-16,-l,0),!0,!0),(t.x&15)===15&&!(t.y&l-1)&&this.setSectionDirty(t.offset(16,-l,0),!0,!0),!(t.z&15)&&!(t.y&l-1)&&this.setSectionDirty(t.offset(0,-l,-16),!0,!0),(t.z&15)===15&&!(t.y&l-1)&&this.setSectionDirty(t.offset(0,-l,16),!0,!0),!(t.y&l-1)&&!(t.x&15)&&!(t.z&15)&&this.setSectionDirty(t.offset(-16,-l,-16),!0,!0),!(t.y&l-1)&&(t.x&15)===15&&!(t.z&15)&&this.setSectionDirty(t.offset(16,-l,-16),!0,!0),!(t.y&l-1)&&!(t.x&15)&&(t.z&15)===15&&this.setSectionDirty(t.offset(-16,-l,16),!0,!0),!(t.y&l-1)&&(t.x&15)===15&&(t.z&15)===15&&this.setSectionDirty(t.offset(16,-l,16),!0,!0))}}getWorkerNumber(t,e=!1){let n=this.getSectionHeight();if(e){let o=`${Math.floor(t.x/16)*16},${Math.floor(t.y/n)*n},${Math.floor(t.z/16)*16}`;if(!(this.sectionsWaiting.get(o)&&!this.finishedSections[o]))return 0}return lo(Math.floor(t.x/16)+Math.floor(t.y/n)+Math.floor(t.z/16),this.workers.length)+0}async debugGetWorkerCustomBlockModel(t){let e=[];for(let i of this.workers)e.push(new Promise(n=>{i.addEventListener("message",s=>{s.data.type==="customBlockModel"&&n(s.data.customBlockModel)})})),i.postMessage({type:"getCustomBlockModel",pos:t});return Promise.all(e)}setSectionDirty(t,e=!0,i=!1){if(!this.forceCallFromMesherReplayer&&this.mesherLogReader)return;if(this.viewDistance===-1)throw new Error("viewDistance not set");let n=this.getDistance(t);if(!this.workers.length||n[0]>this.viewDistance||n[1]>this.viewDistance)return;if(!e){this._dispatchDirtyImmediate(t,e,i);return}let s=16,o=this.getSectionHeight(),a=`${Math.floor(t.x/s)*s},${Math.floor(t.y/o)*o},${Math.floor(t.z/s)*s}`,v=(this.sectionDirtyCount.get(a)??0)+1;this.sectionDirtyCount.set(a,v),v<=Kt.GEOMETRY_THROTTLE_THRESHOLD?(this._dispatchDirtyImmediate(t,e,i),this.sectionDirtyTimers.has(a)||this.sectionDirtyTimers.set(a,setTimeout(()=>{let l=this.sectionDirtyPendingArgs.get(a);this.sectionDirtyCount.delete(a),this.sectionDirtyTimers.delete(a),this.sectionDirtyPendingArgs.delete(a),l&&this._dispatchDirtyImmediate(l.pos,l.value,l.useChangeWorker)},Kt.GEOMETRY_THROTTLE_DELAY))):(this.sectionDirtyPendingArgs.set(a,{pos:t,value:e,useChangeWorker:i}),this.sectionDirtyTimers.has(a)||this.sectionDirtyTimers.set(a,setTimeout(()=>{let l=this.sectionDirtyPendingArgs.get(a);this.sectionDirtyCount.delete(a),this.sectionDirtyTimers.delete(a),this.sectionDirtyPendingArgs.delete(a),l&&this._dispatchDirtyImmediate(l.pos,l.value,l.useChangeWorker)},Kt.GEOMETRY_THROTTLE_DELAY)))}_dispatchDirtyImmediate(t,e,i){var v;this.reactiveState.world.mesherWork=!0;let n=16,s=this.getSectionHeight(),o=`${Math.floor(t.x/n)*n},${Math.floor(t.y/s)*s},${Math.floor(t.z/n)*n}`;this.renderUpdateEmitter.emit("dirty",t,e);let a=this.getWorkerNumber(t,i&&this.mesherLogger.active);this.sectionsWaiting.set(o,(this.sectionsWaiting.get(o)??0)+1),this.forceCallFromMesherReplayer?this.workers[a].postMessage({type:"dirty",x:t.x,y:t.y,z:t.z,value:e,config:this.getMesherConfig()}):((v=this.toWorkerMessagesQueue)[a]??(v[a]=[]),this.toWorkerMessagesQueue[a].push({type:"dirty",x:t.x,y:t.y,z:t.z,value:e,config:this.getMesherConfig()}),this.dispatchMessages())}dispatchMessages(){this.queueAwaited||(this.queueAwaited=!0,setTimeout(()=>{for(let t in this.toWorkerMessagesQueue){this.workers[Number(t)].postMessage(this.toWorkerMessagesQueue[t]);for(let i of this.toWorkerMessagesQueue[t])this.logWorkerWork(`-> ${t} dispatchMessages ${i.type} ${JSON.stringify({x:i.x,y:i.y,z:i.z,value:i.value})}`)}this.toWorkerMessagesQueue={},this.queueAwaited=!1}))}async waitForChunksToRender(){return new Promise((t,e)=>{if([...this.sectionsWaiting].length===0){t();return}let i=()=>{this.sectionsWaiting.size===0&&(this.renderUpdateEmitter.removeListener("update",i),t())};this.renderUpdateEmitter.on("update",i)})}async waitForChunkToLoad(t){return new Promise((e,i)=>{let s=`${Math.floor(t.x/16)*16},${Math.floor(t.z/16)*16}`;if(this.loadedChunks[s]){e();return}let o=()=>{this.loadedChunks[s]&&(this.renderUpdateEmitter.removeListener("update",o),e())};this.renderUpdateEmitter.on("update",o)})}destroy(){for(let t of this.heightmapDebounceTimers.values())clearTimeout(t);this.heightmapDebounceTimers.clear();for(let t of this.sectionDirtyTimers.values())clearTimeout(t);this.sectionDirtyTimers.clear(),this.sectionDirtyCount.clear(),this.sectionDirtyPendingArgs.clear();for(let t of this.workers)t.terminate();this.workers=[],this.soundSystem&&(this.soundSystem.destroy(),this.soundSystem=void 0),this.active=!1,this.loadedChunks={},this.finishedChunks={},this.finishedSections={},this.sectionsWaiting.clear(),this.queuedChunks.clear(),this.blockStateModelInfo.clear(),this.renderUpdateEmitter.removeAllListeners(),this.abortController.abort(),lr()}};f(Kt,"GEOMETRY_THROTTLE_THRESHOLD",1),f(Kt,"GEOMETRY_THROTTLE_DELAY",100);var L5=Kt,co=(r,t="mesher.js")=>{let e;if(D.env.SINGLE_FILE_BUILD){let i=document.getElementById("mesher-worker-code").textContent,n=new Blob([i],{type:"text/javascript"});e=new Worker(window.URL.createObjectURL(n))}else e=new Worker(t);return e.onmessage=({data:i})=>{r(i)},e.on&&e.on("message",i=>{e.onmessage({data:i})}),e},Z1=(r,t,e=We,i)=>{let n={version:JSON.parse(JSON.stringify(i.version))};for(let[s,o]of Object.entries(e))n[s]=i[o];for(let s of r)s.postMessage({type:"mcData",mcData:n})};x();R();T();k();import{Vec3 as uo}from"vec3";import*as X0 from"three";x();R();T();k();function F5(r,t){let e=t/180*Math.PI,i=Math.cos(e),n=Math.sin(e),s={x:0,y:1,z:2}[r],o=(s+1)%3,a=(s+2)%3,v=[[0,0,0],[0,0,0],[0,0,0]];return v[s][s]=1,v[o][o]=i,v[o][a]=-n,v[a][o]=+n,v[a][a]=i,v}function X1(r,t){return t?[r[0]+t[0],r[1]+t[1],r[2]+t[2]]:r}function $1(r,t){return t?[r[0]-t[0],r[1]-t[1],r[2]-t[2]]:r}function fe(r,t){return r?[r[0][0]*t[0]+r[0][1]*t[1]+r[0][2]*t[2],r[1][0]*t[0]+r[1][1]*t[1]+r[1][2]*t[2],r[2][0]*t[0]+r[2][1]*t[1]+r[2][2]*t[2]]:t}function hr(r,t){let e=[[0,0,0],[0,0,0],[0,0,0]],i=r[0][0],n=r[1][0],s=r[2][0],o=r[0][1],a=r[1][1],v=r[2][1],l=r[0][2],c=r[1][2],d=r[2][2],m=t[0][0],p=t[1][0],g=t[2][0],y=t[0][1],E=t[1][1],w=t[2][1],_=t[0][2],C=t[1][2],M=t[2][2];return e[0][0]=i*m+n*y+s*_,e[1][0]=i*p+n*E+s*C,e[2][0]=i*g+n*w+s*M,e[0][1]=o*m+a*y+v*_,e[1][1]=o*p+a*E+v*C,e[2][1]=o*g+a*w+v*M,e[0][2]=l*m+c*y+d*_,e[1][2]=l*p+c*E+d*C,e[2][2]=l*g+c*w+d*M,e}var t2={up:{dir:[0,1,0],mask1:[1,1,0],mask2:[0,1,1],corners:[[0,1,1,0,1],[1,1,1,1,1],[0,1,0,0,0],[1,1,0,1,0]]},down:{dir:[0,-1,0],mask1:[1,1,0],mask2:[0,1,1],corners:[[1,0,1,0,1],[0,0,1,1,1],[1,0,0,0,0],[0,0,0,1,0]]},east:{dir:[1,0,0],mask1:[1,1,0],mask2:[1,0,1],corners:[[1,1,1,0,0],[1,0,1,0,1],[1,1,0,1,0],[1,0,0,1,1]]},west:{dir:[-1,0,0],mask1:[1,1,0],mask2:[1,0,1],corners:[[0,1,0,0,0],[0,0,0,0,1],[0,1,1,1,0],[0,0,1,1,1]]},north:{dir:[0,0,-1],mask1:[1,0,1],mask2:[0,1,1],corners:[[1,0,0,1,1],[0,0,0,0,1],[1,1,0,1,0],[0,1,0,0,0]]},south:{dir:[0,0,1],mask1:[1,0,1],mask2:[0,1,1],corners:[[0,0,1,0,1],[1,0,1,1,1],[0,1,1,0,0],[1,1,1,1,0]]}};function fo(r,t,e,i,n,s,o,a){let v=new uo(0,0,0);for(let l in r.faces){let c=r.faces[l],{corners:d,mask1:m,mask2:p}=t2[l],g=fe(i,t2[l].dir);if(c.cullface&&a[l])continue;let y=r.from[0],E=r.from[1],w=r.from[2],_=r.to[0],C=r.to[1],M=r.to[2],S=c.texture,{u:H}=S,{v:B}=S,{su:I}=S,{sv:W}=S,z=Math.floor(e.positions.length/3),j=[1,1,1];c.tintindex!==void 0&&c.tintindex===0&&(j=[.5686274509803921,.7411764705882353,.34901960784313724]);let q=c.rotation||0,e0=Math.cos(q*Math.PI/180),N=-Math.sin(q*Math.PI/180),Z=null,K=null;r.rotation&&(Z=F5(r.rotation.axis,r.rotation.angle),K=$1(r.rotation.origin,fe(Z,r.rotation.origin)));let n0=[],s0=1;for(let l0 of d){let $=[l0[0]?_:y,l0[1]?C:E,l0[2]?M:w];$=X1(fe(Z,$),K),$=X1(fe(i,$),n),$=$.map(Y0=>Y0/16),e.positions.push($[0],$[1],$[2]),e.normals.push(...g);let u0=(l0[3]-.5)*e0-(l0[4]-.5)*N+.5,$0=(l0[3]-.5)*N+(l0[4]-.5)*e0+.5;e.uvs.push(u0*I+H,$0*W+B);let z0=1;t&&(z0=4/4*(15/15),n0.push(3)),e.colors.push(s0*j[0]*z0,s0*j[1]*z0,s0*j[2]*z0)}t&&n0[0]+n0[3]>=n0[1]+n0[2]?e.indices.push(z,z+3,z+2,z,z+1,z+3):e.indices.push(z,z+1,z+2,z+2,z+1,z+3)}}var ho=(r,t,e,i,n=[],s={})=>{let l={sx:.5,sy:.5,sz:.5,positions:[],normals:[],colors:[],uvs:[],t_positions:[],t_normals:[],t_colors:[],t_uvs:[],indices:[],tiles:{}};for(let[d,m]of r.entries()){let p=m[n[d]]??m[0];if(!p)continue;let g=null,y=null;for(let w of["x","y","z"])w in p&&(g?g=hr(g,F5(w,-(p[w]??0))):g=F5(w,-(p[w]??0)));g&&(y=[8,8,8],y=$1(y,fe(g,y)));let E=p.ao??!0;for(let w of p.elements??[])fo(w,E,l,g,y,t,e,s)}let c=l.positions.length/3;for(let d=0;d<l.t_positions.length/12;d++)l.indices.push(c,c+1,c+2,c+2,c+1,c+3,c,c+2,c+1,c+2,c+3,c+1),c+=4;return l.positions.push(...l.t_positions),l.normals.push(...l.t_normals),l.colors.push(...l.t_colors),l.uvs.push(...l.t_uvs),delete l.t_positions,delete l.t_normals,delete l.t_colors,delete l.t_uvs,l.positions=new Float32Array(l.positions),l.normals=new Float32Array(l.normals),l.colors=new Float32Array(l.colors),l.uvs=new Float32Array(l.uvs),l},mo=(...r)=>{let e={geometry:ho(...r)},i=new X0.BufferGeometry;return i.setAttribute("position",new X0.BufferAttribute(e.geometry.positions,3)),i.setAttribute("normal",new X0.BufferAttribute(e.geometry.normals,3)),i.setAttribute("color",new X0.BufferAttribute(e.geometry.colors,3)),i.setAttribute("uv",new X0.BufferAttribute(e.geometry.uvs,2)),i.setIndex(e.geometry.indices),i.name="block-geometry",i},e2=(r,...t)=>{let e=mo(...t),i=new X0.Mesh(e,r);i.position.set(-.5,-.5,-.5);let n=new X0.Group;return n.add(i),n.rotation.set(0,-X0.MathUtils.degToRad(90),0,"ZYX"),globalThis.mesh=n,n},mr=(r,t)=>{r.position.set(t.x+.5,t.y+.5,t.z+.5)};x();R();T();k();import*as H0 from"three";x();R();T();k();import H2 from"prismarine-nbt";import*as V from"three";x();R();T();k();x();R();T();k();import{BoxGeometry as F0,DoubleSide as a2,FrontSide as gr,Group as nt,Mesh as I0,MeshStandardMaterial as je,Vector2 as U5}from"three";function v2(r,t,e,i,n,s,o,a){let v=(B,I,W,z)=>[new U5(B/o,1-z/a),new U5(W/o,1-z/a),new U5(W/o,1-I/a),new U5(B/o,1-I/a)],l=v(t+s,e,t+i+s,e+s),c=v(t+i+s,e,t+i*2+s,e+s),d=v(t,e+s,t+s,e+s+n),m=v(t+s,e+s,t+i+s,e+s+n),p=v(t+i+s,e+s,t+i+s*2,e+n+s),g=v(t+i+s*2,e+s,t+i*2+s*2,e+n+s),y=r.attributes.uv,E=[p[3],p[2],p[0],p[1]],w=[d[3],d[2],d[0],d[1]],_=[l[3],l[2],l[0],l[1]],C=[c[0],c[1],c[3],c[2]],M=[m[3],m[2],m[0],m[1]],S=[g[3],g[2],g[0],g[1]],H=[];for(let B of[E,w,_,C,M,S])for(let I of B)H.push(I.x,I.y);y.set(new Float32Array(H)),y.needsUpdate=!0}function it(r,t,e,i,n,s){v2(r,t,e,i,n,s,64,64)}function i2(r,t,e,i,n,s){v2(r,t,e,i,n,s,64,32)}var bt=class extends nt{constructor(t,e){super(),Object.defineProperty(this,"innerLayer",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"outerLayer",{enumerable:!0,configurable:!0,writable:!0,value:e}),t.name="inner",e.name="outer"}},n2=class extends nt{constructor(){super(),Object.defineProperty(this,"head",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"rightArm",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"leftArm",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"rightLeg",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"leftLeg",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"modelListeners",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"slim",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_map",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"layer1Material",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"layer1MaterialBiased",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"layer2Material",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"layer2MaterialBiased",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.layer1Material=new je({side:gr}),this.layer2Material=new je({side:a2,transparent:!0,alphaTest:1e-5}),this.layer1MaterialBiased=this.layer1Material.clone(),this.layer1MaterialBiased.polygonOffset=!0,this.layer1MaterialBiased.polygonOffsetFactor=1,this.layer1MaterialBiased.polygonOffsetUnits=1,this.layer2MaterialBiased=this.layer2Material.clone(),this.layer2MaterialBiased.polygonOffset=!0,this.layer2MaterialBiased.polygonOffsetFactor=1,this.layer2MaterialBiased.polygonOffsetUnits=1;let t=new F0(8,8,8);it(t,0,0,8,8,8);let e=new I0(t,this.layer1Material),i=new F0(9,9,9);it(i,32,0,8,8,8);let n=new I0(i,this.layer2Material);this.head=new bt(e,n),this.head.name="head",this.head.add(e,n),e.position.y=4,n.position.y=4,this.add(this.head);let s=new F0(8,12,4);it(s,16,16,8,12,4);let o=new I0(s,this.layer1Material),a=new F0(8.5,12.5,4.5);it(a,16,32,8,12,4);let v=new I0(a,this.layer2Material);this.body=new bt(o,v),this.body.name="body",this.body.add(o,v),this.body.position.y=-6,this.add(this.body);let l=new F0,c=new I0(l,this.layer1MaterialBiased);this.modelListeners.push(()=>{c.scale.x=this.slim?3:4,c.scale.y=12,c.scale.z=4,it(l,40,16,this.slim?3:4,12,4)});let d=new F0,m=new I0(d,this.layer2MaterialBiased);this.modelListeners.push(()=>{m.scale.x=this.slim?3.5:4.5,m.scale.y=12.5,m.scale.z=4.5,it(d,40,32,this.slim?3:4,12,4)});let p=new nt;p.add(c,m),this.modelListeners.push(()=>{p.position.x=this.slim?-.5:-1}),p.position.y=-4,this.rightArm=new bt(c,m),this.rightArm.name="rightArm",this.rightArm.add(p),this.rightArm.position.x=-5,this.rightArm.position.y=-2,this.add(this.rightArm);let g=new F0,y=new I0(g,this.layer1MaterialBiased);this.modelListeners.push(()=>{y.scale.x=this.slim?3:4,y.scale.y=12,y.scale.z=4,it(g,32,48,this.slim?3:4,12,4)});let E=new F0,w=new I0(E,this.layer2MaterialBiased);this.modelListeners.push(()=>{w.scale.x=this.slim?3.5:4.5,w.scale.y=12.5,w.scale.z=4.5,it(E,48,48,this.slim?3:4,12,4)});let _=new nt;_.add(y,w),this.modelListeners.push(()=>{_.position.x=this.slim?.5:1}),_.position.y=-4,this.leftArm=new bt(y,w),this.leftArm.name="leftArm",this.leftArm.add(_),this.leftArm.position.x=5,this.leftArm.position.y=-2,this.add(this.leftArm);let C=new F0(4,12,4);it(C,0,16,4,12,4);let M=new I0(C,this.layer1MaterialBiased),S=new F0(4.5,12.5,4.5);it(S,0,32,4,12,4);let H=new I0(S,this.layer2MaterialBiased),B=new nt;B.add(M,H),B.position.y=-6,this.rightLeg=new bt(M,H),this.rightLeg.name="rightLeg",this.rightLeg.add(B),this.rightLeg.position.x=-1.9,this.rightLeg.position.y=-12,this.rightLeg.position.z=-.1,this.add(this.rightLeg);let I=new F0(4,12,4);it(I,16,48,4,12,4);let W=new I0(I,this.layer1MaterialBiased),z=new F0(4.5,12.5,4.5);it(z,0,48,4,12,4);let j=new I0(z,this.layer2MaterialBiased),q=new nt;q.add(W,j),q.position.y=-6,this.leftLeg=new bt(W,j),this.leftLeg.name="leftLeg",this.leftLeg.add(q),this.leftLeg.position.x=1.9,this.leftLeg.position.y=-12,this.leftLeg.position.z=-.1,this.add(this.leftLeg),this.modelType="default"}get map(){return this._map}set map(t){this._map=t,this.layer1Material.map=t,this.layer1Material.needsUpdate=!0,this.layer1MaterialBiased.map=t,this.layer1MaterialBiased.needsUpdate=!0,this.layer2Material.map=t,this.layer2Material.needsUpdate=!0,this.layer2MaterialBiased.map=t,this.layer2MaterialBiased.needsUpdate=!0}get modelType(){return this.slim?"slim":"default"}set modelType(t){this.slim=t==="slim",this.modelListeners.forEach(e=>e())}getBodyParts(){return this.children.filter(t=>t instanceof bt)}setInnerLayerVisible(t){this.getBodyParts().forEach(e=>e.innerLayer.visible=t)}setOuterLayerVisible(t){this.getBodyParts().forEach(e=>e.outerLayer.visible=t)}resetJoints(){this.head.rotation.set(0,0,0),this.leftArm.rotation.set(0,0,0),this.rightArm.rotation.set(0,0,0),this.leftLeg.rotation.set(0,0,0),this.rightLeg.rotation.set(0,0,0),this.body.rotation.set(0,0,0),this.head.position.y=0,this.body.position.y=-6,this.body.position.z=0,this.rightArm.position.x=-5,this.rightArm.position.y=-2,this.rightArm.position.z=0,this.leftArm.position.x=5,this.leftArm.position.y=-2,this.leftArm.position.z=0,this.rightLeg.position.x=-1.9,this.rightLeg.position.y=-12,this.rightLeg.position.z=-.1,this.leftLeg.position.x=1.9,this.leftLeg.position.y=-12,this.leftLeg.position.z=-.1}},r2=class extends nt{constructor(){super(),Object.defineProperty(this,"cape",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"material",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.material=new je({side:a2,transparent:!0,alphaTest:1e-5});let t=new F0(10,16,1);i2(t,0,0,10,16,1),this.cape=new I0(t,this.material),this.cape.position.y=-8,this.cape.position.z=.5,this.add(this.cape)}get map(){return this.material.map}set map(t){this.material.map=t,this.material.needsUpdate=!0}},s2=class extends nt{constructor(){super(),Object.defineProperty(this,"leftWing",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"rightWing",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"material",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.material=new je({side:a2,transparent:!0,alphaTest:1e-5});let t=new F0(12,22,4);i2(t,22,0,10,20,2);let e=new I0(t,this.material);e.position.x=-5,e.position.y=-10,e.position.z=-1,this.leftWing=new nt,this.leftWing.add(e),this.add(this.leftWing);let i=new F0(12,22,4);i2(i,22,0,10,20,2);let n=new I0(i,this.material);n.scale.x=-1,n.position.x=5,n.position.y=-10,n.position.z=-1,this.rightWing=new nt,this.rightWing.add(n),this.add(this.rightWing),this.leftWing.position.x=5,this.leftWing.rotation.x=.2617994,this.resetJoints()}resetJoints(){this.leftWing.rotation.y=.01,this.leftWing.rotation.z=.2617994,this.updateRightWing()}updateRightWing(){this.rightWing.position.x=-this.leftWing.position.x,this.rightWing.position.y=this.leftWing.position.y,this.rightWing.rotation.x=this.leftWing.rotation.x,this.rightWing.rotation.y=-this.leftWing.rotation.y,this.rightWing.rotation.z=-this.leftWing.rotation.z}get map(){return this.material.map}set map(t){this.material.map=t,this.material.needsUpdate=!0}},o2=class extends nt{constructor(){super(),Object.defineProperty(this,"rightEar",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"leftEar",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"material",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.material=new je({side:gr});let t=new F0(8,8,4/3);v2(t,0,0,6,6,1,14,7),this.rightEar=new I0(t,this.material),this.rightEar.name="rightEar",this.rightEar.position.x=-6,this.add(this.rightEar),this.leftEar=new I0(t,this.material),this.leftEar.name="leftEar",this.leftEar.position.x=6,this.add(this.leftEar)}get map(){return this.material.map}set map(t){this.material.map=t,this.material.needsUpdate=!0}},pr=10.8*Math.PI/180,Ye=class extends nt{constructor(){super(),Object.defineProperty(this,"skin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cape",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"elytra",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ears",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.skin=new n2,this.skin.name="skin",this.skin.position.y=8,this.add(this.skin),this.cape=new r2,this.cape.name="cape",this.cape.position.y=8,this.cape.position.z=-2,this.cape.rotation.x=pr,this.cape.rotation.y=Math.PI,this.add(this.cape),this.elytra=new s2,this.elytra.name="elytra",this.elytra.position.y=8,this.elytra.position.z=-2,this.elytra.visible=!1,this.add(this.elytra),this.ears=new o2,this.ears.name="ears",this.ears.position.y=10,this.ears.position.z=2/3,this.ears.visible=!1,this.skin.head.add(this.ears)}get backEquipment(){return this.cape.visible?"cape":this.elytra.visible?"elytra":null}set backEquipment(t){this.cape.visible=t==="cape",this.elytra.visible=t==="elytra"}resetJoints(){this.skin.resetJoints(),this.cape.rotation.x=pr,this.cape.position.y=8,this.cape.position.z=-2,this.elytra.position.y=8,this.elytra.position.z=-2,this.elytra.rotation.x=0,this.elytra.resetJoints()}};x();R();T();k();import{Color as wf,PointLight as _f,EquirectangularReflectionMapping as Af,Group as Ef,NearestFilter as xf,PerspectiveCamera as Rf,Scene as kf,Texture as Tf,Vector2 as Mf,WebGLRenderer as Sf,AmbientLight as Cf,CanvasTexture as Pf,WebGLRenderTarget as Bf,FloatType as If,DepthTexture as Hf,Clock as zf,Object3D as Of,ColorManagement as Df}from"three";import{OrbitControls as Ff}from"three/examples/jsm/controls/OrbitControls.js";import{EffectComposer as Gf}from"three/examples/jsm/postprocessing/EffectComposer.js";import"three/examples/jsm/postprocessing/Pass.js";import{RenderPass as jf}from"three/examples/jsm/postprocessing/RenderPass.js";import{ShaderPass as Qf}from"three/examples/jsm/postprocessing/ShaderPass.js";import{FXAAShader as Jf}from"three/examples/jsm/shaders/FXAAShader.js";x();R();T();k();var G5=class{constructor(){Object.defineProperty(this,"speed",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(this,"paused",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"progress",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"currentId",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"progress0",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"animationObjects",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}update(t,e){if(this.paused)return;let i=e*this.speed;this.animate(t,i),this.animationObjects.forEach((n,s)=>{let o=this.progress0.get(s);n(t,this.progress-o,s)}),this.progress+=i}addAnimation(t){let e=this.currentId++;return this.progress0.set(e,this.progress),this.animationObjects.set(e,t),e}removeAnimation(t){t!=null&&(this.animationObjects.delete(t),this.progress0.delete(t))}};x();R();T();k();import{CanvasTexture as sf,NearestFilter as of,Sprite as af,SpriteMaterial as vf}from"three";x();R();T();k();var po=Object.defineProperty,go=(r,t,e)=>t in r?po(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,h0=(r,t,e)=>(go(r,typeof t!="symbol"?t+"":t,e),e);function l2(r){let t=[r];if(r.extra&&r.extra.length!==0)for(let e of r.extra)t.push(...l2(e));return t}var X=class{constructor(r,t,e,i,n,s){this.key=r,this.value=t,this.name=e,this.code=i,this.cssForeground=n,this.cssBackground=s}applyToStyle(r){r[this.key]=this.value}matchStyle(r){return r[this.key]===this.value}static fromCode(r){let e="0123456789abcdefklmnor".indexOf(r);if(e)return this.list[e]}toString(){return`${X.CONTROL_STRING}${this.code}`}},m0=X;h0(m0,"CONTROL_STRING","\xA7");h0(m0,"BLACK",new X("color","black","BLACK","0",{color:"#000000"},{color:"#000000"}));h0(m0,"DARK_BLUE",new X("color","dark_blue","DARK_BLUE","1",{color:"#0000AA"},{color:"#00002A"}));h0(m0,"DARK_GREEN",new X("color","dark_green","DARK_GREEN","2",{color:"#00AA00"},{color:"#002A00"}));h0(m0,"DARK_AQUA",new X("color","dark_aqua","DARK_AQUA","3",{color:"#00AAAA"},{color:"#002A2A"}));h0(m0,"DARK_RED",new X("color","dark_red","DARK_RED","4",{color:"#AA0000"},{color:"#2A0000"}));h0(m0,"DARK_PURPLE",new X("color","dark_purple","DARK_PURPLE","5",{color:"#AA00AA"},{color:"#2A002A"}));h0(m0,"GOLD",new X("color","gold","GOLD","6",{color:"#FFAA00"},{color:"#2A2A00"}));h0(m0,"GRAY",new X("color","gray","GRAY","7",{color:"#AAAAAA"},{color:"#2A2A2A"}));h0(m0,"DARK_GRAY",new X("color","dark_gray","DARK_GRAY","8",{color:"#555555"},{color:"#151515"}));h0(m0,"BLUE",new X("color","blue","BLUE","9",{color:"#5555FF"},{color:"#15153F"}));h0(m0,"GREEN",new X("color","green","GREEN","a",{color:"#55FF55"},{color:"#153F15"}));h0(m0,"AQUA",new X("color","aqua","AQUA","b",{color:"#55FFFF"},{color:"#153F3F"}));h0(m0,"RED",new X("color","red","RED","c",{color:"#FF5555"},{color:"#3F1515"}));h0(m0,"LIGHT_PURPLE",new X("color","light_purple","LIGHT_PURPLE","d",{color:"#FF55FF"},{color:"#3F153F"}));h0(m0,"YELLOW",new X("color","yellow","YELLOW","e",{color:"#FFFF55"},{color:"#3F3F15"}));h0(m0,"WHITE",new X("color","white","WHITE","f",{color:"#FFFFFF"},{color:"#3F3F3F"}));h0(m0,"OBFUSCATED",new X("obfuscated",!0,"OBFUSCATED","k",{}));h0(m0,"BOLD",new X("bold",!0,"BOLD","l",{"font-weight":"bold"}));h0(m0,"STRIKETHROUGH",new X("strikethrough",!0,"STRIKETHROUGH","m",{"text-decoration":"line-through"}));h0(m0,"UNDERLINE",new X("underlined",!0,"UNDERLINE","n",{"text-decoration":"underline"}));h0(m0,"ITALIC",new X("italic",!0,"ITALIC","o",{"font-style":"italic"}));h0(m0,"RESET",{name:"RESET",code:"r",applyToStyle(r){r.bold=!1,r.strikethrough=!1,r.underlined=!1,r.italic=!1,r.obfuscated=!1,r.color=void 0},matchStyle(r){return!1},cssBackground:{},cssForeground:{},toString(){return`${X.CONTROL_STRING}r`}});h0(m0,"list",[X.BLACK,X.DARK_BLUE,X.DARK_GREEN,X.DARK_AQUA,X.DARK_RED,X.DARK_PURPLE,X.GOLD,X.GRAY,X.DARK_GRAY,X.BLUE,X.GREEN,X.AQUA,X.RED,X.LIGHT_PURPLE,X.YELLOW,X.WHITE,X.OBFUSCATED,X.BOLD,X.STRIKETHROUGH,X.UNDERLINE,X.ITALIC,X.RESET]);var n5=He(c2(),1);h2();var s6=He(Wr(),1);import o6 from"prismarine-chat";x();R();T();k();import*as x0 from"three";import da from"prismarine-item";x();R();T();k();x();R();T();k();var Tt=class r{constructor(t,e,i,n,s="div"){this.parent=t,this.object=e,this.property=i,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement("div"),this.domElement.classList.add("controller"),this.domElement.classList.add(n),this.$name=document.createElement("div"),this.$name.classList.add("name"),r.nextNameID=r.nextNameID||0,this.$name.id=`lil-gui-name-${++r.nextNameID}`,this.$widget=document.createElement(s),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",o=>o.stopPropagation()),this.domElement.addEventListener("keyup",o=>o.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(i)}name(t){return this._name=t,this.$name.innerHTML=t,this}onChange(t){return this._onChange=t,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(t){return this._onFinishChange=t,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(t=!0){return this.disable(!t)}disable(t=!0){return t===this._disabled?this:(this._disabled=t,this.domElement.classList.toggle("disabled",t),this.$disable.toggleAttribute("disabled",t),this)}show(t=!0){return this._hidden=!t,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(t){let e=this.parent.add(this.object,this.property,t);return e.name(this._name),this.destroy(),e}min(t){return this}max(t){return this}step(t){return this}decimals(t){return this}listen(t=!0){return this._listening=t,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);let t=this.save();t!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=t}getValue(){return this.object[this.property]}setValue(t){return this.object[this.property]=t,this._callOnChange(),this.updateDisplay(),this}updateDisplay(){return this}load(t){return this.setValue(t),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}},m2=class extends Tt{constructor(t,e,i){super(t,e,i,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}};function p2(r){let t,e;return(t=r.match(/(#|0x)?([a-f0-9]{6})/i))?e=t[2]:(t=r.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?e=parseInt(t[1]).toString(16).padStart(2,0)+parseInt(t[2]).toString(16).padStart(2,0)+parseInt(t[3]).toString(16).padStart(2,0):(t=r.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(e=t[1]+t[1]+t[2]+t[2]+t[3]+t[3]),e?"#"+e:!1}var ia={isPrimitive:!0,match:r=>typeof r=="string",fromHexString:p2,toHexString:p2},Xe={isPrimitive:!0,match:r=>typeof r=="number",fromHexString:r=>parseInt(r.substring(1),16),toHexString:r=>"#"+r.toString(16).padStart(6,0)},na={isPrimitive:!1,match:r=>Array.isArray(r),fromHexString(r,t,e=1){let i=Xe.fromHexString(r);t[0]=(i>>16&255)/255*e,t[1]=(i>>8&255)/255*e,t[2]=(i&255)/255*e},toHexString([r,t,e],i=1){i=255/i;let n=r*i<<16^t*i<<8^e*i<<0;return Xe.toHexString(n)}},ra={isPrimitive:!1,match:r=>Object(r)===r,fromHexString(r,t,e=1){let i=Xe.fromHexString(r);t.r=(i>>16&255)/255*e,t.g=(i>>8&255)/255*e,t.b=(i&255)/255*e},toHexString({r,g:t,b:e},i=1){i=255/i;let n=r*i<<16^t*i<<8^e*i<<0;return Xe.toHexString(n)}},sa=[ia,Xe,na,ra];function oa(r){return sa.find(t=>t.match(r))}var g2=class extends Tt{constructor(t,e,i,n){super(t,e,i,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=oa(this.initialValue),this._rgbScale=n,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{let s=p2(this.$text.value);s&&this._setValueFromHexString(s)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(t){if(this._format.isPrimitive){let e=this._format.fromHexString(t);this.setValue(e)}else this._format.fromHexString(t,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(t){return this._setValueFromHexString(t),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}},Ze=class extends Tt{constructor(t,e,i){super(t,e,i,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",n=>{n.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}},b2=class extends Tt{constructor(t,e,i,n,s,o){super(t,e,i,"number"),this._initInput(),this.min(n),this.max(s);let a=o!==void 0;this.step(a?o:this._getImplicitStep(),a),this.updateDisplay()}decimals(t){return this._decimals=t,this.updateDisplay(),this}min(t){return this._min=t,this._onUpdateMinMax(),this}max(t){return this._max=t,this._onUpdateMinMax(),this}step(t,e=!0){return this._step=t,this._stepExplicit=e,this}updateDisplay(){let t=this.getValue();if(this._hasSlider){let e=(t-this._min)/(this._max-this._min);e=Math.max(0,Math.min(e,1)),this.$fill.style.width=e*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?t:t.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;let e=()=>{let _=parseFloat(this.$input.value);isNaN(_)||(this._stepExplicit&&(_=this._snap(_)),this.setValue(this._clamp(_)))},i=_=>{let C=parseFloat(this.$input.value);isNaN(C)||(this._snapClampSetValue(C+_),this.$input.value=this.getValue())},n=_=>{_.key==="Enter"&&this.$input.blur(),_.code==="ArrowUp"&&(_.preventDefault(),i(this._step*this._arrowKeyMultiplier(_))),_.code==="ArrowDown"&&(_.preventDefault(),i(this._step*this._arrowKeyMultiplier(_)*-1))},s=_=>{this._inputFocused&&(_.preventDefault(),i(this._step*this._normalizeMouseWheel(_)))},o=!1,a,v,l,c,d,m=5,p=_=>{a=_.clientX,v=l=_.clientY,o=!0,c=this.getValue(),d=0,window.addEventListener("mousemove",g),window.addEventListener("mouseup",y)},g=_=>{if(o){let C=_.clientX-a,M=_.clientY-v;Math.abs(M)>m?(_.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(C)>m&&y()}if(!o){let C=_.clientY-l;d-=C*this._step*this._arrowKeyMultiplier(_),c+d>this._max?d=this._max-c:c+d<this._min&&(d=this._min-c),this._snapClampSetValue(c+d)}l=_.clientY},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",y)},E=()=>{this._inputFocused=!0},w=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",e),this.$input.addEventListener("keydown",n),this.$input.addEventListener("wheel",s,{passive:!1}),this.$input.addEventListener("mousedown",p),this.$input.addEventListener("focus",E),this.$input.addEventListener("blur",w)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");let t=(w,_,C,M,S)=>(w-_)/(C-_)*(S-M)+M,e=w=>{let _=this.$slider.getBoundingClientRect(),C=t(w,_.left,_.right,this._min,this._max);this._snapClampSetValue(C)},i=w=>{this._setDraggingStyle(!0),e(w.clientX),window.addEventListener("mousemove",n),window.addEventListener("mouseup",s)},n=w=>{e(w.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",s)},o=!1,a,v,l=w=>{w.preventDefault(),this._setDraggingStyle(!0),e(w.touches[0].clientX),o=!1},c=w=>{w.touches.length>1||(this._hasScrollBar?(a=w.touches[0].clientX,v=w.touches[0].clientY,o=!0):l(w),window.addEventListener("touchmove",d,{passive:!1}),window.addEventListener("touchend",m))},d=w=>{if(o){let _=w.touches[0].clientX-a,C=w.touches[0].clientY-v;Math.abs(_)>Math.abs(C)?l(w):(window.removeEventListener("touchmove",d),window.removeEventListener("touchend",m))}else w.preventDefault(),e(w.touches[0].clientX)},m=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",d),window.removeEventListener("touchend",m)},p=this._callOnFinishChange.bind(this),g=400,y,E=w=>{if(Math.abs(w.deltaX)<Math.abs(w.deltaY)&&this._hasScrollBar)return;w.preventDefault();let C=this._normalizeMouseWheel(w)*this._step;this._snapClampSetValue(this.getValue()+C),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(p,g)};this.$slider.addEventListener("mousedown",i),this.$slider.addEventListener("touchstart",c,{passive:!1}),this.$slider.addEventListener("wheel",E,{passive:!1})}_setDraggingStyle(t,e="horizontal"){this.$slider&&this.$slider.classList.toggle("active",t),document.body.classList.toggle("lil-gui-dragging",t),document.body.classList.toggle(`lil-gui-${e}`,t)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(t){let{deltaX:e,deltaY:i}=t;return Math.floor(t.deltaY)!==t.deltaY&&t.wheelDelta&&(e=0,i=-t.wheelDelta/120,i*=this._stepExplicit?1:10),e+-i}_arrowKeyMultiplier(t){let e=this._stepExplicit?1:10;return t.shiftKey?e*=10:t.altKey&&(e/=10),e}_snap(t){let e=Math.round(t/this._step)*this._step;return parseFloat(e.toPrecision(15))}_clamp(t){return t<this._min&&(t=this._min),t>this._max&&(t=this._max),t}_snapClampSetValue(t){this.setValue(this._clamp(this._snap(t)))}get _hasScrollBar(){let t=this.parent.root.$children;return t.scrollHeight>t.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}},y2=class extends Tt{constructor(t,e,i,n){super(t,e,i,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this._values=Array.isArray(n)?n:Object.values(n),this._names=Array.isArray(n)?n:Object.keys(n),this._names.forEach(s=>{let o=document.createElement("option");o.innerHTML=s,this.$select.appendChild(o)}),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.updateDisplay()}updateDisplay(){let t=this.getValue(),e=this._values.indexOf(t);return this.$select.selectedIndex=e,this.$display.innerHTML=e===-1?t:this._names[e],this}},w2=class extends Tt{constructor(t,e,i){super(t,e,i,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",n=>{n.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}},aa=`.lil-gui {
|
|
15
|
+
`))E(B,H),p+=i,m="";else S&&E(S,H);if(C.extra)for(let B of C.extra)y(B,H)},E=(C,M)=>{o||(o=C.trim()!==""),m+=C,g[p]=v.measureText(m).width;let S=M.color??n;S.startsWith("#")||(S=qs[S.toLowerCase()]||S),c.push({fontStyle:`${M.bold?"bold":""} ${M.italic?"italic":""}`,fillStyle:S,underlineStyle:M.underlined??!1,strikeStyle:M.strikethrough??!1,offset:p,text:C})};if(y(l),!d&&!l.toString().trim())return;let w=0,_=0;for(let{fillStyle:C,fontStyle:M,underlineStyle:S,strikeStyle:H,offset:B,text:I}of c){_!==B&&(w=0),_=B,v.fillStyle=C,v.textRendering="optimizeLegibility",v.font=`${M} ${i}px mojangles`;let W=g[B]??v.measureText(I).width,z=(e.width-W)/2+w;v.fillText(I,z,B),H&&(v.lineWidth=i/8,v.strokeStyle=C,v.beginPath(),v.moveTo(z,B-v.lineWidth*2.5),v.lineTo(z+v.measureText(I).width,B-v.lineWidth*2.5),v.stroke()),S&&(v.lineWidth=i/8,v.strokeStyle=C,v.beginPath(),v.moveTo(z,B+v.lineWidth),v.lineTo(z+v.measureText(I).width,B+v.lineWidth),v.stroke()),w+=v.measureText(I).width}return o};x();R();T();k();function de(r){let t=Math.floor(r.x/16),e=Math.floor(r.z/16);return[t,e]}function H1(r){let t=Math.floor(r.x/16),e=Math.floor(r.y/16),i=Math.floor(r.z/16);return[t,e,i]}x();R();T();k();import{Vec3 as Qt}from"vec3";import{subscribeKey as q1}from"valtio/utils";import{proxy as ao,subscribe as vo}from"valtio";x();R();T();k();var We={blocks:"blocksArray",blockCollisionShapes:"blockCollisionShapes",biomes:"biomesArray"};x();R();T();k();var Ve=!1,er=16;var ir=(r,t)=>t?`${r}:${t}`:String(r);x();R();T();k();x();R();T();k();var D1=He(nr(),1);import*as H5 from"three";x();R();T();k();x();R();T();k();var B5=class{constructor(t,e,i){this.name=t,this.fg=e,this.bg=i,this.PR=Math.round(window.devicePixelRatio||1),this.WIDTH=90*this.PR,this.HEIGHT=48*this.PR,this.TEXT_X=3*this.PR,this.TEXT_Y=2*this.PR,this.GRAPH_X=3*this.PR,this.GRAPH_Y=15*this.PR,this.GRAPH_WIDTH=84*this.PR,this.GRAPH_HEIGHT=30*this.PR,this.canvas=document.createElement("canvas"),this.canvas.width=90*this.PR,this.canvas.height=48*this.PR,this.canvas.style.width="90px",this.canvas.style.position="absolute",this.canvas.style.height="48px",this.canvas.style.cssText="width:90px;height:48px",this.context=this.canvas.getContext("2d"),this.context&&(this.context.font="bold "+9*this.PR+"px Helvetica,Arial,sans-serif",this.context.textBaseline="top",this.context.fillStyle=this.bg,this.context.fillRect(0,0,this.WIDTH,this.HEIGHT),this.context.fillStyle=this.fg,this.context.fillText(this.name,this.TEXT_X,this.TEXT_Y),this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT))}update(t,e,i,n,s=0){let o=1/0,a=0;this.context&&(o=Math.min(o,t),a=Math.max(i,t),n=Math.max(n,e),this.context.fillStyle=this.bg,this.context.globalAlpha=1,this.context.fillRect(0,0,this.WIDTH,this.GRAPH_Y),this.context.fillStyle=this.fg,this.context.fillText(t.toFixed(s)+" "+this.name+" ("+o.toFixed(s)+"-"+parseFloat(a.toFixed(s))+")",this.TEXT_X,this.TEXT_Y),this.context.drawImage(this.canvas,this.GRAPH_X+this.PR,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT,this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT),this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y,this.PR,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y,this.PR,(1-e/n)*this.GRAPH_HEIGHT))}};var rr=class I5{constructor({logsPerSecond:t=20,samplesLog:e=100,samplesGraph:i=10,precision:n=2,minimal:s=!1,horizontal:o=!0,mode:a=0}={}){this.mode=a,this.horizontal=o,this.container=document.createElement("div"),this.container.style.cssText="position:fixed;top:0;left:0;opacity:0.9;z-index:10000;",s&&(this.container.style.cssText+="cursor:pointer"),this.gl=null,this.query=null,this.minimal=s,this.beginTime=(performance||Date).now(),this.prevTime=this.beginTime,this.prevCpuTime=this.beginTime,this.frames=0,this.averageCpu={logs:[],graph:[]},this.averageGpu={logs:[],graph:[]},this.queryCreated=!1,this.fpsPanel=this.addPanel(new I5.Panel("FPS","#0ff","#002"),0),this.msPanel=this.addPanel(new I5.Panel("CPU","#0f0","#020"),1),this.gpuPanel=null,this.samplesLog=e,this.samplesGraph=i,this.precision=n,this.logsPerSecond=t,this.minimal?(this.container.addEventListener("click",v=>{v.preventDefault(),this.showPanel(++this.mode%this.container.children.length)},!1),this.mode=a,this.showPanel(this.mode)):window.addEventListener("resize",()=>{this.resizePanel(this.fpsPanel,0),this.resizePanel(this.msPanel,1),this.gpuPanel&&this.resizePanel(this.gpuPanel,2)})}resizePanel(t,e){t.canvas.style.position="absolute",this.minimal?t.canvas.style.display="none":(t.canvas.style.display="block",this.horizontal?(t.canvas.style.top="0px",t.canvas.style.left=e*t.WIDTH/t.PR+"px"):(t.canvas.style.left="0px",t.canvas.style.top=e*t.HEIGHT/t.PR+"px"))}addPanel(t,e){return t.canvas&&(this.container.appendChild(t.canvas),this.resizePanel(t,e)),t}showPanel(t){for(let e=0;e<this.container.children.length;e++){let i=this.container.children[e];i.style.display=e===t?"block":"none"}this.mode=t}init(t){if(t){if(t instanceof WebGL2RenderingContext)this.gl=t;else if(t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas){if(this.gl=t.getContext("webgl2"),!this.gl)return}else return;this.ext=this.gl.getExtension("EXT_disjoint_timer_query_webgl2"),this.ext&&(this.gpuPanel=this.addPanel(new I5.Panel("GPU","#ff0","#220"),2))}}begin(){if(this.beginProfiling("cpu-started"),!(!this.gl||!this.ext)){if(this.query){let t=this.gl.getQueryParameter(this.query,this.gl.QUERY_RESULT_AVAILABLE);if(this.disjoint=this.gl.getParameter(this.ext.GPU_DISJOINT_EXT),t&&!this.disjoint){this.ns=this.gl.getQueryParameter(this.query,this.gl.QUERY_RESULT);let e=this.ns*1e-6;(t||this.disjoint)&&(this.gl.deleteQuery(this.query),this.query=null),t&&this.addToAverage(e,this.averageGpu)}}this.query||(this.queryCreated=!0,this.query=this.gl.createQuery(),this.query&&this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,this.query))}}end(){this.beginTime=this.endInternal(),this.endProfiling("cpu-started","cpu-finished","cpu-duration",this.averageCpu),!(!this.gl||!this.ext)&&this.queryCreated&&this.gl.getQuery(this.ext.TIME_ELAPSED_EXT,this.gl.CURRENT_QUERY)&&this.gl.endQuery(this.ext.TIME_ELAPSED_EXT)}endInternal(){this.frames++;let t=(performance||Date).now();if(t>=this.prevCpuTime+1e3/this.logsPerSecond&&(this.updatePanel(this.msPanel,this.averageCpu),this.updatePanel(this.gpuPanel,this.averageGpu),this.prevCpuTime=t),t>=this.prevTime+1e3){let e=this.frames*1e3/(t-this.prevTime);this.fpsPanel.update(e,e,100,100,0),this.prevTime=t,this.frames=0}return t}addToAverage(t,e){e.logs.push(t),e.logs.length>this.samplesLog&&e.logs.shift(),e.graph.push(t),e.graph.length>this.samplesGraph&&e.graph.shift()}beginProfiling(t){window.performance&&window.performance.mark(t)}endProfiling(t,e,i,n){if(window.performance&&e){window.performance.mark(e);let s=performance.measure(i,t,e);this.addToAverage(s.duration,n)}}updatePanel(t,e){if(e.logs.length>0){let i=0,n=.01;for(let a=0;a<e.logs.length;a++)i+=e.logs[a],e.logs[a]>n&&(n=e.logs[a]);let s=0,o=.01;for(let a=0;a<e.graph.length;a++)s+=e.graph[a],e.graph[a]>o&&(o=e.graph[a]);t&&t.update(i/Math.min(e.logs.length,this.samplesLog),s/Math.min(e.graph.length,this.samplesGraph),n,o,this.precision)}}};rr.Panel=B5;var sr=rr;var _0=typeof globalThis.WorkerGlobalScope<"u"&&globalThis instanceof globalThis.WorkerGlobalScope,L1=class{constructor(t,e=0){this.canvas=t;f(this,"stats");f(this,"stats2");f(this,"statsGl");f(this,"total",0);f(this,"denseMode");this.stats=new D1.default,this.stats2=new D1.default,this.statsGl=new sr({minimal:!0}),this.stats2.showPanel(2),this.denseMode=typeof D<"u"&&!0||typeof window<"u"&&window.innerHeight<500,this.initStats(),this.setVisibility(e)}addStat(t,e=80){t.style.position="absolute",this.denseMode&&(t.style.height="12px"),t.style.overflow="hidden",t.style.left="",t.style.top="0",t.style.right=`${this.total}px`,t.style.width="80px",t.style.zIndex="1",t.style.opacity="0.8";let i=document.getElementById("corner-indicator-stats"),n=i??document.body;i&&(t.style.position="relative"),n.appendChild(t),this.total+=e}initStats(){let t=this.stats2.dom.children.length===3;this.addStat(this.stats.dom),t&&this.addStat(this.stats2.dom),this.statsGl.init(this.canvas),this.statsGl.container.style.display="flex",this.statsGl.container.style.justifyContent="flex-end";let e=0;for(let i of this.statsGl.container.children){let n=i;e++===0&&(n.style.display="none"),n.style.position=""}}setVisibility(t){t>0?(this.stats.dom.style.display="block",this.stats2.dom.style.display=t>=2?"block":"none",this.statsGl.container.style.display=t>=2?"block":"none"):(this.stats.dom.style.display="none",this.stats2.dom.style.display="none",this.statsGl.container.style.display="none")}markStart(){this.stats.begin(),this.stats2.begin(),this.statsGl.begin()}markEnd(){this.stats.end(),this.stats2.end(),this.statsGl.end()}dispose(){this.stats.dom.remove(),this.stats2.dom.remove(),this.statsGl.container.remove()}},Ne=class{constructor(t,e,i){this.initOptions=t;this.externalCanvas=e;f(this,"canvas");f(this,"renderer");f(this,"animationFrameId");f(this,"timeoutId");f(this,"lastRenderTime",0);f(this,"previousCanvasWidth",0);f(this,"previousCanvasHeight",0);f(this,"currentWidth",0);f(this,"currentHeight",0);f(this,"pendingResize",!1);f(this,"renderedFps",0);f(this,"fpsInterval");f(this,"stats");f(this,"paused",!1);f(this,"disconnected",!1);f(this,"preRender",()=>{});f(this,"render",t=>{});f(this,"postRender",()=>{});f(this,"sizeChanged",()=>{});f(this,"droppedFpsPercentage",0);f(this,"config");f(this,"onRender",[]);f(this,"inWorldRenderingConfig");f(this,"nonReactiveState");this.config=t.config,e?this.canvas=e:this.addToPage();try{this.renderer=new H5.WebGLRenderer({canvas:this.canvas,preserveDrawingBuffer:!0,logarithmicDepthBuffer:!0,powerPreference:this.config.powerPreference})}catch(s){throw t.callbacks.displayCriticalError(new Error(`Failed to create WebGL context, not possible to render (restart browser): ${s.message}`)),s}this.renderer.useLegacyLights=!0,this.renderer.outputColorSpace=H5.LinearSRGBColorSpace,e||(this.updatePixelRatio(),this.setupResizeListener()),this.sizeUpdated(),this.previousCanvasWidth=this.canvas.width,this.previousCanvasHeight=this.canvas.height;let n="WebGL2RenderingContext"in globalThis;!e&&n&&!_0&&(this.stats=new L1(this.canvas,this.config.statsVisible)),this.setupFpsTracking(),this.startRenderLoop()}setupResizeListener(){if(typeof window>"u")return;let t,e=()=>{t&&clearTimeout(t),t=setTimeout(()=>{this.pendingResize=!0},16)};window.addEventListener("resize",e,{passive:!0})}updatePixelRatio(){if(typeof window>"u")return;let t=window.devicePixelRatio||1;this.renderer.capabilities.isWebGL2||(t=1),this.renderer.setPixelRatio(t)}sizeUpdated(){this.renderer.setSize(this.currentWidth,this.currentHeight,!1)}addToPage(){this.canvas=or(),this.updateCanvasSize()}updateSizeExternal(t,e,i){this.currentWidth=t,this.currentHeight=e,this.renderer.setPixelRatio(i),this.sizeUpdated()}updateCanvasSize(){if(this.externalCanvas||typeof document>"u")return;let t=document.body.offsetWidth,e=document.body.offsetHeight;this.currentWidth!==t&&(this.currentWidth=t),this.currentHeight!==e&&(this.currentHeight=e)}setupFpsTracking(){let t=0;this.fpsInterval=setInterval(()=>{t>0&&(this.droppedFpsPercentage=this.renderedFps/t),t=Math.max(this.renderedFps,t),this.nonReactiveState&&(this.nonReactiveState.fps=this.renderedFps),this.renderedFps=0},1e3)}startRenderLoop(){let t=()=>{if(this.disconnected)return;if(this.config.timeoutRendering){let n=1e3/(this.config.fpsLimit?Math.min(this.config.fpsLimit,60):60);this.timeoutId=setTimeout(t,n)}else this.animationFrameId=requestAnimationFrame(t);if(this.paused||this.renderer.xr.isPresenting&&!this.inWorldRenderingConfig?.vrPageGameRendering)return;if(!this.config.timeoutRendering&&this.config.fpsLimit){let i=performance.now(),n=i-this.lastRenderTime,s=1e3/this.config.fpsLimit;if(n<s)return;this.lastRenderTime=i-n%s}let e=!1;this.pendingResize&&(this.updateCanvasSize(),this.pendingResize=!1),(this.previousCanvasWidth!==this.currentWidth||this.previousCanvasHeight!==this.currentHeight)&&(this.previousCanvasWidth=this.currentWidth,this.previousCanvasHeight=this.currentHeight,this.sizeUpdated(),e=!0),this.frameRender(e),this.config.statsVisible!==void 0&&this.stats?.setVisibility(this.config.statsVisible)};t()}frameRender(t){this.preRender(),this.stats?.markStart(),tr(),globalThis.freezeRender||this.render(t);for(let e of this.onRender)e(t);this.renderedFps++,this.stats?.markEnd(),this.postRender()}setPaused(t){this.paused=t}dispose(){this.disconnected=!0,this.animationFrameId&&cancelAnimationFrame(this.animationFrameId),this.timeoutId&&clearTimeout(this.timeoutId),this.canvas instanceof HTMLCanvasElement&&this.canvas.remove(),clearInterval(this.fpsInterval),this.stats?.dispose(),this.renderer.dispose()}};function or(){let r=document.createElement("canvas");return r.id="viewer-canvas",document.body.appendChild(r),r}var F1=()=>{let r=or(),t=r.transferControlToOffscreen(),e=!1,i=(o,a)=>{},n={width:0,height:0},s=()=>{e||((n.width!==window.innerWidth||n.height!==window.innerHeight)&&(i(window.innerWidth,window.innerHeight),n={width:window.innerWidth,height:window.innerHeight}),requestAnimationFrame(s))};return requestAnimationFrame(s),{canvas:t,destroy(){e=!0,r.remove()},onSizeChanged(o){i=o},get size(){return{width:window.innerWidth,height:window.innerHeight}}}};var ar=0,pt={},U1=40,ue=(r,t=80,e=ar,i=U1)=>{if(_0)return{updateText(){},setVisibility(){}};let n=document.createElement("div");return n.style.position="fixed",n.style.top=`${i??U1}px`,n.style.right=`${e}px`,n.style.backgroundColor="rgba(0, 0, 0, 0.7)",n.style.color="white",n.style.padding="2px",n.style.fontFamily="monospace",n.style.fontSize="12px",n.style.zIndex="100",n.style.pointerEvents="none",document.body.appendChild(n),pt[r]=n,i===void 0&&e===ar&&(U1+=20),{updateText(s){n.innerText!==s&&(n.innerText=s)},setVisibility(s){n.style.display=s?"block":"none"}}};var G1=(r,t)=>{_0||!pt[r]||(pt[r].innerText=t)},vr=r=>{if(!_0)for(let t in pt)pt[t].style.display=r?"block":"none"},lr=()=>{if(!_0)for(let r in pt)Zs(r)},Zs=r=>{_0||!pt[r]||(pt[r].remove(),delete pt[r])};x();R();T();k();x();R();T();k();x();R();T();k();x();R();T();k();function W1(r,t,e,i,n){let s=r.getImageData(t,e,i,n);for(let o=0;o<i;o++)for(let a=0;a<n;a++){let v=(o+a*i)*4;if(s.data[v+3]!==255)return!0}return!1}function z5(r){return r/64}function cr(r,t,e){if(e){if(W1(r,0,0,t,t))return}else if(W1(r,0,0,t,t/2))return;let i=z5(t),n=(s,o,a,v)=>r.clearRect(s*i,o*i,a*i,v*i);n(40,0,8,8),n(48,0,8,8),n(32,8,8,8),n(40,8,8,8),n(48,8,8,8),n(56,8,8,8),e&&(n(4,32,4,4),n(8,32,4,4),n(0,36,4,12),n(4,36,4,12),n(8,36,4,12),n(12,36,4,12),n(20,32,8,4),n(28,32,8,4),n(16,36,4,12),n(20,36,8,12),n(28,36,4,12),n(32,36,8,12),n(44,32,4,4),n(48,32,4,4),n(40,36,4,12),n(44,36,4,12),n(48,36,4,12),n(52,36,12,12),n(4,48,4,4),n(8,48,4,4),n(0,52,4,12),n(4,52,4,12),n(8,52,4,12),n(12,52,4,12),n(52,48,4,4),n(56,48,4,4),n(48,52,4,12),n(52,52,4,12),n(56,52,4,12),n(60,52,4,12))}function Xs(r,t){r.save(),r.scale(-1,1);let e=z5(t),i=(n,s,o,a,v,l)=>r.drawImage(r.canvas,n*e,s*e,o*e,a*e,-v*e,l*e,-o*e,a*e);i(4,16,4,4,20,48),i(8,16,4,4,24,48),i(0,20,4,12,24,52),i(4,20,4,12,20,52),i(8,20,4,12,16,52),i(12,20,4,12,28,52),i(44,16,4,4,36,48),i(48,16,4,4,40,48),i(40,20,4,12,40,52),i(44,20,4,12,36,52),i(48,20,4,12,32,52),i(52,20,4,12,44,52),r.restore()}function V1(r,t){let e=!1;if(t.width!==t.height)if(t.width===2*t.height)e=!0;else throw new Error(`Bad skin size: ${t.width}x${t.height}`);let i=r.getContext("2d",{willReadFrequently:!0});if(e){let n=t.width;r.width=n,r.height=n,i.clearRect(0,0,n,n),i.drawImage(t,0,0,n,n/2),Xs(i,n),cr(i,r.width,!1)}else r.width=t.width,r.height=t.height,i.clearRect(0,0,t.width,t.height),i.drawImage(t,0,0,r.width,r.height),cr(i,r.width,!0)}function $s(r){if(r.width===2*r.height)return r.width/64;if(r.width*17===r.height*22)return r.width/22;if(r.width*11===r.height*23)return r.width/46;throw new Error(`Bad cape size: ${r.width}x${r.height}`)}function N1(r,t){let e=$s(t);r.width=64*e,r.height=32*e;let i=r.getContext("2d",{willReadFrequently:!0});i.clearRect(0,0,r.width,r.height),i.drawImage(t,0,0,t.width,t.height)}function to(r,t,e,i,n){let s=r.getImageData(t,e,i,n);for(let o=0;o<i;o++)for(let a=0;a<n;a++){let v=(o+a*i)*4;if(!(s.data[v+0]===0&&s.data[v+1]===0&&s.data[v+2]===0&&s.data[v+3]===255))return!1}return!0}function eo(r,t,e,i,n){let s=r.getImageData(t,e,i,n);for(let o=0;o<i;o++)for(let a=0;a<n;a++){let v=(o+a*i)*4;if(!(s.data[v+0]===255&&s.data[v+1]===255&&s.data[v+2]===255&&s.data[v+3]===255))return!1}return!0}function j1(r){let t=z5(r.width),e=r.getContext("2d",{willReadFrequently:!0}),i=(a,v,l,c)=>W1(e,a*t,v*t,l*t,c*t),n=(a,v,l,c)=>to(e,a*t,v*t,l*t,c*t),s=(a,v,l,c)=>eo(e,a*t,v*t,l*t,c*t);return i(50,16,2,4)||i(54,20,2,12)||i(42,48,2,4)||i(46,52,2,12)||n(50,16,2,4)&&n(54,20,2,12)&&n(42,48,2,4)&&n(46,52,2,12)||s(50,16,2,4)&&s(54,20,2,12)&&s(42,48,2,4)&&s(46,52,2,12)?"slim":"default"}function Y1(r,t){if(t.width!==t.height&&t.width!==2*t.height)throw new Error(`Bad skin size: ${t.width}x${t.height}`);let e=z5(t.width),i=14*e,n=7*e;r.width=i,r.height=n;let s=r.getContext("2d",{willReadFrequently:!0});s.clearRect(0,0,i,n),s.drawImage(t,24*e,0,i,n,0,0,i,n)}x();R();T();k();import io from"mc-assets/dist/other-textures/latest/entity/player/wide/steve.png";x();R();T();k();import*as gt from"three";var A0=(r,t=!1)=>{r instanceof gt.Mesh&&(r.geometry?.dispose?.(),r.material?.dispose?.()),r.children&&r.children.forEach(e=>A0(e,t)),t&&r instanceof gt.Mesh&&r.material?.map?.dispose?.()},Q1={},dr={},O5=r=>{let t=new gt.Texture,e=C5(r).then(i=>{let n=new OffscreenCanvas(i.width,i.height);return n.getContext("2d").drawImage(i,0,0),t.source.data=n,t.needsUpdate=!0,t});return{texture:t,promise:e}},Rt=async r=>O5(r).texture,K1=r=>{let t=L0(r.width,r.height);t.getContext("2d").drawImage(r,0,0);let i=new gt.Texture(t);return i.magFilter=gt.NearestFilter,i.minFilter=gt.NearestFilter,i};async function D5(r,t,e){if(!Q1[r]){let{promise:n,resolve:s}=Promise.withResolvers(),o=O5(r);Q1[r]=o.texture,o.promise.then(s),dr[r]=n}t(Q1[r]),dr[r].then(()=>{e?.()})}var vt=io,Kd=Rt(vt),ur={apiEnabled:!0},fr=r=>{Object.assign(ur,r)};async function kt(r,t){if(!ur.apiEnabled||t==="cape")return;let e=`https://playerdb.co/api/player/minecraft/${r}`,i=await fetch(e);return i.ok?(await i.json()).data.player.skin_texture:void 0}async function Yt(r){r.startsWith("data:")||(r=await no(r.replace("http://","https://")));let t=await C5(r),e=L0(64,64);return V1(e,t),{canvas:e,image:t}}var no=async r=>{let e=await(await fetch(r,{})).arrayBuffer();return`data:image/png;base64,${L.from(e).toString("base64")}`};x();R();T();k();var ro=r=>{let t=r%24e3/24e3-.25;return t<0&&(t+=1),t>1&&(t-=1),t+(1-Math.cos(t*Math.PI))/2},so=r=>{let t=(r%24e3+24e3)%24e3,e=ro(t),n=Math.cos(e*Math.PI*2)*.5+.5,s=Math.round(4+n*11);return Math.max(4,Math.min(15,s))},J1=r=>{let t=(r%24e3+24e3)%24e3;if(t>=0&&t<12e3)return 15;if(t>=12e3&&t<13e3){let e=(t-12e3)/1e3;return Math.round(15-e*11)}else{if(t>=13e3&&t<23e3)return 4;{let e=(t-23e3)/1e3;return Math.round(4+e*11)}}},oo=()=>{let r=[{ticks:0,label:"6:00 AM (sunrise)"},{ticks:6e3,label:"12:00 PM (noon)"},{ticks:12e3,label:"6:00 PM (sunset starts)"},{ticks:12500,label:"6:30 PM (sunset mid)"},{ticks:13e3,label:"7:00 PM (night begins)"},{ticks:18e3,label:"12:00 AM (midnight)"},{ticks:19e3,label:"1:00 AM"},{ticks:23e3,label:"5:00 AM (dawn begins)"},{ticks:23500,label:"5:30 AM (dawn mid)"}];for(let{ticks:t,label:e}of r){let i=so(t),n=J1(t)}};typeof window<"u"&&(window.debugSkyLight=oo);function lo(r,t){return(r%t+t)%t}var Kt=class Kt{constructor(t,e,i){this.resourcesManager=t;this.displayOptions=e;this.initOptions=i;f(this,"worldReadyResolvers",Promise.withResolvers());f(this,"worldReadyPromise",this.worldReadyResolvers.promise);f(this,"timeOfTheDay",0);f(this,"worldSizeParams",{minY:0,worldHeight:256});f(this,"reactiveDebugParams",ao({stopRendering:!1,chunksRenderAboveOverride:void 0,chunksRenderAboveEnabled:!1,chunksRenderBelowOverride:void 0,chunksRenderBelowEnabled:!1,chunksRenderDistanceOverride:void 0,chunksRenderDistanceEnabled:!1,disableEntities:!1}));f(this,"active",!1);f(this,"loadedChunks",{});f(this,"finishedChunks",{});f(this,"finishedSections",{});f(this,"sectionsWaiting",new Map);f(this,"queuedChunks",new Set);f(this,"queuedFunctions",[]);f(this,"renderUpdateEmitter",new Wt);f(this,"customTexturesDataUrl");f(this,"workers",[]);f(this,"viewerChunkPosition");f(this,"lastCamUpdate",0);f(this,"droppedFpsPercentage",0);f(this,"initialChunkLoadWasStartedIn");f(this,"initialChunksLoad",!0);f(this,"enableChunksLoadDelay",!1);f(this,"texturesVersion");f(this,"viewDistance",-1);f(this,"onRenderDistanceChanged");f(this,"chunksLength",0);f(this,"allChunksFinished",!1);f(this,"messageQueue",[]);f(this,"isProcessingQueue",!1);f(this,"ONMESSAGE_TIME_LIMIT",30);f(this,"handleResize",()=>{});f(this,"highestBlocksByChunks",new Map);f(this,"blockEntities",{});f(this,"workersProcessAverageTime",0);f(this,"workersProcessAverageTimeCount",0);f(this,"maxWorkersProcessTime",0);f(this,"geometryReceiveCount",{});f(this,"allLoadedIn");f(this,"onWorldSwitched",[]);f(this,"renderTimeMax",0);f(this,"renderTimeAvg",0);f(this,"renderTimeAvgCount",0);f(this,"edgeChunks",{});f(this,"lastAddChunk",null);f(this,"neighborChunkUpdates",!0);f(this,"lastChunkDistance",0);f(this,"debugStopGeometryUpdate",!1);f(this,"protocolCustomBlocks",new Map);f(this,"heightmapDebounceTimers",new Map);f(this,"sectionDirtyCount",new Map);f(this,"sectionDirtyTimers",new Map);f(this,"sectionDirtyPendingArgs",new Map);f(this,"blockStateModelInfo",new Map);f(this,"worldBlockProvider");f(this,"soundSystem");f(this,"worldRendererConfig");f(this,"playerStateReactive");f(this,"playerStateUtils");f(this,"reactiveState");f(this,"mesherLogReader");f(this,"forceCallFromMesherReplayer",!1);f(this,"stopMesherMessagesProcessing",!1);f(this,"abortController",new AbortController);f(this,"lastRendered",0);f(this,"renderingActive",!0);f(this,"geometryReceiveCountPerSec",0);f(this,"mesherLogger",{contents:[],active:new URL(location.href).searchParams.get("mesherlog")==="true"});f(this,"currentRenderedFrames",0);f(this,"fpsAverage",0);f(this,"lastFps",0);f(this,"fpsWorst");f(this,"fpsSamples",0);f(this,"backendInfoReport","-");f(this,"chunksFullInfo","-");f(this,"workerCustomHandleTime",0);f(this,"queueAwaited",!1);f(this,"toWorkerMessagesQueue",{});this.snapshotInitialValues(),this.worldRendererConfig=e.inWorldRenderingConfig,this.playerStateReactive=e.playerStateReactive,this.playerStateUtils=Dn(this.playerStateReactive),this.reactiveState=e.rendererState,this.renderUpdateEmitter.on("update",()=>{let o=Object.keys(this.finishedChunks).length;G1("loaded-chunks",`${o}/${this.chunksLength} chunks (${this.lastChunkDistance}/${this.viewDistance})`)}),ue("downloaded-chunks",100,140,20),this.connect(this.displayOptions.worldView);let n=setInterval(()=>{this.geometryReceiveCountPerSec=Object.values(this.geometryReceiveCount).reduce((o,a)=>o+a,0),this.geometryReceiveCount={},vr(this.displayAdvancedStats),this.updateChunksStats()},500),s=setInterval(()=>{this.fpsUpdate()},1e3);this.abortController.signal.addEventListener("abort",()=>{clearInterval(n),clearInterval(s)})}anyModuleRequiresHeightmap(){return!1}get version(){return this.displayOptions.version}get displayAdvancedStats(){return(this.initOptions.config.statsVisible??0)>1}fpsUpdate(){this.fpsSamples++,this.fpsAverage=(this.fpsAverage*(this.fpsSamples-1)+this.currentRenderedFrames)/this.fpsSamples,this.fpsWorst===void 0?this.fpsWorst=this.currentRenderedFrames:this.fpsWorst=Math.min(this.fpsWorst,this.currentRenderedFrames),this.lastFps=this.currentRenderedFrames,this.displayOptions.nonReactiveState.fps=this.currentRenderedFrames,this.displayOptions.nonReactiveState.worstRenderTime=this.renderTimeMax,this.displayOptions.nonReactiveState.avgRenderTime=this.renderTimeAvg,this.currentRenderedFrames=0}logWorkerWork(t){this.mesherLogger.active&&this.mesherLogger.contents.push(typeof t=="function"?t():t)}async init(){if(this.active)throw new Error("WorldRendererCommon is already initialized");await Promise.all([this.resetWorkers(),(async()=>{this.resourcesManager.currentResources?.allReady&&await this.updateAssetsData()})()]),this.resourcesManager.on("assetsTexturesUpdated",async()=>{this.active&&await this.updateAssetsData()}),this.watchReactivePlayerState(),this.watchReactiveConfig(),this.worldReadyResolvers.resolve()}snapshotInitialValues(){}wasChunkSentToWorker(t){return this.loadedChunks[t]}async getHighestBlocks(t){return this.highestBlocksByChunks.get(t)}updateCustomBlock(t,e,i){if(this.protocolCustomBlocks.set(t,{...this.protocolCustomBlocks.get(t),[e]:i}),this.logWorkerWork(()=>`-> updateCustomBlock ${t} ${e} ${i} ${this.wasChunkSentToWorker(t)}`),this.wasChunkSentToWorker(t)){let[n,s,o]=e.split(",").map(Number);this.setBlockStateId(new Qt(n,s,o),void 0)}}async getBlockInfo(t,e){let n=`${Math.floor(t.x/16)*16},${Math.floor(t.z/16)*16}`,s=this.protocolCustomBlocks.get(n)?.[`${t.x},${t.y},${t.z}`],o=ir(e,s),a=this.blockStateModelInfo.get(o);return{customBlockName:s,modelInfo:a}}initWorkers(t=this.worldRendererConfig.mesherWorkers){for(let e=0;e<t+0;e++){let i=co(n=>{Array.isArray(n)?this.messageQueue.push(...n):this.messageQueue.push(n),this.processMessageQueue("worker")},this.worldRendererConfig.wasmMesher?"mesherWasm.js":"mesher.js");this.workers.push(i)}}onReactivePlayerStateUpdated(t,e,i=!0){return i&&e(this.playerStateReactive[t]),q1(this.playerStateReactive,t,e)}onReactiveConfigUpdated(t,e){e(this.worldRendererConfig[t]),t==="*"?vo(this.worldRendererConfig,e):q1(this.worldRendererConfig,t,e)}onReactiveDebugUpdated(t,e){e(this.reactiveDebugParams[t]),q1(this.reactiveDebugParams,t,e)}watchReactivePlayerState(){this.onReactivePlayerStateUpdated("backgroundColor",t=>{this.changeBackgroundColor(t)}),this.onReactivePlayerStateUpdated("cardinalLight",t=>{this.changeCardinalLight(t)})}watchReactiveConfig(){this.onReactiveConfigUpdated("fetchPlayerSkins",t=>{fr({apiEnabled:t})})}async processMessageQueue(t){if(this.isProcessingQueue||this.messageQueue.length===0)return;if(this.logWorkerWork(`# ${t} processing queue`),this.lastRendered&&performance.now()-this.lastRendered>this.ONMESSAGE_TIME_LIMIT&&this.worldRendererConfig._experimentalSmoothChunkLoading&&this.renderingActive){let n=performance.now();await new Promise(s=>{requestAnimationFrame(s)}),this.logWorkerWork(`# processing got delayed by ${performance.now()-n}ms`)}this.isProcessingQueue=!0;let e=performance.now(),i=0;for(;this.messageQueue.length>0;){let n=this.stopMesherMessagesProcessing;if(!n){let s=this.messageQueue.shift();this.handleMessage(s),i++}if(n||performance.now()-e>this.ONMESSAGE_TIME_LIMIT&&this.renderingActive&&this.worldRendererConfig._experimentalSmoothChunkLoading){if(this.messageQueue.length>0){requestAnimationFrame(async()=>{this.isProcessingQueue=!1,this.processMessageQueue("queue-delay")});return}break}}this.isProcessingQueue=!1}handleMessage(t){var i,n;let e=t;if(this.active){if(this.mesherLogReader?.workerMessageReceived(e.type,e),e.type!=="geometry"||!this.debugStopGeometryUpdate){let s=performance.now();this.handleWorkerMessage(e),this.workerCustomHandleTime+=performance.now()-s}if(e.type==="geometry"){this.logWorkerWork(()=>`-> ${e.workerIndex} geometry ${e.key} ${JSON.stringify({dataSize:JSON.stringify(e).length})}`),(i=this.geometryReceiveCount)[n=e.workerIndex]??(i[n]=0),this.geometryReceiveCount[e.workerIndex]++;let s=e.key.split(",").map(Number);this.lastChunkDistance=Math.max(...this.getDistance(new Qt(s[0],0,s[2])))}if(e.type==="sectionFinished"){if(this.logWorkerWork(`<- ${e.workerIndex} sectionFinished ${e.key} ${JSON.stringify({processTime:e.processTime})}`),!this.sectionsWaiting.has(e.key))throw new Error(`sectionFinished event for non-outstanding section ${e.key}`);this.sectionsWaiting.set(e.key,this.sectionsWaiting.get(e.key)-1),this.sectionsWaiting.get(e.key)===0&&(this.sectionsWaiting.delete(e.key),this.finishedSections[e.key]=!0);let s=e.key.split(",").map(Number),o=`${s[0]},${s[2]}`;if(this.loadedChunks[o]){let a=!0,v=this.getSectionHeight();if(Ve){let l=this.worldMinYRender;this.finishedSections[`${s[0]},${l},${s[2]}`]||(a=!1)}else for(let l=this.worldMinYRender;l<this.worldSizeParams.worldHeight;l+=v)if(!this.finishedSections[`${s[0]},${l},${s[2]}`]){a=!1;break}if(a){this.finishedChunks[o]=!0;let l=16;this.reactiveState.world.chunksLoaded.add(`${Math.floor(s[0]/l)},${Math.floor(s[2]/l)}`),this.renderUpdateEmitter.emit("chunkFinished",`${s[0]},${s[2]}`),this.checkAllFinished()}}this.renderUpdateEmitter.emit("update"),e.processTime&&(this.workersProcessAverageTimeCount++,this.workersProcessAverageTime=(this.workersProcessAverageTime*(this.workersProcessAverageTimeCount-1)+e.processTime)/this.workersProcessAverageTimeCount,this.maxWorkersProcessTime=Math.max(this.maxWorkersProcessTime,e.processTime))}if(e.type==="blockStateModelInfo")for(let[s,o]of Object.entries(e.info))this.blockStateModelInfo.set(s,o);e.type==="heightmap"&&this.reactiveState.world.heightmaps.set(e.key,new Int16Array(e.heightmap))}}downloadMesherLog(){let t=document.createElement("a");t.href="data:text/plain;charset=utf-8,"+encodeURIComponent(this.mesherLogger.contents.join(`
|
|
16
|
+
`)),t.download="mesher.log",t.click()}checkAllFinished(){this.sectionsWaiting.size===0&&(this.reactiveState.world.mesherWork=!1),Object.keys(this.finishedChunks).length>=this.chunksLength&&(this.allChunksLoaded?.(),this.allChunksFinished=!0,this.allLoadedIn??(this.allLoadedIn=Date.now()-this.initialChunkLoadWasStartedIn)),this.updateChunksStats()}changeHandSwingingState(t,e){}updateViewerPosition(t){this.viewerChunkPosition=t;for(let[e,i]of Object.entries(this.loadedChunks))i&&this.updatePosDataChunk?.(e)}sendWorkers(t){for(let e of this.workers)e.postMessage(t)}getDistance(t){let[e,i]=de(this.viewerChunkPosition),n=16,s=Math.abs(e-Math.floor(t.x/n)),o=Math.abs(i-Math.floor(t.z/n));return[s,o]}resetWorld(){for(let t of this.workers)t.terminate();this.workers=[]}async resetWorkers(){this.resetWorld(),typeof document<"u"&&document?.readyState==="loading"&&await new Promise(t=>{document.addEventListener("DOMContentLoaded",t)}),this.initWorkers(),this.active=!0,this.sendMesherMcData()}getMesherConfig(){let t=this.timeOfTheDay,e=t<0||t>24e3?15:J1(t);return{version:this.version,enableLighting:this.worldRendererConfig.enableLighting,skyLight:e,smoothLighting:this.worldRendererConfig.smoothLighting,shadingTheme:this.worldRendererConfig.shadingTheme,cardinalLight:this.worldRendererConfig.cardinalLight,outputFormat:this.outputFormat,debugModelVariant:this.worldRendererConfig.debugModelVariant,clipWorldBelowY:this.worldRendererConfig.clipWorldBelowY,disableBlockEntityTextures:!this.worldRendererConfig.extraBlockRenderers,worldMinY:this.worldMinYRender,worldMaxY:this.worldMinYRender+this.worldSizeParams.worldHeight}}sendMesherMcData(){let t=this.resourcesManager.currentResources.mcData;Z1(this.workers,this.version,We,t),this.logWorkerWork("# mcData sent")}async updateAssetsData(){let t=this.resourcesManager.currentResources;if(this.workers.length===0)throw new Error("workers not initialized yet");for(let[e,i]of this.workers.entries()){let{blockstatesModels:n}=t;i.postMessage({type:"mesherData",workerIndex:e,blocksAtlas:{latest:t.blocksAtlasJson},blockstatesModels:n,config:this.getMesherConfig()})}this.logWorkerWork("# mesherData sent")}getSectionHeight(){return Ve?this.worldSizeParams.worldHeight:er}get worldMinYRender(){let t=this.getSectionHeight();return Math.floor(Math.max(this.worldSizeParams.minY,this.worldRendererConfig.clipWorldBelowY??-1/0)/t)*t}updateChunksStats(){let t=Object.keys(this.finishedChunks);this.displayOptions.nonReactiveState.world.chunksLoaded=new Set(t),this.displayOptions.nonReactiveState.world.chunksTotalNumber=this.chunksLength,this.reactiveState.world.allChunksLoaded=this.allChunksFinished;let e=`Q: ${this.messageQueue.length} ${Object.keys(this.loadedChunks).length}/${Object.keys(this.finishedChunks).length}/${this.chunksLength} chunks (${this.workers.length}:${this.workersProcessAverageTime.toFixed(0)}ms/${this.geometryReceiveCountPerSec}ss/${this.allLoadedIn?.toFixed(1)??"-"}s)`;this.chunksFullInfo=e,G1("downloaded-chunks",e)}addColumn(t,e,i,n){if(!this.active)return;if(this.workers.length===0)throw new Error("workers not initialized yet");this.initialChunksLoad=!1,this.initialChunkLoadWasStartedIn??(this.initialChunkLoadWasStartedIn=Date.now()),this.loadedChunks[`${t},${e}`]=!0,this.updateChunksStats();let s=`${t},${e}`,o=this.protocolCustomBlocks.get(s);for(let l of this.workers)l.postMessage({type:"chunk",x:t,z:e,chunk:i,customBlockModels:o||void 0});this.workers[0].postMessage({type:"getHeightmap",x:t,z:e}),this.logWorkerWork(()=>`-> chunk ${JSON.stringify({x:t,z:e,chunkLength:i.length,customBlockModelsLength:o?Object.keys(o).length:0})}`),this.mesherLogReader?.chunkReceived(t,e,i.length);let a=this.getSectionHeight(),v=16;if(Ve){let l=new Qt(t,this.worldMinYRender,e);this.setSectionDirty(l),this.neighborChunkUpdates&&(!n||this.worldRendererConfig.smoothLighting)&&(this.setSectionDirty(l.offset(-v,0,0)),this.setSectionDirty(l.offset(v,0,0)),this.setSectionDirty(l.offset(0,0,-v)),this.setSectionDirty(l.offset(0,0,v)))}else for(let l=this.worldMinYRender;l<this.worldSizeParams.worldHeight;l+=a){let c=new Qt(t,l,e);this.setSectionDirty(c),this.neighborChunkUpdates&&(!n||this.worldRendererConfig.smoothLighting)&&(this.setSectionDirty(c.offset(-v,0,0)),this.setSectionDirty(c.offset(v,0,0)),this.setSectionDirty(c.offset(0,0,-v)),this.setSectionDirty(c.offset(0,0,v)))}}markAsLoaded(t,e){this.loadedChunks[`${t},${e}`]=!0,this.finishedChunks[`${t},${e}`]=!0,this.logWorkerWork(`-> markAsLoaded ${JSON.stringify({x:t,z:e})}`),this.checkAllFinished()}removeColumn(t,e){delete this.loadedChunks[`${t},${e}`];let i=`${t},${e}`,n=this.heightmapDebounceTimers.get(i);n&&(clearTimeout(n),this.heightmapDebounceTimers.delete(i));for(let[o,a]of this.sectionDirtyTimers)o.startsWith(`${t},`)&&o.endsWith(`,${e}`)&&(clearTimeout(a),this.sectionDirtyTimers.delete(o),this.sectionDirtyCount.delete(o),this.sectionDirtyPendingArgs.delete(o));for(let o of this.workers)o.postMessage({type:"unloadChunk",x:t,z:e});this.logWorkerWork(`-> unloadChunk ${JSON.stringify({x:t,z:e})}`),delete this.finishedChunks[`${t},${e}`],this.allChunksFinished=Object.keys(this.finishedChunks).length===this.chunksLength,Object.keys(this.finishedChunks).length===0&&(this.allLoadedIn=void 0,this.initialChunkLoadWasStartedIn=void 0);let s=this.getSectionHeight();if(Ve){let o=this.worldMinYRender;this.setSectionDirty(new Qt(t,o,e),!1),delete this.finishedSections[`${t},${o},${e}`]}else for(let o=this.worldSizeParams.minY;o<this.worldSizeParams.worldHeight;o+=s)this.setSectionDirty(new Qt(t,o,e),!1),delete this.finishedSections[`${t},${o},${e}`];this.highestBlocksByChunks.delete(`${t},${e}`),this.reactiveState.world.heightmaps.delete(`${Math.floor(t/16)},${Math.floor(e/16)}`),this.updateChunksStats(),Object.keys(this.loadedChunks).length===0&&(this.mesherLogger.contents=[],this.logWorkerWork("# all chunks unloaded. New log started"),this.mesherLogReader?.maybeStartReplay())}setBlockStateId(t,e,i=!0){(async()=>{let o=Math.floor(t.x/16)*16,a=Math.floor(t.z/16)*16;this.queuedChunks.has(`${o},${a}`)&&await new Promise(v=>{this.queuedFunctions.push(()=>{v()})}),this.loadedChunks[`${o},${a}`],this.setBlockStateIdInner(t,e,i)})()}updateEntity(t,e=!1){}lightUpdate(t,e){}connect(t){let e=t;e.on("entity",n=>{this.updateEntity(n,!1)}),e.on("entityMoved",n=>{this.updateEntity(n,!0)}),e.on("playerEntity",n=>{this.updatePlayerEntity?.(n)});let i=null;e.on("loadChunk",({x:n,z:s,chunk:o,worldConfig:a,isLightUpdate:v})=>{this.worldSizeParams=a,this.queuedChunks.add(`${n},${s}`);let l=[n,s,o,v];i||(i={data:[],timeout:setTimeout(()=>{for(let c of i.data)this.queuedChunks.delete(`${c[0]},${c[1]}`),this.addColumn(...c);for(let c of this.queuedFunctions)c();this.queuedFunctions=[],i=null},this.worldRendererConfig.addChunksBatchWaitTime)}),i.data.push(l)}),e.on("blockEntities",n=>{this.blockEntities=n}),e.on("unloadChunk",({x:n,z:s})=>{this.removeColumn(n,s)}),e.on("blockUpdate",({pos:n,stateId:s})=>{this.setBlockStateId(new Qt(n.x,n.y,n.z),s)}),e.on("chunkPosUpdate",({pos:n})=>{this.updateViewerPosition(n)}),e.on("end",()=>{this.worldStop?.()}),e.on("renderDistance",n=>{this.viewDistance=n,this.chunksLength=n===0?1:De(n).length,this.allChunksFinished=Object.keys(this.finishedChunks).length===this.chunksLength,this.onRenderDistanceChanged?.(n)}),e.on("markAsLoaded",({x:n,z:s})=>{this.markAsLoaded(n,s)}),e.on("updateLight",({pos:n})=>{this.lightUpdate(n.x,n.z)}),e.on("onWorldSwitch",()=>{for(let n of this.onWorldSwitched)try{n()}catch(s){setTimeout(()=>{throw s},0)}}),e.on("time",n=>{this.worldRendererConfig.dayCycle&&(this.timeUpdated?.(n),this.timeOfTheDay=n)}),e.on("biomeUpdate",({biome:n})=>{this.biomeUpdated?.(n)}),e.on("biomeReset",()=>{this.biomeReset?.()})}setBlockStateIdInner(t,e,i=!0){let s=`${Math.floor(t.x/16)*16},${Math.floor(t.z/16)*16}`,o=`${t.x},${t.y},${t.z}`,a=this.protocolCustomBlocks.get(s)||{};for(let v of this.workers)v.postMessage({type:"blockUpdate",pos:t,stateId:e,customBlockModels:a});if(this.anyModuleRequiresHeightmap()){let v=Math.floor(t.x/16)*16,l=Math.floor(t.z/16)*16,c=`${v},${l}`,d=this.heightmapDebounceTimers.get(c);d&&clearTimeout(d),this.heightmapDebounceTimers.set(c,setTimeout(()=>{this.heightmapDebounceTimers.delete(c),this.workers[0]?.postMessage({type:"getHeightmap",x:v,z:l})},100))}if(this.logWorkerWork(`-> blockUpdate ${JSON.stringify({pos:t,stateId:e,customBlockModels:a})}`),this.setSectionDirty(t,!0,!0),this.neighborChunkUpdates){let l=this.getSectionHeight();t.x&15||this.setSectionDirty(t.offset(-16,0,0),!0,!0),(t.x&15)===15&&this.setSectionDirty(t.offset(16,0,0),!0,!0),t.y&l-1||this.setSectionDirty(t.offset(0,-l,0),!0,!0),(t.y&l-1)===l-1&&this.setSectionDirty(t.offset(0,l,0),!0,!0),t.z&15||this.setSectionDirty(t.offset(0,0,-16),!0,!0),(t.z&15)===15&&this.setSectionDirty(t.offset(0,0,16),!0,!0),i&&(!(t.x&15)&&!(t.z&15)&&this.setSectionDirty(t.offset(-16,0,-16),!0,!0),(t.x&15)===15&&!(t.z&15)&&this.setSectionDirty(t.offset(16,0,-16),!0,!0),!(t.x&15)&&(t.z&15)===15&&this.setSectionDirty(t.offset(-16,0,16),!0,!0),(t.x&15)===15&&(t.z&15)===15&&this.setSectionDirty(t.offset(16,0,16),!0,!0),!(t.x&15)&&!(t.y&l-1)&&this.setSectionDirty(t.offset(-16,-l,0),!0,!0),(t.x&15)===15&&!(t.y&l-1)&&this.setSectionDirty(t.offset(16,-l,0),!0,!0),!(t.z&15)&&!(t.y&l-1)&&this.setSectionDirty(t.offset(0,-l,-16),!0,!0),(t.z&15)===15&&!(t.y&l-1)&&this.setSectionDirty(t.offset(0,-l,16),!0,!0),!(t.y&l-1)&&!(t.x&15)&&!(t.z&15)&&this.setSectionDirty(t.offset(-16,-l,-16),!0,!0),!(t.y&l-1)&&(t.x&15)===15&&!(t.z&15)&&this.setSectionDirty(t.offset(16,-l,-16),!0,!0),!(t.y&l-1)&&!(t.x&15)&&(t.z&15)===15&&this.setSectionDirty(t.offset(-16,-l,16),!0,!0),!(t.y&l-1)&&(t.x&15)===15&&(t.z&15)===15&&this.setSectionDirty(t.offset(16,-l,16),!0,!0))}}getWorkerNumber(t,e=!1){let n=this.getSectionHeight();if(e){let o=`${Math.floor(t.x/16)*16},${Math.floor(t.y/n)*n},${Math.floor(t.z/16)*16}`;if(!(this.sectionsWaiting.get(o)&&!this.finishedSections[o]))return 0}return lo(Math.floor(t.x/16)+Math.floor(t.y/n)+Math.floor(t.z/16),this.workers.length)+0}async debugGetWorkerCustomBlockModel(t){let e=[];for(let i of this.workers)e.push(new Promise(n=>{i.addEventListener("message",s=>{s.data.type==="customBlockModel"&&n(s.data.customBlockModel)})})),i.postMessage({type:"getCustomBlockModel",pos:t});return Promise.all(e)}setSectionDirty(t,e=!0,i=!1){if(!this.forceCallFromMesherReplayer&&this.mesherLogReader)return;if(this.viewDistance===-1)throw new Error("viewDistance not set");let n=this.getDistance(t);if(!this.workers.length||n[0]>this.viewDistance||n[1]>this.viewDistance)return;if(!e){this._dispatchDirtyImmediate(t,e,i);return}let s=16,o=this.getSectionHeight(),a=`${Math.floor(t.x/s)*s},${Math.floor(t.y/o)*o},${Math.floor(t.z/s)*s}`,v=(this.sectionDirtyCount.get(a)??0)+1;this.sectionDirtyCount.set(a,v),v<=Kt.GEOMETRY_THROTTLE_THRESHOLD?(this._dispatchDirtyImmediate(t,e,i),this.sectionDirtyTimers.has(a)||this.sectionDirtyTimers.set(a,setTimeout(()=>{let l=this.sectionDirtyPendingArgs.get(a);this.sectionDirtyCount.delete(a),this.sectionDirtyTimers.delete(a),this.sectionDirtyPendingArgs.delete(a),l&&this._dispatchDirtyImmediate(l.pos,l.value,l.useChangeWorker)},Kt.GEOMETRY_THROTTLE_DELAY))):(this.sectionDirtyPendingArgs.set(a,{pos:t,value:e,useChangeWorker:i}),this.sectionDirtyTimers.has(a)||this.sectionDirtyTimers.set(a,setTimeout(()=>{let l=this.sectionDirtyPendingArgs.get(a);this.sectionDirtyCount.delete(a),this.sectionDirtyTimers.delete(a),this.sectionDirtyPendingArgs.delete(a),l&&this._dispatchDirtyImmediate(l.pos,l.value,l.useChangeWorker)},Kt.GEOMETRY_THROTTLE_DELAY)))}_dispatchDirtyImmediate(t,e,i){var v;this.reactiveState.world.mesherWork=!0;let n=16,s=this.getSectionHeight(),o=`${Math.floor(t.x/n)*n},${Math.floor(t.y/s)*s},${Math.floor(t.z/n)*n}`;this.renderUpdateEmitter.emit("dirty",t,e);let a=this.getWorkerNumber(t,i&&this.mesherLogger.active);this.sectionsWaiting.set(o,(this.sectionsWaiting.get(o)??0)+1),this.forceCallFromMesherReplayer?this.workers[a].postMessage({type:"dirty",x:t.x,y:t.y,z:t.z,value:e,config:this.getMesherConfig()}):((v=this.toWorkerMessagesQueue)[a]??(v[a]=[]),this.toWorkerMessagesQueue[a].push({type:"dirty",x:t.x,y:t.y,z:t.z,value:e,config:this.getMesherConfig()}),this.dispatchMessages())}dispatchMessages(){this.queueAwaited||(this.queueAwaited=!0,setTimeout(()=>{for(let t in this.toWorkerMessagesQueue){this.workers[Number(t)].postMessage(this.toWorkerMessagesQueue[t]);for(let i of this.toWorkerMessagesQueue[t])this.logWorkerWork(`-> ${t} dispatchMessages ${i.type} ${JSON.stringify({x:i.x,y:i.y,z:i.z,value:i.value})}`)}this.toWorkerMessagesQueue={},this.queueAwaited=!1}))}async waitForChunksToRender(){return new Promise((t,e)=>{if([...this.sectionsWaiting].length===0){t();return}let i=()=>{this.sectionsWaiting.size===0&&(this.renderUpdateEmitter.removeListener("update",i),t())};this.renderUpdateEmitter.on("update",i)})}async waitForChunkToLoad(t){return new Promise((e,i)=>{let s=`${Math.floor(t.x/16)*16},${Math.floor(t.z/16)*16}`;if(this.loadedChunks[s]){e();return}let o=()=>{this.loadedChunks[s]&&(this.renderUpdateEmitter.removeListener("update",o),e())};this.renderUpdateEmitter.on("update",o)})}destroy(){for(let t of this.heightmapDebounceTimers.values())clearTimeout(t);this.heightmapDebounceTimers.clear();for(let t of this.sectionDirtyTimers.values())clearTimeout(t);this.sectionDirtyTimers.clear(),this.sectionDirtyCount.clear(),this.sectionDirtyPendingArgs.clear();for(let t of this.workers)t.terminate();this.workers=[],this.soundSystem&&(this.soundSystem.destroy(),this.soundSystem=void 0),this.active=!1,this.loadedChunks={},this.finishedChunks={},this.finishedSections={},this.sectionsWaiting.clear(),this.queuedChunks.clear(),this.blockStateModelInfo.clear(),this.renderUpdateEmitter.removeAllListeners(),this.abortController.abort(),lr()}};f(Kt,"GEOMETRY_THROTTLE_THRESHOLD",1),f(Kt,"GEOMETRY_THROTTLE_DELAY",100);var L5=Kt,co=(r,t="mesher.js")=>{let e;if(D.env.SINGLE_FILE_BUILD){let i=document.getElementById("mesher-worker-code").textContent,n=new Blob([i],{type:"text/javascript"});e=new Worker(window.URL.createObjectURL(n))}else e=new Worker(t);return e.onmessage=({data:i})=>{r(i)},e.on&&e.on("message",i=>{e.onmessage({data:i})}),e},Z1=(r,t,e=We,i)=>{let n={version:JSON.parse(JSON.stringify(i.version))};for(let[s,o]of Object.entries(e))n[s]=i[o];for(let s of r)s.postMessage({type:"mcData",mcData:n})};x();R();T();k();import{Vec3 as uo}from"vec3";import*as X0 from"three";x();R();T();k();function F5(r,t){let e=t/180*Math.PI,i=Math.cos(e),n=Math.sin(e),s={x:0,y:1,z:2}[r],o=(s+1)%3,a=(s+2)%3,v=[[0,0,0],[0,0,0],[0,0,0]];return v[s][s]=1,v[o][o]=i,v[o][a]=-n,v[a][o]=+n,v[a][a]=i,v}function X1(r,t){return t?[r[0]+t[0],r[1]+t[1],r[2]+t[2]]:r}function $1(r,t){return t?[r[0]-t[0],r[1]-t[1],r[2]-t[2]]:r}function fe(r,t){return r?[r[0][0]*t[0]+r[0][1]*t[1]+r[0][2]*t[2],r[1][0]*t[0]+r[1][1]*t[1]+r[1][2]*t[2],r[2][0]*t[0]+r[2][1]*t[1]+r[2][2]*t[2]]:t}function hr(r,t){let e=[[0,0,0],[0,0,0],[0,0,0]],i=r[0][0],n=r[1][0],s=r[2][0],o=r[0][1],a=r[1][1],v=r[2][1],l=r[0][2],c=r[1][2],d=r[2][2],m=t[0][0],p=t[1][0],g=t[2][0],y=t[0][1],E=t[1][1],w=t[2][1],_=t[0][2],C=t[1][2],M=t[2][2];return e[0][0]=i*m+n*y+s*_,e[1][0]=i*p+n*E+s*C,e[2][0]=i*g+n*w+s*M,e[0][1]=o*m+a*y+v*_,e[1][1]=o*p+a*E+v*C,e[2][1]=o*g+a*w+v*M,e[0][2]=l*m+c*y+d*_,e[1][2]=l*p+c*E+d*C,e[2][2]=l*g+c*w+d*M,e}var t2={up:{dir:[0,1,0],mask1:[1,1,0],mask2:[0,1,1],corners:[[0,1,1,0,1],[1,1,1,1,1],[0,1,0,0,0],[1,1,0,1,0]]},down:{dir:[0,-1,0],mask1:[1,1,0],mask2:[0,1,1],corners:[[1,0,1,0,1],[0,0,1,1,1],[1,0,0,0,0],[0,0,0,1,0]]},east:{dir:[1,0,0],mask1:[1,1,0],mask2:[1,0,1],corners:[[1,1,1,0,0],[1,0,1,0,1],[1,1,0,1,0],[1,0,0,1,1]]},west:{dir:[-1,0,0],mask1:[1,1,0],mask2:[1,0,1],corners:[[0,1,0,0,0],[0,0,0,0,1],[0,1,1,1,0],[0,0,1,1,1]]},north:{dir:[0,0,-1],mask1:[1,0,1],mask2:[0,1,1],corners:[[1,0,0,1,1],[0,0,0,0,1],[1,1,0,1,0],[0,1,0,0,0]]},south:{dir:[0,0,1],mask1:[1,0,1],mask2:[0,1,1],corners:[[0,0,1,0,1],[1,0,1,1,1],[0,1,1,0,0],[1,1,1,1,0]]}};function fo(r,t,e,i,n,s,o,a){let v=new uo(0,0,0);for(let l in r.faces){let c=r.faces[l],{corners:d,mask1:m,mask2:p}=t2[l],g=fe(i,t2[l].dir);if(c.cullface&&a[l])continue;let y=r.from[0],E=r.from[1],w=r.from[2],_=r.to[0],C=r.to[1],M=r.to[2],S=c.texture,{u:H}=S,{v:B}=S,{su:I}=S,{sv:W}=S,z=Math.floor(e.positions.length/3),j=[1,1,1];c.tintindex!==void 0&&c.tintindex===0&&(j=[.5686274509803921,.7411764705882353,.34901960784313724]);let q=c.rotation||0,e0=Math.cos(q*Math.PI/180),N=-Math.sin(q*Math.PI/180),Z=null,K=null;r.rotation&&(Z=F5(r.rotation.axis,r.rotation.angle),K=$1(r.rotation.origin,fe(Z,r.rotation.origin)));let n0=[],s0=1;for(let l0 of d){let $=[l0[0]?_:y,l0[1]?C:E,l0[2]?M:w];$=X1(fe(Z,$),K),$=X1(fe(i,$),n),$=$.map(Y0=>Y0/16),e.positions.push($[0],$[1],$[2]),e.normals.push(...g);let u0=(l0[3]-.5)*e0-(l0[4]-.5)*N+.5,$0=(l0[3]-.5)*N+(l0[4]-.5)*e0+.5;e.uvs.push(u0*I+H,$0*W+B);let z0=1;t&&(z0=4/4*(15/15),n0.push(3)),e.colors.push(s0*j[0]*z0,s0*j[1]*z0,s0*j[2]*z0)}t&&n0[0]+n0[3]>=n0[1]+n0[2]?e.indices.push(z,z+3,z+2,z,z+1,z+3):e.indices.push(z,z+1,z+2,z+2,z+1,z+3)}}var ho=(r,t,e,i,n=[],s={})=>{let l={sx:.5,sy:.5,sz:.5,positions:[],normals:[],colors:[],uvs:[],t_positions:[],t_normals:[],t_colors:[],t_uvs:[],indices:[],tiles:{}};for(let[d,m]of r.entries()){let p=m[n[d]]??m[0];if(!p)continue;let g=null,y=null;for(let w of["x","y","z"])w in p&&(g?g=hr(g,F5(w,-(p[w]??0))):g=F5(w,-(p[w]??0)));g&&(y=[8,8,8],y=$1(y,fe(g,y)));let E=p.ao??!0;for(let w of p.elements??[])fo(w,E,l,g,y,t,e,s)}let c=l.positions.length/3;for(let d=0;d<l.t_positions.length/12;d++)l.indices.push(c,c+1,c+2,c+2,c+1,c+3,c,c+2,c+1,c+2,c+3,c+1),c+=4;return l.positions.push(...l.t_positions),l.normals.push(...l.t_normals),l.colors.push(...l.t_colors),l.uvs.push(...l.t_uvs),delete l.t_positions,delete l.t_normals,delete l.t_colors,delete l.t_uvs,l.positions=new Float32Array(l.positions),l.normals=new Float32Array(l.normals),l.colors=new Float32Array(l.colors),l.uvs=new Float32Array(l.uvs),l},mo=(...r)=>{let e={geometry:ho(...r)},i=new X0.BufferGeometry;return i.setAttribute("position",new X0.BufferAttribute(e.geometry.positions,3)),i.setAttribute("normal",new X0.BufferAttribute(e.geometry.normals,3)),i.setAttribute("color",new X0.BufferAttribute(e.geometry.colors,3)),i.setAttribute("uv",new X0.BufferAttribute(e.geometry.uvs,2)),i.setIndex(e.geometry.indices),i.name="block-geometry",i},e2=(r,...t)=>{let e=mo(...t),i=new X0.Mesh(e,r);i.position.set(-.5,-.5,-.5);let n=new X0.Group;return n.add(i),n.rotation.set(0,-X0.MathUtils.degToRad(90),0,"ZYX"),globalThis.mesh=n,n},mr=(r,t)=>{r.position.set(t.x+.5,t.y+.5,t.z+.5)};x();R();T();k();import*as H0 from"three";x();R();T();k();import H2 from"prismarine-nbt";import*as V from"three";x();R();T();k();x();R();T();k();import{BoxGeometry as F0,DoubleSide as a2,FrontSide as gr,Group as nt,Mesh as I0,MeshStandardMaterial as je,Vector2 as U5}from"three";function v2(r,t,e,i,n,s,o,a){let v=(B,I,W,z)=>[new U5(B/o,1-z/a),new U5(W/o,1-z/a),new U5(W/o,1-I/a),new U5(B/o,1-I/a)],l=v(t+s,e,t+i+s,e+s),c=v(t+i+s,e,t+i*2+s,e+s),d=v(t,e+s,t+s,e+s+n),m=v(t+s,e+s,t+i+s,e+s+n),p=v(t+i+s,e+s,t+i+s*2,e+n+s),g=v(t+i+s*2,e+s,t+i*2+s*2,e+n+s),y=r.attributes.uv,E=[p[3],p[2],p[0],p[1]],w=[d[3],d[2],d[0],d[1]],_=[l[3],l[2],l[0],l[1]],C=[c[0],c[1],c[3],c[2]],M=[m[3],m[2],m[0],m[1]],S=[g[3],g[2],g[0],g[1]],H=[];for(let B of[E,w,_,C,M,S])for(let I of B)H.push(I.x,I.y);y.set(new Float32Array(H)),y.needsUpdate=!0}function it(r,t,e,i,n,s){v2(r,t,e,i,n,s,64,64)}function i2(r,t,e,i,n,s){v2(r,t,e,i,n,s,64,32)}var bt=class extends nt{constructor(t,e){super(),Object.defineProperty(this,"innerLayer",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"outerLayer",{enumerable:!0,configurable:!0,writable:!0,value:e}),t.name="inner",e.name="outer"}},n2=class extends nt{constructor(){super(),Object.defineProperty(this,"head",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"rightArm",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"leftArm",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"rightLeg",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"leftLeg",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"modelListeners",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"slim",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_map",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"layer1Material",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"layer1MaterialBiased",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"layer2Material",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"layer2MaterialBiased",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.layer1Material=new je({side:gr}),this.layer2Material=new je({side:a2,transparent:!0,alphaTest:1e-5}),this.layer1MaterialBiased=this.layer1Material.clone(),this.layer1MaterialBiased.polygonOffset=!0,this.layer1MaterialBiased.polygonOffsetFactor=1,this.layer1MaterialBiased.polygonOffsetUnits=1,this.layer2MaterialBiased=this.layer2Material.clone(),this.layer2MaterialBiased.polygonOffset=!0,this.layer2MaterialBiased.polygonOffsetFactor=1,this.layer2MaterialBiased.polygonOffsetUnits=1;let t=new F0(8,8,8);it(t,0,0,8,8,8);let e=new I0(t,this.layer1Material),i=new F0(9,9,9);it(i,32,0,8,8,8);let n=new I0(i,this.layer2Material);this.head=new bt(e,n),this.head.name="head",this.head.add(e,n),e.position.y=4,n.position.y=4,this.add(this.head);let s=new F0(8,12,4);it(s,16,16,8,12,4);let o=new I0(s,this.layer1Material),a=new F0(8.5,12.5,4.5);it(a,16,32,8,12,4);let v=new I0(a,this.layer2Material);this.body=new bt(o,v),this.body.name="body",this.body.add(o,v),this.body.position.y=-6,this.add(this.body);let l=new F0,c=new I0(l,this.layer1MaterialBiased);this.modelListeners.push(()=>{c.scale.x=this.slim?3:4,c.scale.y=12,c.scale.z=4,it(l,40,16,this.slim?3:4,12,4)});let d=new F0,m=new I0(d,this.layer2MaterialBiased);this.modelListeners.push(()=>{m.scale.x=this.slim?3.5:4.5,m.scale.y=12.5,m.scale.z=4.5,it(d,40,32,this.slim?3:4,12,4)});let p=new nt;p.add(c,m),this.modelListeners.push(()=>{p.position.x=this.slim?-.5:-1}),p.position.y=-4,this.rightArm=new bt(c,m),this.rightArm.name="rightArm",this.rightArm.add(p),this.rightArm.position.x=-5,this.rightArm.position.y=-2,this.add(this.rightArm);let g=new F0,y=new I0(g,this.layer1MaterialBiased);this.modelListeners.push(()=>{y.scale.x=this.slim?3:4,y.scale.y=12,y.scale.z=4,it(g,32,48,this.slim?3:4,12,4)});let E=new F0,w=new I0(E,this.layer2MaterialBiased);this.modelListeners.push(()=>{w.scale.x=this.slim?3.5:4.5,w.scale.y=12.5,w.scale.z=4.5,it(E,48,48,this.slim?3:4,12,4)});let _=new nt;_.add(y,w),this.modelListeners.push(()=>{_.position.x=this.slim?.5:1}),_.position.y=-4,this.leftArm=new bt(y,w),this.leftArm.name="leftArm",this.leftArm.add(_),this.leftArm.position.x=5,this.leftArm.position.y=-2,this.add(this.leftArm);let C=new F0(4,12,4);it(C,0,16,4,12,4);let M=new I0(C,this.layer1MaterialBiased),S=new F0(4.5,12.5,4.5);it(S,0,32,4,12,4);let H=new I0(S,this.layer2MaterialBiased),B=new nt;B.add(M,H),B.position.y=-6,this.rightLeg=new bt(M,H),this.rightLeg.name="rightLeg",this.rightLeg.add(B),this.rightLeg.position.x=-1.9,this.rightLeg.position.y=-12,this.rightLeg.position.z=-.1,this.add(this.rightLeg);let I=new F0(4,12,4);it(I,16,48,4,12,4);let W=new I0(I,this.layer1MaterialBiased),z=new F0(4.5,12.5,4.5);it(z,0,48,4,12,4);let j=new I0(z,this.layer2MaterialBiased),q=new nt;q.add(W,j),q.position.y=-6,this.leftLeg=new bt(W,j),this.leftLeg.name="leftLeg",this.leftLeg.add(q),this.leftLeg.position.x=1.9,this.leftLeg.position.y=-12,this.leftLeg.position.z=-.1,this.add(this.leftLeg),this.modelType="default"}get map(){return this._map}set map(t){this._map=t,this.layer1Material.map=t,this.layer1Material.needsUpdate=!0,this.layer1MaterialBiased.map=t,this.layer1MaterialBiased.needsUpdate=!0,this.layer2Material.map=t,this.layer2Material.needsUpdate=!0,this.layer2MaterialBiased.map=t,this.layer2MaterialBiased.needsUpdate=!0}get modelType(){return this.slim?"slim":"default"}set modelType(t){this.slim=t==="slim",this.modelListeners.forEach(e=>e())}getBodyParts(){return this.children.filter(t=>t instanceof bt)}setInnerLayerVisible(t){this.getBodyParts().forEach(e=>e.innerLayer.visible=t)}setOuterLayerVisible(t){this.getBodyParts().forEach(e=>e.outerLayer.visible=t)}resetJoints(){this.head.rotation.set(0,0,0),this.leftArm.rotation.set(0,0,0),this.rightArm.rotation.set(0,0,0),this.leftLeg.rotation.set(0,0,0),this.rightLeg.rotation.set(0,0,0),this.body.rotation.set(0,0,0),this.head.position.y=0,this.body.position.y=-6,this.body.position.z=0,this.rightArm.position.x=-5,this.rightArm.position.y=-2,this.rightArm.position.z=0,this.leftArm.position.x=5,this.leftArm.position.y=-2,this.leftArm.position.z=0,this.rightLeg.position.x=-1.9,this.rightLeg.position.y=-12,this.rightLeg.position.z=-.1,this.leftLeg.position.x=1.9,this.leftLeg.position.y=-12,this.leftLeg.position.z=-.1}},r2=class extends nt{constructor(){super(),Object.defineProperty(this,"cape",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"material",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.material=new je({side:a2,transparent:!0,alphaTest:1e-5});let t=new F0(10,16,1);i2(t,0,0,10,16,1),this.cape=new I0(t,this.material),this.cape.position.y=-8,this.cape.position.z=.5,this.add(this.cape)}get map(){return this.material.map}set map(t){this.material.map=t,this.material.needsUpdate=!0}},s2=class extends nt{constructor(){super(),Object.defineProperty(this,"leftWing",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"rightWing",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"material",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.material=new je({side:a2,transparent:!0,alphaTest:1e-5});let t=new F0(12,22,4);i2(t,22,0,10,20,2);let e=new I0(t,this.material);e.position.x=-5,e.position.y=-10,e.position.z=-1,this.leftWing=new nt,this.leftWing.add(e),this.add(this.leftWing);let i=new F0(12,22,4);i2(i,22,0,10,20,2);let n=new I0(i,this.material);n.scale.x=-1,n.position.x=5,n.position.y=-10,n.position.z=-1,this.rightWing=new nt,this.rightWing.add(n),this.add(this.rightWing),this.leftWing.position.x=5,this.leftWing.rotation.x=.2617994,this.resetJoints()}resetJoints(){this.leftWing.rotation.y=.01,this.leftWing.rotation.z=.2617994,this.updateRightWing()}updateRightWing(){this.rightWing.position.x=-this.leftWing.position.x,this.rightWing.position.y=this.leftWing.position.y,this.rightWing.rotation.x=this.leftWing.rotation.x,this.rightWing.rotation.y=-this.leftWing.rotation.y,this.rightWing.rotation.z=-this.leftWing.rotation.z}get map(){return this.material.map}set map(t){this.material.map=t,this.material.needsUpdate=!0}},o2=class extends nt{constructor(){super(),Object.defineProperty(this,"rightEar",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"leftEar",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"material",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.material=new je({side:gr});let t=new F0(8,8,4/3);v2(t,0,0,6,6,1,14,7),this.rightEar=new I0(t,this.material),this.rightEar.name="rightEar",this.rightEar.position.x=-6,this.add(this.rightEar),this.leftEar=new I0(t,this.material),this.leftEar.name="leftEar",this.leftEar.position.x=6,this.add(this.leftEar)}get map(){return this.material.map}set map(t){this.material.map=t,this.material.needsUpdate=!0}},pr=10.8*Math.PI/180,Ye=class extends nt{constructor(){super(),Object.defineProperty(this,"skin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cape",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"elytra",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ears",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.skin=new n2,this.skin.name="skin",this.skin.position.y=8,this.add(this.skin),this.cape=new r2,this.cape.name="cape",this.cape.position.y=8,this.cape.position.z=-2,this.cape.rotation.x=pr,this.cape.rotation.y=Math.PI,this.add(this.cape),this.elytra=new s2,this.elytra.name="elytra",this.elytra.position.y=8,this.elytra.position.z=-2,this.elytra.visible=!1,this.add(this.elytra),this.ears=new o2,this.ears.name="ears",this.ears.position.y=10,this.ears.position.z=2/3,this.ears.visible=!1,this.skin.head.add(this.ears)}get backEquipment(){return this.cape.visible?"cape":this.elytra.visible?"elytra":null}set backEquipment(t){this.cape.visible=t==="cape",this.elytra.visible=t==="elytra"}resetJoints(){this.skin.resetJoints(),this.cape.rotation.x=pr,this.cape.position.y=8,this.cape.position.z=-2,this.elytra.position.y=8,this.elytra.position.z=-2,this.elytra.rotation.x=0,this.elytra.resetJoints()}};x();R();T();k();import{Color as wf,PointLight as _f,EquirectangularReflectionMapping as Af,Group as Ef,NearestFilter as xf,PerspectiveCamera as Rf,Scene as kf,Texture as Tf,Vector2 as Mf,WebGLRenderer as Sf,AmbientLight as Cf,CanvasTexture as Pf,WebGLRenderTarget as Bf,FloatType as If,DepthTexture as Hf,Clock as zf,Object3D as Of,ColorManagement as Df}from"three";import{OrbitControls as Ff}from"three/examples/jsm/controls/OrbitControls.js";import{EffectComposer as Gf}from"three/examples/jsm/postprocessing/EffectComposer.js";import"three/examples/jsm/postprocessing/Pass.js";import{RenderPass as jf}from"three/examples/jsm/postprocessing/RenderPass.js";import{ShaderPass as Qf}from"three/examples/jsm/postprocessing/ShaderPass.js";import{FXAAShader as Jf}from"three/examples/jsm/shaders/FXAAShader.js";x();R();T();k();var G5=class{constructor(){Object.defineProperty(this,"speed",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(this,"paused",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"progress",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"currentId",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"progress0",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"animationObjects",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}update(t,e){if(this.paused)return;let i=e*this.speed;this.animate(t,i),this.animationObjects.forEach((n,s)=>{let o=this.progress0.get(s);n(t,this.progress-o,s)}),this.progress+=i}addAnimation(t){let e=this.currentId++;return this.progress0.set(e,this.progress),this.animationObjects.set(e,t),e}removeAnimation(t){t!=null&&(this.animationObjects.delete(t),this.progress0.delete(t))}};x();R();T();k();import{CanvasTexture as sf,NearestFilter as of,Sprite as af,SpriteMaterial as vf}from"three";x();R();T();k();var po=Object.defineProperty,go=(r,t,e)=>t in r?po(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,h0=(r,t,e)=>(go(r,typeof t!="symbol"?t+"":t,e),e);function l2(r){let t=[r];if(r.extra&&r.extra.length!==0)for(let e of r.extra)t.push(...l2(e));return t}var X=class{constructor(r,t,e,i,n,s){this.key=r,this.value=t,this.name=e,this.code=i,this.cssForeground=n,this.cssBackground=s}applyToStyle(r){r[this.key]=this.value}matchStyle(r){return r[this.key]===this.value}static fromCode(r){let e="0123456789abcdefklmnor".indexOf(r);if(e)return this.list[e]}toString(){return`${X.CONTROL_STRING}${this.code}`}},m0=X;h0(m0,"CONTROL_STRING","\xA7");h0(m0,"BLACK",new X("color","black","BLACK","0",{color:"#000000"},{color:"#000000"}));h0(m0,"DARK_BLUE",new X("color","dark_blue","DARK_BLUE","1",{color:"#0000AA"},{color:"#00002A"}));h0(m0,"DARK_GREEN",new X("color","dark_green","DARK_GREEN","2",{color:"#00AA00"},{color:"#002A00"}));h0(m0,"DARK_AQUA",new X("color","dark_aqua","DARK_AQUA","3",{color:"#00AAAA"},{color:"#002A2A"}));h0(m0,"DARK_RED",new X("color","dark_red","DARK_RED","4",{color:"#AA0000"},{color:"#2A0000"}));h0(m0,"DARK_PURPLE",new X("color","dark_purple","DARK_PURPLE","5",{color:"#AA00AA"},{color:"#2A002A"}));h0(m0,"GOLD",new X("color","gold","GOLD","6",{color:"#FFAA00"},{color:"#2A2A00"}));h0(m0,"GRAY",new X("color","gray","GRAY","7",{color:"#AAAAAA"},{color:"#2A2A2A"}));h0(m0,"DARK_GRAY",new X("color","dark_gray","DARK_GRAY","8",{color:"#555555"},{color:"#151515"}));h0(m0,"BLUE",new X("color","blue","BLUE","9",{color:"#5555FF"},{color:"#15153F"}));h0(m0,"GREEN",new X("color","green","GREEN","a",{color:"#55FF55"},{color:"#153F15"}));h0(m0,"AQUA",new X("color","aqua","AQUA","b",{color:"#55FFFF"},{color:"#153F3F"}));h0(m0,"RED",new X("color","red","RED","c",{color:"#FF5555"},{color:"#3F1515"}));h0(m0,"LIGHT_PURPLE",new X("color","light_purple","LIGHT_PURPLE","d",{color:"#FF55FF"},{color:"#3F153F"}));h0(m0,"YELLOW",new X("color","yellow","YELLOW","e",{color:"#FFFF55"},{color:"#3F3F15"}));h0(m0,"WHITE",new X("color","white","WHITE","f",{color:"#FFFFFF"},{color:"#3F3F3F"}));h0(m0,"OBFUSCATED",new X("obfuscated",!0,"OBFUSCATED","k",{}));h0(m0,"BOLD",new X("bold",!0,"BOLD","l",{"font-weight":"bold"}));h0(m0,"STRIKETHROUGH",new X("strikethrough",!0,"STRIKETHROUGH","m",{"text-decoration":"line-through"}));h0(m0,"UNDERLINE",new X("underlined",!0,"UNDERLINE","n",{"text-decoration":"underline"}));h0(m0,"ITALIC",new X("italic",!0,"ITALIC","o",{"font-style":"italic"}));h0(m0,"RESET",{name:"RESET",code:"r",applyToStyle(r){r.bold=!1,r.strikethrough=!1,r.underlined=!1,r.italic=!1,r.obfuscated=!1,r.color=void 0},matchStyle(r){return!1},cssBackground:{},cssForeground:{},toString(){return`${X.CONTROL_STRING}r`}});h0(m0,"list",[X.BLACK,X.DARK_BLUE,X.DARK_GREEN,X.DARK_AQUA,X.DARK_RED,X.DARK_PURPLE,X.GOLD,X.GRAY,X.DARK_GRAY,X.BLUE,X.GREEN,X.AQUA,X.RED,X.LIGHT_PURPLE,X.YELLOW,X.WHITE,X.OBFUSCATED,X.BOLD,X.STRIKETHROUGH,X.UNDERLINE,X.ITALIC,X.RESET]);var n5=He(c2(),1);h2();var s6=He(Wr(),1);import o6 from"prismarine-chat";x();R();T();k();import*as x0 from"three";import da from"prismarine-item";x();R();T();k();x();R();T();k();var Tt=class r{constructor(t,e,i,n,s="div"){this.parent=t,this.object=e,this.property=i,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement("div"),this.domElement.classList.add("controller"),this.domElement.classList.add(n),this.$name=document.createElement("div"),this.$name.classList.add("name"),r.nextNameID=r.nextNameID||0,this.$name.id=`lil-gui-name-${++r.nextNameID}`,this.$widget=document.createElement(s),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",o=>o.stopPropagation()),this.domElement.addEventListener("keyup",o=>o.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(i)}name(t){return this._name=t,this.$name.innerHTML=t,this}onChange(t){return this._onChange=t,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(t){return this._onFinishChange=t,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(t=!0){return this.disable(!t)}disable(t=!0){return t===this._disabled?this:(this._disabled=t,this.domElement.classList.toggle("disabled",t),this.$disable.toggleAttribute("disabled",t),this)}show(t=!0){return this._hidden=!t,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(t){let e=this.parent.add(this.object,this.property,t);return e.name(this._name),this.destroy(),e}min(t){return this}max(t){return this}step(t){return this}decimals(t){return this}listen(t=!0){return this._listening=t,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);let t=this.save();t!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=t}getValue(){return this.object[this.property]}setValue(t){return this.object[this.property]=t,this._callOnChange(),this.updateDisplay(),this}updateDisplay(){return this}load(t){return this.setValue(t),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}},m2=class extends Tt{constructor(t,e,i){super(t,e,i,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}};function p2(r){let t,e;return(t=r.match(/(#|0x)?([a-f0-9]{6})/i))?e=t[2]:(t=r.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?e=parseInt(t[1]).toString(16).padStart(2,0)+parseInt(t[2]).toString(16).padStart(2,0)+parseInt(t[3]).toString(16).padStart(2,0):(t=r.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(e=t[1]+t[1]+t[2]+t[2]+t[3]+t[3]),e?"#"+e:!1}var ia={isPrimitive:!0,match:r=>typeof r=="string",fromHexString:p2,toHexString:p2},Xe={isPrimitive:!0,match:r=>typeof r=="number",fromHexString:r=>parseInt(r.substring(1),16),toHexString:r=>"#"+r.toString(16).padStart(6,0)},na={isPrimitive:!1,match:r=>Array.isArray(r),fromHexString(r,t,e=1){let i=Xe.fromHexString(r);t[0]=(i>>16&255)/255*e,t[1]=(i>>8&255)/255*e,t[2]=(i&255)/255*e},toHexString([r,t,e],i=1){i=255/i;let n=r*i<<16^t*i<<8^e*i<<0;return Xe.toHexString(n)}},ra={isPrimitive:!1,match:r=>Object(r)===r,fromHexString(r,t,e=1){let i=Xe.fromHexString(r);t.r=(i>>16&255)/255*e,t.g=(i>>8&255)/255*e,t.b=(i&255)/255*e},toHexString({r,g:t,b:e},i=1){i=255/i;let n=r*i<<16^t*i<<8^e*i<<0;return Xe.toHexString(n)}},sa=[ia,Xe,na,ra];function oa(r){return sa.find(t=>t.match(r))}var g2=class extends Tt{constructor(t,e,i,n){super(t,e,i,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=oa(this.initialValue),this._rgbScale=n,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{let s=p2(this.$text.value);s&&this._setValueFromHexString(s)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(t){if(this._format.isPrimitive){let e=this._format.fromHexString(t);this.setValue(e)}else this._format.fromHexString(t,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(t){return this._setValueFromHexString(t),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}},Ze=class extends Tt{constructor(t,e,i){super(t,e,i,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",n=>{n.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}},b2=class extends Tt{constructor(t,e,i,n,s,o){super(t,e,i,"number"),this._initInput(),this.min(n),this.max(s);let a=o!==void 0;this.step(a?o:this._getImplicitStep(),a),this.updateDisplay()}decimals(t){return this._decimals=t,this.updateDisplay(),this}min(t){return this._min=t,this._onUpdateMinMax(),this}max(t){return this._max=t,this._onUpdateMinMax(),this}step(t,e=!0){return this._step=t,this._stepExplicit=e,this}updateDisplay(){let t=this.getValue();if(this._hasSlider){let e=(t-this._min)/(this._max-this._min);e=Math.max(0,Math.min(e,1)),this.$fill.style.width=e*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?t:t.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;let e=()=>{let _=parseFloat(this.$input.value);isNaN(_)||(this._stepExplicit&&(_=this._snap(_)),this.setValue(this._clamp(_)))},i=_=>{let C=parseFloat(this.$input.value);isNaN(C)||(this._snapClampSetValue(C+_),this.$input.value=this.getValue())},n=_=>{_.key==="Enter"&&this.$input.blur(),_.code==="ArrowUp"&&(_.preventDefault(),i(this._step*this._arrowKeyMultiplier(_))),_.code==="ArrowDown"&&(_.preventDefault(),i(this._step*this._arrowKeyMultiplier(_)*-1))},s=_=>{this._inputFocused&&(_.preventDefault(),i(this._step*this._normalizeMouseWheel(_)))},o=!1,a,v,l,c,d,m=5,p=_=>{a=_.clientX,v=l=_.clientY,o=!0,c=this.getValue(),d=0,window.addEventListener("mousemove",g),window.addEventListener("mouseup",y)},g=_=>{if(o){let C=_.clientX-a,M=_.clientY-v;Math.abs(M)>m?(_.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(C)>m&&y()}if(!o){let C=_.clientY-l;d-=C*this._step*this._arrowKeyMultiplier(_),c+d>this._max?d=this._max-c:c+d<this._min&&(d=this._min-c),this._snapClampSetValue(c+d)}l=_.clientY},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",y)},E=()=>{this._inputFocused=!0},w=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",e),this.$input.addEventListener("keydown",n),this.$input.addEventListener("wheel",s,{passive:!1}),this.$input.addEventListener("mousedown",p),this.$input.addEventListener("focus",E),this.$input.addEventListener("blur",w)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");let t=(w,_,C,M,S)=>(w-_)/(C-_)*(S-M)+M,e=w=>{let _=this.$slider.getBoundingClientRect(),C=t(w,_.left,_.right,this._min,this._max);this._snapClampSetValue(C)},i=w=>{this._setDraggingStyle(!0),e(w.clientX),window.addEventListener("mousemove",n),window.addEventListener("mouseup",s)},n=w=>{e(w.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",s)},o=!1,a,v,l=w=>{w.preventDefault(),this._setDraggingStyle(!0),e(w.touches[0].clientX),o=!1},c=w=>{w.touches.length>1||(this._hasScrollBar?(a=w.touches[0].clientX,v=w.touches[0].clientY,o=!0):l(w),window.addEventListener("touchmove",d,{passive:!1}),window.addEventListener("touchend",m))},d=w=>{if(o){let _=w.touches[0].clientX-a,C=w.touches[0].clientY-v;Math.abs(_)>Math.abs(C)?l(w):(window.removeEventListener("touchmove",d),window.removeEventListener("touchend",m))}else w.preventDefault(),e(w.touches[0].clientX)},m=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",d),window.removeEventListener("touchend",m)},p=this._callOnFinishChange.bind(this),g=400,y,E=w=>{if(Math.abs(w.deltaX)<Math.abs(w.deltaY)&&this._hasScrollBar)return;w.preventDefault();let C=this._normalizeMouseWheel(w)*this._step;this._snapClampSetValue(this.getValue()+C),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(p,g)};this.$slider.addEventListener("mousedown",i),this.$slider.addEventListener("touchstart",c,{passive:!1}),this.$slider.addEventListener("wheel",E,{passive:!1})}_setDraggingStyle(t,e="horizontal"){this.$slider&&this.$slider.classList.toggle("active",t),document.body.classList.toggle("lil-gui-dragging",t),document.body.classList.toggle(`lil-gui-${e}`,t)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(t){let{deltaX:e,deltaY:i}=t;return Math.floor(t.deltaY)!==t.deltaY&&t.wheelDelta&&(e=0,i=-t.wheelDelta/120,i*=this._stepExplicit?1:10),e+-i}_arrowKeyMultiplier(t){let e=this._stepExplicit?1:10;return t.shiftKey?e*=10:t.altKey&&(e/=10),e}_snap(t){let e=Math.round(t/this._step)*this._step;return parseFloat(e.toPrecision(15))}_clamp(t){return t<this._min&&(t=this._min),t>this._max&&(t=this._max),t}_snapClampSetValue(t){this.setValue(this._clamp(this._snap(t)))}get _hasScrollBar(){let t=this.parent.root.$children;return t.scrollHeight>t.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}},y2=class extends Tt{constructor(t,e,i,n){super(t,e,i,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this._values=Array.isArray(n)?n:Object.values(n),this._names=Array.isArray(n)?n:Object.keys(n),this._names.forEach(s=>{let o=document.createElement("option");o.innerHTML=s,this.$select.appendChild(o)}),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.updateDisplay()}updateDisplay(){let t=this.getValue(),e=this._values.indexOf(t);return this.$select.selectedIndex=e,this.$display.innerHTML=e===-1?t:this._names[e],this}},w2=class extends Tt{constructor(t,e,i){super(t,e,i,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",n=>{n.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}},aa=`.lil-gui {
|
|
17
17
|
font-family: var(--font-family);
|
|
18
18
|
font-size: var(--font-size);
|
|
19
19
|
line-height: 1;
|
|
@@ -21233,7 +21233,7 @@ void main() {
|
|
|
21233
21233
|
|
|
21234
21234
|
#include <tonemapping_fragment>
|
|
21235
21235
|
#include <${J8>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
21236
|
-
}`})}},ti=class{constructor(t){this.worldRenderer=t;f(this,"points");f(this,"clock",new E0.Clock);f(this,"enabled",!1);f(this,"currentTime");f(this,"enablementCheck",()=>this.currentTime?this.currentTime>13500&&this.currentTime<23e3:!1);f(this,"render",t=>{this.points&&(this.points.position.set(0,0,0),this.points.material.uniforms.time.value=this.clock.getElapsedTime()*.2)})}enable(){this.enabled||(this.enabled=!0,this.updateVisibility())}disable(){this.enabled&&(this.enabled=!1,this.removeStars())}toggle(){return this.enabled?this.disable():this.enable(),this.enabled}updateTimeOfDay(t){this.currentTime=t,this.enabled&&this.updateVisibility()}updateVisibility(){if(!this.enabled)return;let t=this.enablementCheck?.()??!1;t&&!this.points?this.createStars():!t&&this.points&&this.removeStars()}createStars(){if(this.points)return;let t=80,e=50,i=7e3,n=7,s=10,o=new E0.BufferGeometry,a=y=>new E0.Vector3().setFromSpherical(new E0.Spherical(y,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)),v=[],l=[],c=Array.from({length:i},()=>(.5+.5*Math.random())*n),d=new E0.Color,m=t+e,p=e/i;for(let y=0;y<i;y++)m-=p*Math.random(),v.push(...a(m).toArray()),d.setHSL(y/i,s,.9),l.push(d.r,d.g,d.b);o.setAttribute("position",new E0.Float32BufferAttribute(v,3)),o.setAttribute("color",new E0.Float32BufferAttribute(l,3)),o.setAttribute("size",new E0.Float32BufferAttribute(c,1));let g=new $2;g.blending=E0.AdditiveBlending,g.depthTest=!1,g.transparent=!0,this.points=new E0.Points(o,g),this.points.renderOrder=-1,this.worldRenderer.scene.add(this.points)}dispose(){this.removeStars()}removeStars(){this.points&&(this.points.geometry.dispose(),this.points.material.dispose(),this.worldRenderer.scene.remove(this.points),this.points=void 0)}},es={id:"starfield",controller:ti,enabledDefault:!0,cannotBeDisabled:!0};var is={starfield:es,futuristicReveal:ts,rain:X6,cameraBobbing:K6,blockBreakParticles:Q6};var ie=class r extends L5{constructor(e,i,n){if(!n.resourcesManager)throw new Error("resourcesManager is required in displayOptions");super(n.resourcesManager,n,i);this.renderer=e;this.initOptions=i;this.displayOptions=n;f(this,"outputFormat","threeJs");f(this,"chunkMeshManager");f(this,"chunkTextures",new Map);f(this,"signsCache",new Map);f(this,"cameraSectionPos",new It(0,0,0));f(this,"holdingBlock");f(this,"holdingBlockLeft");f(this,"realScene",new Y.Scene);f(this,"scene",new Y.Group);f(this,"ambientLight",new Y.AmbientLight(13421772));f(this,"directionalLight",new Y.DirectionalLight(16777215,.5));f(this,"entities",new r1(this,globalThis.mcData));f(this,"cameraGroupVr");f(this,"material",new Y.MeshLambertMaterial({vertexColors:!0,transparent:!0,alphaTest:.1}));f(this,"itemsTexture");f(this,"cursorBlock");f(this,"onRender",[]);f(this,"lastRenderTime",0);f(this,"cameraShake");f(this,"cameraContainer");f(this,"media");f(this,"waypoints");f(this,"cinimaticScript");f(this,"camera");f(this,"renderTimeAvg",0);f(this,"modules",{});f(this,"sectionsOffsetsAnimations",{});f(this,"fountains",[]);f(this,"fireworksLegacy");f(this,"DEBUG_RAYCAST",!1);f(this,"skyboxRenderer");f(this,"fireworks");f(this,"sceneOrigin",new p1(this.realScene));f(this,"cameraWorldPos",{x:0,y:0,z:0});f(this,"_cameraPositionAccessWarned",!1);f(this,"_tmpCameraPos",new Y.Vector3);f(this,"currentPosTween");f(this,"currentRotTween");f(this,"_tpDirection",new Y.Vector3);f(this,"_tpPitchQuat",new Y.Quaternion);f(this,"_tpYawQuat",new Y.Quaternion);f(this,"_tpFinalQuat",new Y.Quaternion);f(this,"_tpScenePos",new Y.Vector3);f(this,"_tpAxisX",new Y.Vector3(1,0,0));f(this,"_tpAxisY",new Y.Vector3(0,1,0));f(this,"_tpRaycaster",new Y.Raycaster);f(this,"_tpChunkWorldPos",new Y.Vector3);f(this,"debugOverlayAdded",!1);f(this,"debugRaycastHelper");f(this,"debugHitPoint");f(this,"prevFramePerspective",null);this.renderer=e,n.rendererState.renderer=r.getRendererInfo(e)??"...",this.chunkMeshManager=new f5(this,this.scene,this.material,this.worldSizeParams.worldHeight,this.viewDistance),this.onRenderDistanceChanged=s=>{this.chunkMeshManager.updateViewDistance(s)},this.cursorBlock=new s1(this),this.holdingBlock=a5(this),this.holdingBlockLeft=a5(this,!0);for(let s of Object.values(is))this.registerModule(s);this.skyboxRenderer=new h1(this.realScene,!1,null),this.skyboxRenderer.init(),this.addDebugOverlay(),this.resetScene(),this.init(),this.soundSystem=new a1(this),this.cameraShake=new v1(this,this.onRender),this.media=new l1(this),this.fireworksLegacy=new u1(this),this.waypoints=new d1(this),this.cinimaticScript=new f1(this,(s,o,a)=>this.setCinimaticCamera(s,o,a),s=>this.setCinimaticFov(s),()=>({position:new It(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),yaw:this.cameraShake.getBaseRotation().yaw,pitch:this.cameraShake.getBaseRotation().pitch,fov:this.camera.fov})),this.fireworks=new m1(this.realScene,this.sceneOrigin),this.renderUpdateEmitter.on("chunkFinished",s=>{this.finishChunk(s)}),this.worldSwitchActions(),this.initializeModules()}get sectionObjects(){return this.chunkMeshManager.sectionObjects}get waitingChunksToDisplay(){return{}}get estimatedMemoryUsage(){return this.chunkMeshManager.getEstimatedMemoryUsage().total}get tilesRendered(){return this.chunkMeshManager.getTotalTiles()}get blocksRendered(){return this.chunkMeshManager.getTotalBlocks()}registerModule(e){if(e.id in this.modules)return;let i=new e.controller(this),n={manifest:e,controller:i,enabled:!1,toggle:()=>this.toggleModule(e.id)};this.modules[e.id]=n,e.enabledDefault&&this.toggleModule(e.id,!0)}enableModule(e){let i=this.modules[e];i&&(i.enabled||(i.enabled=!0,i.controller.enable(),i.controller.render&&this.onRender.push(i.controller.render)))}disableModule(e){let i=this.modules[e];if(i&&!i.manifest.cannotBeDisabled&&i.enabled&&(i.enabled=!1,i.controller.disable(),i.controller.render)){let n=this.onRender.indexOf(i.controller.render);n>-1&&this.onRender.splice(n,1)}}toggleModule(e,i){let n=this.modules[e];if(!n)return!1;let s=i!==void 0?i:!n.enabled;if(s===n.enabled)return n.enabled;if(!s&&n.manifest.cannotBeDisabled)return!0;if(n.enabled=s,s)n.controller.enable(),n.controller.render&&!this.onRender.includes(n.controller.render)&&this.onRender.push(n.controller.render);else if(n.controller.disable(),n.controller.render){let o=this.onRender.indexOf(n.controller.render);o>-1&&this.onRender.splice(o,1)}return s}disposeModules(){for(let e of Object.values(this.modules))e.controller.dispose();this.modules={}}initializeModules(){this.updateModulesFromConfig()}getModule(e){return this.modules[e]?.controller}anyModuleRequiresHeightmap(){return Object.values(this.modules).some(e=>e.enabled&&e.manifest.requiresHeightmap)}get cameraObject(){return this.cameraGroupVr??this.cameraContainer}_wrapCameraPositionWithWarning(){let e=this.camera.position,i=this,n=20,s=(v,l,c)=>Math.abs(v)>n||Math.abs(l)>n||Math.abs(c)>n,o=()=>{!i._cameraPositionAccessWarned&&typeof D<"u"},a=new Proxy(e,{set(v,l,c){return(l==="x"||l==="y"||l==="z")&&typeof c=="number"&&Math.abs(c)>n&&o(),v[l]=c,!0},get(v,l,c){let d=v[l];return l==="set"?function(m,p,g){return s(m,p,g)&&o(),v.set(m,p,g)}:l==="setX"||l==="setY"||l==="setZ"?function(m){return Math.abs(m)>n&&o(),v[l](m)}:l==="copy"?function(m){return s(m.x,m.y,m.z)&&o(),v.copy(m)}:typeof d=="function"?d.bind(v):d}});Object.defineProperty(this.camera,"position",{value:a,configurable:!0,enumerable:!0})}worldSwitchActions(){this.onWorldSwitched.push(()=>{this.protocolCustomBlocks.clear(),this.sectionsOffsetsAnimations={},this.waypoints.clear(),this.cinimaticScript.stopScript(),this.fireworks.clear()})}downloadWorldGeometry(){V2(this,new Y.Vector3(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),this.cameraShake.getBaseRotation(),"world-geometry.json")}updateEntity(e,i=!1){let n={rotation:{head:{x:e.headPitch??e.pitch,y:e.headYaw,z:0}}};i?this.entities.updateEntityPosition(e,!1,n):this.entities.update(e,n)}updatePlayerEntity(e){this.entities.handlePlayerEntity(e)}resetScene(){this.sceneOrigin.update(0,0,0),this.cameraWorldPos.x=0,this.cameraWorldPos.y=0,this.cameraWorldPos.z=0,this.realScene.matrixAutoUpdate=!1,this.realScene.background=new Y.Color(this.initOptions.config.sceneBackground),this.realScene.add(this.ambientLight),this.directionalLight.position.set(1,1,.5).normalize(),this.directionalLight.castShadow=!0,this.realScene.add(this.directionalLight);let e=this.renderer.getSize(new Y.Vector2);this.camera=new Y.PerspectiveCamera(75,e.x/e.y,.1,1e3),this._wrapCameraPositionWithWarning(),this.cameraContainer=new Y.Object3D,this.cameraContainer.add(this.camera),this.realScene.add(this.cameraContainer),this.realScene.add(this.scene)}watchReactivePlayerState(){super.watchReactivePlayerState(),this.onReactivePlayerStateUpdated("inWater",e=>{this.skyboxRenderer.updateWaterState(e,this.playerStateReactive.waterBreathing)}),this.onReactivePlayerStateUpdated("waterBreathing",e=>{this.skyboxRenderer.updateWaterState(this.playerStateReactive.inWater,e)}),this.onReactivePlayerStateUpdated("ambientLight",e=>{e&&(this.ambientLight.intensity=e)}),this.onReactivePlayerStateUpdated("directionalLight",e=>{e&&(this.directionalLight.intensity=e)}),this.onReactivePlayerStateUpdated("lookingAtBlock",e=>{this.cursorBlock.setHighlightCursorBlock(e?new It(e.x,e.y,e.z):null,e?.shapes)}),this.onReactivePlayerStateUpdated("diggingBlock",e=>{this.cursorBlock.updateBreakAnimation(e?{x:e.x,y:e.y,z:e.z}:void 0,e?.stage??null,e?.mergedShape)}),this.onReactivePlayerStateUpdated("perspective",e=>{let i=new It(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z);this.updateCamera(i,this.cameraShake.getBaseRotation().yaw,this.cameraShake.getBaseRotation().pitch)})}watchReactiveConfig(){super.watchReactiveConfig(),this.onReactiveConfigUpdated("showChunkBorders",i=>{this.updateShowChunksBorder(i)}),this.onReactiveConfigUpdated("defaultSkybox",i=>{this.skyboxRenderer.updateDefaultSkybox(i)});let e=this.displayOptions.inWorldRenderingConfig.handRenderer;this.onReactiveConfigUpdated("handRenderer",i=>{if(i===e)return;e=i;let n=this.holdingBlock.ready,s=this.holdingBlockLeft.ready;this.holdingBlock.dispose(),this.holdingBlockLeft.dispose(),this.holdingBlock=a5(this),this.holdingBlockLeft=a5(this,!0),n&&(this.holdingBlock.ready=!0,this.holdingBlock.updateItem()),s&&(this.holdingBlockLeft.ready=!0,this.holdingBlockLeft.updateItem())}),this.onReactiveConfigUpdated("*",()=>{this.updateModulesFromConfig()}),this.updateModulesFromConfig()}updateModulesFromConfig(){let{moduleStates:e}=this.worldRendererConfig;for(let[i,n]of Object.entries(this.modules)){let s=e[i];if(s==="enabled"){n.enabled||this.toggleModule(i,!0);continue}if(s==="disabled"){n.enabled&&!n.manifest.cannotBeDisabled&&this.toggleModule(i,!1);continue}if(s==="auto"||s===void 0)if(n.controller.autoEnableCheck){let o=n.controller.autoEnableCheck();o&&!n.enabled?this.toggleModule(i,!0):!o&&n.enabled&&!n.manifest.cannotBeDisabled&&this.toggleModule(i,!1)}else{let o=n.manifest.enabledDefault??!1;o&&!n.enabled?this.toggleModule(i,!0):!o&&n.enabled&&!n.manifest.cannotBeDisabled&&this.toggleModule(i,!1)}}}changeHandSwingingState(e,i=!1){let n=i?this.holdingBlockLeft:this.holdingBlock;e?n.startSwing():n.stopSwing()}async updateAssetsData(){let e=this.resourcesManager.currentResources,i=this.material.map,n=this.itemsTexture,s=K1(e.blocksAtlasImage);s.needsUpdate=!0,s.flipY=!1,this.material.map=s;let o=K1(e.itemsAtlasImage);o.needsUpdate=!0,o.flipY=!1,this.itemsTexture=o,i&&i.dispose(),n&&n.dispose(),await super.updateAssetsData(),this.onAllTexturesLoaded(),Object.keys(this.loadedChunks).length>0&&this.rerenderAllChunks()}onAllTexturesLoaded(){this.holdingBlock.ready=!0,this.holdingBlock.updateItem(),this.holdingBlockLeft.ready=!0,this.holdingBlockLeft.updateItem()}changeBackgroundColor(e){this.realScene.background=new Y.Color(e[0],e[1],e[2])}timeUpdated(e){let i=this.getModule("starfield");i?.updateTimeOfDay&&i.updateTimeOfDay(e),this.skyboxRenderer.updateTime(e)}biomeUpdated(e){e?.temperature!==void 0&&this.skyboxRenderer.updateTemperature(e.temperature)}biomeReset(){this.skyboxRenderer.updateTemperature(U2)}getItemRenderData(e,i){return C6(e,i,this.resourcesManager,this.playerStateReactive)}async demoModel(){let e=cursorBlockRel(0,1,0).position,i=await t5();mr(i,e);let n=new Y.BoxHelper(i,16776960);i.add(n),this.realScene.add(i)}demoItem(){let e=cursorBlockRel(0,1,0).position,{mesh:i}=this.entities.getItemMesh({itemId:541},{});i.position.set(e.x+.5,e.y+.5,e.z+.5);let n=new Y.BoxHelper(i,16776960);i.add(n),this.realScene.add(i)}addDebugOverlay(){if(this.debugOverlayAdded)return;this.debugOverlayAdded=!0;let e=ue("debug-overlay");setInterval(()=>{if(e.setVisibility(this.displayAdvancedStats),this.displayAdvancedStats){let i=o=>new Intl.NumberFormat("en-US",{}).format(o),n="";n+=`C: ${i(this.renderer.info.render.calls)} `,n+=`TR: ${i(this.renderer.info.render.triangles)} `,n+=`TE: ${i(this.renderer.info.memory.textures)} `,n+=`F: ${i(this.tilesRendered)} `,n+=`B: ${i(this.blocksRendered)} `,n+=`MEM: ${this.chunkMeshManager.getEstimatedMemoryUsage().total} `;let s=this.chunkMeshManager.getStats();n+=`POOL: ${s.activeCount}/${s.poolSize} HR: ${s.hitRate}`,e.updateText(n),this.backendInfoReport=n}},200)}updatePosDataChunk(e){let[i,n,s]=e.split(",").map(l=>Math.floor(+l/16)),o=Math.abs(i-this.cameraSectionPos.x)+Math.abs(n-this.cameraSectionPos.y)+Math.abs(s-this.cameraSectionPos.z),a=this.sectionObjects[e],v=a.mesh??a.children.find(l=>l.name==="mesh");v.renderOrder=500-o}updateViewerPosition(e){this.viewerChunkPosition=e}cameraSectionPositionUpdate(){for(let e in this.sectionObjects)this.sectionObjects[e]&&this.updatePosDataChunk(e)}getDir(e,i){return e===i?0:e<i?1:-1}finishChunk(e){}handleWorkerMessage(e){if(e.type==="geometry"){let i=e.key.split(",");if(!this.loadedChunks[i[0]+","+i[2]]||!e.geometry.positions.length||!this.active)return;this.chunkMeshManager.updateSection(e.key,e.geometry),this.updatePosDataChunk(e.key)}}getSignTexture(e,i,n,s=!1){let o=de(e),a=this.chunkTextures.get(`${o[0]},${o[1]}`);a||(a={},this.chunkTextures.set(`${o[0]},${o[1]}`,a));let v=`${e.x},${e.y},${e.z}`;if(a[v])return a[v];let l=q8(this.version),c=P5(i,n,l);if(!c)return;let d=new Y.Texture(c);return d.magFilter=Y.NearestFilter,d.minFilter=Y.NearestFilter,d.needsUpdate=!0,a[v]=d,d}getCameraPosition(e){return(e??this._tmpCameraPos).set(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z)}getSectionCameraPosition(){let e=this.getCameraPosition();return new It(Math.floor(e.x/16),Math.floor(e.y/16),Math.floor(e.z/16))}updateCameraSectionPos(){let e=this.getSectionCameraPosition();this.cameraSectionPos.equals(e)||(this.cameraSectionPos=e,this.cameraSectionPositionUpdate())}setFirstPersonCamera(e,i,n){let s=this.playerStateReactive.eyeHeight;this.updateCamera(e?.offset(0,s,0)??null,i,n),this.media.tryIntersectMedia(),this.updateCameraSectionPos()}getThirdPersonCamera(e,i,n){e??(e=new Y.Vector3(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z));let s=this.playerStateReactive.perspective==="third_person_back",o=4,a=this._tpDirection.set(0,0,-1),v=this._tpPitchQuat.setFromAxisAngle(this._tpAxisX,n),l=this._tpYawQuat.setFromAxisAngle(this._tpAxisY,i),c=this._tpFinalQuat.multiplyQuaternions(l,v);a.applyQuaternion(c),s&&a.multiplyScalar(-1),this.DEBUG_RAYCAST&&this.debugRaycast(e,a,o);let d=this._tpScenePos.set(this.sceneOrigin.toSceneX(e.x),this.sceneOrigin.toSceneY(e.y),this.sceneOrigin.toSceneZ(e.z)),m=this._tpRaycaster;m.set(d,a),m.far=o;let p=Object.values(this.sectionObjects).filter(_=>_.name==="chunk"&&_.visible).filter(_=>{let C=_.children.find(H=>H.name==="mesh");if(!C)return!1;let M=this._tpChunkWorldPos;return C.getWorldPosition(M),d.distanceTo(M)<80}),g=[];for(let _ of p){let C=_.children.find(M=>M.name==="mesh");C&&g.push(C)}let y=m.intersectObjects(g,!1),E=o;return y.length>0&&(E=Math.max(.5,y[0].distance-.2)),new It(e.x+a.x*E,e.y+a.y*E,e.z+a.z*E)}debugRaycast(e,i,n){this.debugRaycastHelper&&(this.realScene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.realScene.remove(this.debugHitPoint),this.debugHitPoint=void 0);let s=new Y.Vector3(this.sceneOrigin.toSceneX(e.x),this.sceneOrigin.toSceneY(e.y),this.sceneOrigin.toSceneZ(e.z));this.debugRaycastHelper=new Y.ArrowHelper(i.clone().normalize(),s,n,16711680,n*.1,n*.05),this.realScene.add(this.debugRaycastHelper);let o=new Y.SphereGeometry(.2,8,8),a=new Y.MeshBasicMaterial({color:65280});this.debugHitPoint=new Y.Mesh(o,a),this.debugHitPoint.position.copy(s).add(i.clone().multiplyScalar(n)),this.realScene.add(this.debugHitPoint)}setCinimaticCamera(e,i,n){this.cameraWorldPos.x=e.x,this.cameraWorldPos.y=e.y,this.cameraWorldPos.z=e.z,this.sceneOrigin.update(e.x,e.y,e.z),this.cameraObject.position.set(0,0,0),this.cameraShake.setBaseRotation(n,i),this.updateCameraSectionPos()}setCinimaticFov(e){this.camera.fov=e,this.camera.updateProjectionMatrix()}updateCamera(e,i,n){if(!this.cinimaticScript.running){if(e){this.renderer.xr.isPresenting&&(e.y-=this.camera.position.y),this.currentPosTween?.stop();let s=this.displayOptions.inWorldRenderingConfig.instantCameraUpdate?0:this.playerStateUtils.isSpectatingEntity()?150:50;this.currentPosTween=new S0(this.cameraWorldPos).to({x:e.x,y:e.y,z:e.z},s).onUpdate(()=>{this.sceneOrigin.update(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),this.cameraObject.position.set(0,0,0)}).start()}if(this.playerStateUtils.isSpectatingEntity()){let s=this.cameraShake.getBaseRotation(),o=0,a=Math.PI/2;s.yaw<a&&i>Math.PI+a?o=-Math.PI*2:i<a&&s.yaw>Math.PI+a&&(o=Math.PI*2),this.currentRotTween?.stop(),this.currentRotTween=new S0(s).to({pitch:n,yaw:i+o},100).onUpdate(v=>this.cameraShake.setBaseRotation(v.pitch,v.yaw-o)).start()}else{this.currentRotTween?.stop(),this.cameraShake.setBaseRotation(n,i);let{perspective:s}=this.playerStateReactive;if(s==="third_person_back"||s==="third_person_front"){let o=new Y.Vector3(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),a=this.getThirdPersonCamera(o,i,n),v=o.distanceTo(new Y.Vector3(a.x,a.y,a.z)),l=s==="third_person_back"?v:-v;this.camera.position.set(0,0,l),s==="third_person_front"?this.camera.rotation.set(0,Math.PI,0):this.camera.rotation.set(0,0,0)}else this.camera.position.z=0,this.camera.rotation.set(0,0,0),this.debugRaycastHelper&&(this.realScene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.realScene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}this.updateCameraSectionPos()}}debugChunksVisibilityOverride(){let{chunksRenderAboveOverride:e,chunksRenderBelowOverride:i,chunksRenderDistanceOverride:n,chunksRenderAboveEnabled:s,chunksRenderBelowEnabled:o,chunksRenderDistanceEnabled:a}=this.reactiveDebugParams,v=this.getSectionHeight(),l=this.cameraSectionPos.y*v;if(this.displayOptions.inWorldRenderingConfig.enableDebugOverlay&&e!==void 0||i!==void 0||n!==void 0)for(let[c,d]of Object.entries(this.sectionObjects)){let[m,p,g]=c.split(",").map(Number),y=s&&e!==void 0?p<=l+e:o&&i!==void 0?p>=l-i:a&&n!==void 0?Math.abs(p-l)<=n:!0;d.visible=y}else for(let c of Object.values(this.sectionObjects))c.visible=!0}render(e=!1){if(this.currentRenderedFrames++,this.reactiveDebugParams.stopRendering)return;this.debugChunksVisibilityOverride();let i=performance.now();this.lastRendered=performance.now();let n=this.lastRenderTime>0?Math.min(Math.max((i-this.lastRenderTime)/1e3,0),.1):1/60;this.lastRenderTime=i,this.cursorBlock.render(),this.updateSectionOffsets();let s=this.getCameraPosition();if(this.skyboxRenderer.update(s,this.viewDistance),e||this.displayOptions.inWorldRenderingConfig.fov!==this.camera.fov){let c=this.renderer.getSize(new Y.Vector2);this.camera.aspect=c.width/c.height,this.camera.fov=this.displayOptions.inWorldRenderingConfig.fov,this.camera.updateProjectionMatrix()}this.reactiveDebugParams.disableEntities||this.entities.render();let a=this.cameraGroupVr instanceof Y.Group?this.cameraGroupVr.children.find(c=>c instanceof Y.PerspectiveCamera):this.camera;this.renderer.render(this.realScene,a),this.displayOptions.inWorldRenderingConfig.showHand&&this.playerStateReactive.gameMode!=="spectator"&&this.playerStateReactive.perspective==="first_person"&&!this.renderer.xr.isPresenting&&(this.holdingBlock.render(this.camera,this.renderer,this.ambientLight,this.directionalLight),this.holdingBlockLeft.render(this.camera,this.renderer,this.ambientLight,this.directionalLight));for(let c of this.fountains)this.sectionObjects[c.sectionId]&&!this.sectionObjects[c.sectionId].foutain&&(c.createParticles(this.sectionObjects[c.sectionId]),this.sectionObjects[c.sectionId].foutain=!0),c.render();this.waypoints.render(),this.fireworks.update();for(let c of this.onRender)c(n);let l=performance.now()-i;this.worldRendererConfig.autoLowerRenderDistance&&this.chunkMeshManager.recordRenderTime(l),this.renderTimeAvgCount++,this.renderTimeAvg=(this.renderTimeAvg*(this.renderTimeAvgCount-1)+l)/this.renderTimeAvgCount,this.renderTimeMax=Math.max(this.renderTimeMax,l)}renderHead(e,i,n,s){let o;if(s.SkullOwner?o=s.SkullOwner.Properties?.textures?.[0]?.Value:o=s.profile?.properties?.find(a=>a.name==="textures")?.value,!!o)try{let v=JSON.parse(L.from(o,"base64").toString()).textures?.SKIN?.url,{skinTexturesProxy:l}=this.worldRendererConfig;l&&(v=v?.replace("http://textures.minecraft.net/",l).replace("https://textures.minecraft.net/",l));let c=Mt(this,v,St.head),d=new Y.Group;return n&&c.position.set(0,.3125,.3125),c.position.y-=23/16,d.add(c),this.sceneOrigin.track(d),d.position.set(e.x+.5,e.y+.045,e.z+.5),d.rotation.set(0,-Y.MathUtils.degToRad(i*(n?90:45/2)),0),d.scale.set(.8,.8,.8),d}catch{}}renderSign(e,i,n,s,o){let a=this.getSignTexture(e,o,s);if(!a)return;let v=new Y.Mesh(new Y.PlaneGeometry(1,1),new Y.MeshBasicMaterial({map:a,transparent:!0}));v.renderOrder=999;let l=7/16,c=s?1.3:1;v.scale.set(1*c,l*c,1*c);let d=(s?2:1.5)/16,m=.25/16;n&&!s?v.position.set(0,0,-.5+d+m+1e-4):v.position.set(0,0,d/2+1e-4);let p=new Y.Group;p.rotation.set(0,-Y.MathUtils.degToRad(i*(n?90:45/2)),0),p.add(v);let g=(s?10:8)/16,y=(s?0:n?4.333:9.333)/16,E=g/2+y;return this.sceneOrigin.track(p),p.position.set(e.x+.5,e.y+E,e.z+.5),p}lightUpdate(e,i){for(let n=this.worldSizeParams.minY;n<this.worldSizeParams.worldHeight;n+=16)this.setSectionDirty(new It(e,n,i))}rerenderAllChunks(){for(let e of Object.keys(this.sectionObjects)){let[i,n,s]=e.split(",").map(Number);this.setSectionDirty(new It(i,n,s))}}updateShowChunksBorder(e){for(let i of Object.values(this.sectionObjects))for(let n of i.children)n.name==="helper"&&(n.visible=e)}resetWorld(){super.resetWorld(),this.chunkMeshManager.dispose(),this.chunkMeshManager=new f5(this,this.scene,this.material,this.worldSizeParams.worldHeight,this.viewDistance),this.debugRaycastHelper&&(this.realScene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.realScene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}getLoadedChunksRelative(e,i=!1){let[n,s,o]=H1(e);return Object.fromEntries(Object.entries(this.sectionObjects).map(([a,v])=>{let[l,c,d]=a.split(",").map(Number),[m,p,g]=H1({x:l,y:c,z:d});return[i?`${m-n},${p-s},${g-o}`:`${m-n},${g-o}`,v]}))}cleanChunkTextures(e,i){let n=this.chunkTextures.get(`${Math.floor(e/16)},${Math.floor(i/16)}`)??{};for(let s of Object.keys(n))n[s].dispose(),delete n[s]}readdChunks(){for(let e of Object.keys(this.sectionObjects))this.scene.remove(this.sectionObjects[e]);setTimeout(()=>{for(let e of Object.keys(this.sectionObjects))this.scene.add(this.sectionObjects[e])},500)}disableUpdates(e=this.scene.children){for(let i of e)i.matrixWorldNeedsUpdate=!1,this.disableUpdates(i.children??[])}removeColumn(e,i){super.removeColumn(e,i),this.cleanChunkTextures(e,i);let n=this.getSectionHeight(),s=this.worldMinYRender;for(let o=s;o<this.worldSizeParams.worldHeight;o+=n){let a=`${e},${o},${i}`;this.chunkMeshManager.sectionObjects[a]&&this.chunkMeshManager.releaseSection(a)}}setSectionDirty(...e){let[i]=e;this.cleanChunkTextures(i.x,i.z),super.setSectionDirty(...e)}static getRendererInfo(e){try{let i=e.getContext();return`${i.getParameter(i.getExtension("WEBGL_debug_renderer_info").UNMASKED_RENDERER_WEBGL)}`}catch{}}worldStop(){this.media.onWorldStop()}destroy(){this.chunkMeshManager.dispose(),this.disposeModules(),this.fireworksLegacy.destroy(),super.destroy(),this.skyboxRenderer.dispose(),this.fireworks.dispose()}shouldObjectVisible(e){let n=this.getSectionHeight(),s,o,a,v=this.sceneOrigin.getWorldPosition(e);v?(s=v.x,o=v.y,a=v.z):(s=this.sceneOrigin.toWorldX(e.position.x),o=this.sceneOrigin.toWorldY(e.position.y),a=this.sceneOrigin.toWorldZ(e.position.z));let l=Math.floor(s/16)*16,c=Math.floor(a/16)*16,d=Math.floor(o/n)*n,m=`${l},${c}`,p=`${l},${d},${c}`;return!!this.finishedChunks[m]||!!this.sectionObjects[p]}handleUserClick(e){this.media.handleUserClick(e)}updateSectionOffsets(){let e=performance.now();for(let[i,n]of Object.entries(this.sectionsOffsetsAnimations)){let s=(e-n.time)/1e3;n.time=e,n.currentOffsetX+=n.speedX*s,n.currentOffsetY+=n.speedY*s,n.currentOffsetZ+=n.speedZ*s,n.limitX!==void 0&&(n.speedX>0?n.currentOffsetX=Math.min(n.currentOffsetX,n.limitX):n.currentOffsetX=Math.max(n.currentOffsetX,n.limitX)),n.limitY!==void 0&&(n.speedY>0?n.currentOffsetY=Math.min(n.currentOffsetY,n.limitY):n.currentOffsetY=Math.max(n.currentOffsetY,n.limitY)),n.limitZ!==void 0&&(n.speedZ>0?n.currentOffsetZ=Math.min(n.currentOffsetZ,n.limitZ):n.currentOffsetZ=Math.max(n.currentOffsetZ,n.limitZ));let o=this.sectionObjects[i];o&&(o.position.set(n.currentOffsetX,n.currentOffsetY,n.currentOffsetZ),o.updateMatrix())}}reloadWorld(){this.entities.reloadEntities()}};x();R();T();k();x();R();T();k();x();R();T();k();x();R();T();k();function ri(r){throw new Error("Node.js process "+r+" is not supported by JSPM core outside of Node.js")}var _t=[],Te=!1,ne,A1=-1;function Z8(){!Te||!ne||(Te=!1,ne.length?_t=ne.concat(_t):A1=-1,_t.length&&ns())}function ns(){if(!Te){var r=setTimeout(Z8,0);Te=!0;for(var t=_t.length;t;){for(ne=_t,_t=[];++A1<t;)ne&&ne[A1].run();A1=-1,t=_t.length}ne=null,Te=!1,clearTimeout(r)}}function X8(r){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];_t.push(new rs(r,t)),_t.length===1&&!Te&&setTimeout(ns,0)}function rs(r,t){this.fun=r,this.array=t}rs.prototype.run=function(){this.fun.apply(null,this.array)};var $8="browser",t4="x64",e4="browser",i4={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},n4=["/usr/bin/node"],r4=[],s4="v16.8.0",o4={},a4=function(r,t){},v4=function(r){ri("binding")},l4=function(r){return 0},c4=function(){return"/"},d4=function(r){},u4={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function N0(){}var f4=N0,h4=[];function m4(r){ri("_linkedBinding")}var p4={},g4=!1,b4={};function y4(r){ri("dlopen")}function w4(){return[]}function _4(){return[]}var A4=N0,E4=N0,si=function(){return{}},x4=si,R4=si,k4=N0,T4=N0,M4=N0,S4={};function C4(r,t){if(!r)throw new Error(t||"assertion error")}var P4={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},B4=N0,I4=N0;function H4(){return!1}var z4=N0,O4=N0,D4=N0,L4=N0,F4=N0,U4=void 0,G4=void 0,W4=void 0,V4=N0,N4=2,j4=1,Y4="/bin/usr/node",Q4=9229,K4="node",J4=[],q4=N0,Ht={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};Ht.now===void 0&&(ei=Date.now(),Ht.timing&&Ht.timing.navigationStart&&(ei=Ht.timing.navigationStart),Ht.now=()=>Date.now()-ei);var ei;function Z4(){return Ht.now()/1e3}var ii=1e9;function ni(r){var t=Math.floor((Date.now()-Ht.now())*.001),e=Ht.now()*.001,i=Math.floor(e)+t,n=Math.floor(e%1*1e9);return r&&(i=i-r[0],n=n-r[1],n<0&&(i--,n+=ii)),[i,n]}ni.bigint=function(r){var t=ni(r);return typeof BigInt>"u"?t[0]*ii+t[1]:BigInt(t[0]*ii)+BigInt(t[1])};var X4=10,$4={},tv=0;function zt(){return oi}var ev=zt,iv=zt,nv=zt,rv=zt,sv=zt,ov=N0,av=zt,vv=zt;function lv(r){return[]}var oi={version:s4,versions:o4,arch:t4,platform:e4,release:u4,_rawDebug:f4,moduleLoadList:h4,binding:v4,_linkedBinding:m4,_events:$4,_eventsCount:tv,_maxListeners:X4,on:zt,addListener:ev,once:iv,off:nv,removeListener:rv,removeAllListeners:sv,emit:ov,prependListener:av,prependOnceListener:vv,listeners:lv,domain:p4,_exiting:g4,config:b4,dlopen:y4,uptime:Z4,_getActiveRequests:w4,_getActiveHandles:_4,reallyExit:A4,_kill:E4,cpuUsage:si,resourceUsage:x4,memoryUsage:R4,kill:k4,exit:T4,openStdin:M4,allowedNodeEnvironmentFlags:S4,assert:C4,features:P4,_fatalExceptions:B4,setUncaughtExceptionCaptureCallback:I4,hasUncaughtExceptionCaptureCallback:H4,emitWarning:a4,nextTick:X8,_tickCallback:z4,_debugProcess:O4,_debugEnd:D4,_startProfilerIdleNotifier:L4,_stopProfilerIdleNotifier:F4,stdout:U4,stdin:W4,stderr:G4,abort:V4,umask:l4,chdir:d4,cwd:c4,env:i4,title:$8,argv:n4,execArgv:r4,pid:N4,ppid:j4,execPath:Y4,debugPort:Q4,hrtime:ni,argv0:K4,_preload_modules:J4,setSourceMapsEnabled:q4};var ai={},ss=!1;function cv(){if(ss)return ai;ss=!0;var r=oi;function t(s){if(typeof s!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(s))}function e(s,o){for(var a="",v=0,l=-1,c=0,d,m=0;m<=s.length;++m){if(m<s.length)d=s.charCodeAt(m);else{if(d===47)break;d=47}if(d===47){if(!(l===m-1||c===1))if(l!==m-1&&c===2){if(a.length<2||v!==2||a.charCodeAt(a.length-1)!==46||a.charCodeAt(a.length-2)!==46){if(a.length>2){var p=a.lastIndexOf("/");if(p!==a.length-1){p===-1?(a="",v=0):(a=a.slice(0,p),v=a.length-1-a.lastIndexOf("/")),l=m,c=0;continue}}else if(a.length===2||a.length===1){a="",v=0,l=m,c=0;continue}}o&&(a.length>0?a+="/..":a="..",v=2)}else a.length>0?a+="/"+s.slice(l+1,m):a=s.slice(l+1,m),v=m-l-1;l=m,c=0}else d===46&&c!==-1?++c:c=-1}return a}function i(s,o){var a=o.dir||o.root,v=o.base||(o.name||"")+(o.ext||"");return a?a===o.root?a+v:a+s+v:v}var n={resolve:function(){for(var o="",a=!1,v,l=arguments.length-1;l>=-1&&!a;l--){var c;l>=0?c=arguments[l]:(v===void 0&&(v=r.cwd()),c=v),t(c),c.length!==0&&(o=c+"/"+o,a=c.charCodeAt(0)===47)}return o=e(o,!a),a?o.length>0?"/"+o:"/":o.length>0?o:"."},normalize:function(o){if(t(o),o.length===0)return".";var a=o.charCodeAt(0)===47,v=o.charCodeAt(o.length-1)===47;return o=e(o,!a),o.length===0&&!a&&(o="."),o.length>0&&v&&(o+="/"),a?"/"+o:o},isAbsolute:function(o){return t(o),o.length>0&&o.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var o,a=0;a<arguments.length;++a){var v=arguments[a];t(v),v.length>0&&(o===void 0?o=v:o+="/"+v)}return o===void 0?".":n.normalize(o)},relative:function(o,a){if(t(o),t(a),o===a||(o=n.resolve(o),a=n.resolve(a),o===a))return"";for(var v=1;v<o.length&&o.charCodeAt(v)===47;++v);for(var l=o.length,c=l-v,d=1;d<a.length&&a.charCodeAt(d)===47;++d);for(var m=a.length,p=m-d,g=c<p?c:p,y=-1,E=0;E<=g;++E){if(E===g){if(p>g){if(a.charCodeAt(d+E)===47)return a.slice(d+E+1);if(E===0)return a.slice(d+E)}else c>g&&(o.charCodeAt(v+E)===47?y=E:E===0&&(y=0));break}var w=o.charCodeAt(v+E),_=a.charCodeAt(d+E);if(w!==_)break;w===47&&(y=E)}var C="";for(E=v+y+1;E<=l;++E)(E===l||o.charCodeAt(E)===47)&&(C.length===0?C+="..":C+="/..");return C.length>0?C+a.slice(d+y):(d+=y,a.charCodeAt(d)===47&&++d,a.slice(d))},_makeLong:function(o){return o},dirname:function(o){if(t(o),o.length===0)return".";for(var a=o.charCodeAt(0),v=a===47,l=-1,c=!0,d=o.length-1;d>=1;--d)if(a=o.charCodeAt(d),a===47){if(!c){l=d;break}}else c=!1;return l===-1?v?"/":".":v&&l===1?"//":o.slice(0,l)},basename:function(o,a){if(a!==void 0&&typeof a!="string")throw new TypeError('"ext" argument must be a string');t(o);var v=0,l=-1,c=!0,d;if(a!==void 0&&a.length>0&&a.length<=o.length){if(a.length===o.length&&a===o)return"";var m=a.length-1,p=-1;for(d=o.length-1;d>=0;--d){var g=o.charCodeAt(d);if(g===47){if(!c){v=d+1;break}}else p===-1&&(c=!1,p=d+1),m>=0&&(g===a.charCodeAt(m)?--m===-1&&(l=d):(m=-1,l=p))}return v===l?l=p:l===-1&&(l=o.length),o.slice(v,l)}else{for(d=o.length-1;d>=0;--d)if(o.charCodeAt(d)===47){if(!c){v=d+1;break}}else l===-1&&(c=!1,l=d+1);return l===-1?"":o.slice(v,l)}},extname:function(o){t(o);for(var a=-1,v=0,l=-1,c=!0,d=0,m=o.length-1;m>=0;--m){var p=o.charCodeAt(m);if(p===47){if(!c){v=m+1;break}continue}l===-1&&(c=!1,l=m+1),p===46?a===-1?a=m:d!==1&&(d=1):a!==-1&&(d=-1)}return a===-1||l===-1||d===0||d===1&&a===l-1&&a===v+1?"":o.slice(a,l)},format:function(o){if(o===null||typeof o!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof o);return i("/",o)},parse:function(o){t(o);var a={root:"",dir:"",base:"",ext:"",name:""};if(o.length===0)return a;var v=o.charCodeAt(0),l=v===47,c;l?(a.root="/",c=1):c=0;for(var d=-1,m=0,p=-1,g=!0,y=o.length-1,E=0;y>=c;--y){if(v=o.charCodeAt(y),v===47){if(!g){m=y+1;break}continue}p===-1&&(g=!1,p=y+1),v===46?d===-1?d=y:E!==1&&(E=1):d!==-1&&(E=-1)}return d===-1||p===-1||E===0||E===1&&d===p-1&&d===m+1?p!==-1&&(m===0&&l?a.base=a.name=o.slice(1,p):a.base=a.name=o.slice(m,p)):(m===0&&l?(a.name=o.slice(1,d),a.base=o.slice(1,p)):(a.name=o.slice(m,d),a.base=o.slice(m,p)),a.ext=o.slice(d,p)),m>0?a.dir=o.slice(0,m-1):l&&(a.dir="/"),a},sep:"/",delimiter:":",win32:null,posix:null};return n.posix=n,ai=n,ai}var j0=cv();var rR=j0._makeLong,sR=j0.basename,oR=j0.delimiter,aR=j0.dirname,vR=j0.extname,lR=j0.format,cR=j0.isAbsolute,vi=j0.join,dR=j0.normalize,uR=j0.parse,fR=j0.posix,hR=j0.relative,mR=j0.resolve,pR=j0.sep,gR=j0.win32;import*as v0 from"three";x();R();T();k();import dv from"prismarine-world";import uv from"prismarine-chunk";var os=r=>{let t=dv(r),e=uv(r),i=new t(r).sync,n=fv(i);for(let s of n)if(s.startsWith("set")&&s!=="setColumn"){let o=i[s].bind(i);i[s]=(...a)=>{let v=a[0];v.x!==void 0&&!i.getColumnAt(v)&&i.setColumn(Math.floor(v.x/16),Math.floor(v.z/16),new e(void 0)),o(...a)}}return i};function fv(r){let t=new Set,e=r;do for(let i of Object.getOwnPropertyNames(e))typeof r[i]=="function"&&i!=="constructor"&&t.add(i);while(e=Object.getPrototypeOf(e));return[...t]}import{Vec3 as vs}from"vec3";x();R();T();k();var as="1.21.4";var li=new Date,ls=li.getMonth()===11&&li.getDate()>=24&&li.getDate()<=26,hv=["panorama_3.webp","panorama_1.webp","panorama_4.webp","panorama_5.webp","panorama_0.webp","panorama_2.webp"],E1=class{constructor(t,e,i=!1){this.documentRenderer=t;this.options=e;this.doWorldBlocksPanorama=i;f(this,"camera");f(this,"scene");f(this,"ambientLight");f(this,"directionalLight");f(this,"panoramaGroup",null);f(this,"time",0);f(this,"abortController",new AbortController);f(this,"worldRenderer");f(this,"WorldRendererClass",ie);f(this,"startTimes",new Map);this.scene=new v0.Scene,this.scene.background=new v0.Color(3294568),this.ambientLight=new v0.AmbientLight(13421772),this.scene.add(this.ambientLight),this.directionalLight=new v0.DirectionalLight(16777215,.5),this.directionalLight.position.set(1,1,.5).normalize(),this.directionalLight.castShadow=!0,this.scene.add(this.directionalLight),this.camera=new v0.PerspectiveCamera(85,this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,.05,1e3),this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0)}async start(){this.doWorldBlocksPanorama?await this.worldBlocksPanorama():this.addClassicPanorama(),this.documentRenderer.render=(t=!1)=>{t&&(this.camera.aspect=this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,this.camera.updateProjectionMatrix()),this.documentRenderer.renderer.render(this.scene,this.camera)}}async debugImageInFrontOfCamera(){let t=await Rt(vi("background","panorama_0.webp")),e=new v0.Mesh(new v0.PlaneGeometry(1e3,1e3),new v0.MeshBasicMaterial({map:t}));e.position.set(0,0,-500),e.rotation.set(0,0,0),this.scene.add(e)}addClassicPanorama(){let t=new v0.BoxGeometry(1e3,1e3,1e3),e=[],i=200;for(let o of hv)(async()=>{let{texture:v}=O5(vi("background",ls?"christmas":"",o));v.matrixAutoUpdate=!1,v.matrix.set(-1,0,1,0,1,0,0,0,1),v.wrapS=v0.ClampToEdgeWrapping,v.wrapT=v0.ClampToEdgeWrapping,v.minFilter=v0.LinearFilter,v.magFilter=v0.LinearFilter;let l=new v0.MeshBasicMaterial({map:v,transparent:!0,side:v0.DoubleSide,depthWrite:!1,opacity:0});this.startTimes.set(l,Date.now()),e.push(l)})();let n=new v0.Mesh(t,e);n.onBeforeRender=()=>{this.time+=.01,n.rotation.y=Math.PI+this.time*.01,n.rotation.z=Math.sin(-this.time*.001)*.001;for(let o of e){let a=this.startTimes.get(o);if(a){let v=Date.now()-a,l=Math.min(1,v/i);o.opacity=l}}};let s=new v0.Object3D;if(s.add(n),!ls)for(let o=0;o<20;o++){let a=new wt("1.16.4","squid").mesh;a.position.set(Math.random()*30-15,Math.random()*20-10,Math.random()*10-17),a.rotation.set(0,Math.PI+Math.random(),-Math.PI/4,"ZYX");let v=Math.random()*.01;a.children[0].onBeforeRender=()=>{a.rotation.y+=v,a.rotation.z=Math.cos(n.rotation.y*3)*Math.PI/4-Math.PI/2},s.add(a)}this.scene.add(s),this.panoramaGroup=s}async worldBlocksPanorama(){let t=as,e=new mt;if(e.currentConfig={version:t,noInventoryGui:!0},await e.updateAssetsData?.({}),this.abortController.signal.aborted)return;let i=os(t),s=ys("prismarine-block")(t),a=globalThis.mcData.blocksArray.filter(w=>{if(!w.name.includes("stained_glass"))return!1;let _=s.fromStateId(w.defaultState,0);if(_.shapes?.length!==1)return!1;let C=_.shapes[0];return C[0]===0&&C[1]===0&&C[2]===0&&C[3]===1&&C[4]===1&&C[5]===1}),v=-15,l=100,c=100;for(let w=-l;w<l;w++)for(let _=-c;_<c;_++){let C=a[Math.floor(Math.random()*a.length)];i.setBlockStateId(new vs(w,_,v),C.defaultState)}this.camera.updateProjectionMatrix(),this.camera.position.set(.5,c/2+.5,.5),this.camera.rotation.set(0,0,0);let d=new vs(...this.camera.position.toArray()),m=new jt(i,2,d);if(this.abortController.signal.aborted||(this.worldRenderer=new this.WorldRendererClass(this.documentRenderer.renderer,this.options,{version:t,worldView:m,inWorldRenderingConfig:Oe,playerStateReactive:Ln().reactive,rendererState:Gt().reactive,nonReactiveState:Gt().nonReactive,resourcesManager:e}),this.worldRenderer instanceof ie&&(this.scene=this.worldRenderer.realScene),m.init(d),await this.worldRenderer.waitForChunksToRender(),this.abortController.signal.aborted))return;let{camera:p}=this,g=p.position.x,y=p.position.y,E;document.body.addEventListener("pointermove",w=>{if(w.pointerType!=="mouse")return;let _=new v0.Vector2(w.clientX,w.clientY),C=.2,M=_.x/window.innerWidth-.5,S=-(_.y/window.innerHeight-.5);E?.stop();let H={x:g+M*C,y:y+S*C};E=new S0(p.position).to(H,0),E.start(),p.updateProjectionMatrix()},{signal:this.abortController.signal})}dispose(){this.scene.clear(),this.worldRenderer?.destroy(),this.abortController.abort()}};h5.ColorManagement.enabled=!1;globalThis.THREE=h5;var cs=r=>({updateMap:r.entities.updateMap.bind(r.entities),updateCustomBlock:r.updateCustomBlock.bind(r),getBlockInfo:r.getBlockInfo.bind(r),playEntityAnimation:r.entities.playAnimation.bind(r.entities),damageEntity:r.entities.handleDamageEvent.bind(r.entities),updatePlayerSkin:r.entities.updatePlayerSkin.bind(r.entities),changeHandSwingingState:r.changeHandSwingingState.bind(r),getHighestBlocks:r.getHighestBlocks.bind(r),reloadWorld:r.reloadWorld.bind(r),updateEntityModel:r.entities.updateEntityModel.bind(r.entities),playEntityModelAnimation:r.entities.playEntityModelAnimation.bind(r.entities),addMedia:r.media.addMedia.bind(r.media),destroyMedia:r.media.destroyMedia.bind(r.media),setControlMode:r.media.setControlMode.bind(r.media),setVideoPlaying:r.media.setVideoPlaying.bind(r.media),setVideoSeeking:r.media.setVideoSeeking.bind(r.media),setVideoVolume:r.media.setVideoVolume.bind(r.media),setVideoSpeed:r.media.setVideoSpeed.bind(r.media),handleUserClick:r.media.handleUserClick.bind(r.media),addSectionAnimation(t,e){r.sectionsOffsetsAnimations[t]=e},removeSectionAnimation(t){delete r.sectionsOffsetsAnimations[t]},shakeFromDamage:r.cameraShake.shakeFromDamage.bind(r.cameraShake),onPageInteraction:r.media.onPageInteraction.bind(r.media),downloadMesherLog:r.downloadMesherLog.bind(r),explodeFirework:r.fireworksLegacy.explode.bind(r.fireworksLegacy),explodeFireworkFacingCamera:r.fireworksLegacy.explodeFacingCamera.bind(r.fireworksLegacy),addWaypoint:r.waypoints.addWaypoint.bind(r.waypoints),removeWaypoint:r.waypoints.removeWaypoint.bind(r.waypoints),startCinimaticScript:r.cinimaticScript.startScript.bind(r.cinimaticScript),stopCinimaticScript:r.cinimaticScript.stopScript.bind(r.cinimaticScript),launchFirework:r.fireworks.launchFirework.bind(r.fireworks),setSkyboxImage:r.skyboxRenderer.setSkyboxImage.bind(r.skyboxRenderer),setRain:t=>r.toggleModule("rain",t),spawnBlockBreakParticles(t,e,i,n,s,o){r.getModule("blockBreakParticles")?.spawnBlockBreakParticles(t,e,i,n,s,o)},spawnBlockCrackParticle(t,e,i,n,s,o,a){r.getModule("blockBreakParticles")?.spawnCrackParticle(t,e,i,n,s,o,a)},async loadGeometryExport(t){let{applyWorldGeometryExport:e}=await Promise.resolve().then(()=>(N2(),D6));return e(r,t)}}),pv=[],x1=(r,...t)=>{for(let e of Object.values(globalThis.loadedMods??{}))try{e.threeJsBackendModule?.[r]?.(...t)}catch(i){let n=`[mod three.js] Error calling ${r} on ${e.name}: ${i}`;throw new Error(n)}},ds=()=>{let r,t=null,e=null,i=null,n=null,s=(c,d)=>{_0?r=M5(c,pv,globalThis):r=c,t=new Ne(r,d?.canvas),globalThis.renderer=t.renderer,globalThis.documentRenderer=t,globalThis.threeJsBackend=l,x1("default",l)},o=async()=>{if(!t)throw new Error("Document renderer not initialized");if(!i&&!e){let c={...r};e=new E1(t,c,!!D.env.SINGLE_FILE_BUILD_MODE),globalThis.panoramaRenderer=e,x1("panoramaCreated",e),await e.start(),x1("panoramaReady",e)}},a=async c=>{let m=_0?M5(c,[mt,Nt],globalThis):c;if(!t)throw new Error("Document renderer not initialized");t.nonReactiveState=m.nonReactiveState,globalThis.resourcesManager=m.resourcesManager,e&&(e.dispose(),e=null),i=new ie(t.renderer,r,m),await i.worldReadyPromise,n=new S5(m.nonReactiveState),globalThis.frameTimingCollector=n;let p=t.render;t.render=function(g){p.call(this,g),n?.markFrameStart(),m.inWorldRenderingConfig.paused||i?.render(g),n?.markFrameEnd(),n?.markFrameDisplay()},t.inWorldRenderingConfig=m.inWorldRenderingConfig,globalThis.world=i,x1("worldReady",i)},v=()=>{e&&(e.dispose(),e=null),t&&t.dispose(),i&&(i.destroy(),i=null)},l={id:"threejs",displayName:`three.js ${h5.REVISION}`,startPanorama:o,startWorld:a,disconnect:v,setRendering(c){t.setPaused(!c),i&&(i.renderingActive=c)},getDebugOverlay:()=>({get entitiesString(){return i?.entities.getDebugString()},get left(){return{"Geo Memory":i?.chunkMeshManager.getEstimatedMemoryUsage().total??"-"}}}),updateCamera(c,d,m){n?.markCameraUpdate(!c),i?.setFirstPersonCamera(c,d,m)},get soundSystem(){return i?.soundSystem},get backendMethods(){if(i)return cs(i)}};return{main:{init:s,backend:l},workerProxy(){return qn({init(c,d){s(c,{canvas:d})},updateSizeExternal(c,d,m){t?.updateSizeExternal(c,d,m)},startPanorama:o,startWorld:a,disconnect:v,setRendering:l.setRendering,updateCamera(c,d,m){let p=c?new mv(c.x,c.y,c.z):null;n?.markCameraUpdate(!p),l.updateCamera(p,d,m)},async callBackendMethod(c,...d){if(!i)throw new Error("World renderer not initialized");let p=cs(i)[c];if(!p)throw new Error(`Backend method ${String(c)} is unavailable`);return p(...d)}})}}};var R1=r=>{let{main:t}=ds();return t.init(r),t.backend};R1.id="threejs";R1.displayName="three.js Blocking";R1.description="Simple, old and stable main thread graphics backend providing balanced performance on top of WebGL2.";x();R();T();k();import*as us from"three";function gv(r){let t="threeWorker.js",e;if(D.env.SINGLE_FILE_BUILD){let i=document.getElementById("three-worker-code").textContent,n=new Blob([i],{type:"text/javascript"});e=new Worker(window.URL.createObjectURL(n))}else e=new Worker(t);return e.onmessage=({data:i})=>{r(i)},e.on&&e.on("message",i=>{e.onmessage({data:i})}),e}var k1=async r=>{let t=gv(()=>{}),e=Zn(t),i=F1();i.onSizeChanged((a,v)=>{e.updateSizeExternal(a,v,window.devicePixelRatio||1)});let n=T5(r,t);try{e.init(n,i.canvas)}catch(a){throw Ue(n),a}let s=new Proxy({},{get(a,v){if(typeof v=="string")return async(...l)=>e.callBackendMethod(v,...l)}});return{id:"threejs",displayName:`three.js ${us.REVISION}`,async startPanorama(){},async startWorld(a){let v={...We,items:"itemsArray",entities:"entitiesArray"};Z1([t],a.version,v,a.resourcesManager.currentResources.mcData),a.inWorldRenderingConfig.__syncToWorker=!0,a.playerStateReactive&&(a.playerStateReactive.__syncToWorker=!0),a.rendererState&&(a.rendererState.__syncFromWorker=!0),a.nonReactiveState&&(a.nonReactiveState.__syncFromWorker=!0),a.nonReactiveState.__syncFromWorkerInterval=200;let l=T5(a,t);try{await e.startWorld(structuredClone(l))}catch(d){throw Ue(l),d}e.updateSizeExternal(i.size.width,i.size.height,window.devicePixelRatio||1);let c=ue("fps");setInterval(()=>{let{fps:d,avgRenderTime:m,worstRenderTime:p}=a.nonReactiveState;c.updateText(`FPS: ${d.toFixed(0)} (${m.toFixed(0)}ms/${p.toFixed(0)}ms)`),a.nonReactiveState.fps=0},1e3)},disconnect(){i.destroy(),e.disconnect(),t.terminate()},setRendering(a){e.setRendering(a)},updateCamera(a,v,l){e.updateCamera(a?{x:a.x,y:a.y,z:a.z}:null,v,l)},soundSystem:void 0,backendMethods:s}};k1.id="threejs-off-thread";k1.displayName="three.js Multi-thread";k1.description=["Edge-cutting technology that uses a dedicated thread for graphics.","Slightly higher power and RAM usage.","More stable FPS (mid-range devices), but possible inputlag if TPS is low.","On low-end devices it might result in device throttling and stuttering."].join(" ");export{Vn as AppViewer,Ne as DocumentRenderer,ve as LoadedResourcesTransferrable,mt as ResourcesManager,jt as WorldView,Nt as WorldViewWorker,F1 as addCanvasForWorker,ae as chunkPos,k1 as createGraphicsBackendOffThread,R1 as createGraphicsBackendSingleThread,Kv as createWorldRendererConfig,On as defaultGraphicsBackendConfig,Oe as defaultWorldRendererConfig,Un as delayedIterator,Gt as getDefaultRendererState,Nn as getInitialPlayerState,Ws as getInitialPlayerStateRenderer,Gs as getPlayerStateUtils,_0 as isWebWorker,ks as sectionPos};
|
|
21236
|
+
}`})}},ti=class{constructor(t){this.worldRenderer=t;f(this,"points");f(this,"clock",new E0.Clock);f(this,"enabled",!1);f(this,"currentTime");f(this,"enablementCheck",()=>this.currentTime?this.currentTime>13500&&this.currentTime<23e3:!1);f(this,"render",t=>{this.points&&(this.points.position.set(0,0,0),this.points.material.uniforms.time.value=this.clock.getElapsedTime()*.2)})}enable(){this.enabled||(this.enabled=!0,this.updateVisibility())}disable(){this.enabled&&(this.enabled=!1,this.removeStars())}toggle(){return this.enabled?this.disable():this.enable(),this.enabled}updateTimeOfDay(t){this.currentTime=t,this.enabled&&this.updateVisibility()}updateVisibility(){if(!this.enabled)return;let t=this.enablementCheck?.()??!1;t&&!this.points?this.createStars():!t&&this.points&&this.removeStars()}createStars(){if(this.points)return;let t=80,e=50,i=7e3,n=7,s=10,o=new E0.BufferGeometry,a=y=>new E0.Vector3().setFromSpherical(new E0.Spherical(y,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)),v=[],l=[],c=Array.from({length:i},()=>(.5+.5*Math.random())*n),d=new E0.Color,m=t+e,p=e/i;for(let y=0;y<i;y++)m-=p*Math.random(),v.push(...a(m).toArray()),d.setHSL(y/i,s,.9),l.push(d.r,d.g,d.b);o.setAttribute("position",new E0.Float32BufferAttribute(v,3)),o.setAttribute("color",new E0.Float32BufferAttribute(l,3)),o.setAttribute("size",new E0.Float32BufferAttribute(c,1));let g=new $2;g.blending=E0.AdditiveBlending,g.depthTest=!1,g.transparent=!0,this.points=new E0.Points(o,g),this.points.renderOrder=-1,this.worldRenderer.scene.add(this.points)}dispose(){this.removeStars()}removeStars(){this.points&&(this.points.geometry.dispose(),this.points.material.dispose(),this.worldRenderer.scene.remove(this.points),this.points=void 0)}},es={id:"starfield",controller:ti,enabledDefault:!0,cannotBeDisabled:!0};var is={starfield:es,futuristicReveal:ts,rain:X6,cameraBobbing:K6,blockBreakParticles:Q6};var ie=class r extends L5{constructor(e,i,n){if(!n.resourcesManager)throw new Error("resourcesManager is required in displayOptions");super(n.resourcesManager,n,i);this.renderer=e;this.initOptions=i;this.displayOptions=n;f(this,"outputFormat","threeJs");f(this,"chunkMeshManager");f(this,"chunkTextures",new Map);f(this,"signsCache",new Map);f(this,"cameraSectionPos",new It(0,0,0));f(this,"holdingBlock");f(this,"holdingBlockLeft");f(this,"realScene",new Y.Scene);f(this,"scene",new Y.Group);f(this,"ambientLight",new Y.AmbientLight(13421772));f(this,"directionalLight",new Y.DirectionalLight(16777215,.5));f(this,"entities",new r1(this,globalThis.mcData));f(this,"cameraGroupVr");f(this,"material",new Y.MeshBasicMaterial({vertexColors:!0,transparent:!0,alphaTest:.1}));f(this,"itemsTexture");f(this,"cursorBlock");f(this,"onRender",[]);f(this,"lastRenderTime",0);f(this,"cameraShake");f(this,"cameraContainer");f(this,"media");f(this,"waypoints");f(this,"cinimaticScript");f(this,"camera");f(this,"renderTimeAvg",0);f(this,"modules",{});f(this,"sectionsOffsetsAnimations",{});f(this,"fountains",[]);f(this,"fireworksLegacy");f(this,"DEBUG_RAYCAST",!1);f(this,"skyboxRenderer");f(this,"fireworks");f(this,"sceneOrigin",new p1(this.realScene));f(this,"cameraWorldPos",{x:0,y:0,z:0});f(this,"_cameraPositionAccessWarned",!1);f(this,"_tmpCameraPos",new Y.Vector3);f(this,"currentPosTween");f(this,"currentRotTween");f(this,"_tpDirection",new Y.Vector3);f(this,"_tpPitchQuat",new Y.Quaternion);f(this,"_tpYawQuat",new Y.Quaternion);f(this,"_tpFinalQuat",new Y.Quaternion);f(this,"_tpScenePos",new Y.Vector3);f(this,"_tpAxisX",new Y.Vector3(1,0,0));f(this,"_tpAxisY",new Y.Vector3(0,1,0));f(this,"_tpRaycaster",new Y.Raycaster);f(this,"_tpChunkWorldPos",new Y.Vector3);f(this,"debugOverlayAdded",!1);f(this,"debugRaycastHelper");f(this,"debugHitPoint");f(this,"prevFramePerspective",null);this.renderer=e,n.rendererState.renderer=r.getRendererInfo(e)??"...",this.chunkMeshManager=new f5(this,this.scene,this.material,this.worldSizeParams.worldHeight,this.viewDistance),this.onRenderDistanceChanged=s=>{this.chunkMeshManager.updateViewDistance(s)},this.cursorBlock=new s1(this),this.holdingBlock=a5(this),this.holdingBlockLeft=a5(this,!0);for(let s of Object.values(is))this.registerModule(s);this.skyboxRenderer=new h1(this.realScene,!1,null),this.skyboxRenderer.init(),this.addDebugOverlay(),this.resetScene(),this.init(),this.soundSystem=new a1(this),this.cameraShake=new v1(this,this.onRender),this.media=new l1(this),this.fireworksLegacy=new u1(this),this.waypoints=new d1(this),this.cinimaticScript=new f1(this,(s,o,a)=>this.setCinimaticCamera(s,o,a),s=>this.setCinimaticFov(s),()=>({position:new It(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),yaw:this.cameraShake.getBaseRotation().yaw,pitch:this.cameraShake.getBaseRotation().pitch,fov:this.camera.fov})),this.fireworks=new m1(this.realScene,this.sceneOrigin),this.renderUpdateEmitter.on("chunkFinished",s=>{this.finishChunk(s)}),this.worldSwitchActions(),this.initializeModules()}get sectionObjects(){return this.chunkMeshManager.sectionObjects}get waitingChunksToDisplay(){return{}}get estimatedMemoryUsage(){return this.chunkMeshManager.getEstimatedMemoryUsage().total}get tilesRendered(){return this.chunkMeshManager.getTotalTiles()}get blocksRendered(){return this.chunkMeshManager.getTotalBlocks()}registerModule(e){if(e.id in this.modules)return;let i=new e.controller(this),n={manifest:e,controller:i,enabled:!1,toggle:()=>this.toggleModule(e.id)};this.modules[e.id]=n,e.enabledDefault&&this.toggleModule(e.id,!0)}enableModule(e){let i=this.modules[e];i&&(i.enabled||(i.enabled=!0,i.controller.enable(),i.controller.render&&this.onRender.push(i.controller.render)))}disableModule(e){let i=this.modules[e];if(i&&!i.manifest.cannotBeDisabled&&i.enabled&&(i.enabled=!1,i.controller.disable(),i.controller.render)){let n=this.onRender.indexOf(i.controller.render);n>-1&&this.onRender.splice(n,1)}}toggleModule(e,i){let n=this.modules[e];if(!n)return!1;let s=i!==void 0?i:!n.enabled;if(s===n.enabled)return n.enabled;if(!s&&n.manifest.cannotBeDisabled)return!0;if(n.enabled=s,s)n.controller.enable(),n.controller.render&&!this.onRender.includes(n.controller.render)&&this.onRender.push(n.controller.render);else if(n.controller.disable(),n.controller.render){let o=this.onRender.indexOf(n.controller.render);o>-1&&this.onRender.splice(o,1)}return s}disposeModules(){for(let e of Object.values(this.modules))e.controller.dispose();this.modules={}}initializeModules(){this.updateModulesFromConfig()}getModule(e){return this.modules[e]?.controller}anyModuleRequiresHeightmap(){return Object.values(this.modules).some(e=>e.enabled&&e.manifest.requiresHeightmap)}get cameraObject(){return this.cameraGroupVr??this.cameraContainer}_wrapCameraPositionWithWarning(){let e=this.camera.position,i=this,n=20,s=(v,l,c)=>Math.abs(v)>n||Math.abs(l)>n||Math.abs(c)>n,o=()=>{!i._cameraPositionAccessWarned&&typeof D<"u"},a=new Proxy(e,{set(v,l,c){return(l==="x"||l==="y"||l==="z")&&typeof c=="number"&&Math.abs(c)>n&&o(),v[l]=c,!0},get(v,l,c){let d=v[l];return l==="set"?function(m,p,g){return s(m,p,g)&&o(),v.set(m,p,g)}:l==="setX"||l==="setY"||l==="setZ"?function(m){return Math.abs(m)>n&&o(),v[l](m)}:l==="copy"?function(m){return s(m.x,m.y,m.z)&&o(),v.copy(m)}:typeof d=="function"?d.bind(v):d}});Object.defineProperty(this.camera,"position",{value:a,configurable:!0,enumerable:!0})}worldSwitchActions(){this.onWorldSwitched.push(()=>{this.protocolCustomBlocks.clear(),this.sectionsOffsetsAnimations={},this.waypoints.clear(),this.cinimaticScript.stopScript(),this.fireworks.clear()})}downloadWorldGeometry(){V2(this,new Y.Vector3(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),this.cameraShake.getBaseRotation(),"world-geometry.json")}updateEntity(e,i=!1){let n={rotation:{head:{x:e.headPitch??e.pitch,y:e.headYaw,z:0}}};i?this.entities.updateEntityPosition(e,!1,n):this.entities.update(e,n)}updatePlayerEntity(e){this.entities.handlePlayerEntity(e)}resetScene(){this.sceneOrigin.update(0,0,0),this.cameraWorldPos.x=0,this.cameraWorldPos.y=0,this.cameraWorldPos.z=0,this.realScene.matrixAutoUpdate=!1,this.realScene.background=new Y.Color(this.initOptions.config.sceneBackground),this.realScene.add(this.ambientLight),this.directionalLight.position.set(1,1,.5).normalize(),this.directionalLight.castShadow=!0,this.realScene.add(this.directionalLight);let e=this.renderer.getSize(new Y.Vector2);this.camera=new Y.PerspectiveCamera(75,e.x/e.y,.1,1e3),this._wrapCameraPositionWithWarning(),this.cameraContainer=new Y.Object3D,this.cameraContainer.add(this.camera),this.realScene.add(this.cameraContainer),this.realScene.add(this.scene)}watchReactivePlayerState(){super.watchReactivePlayerState(),this.onReactivePlayerStateUpdated("inWater",e=>{this.skyboxRenderer.updateWaterState(e,this.playerStateReactive.waterBreathing)}),this.onReactivePlayerStateUpdated("waterBreathing",e=>{this.skyboxRenderer.updateWaterState(this.playerStateReactive.inWater,e)}),this.onReactivePlayerStateUpdated("ambientLight",e=>{e&&(this.ambientLight.intensity=e)}),this.onReactivePlayerStateUpdated("directionalLight",e=>{e&&(this.directionalLight.intensity=e)}),this.onReactivePlayerStateUpdated("lookingAtBlock",e=>{this.cursorBlock.setHighlightCursorBlock(e?new It(e.x,e.y,e.z):null,e?.shapes)}),this.onReactivePlayerStateUpdated("diggingBlock",e=>{this.cursorBlock.updateBreakAnimation(e?{x:e.x,y:e.y,z:e.z}:void 0,e?.stage??null,e?.mergedShape)}),this.onReactivePlayerStateUpdated("perspective",e=>{let i=new It(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z);this.updateCamera(i,this.cameraShake.getBaseRotation().yaw,this.cameraShake.getBaseRotation().pitch)})}watchReactiveConfig(){super.watchReactiveConfig(),this.onReactiveConfigUpdated("showChunkBorders",i=>{this.updateShowChunksBorder(i)}),this.onReactiveConfigUpdated("defaultSkybox",i=>{this.skyboxRenderer.updateDefaultSkybox(i)});let e=this.displayOptions.inWorldRenderingConfig.handRenderer;this.onReactiveConfigUpdated("handRenderer",i=>{if(i===e)return;e=i;let n=this.holdingBlock.ready,s=this.holdingBlockLeft.ready;this.holdingBlock.dispose(),this.holdingBlockLeft.dispose(),this.holdingBlock=a5(this),this.holdingBlockLeft=a5(this,!0),n&&(this.holdingBlock.ready=!0,this.holdingBlock.updateItem()),s&&(this.holdingBlockLeft.ready=!0,this.holdingBlockLeft.updateItem())}),this.onReactiveConfigUpdated("*",()=>{this.updateModulesFromConfig()}),this.updateModulesFromConfig()}updateModulesFromConfig(){let{moduleStates:e}=this.worldRendererConfig;for(let[i,n]of Object.entries(this.modules)){let s=e[i];if(s==="enabled"){n.enabled||this.toggleModule(i,!0);continue}if(s==="disabled"){n.enabled&&!n.manifest.cannotBeDisabled&&this.toggleModule(i,!1);continue}if(s==="auto"||s===void 0)if(n.controller.autoEnableCheck){let o=n.controller.autoEnableCheck();o&&!n.enabled?this.toggleModule(i,!0):!o&&n.enabled&&!n.manifest.cannotBeDisabled&&this.toggleModule(i,!1)}else{let o=n.manifest.enabledDefault??!1;o&&!n.enabled?this.toggleModule(i,!0):!o&&n.enabled&&!n.manifest.cannotBeDisabled&&this.toggleModule(i,!1)}}}changeHandSwingingState(e,i=!1){let n=i?this.holdingBlockLeft:this.holdingBlock;e?n.startSwing():n.stopSwing()}async updateAssetsData(){let e=this.resourcesManager.currentResources,i=this.material.map,n=this.itemsTexture,s=K1(e.blocksAtlasImage);s.needsUpdate=!0,s.flipY=!1,this.material.map=s;let o=K1(e.itemsAtlasImage);o.needsUpdate=!0,o.flipY=!1,this.itemsTexture=o,i&&i.dispose(),n&&n.dispose(),await super.updateAssetsData(),this.onAllTexturesLoaded(),Object.keys(this.loadedChunks).length>0&&this.rerenderAllChunks()}onAllTexturesLoaded(){this.holdingBlock.ready=!0,this.holdingBlock.updateItem(),this.holdingBlockLeft.ready=!0,this.holdingBlockLeft.updateItem()}changeBackgroundColor(e){this.realScene.background=new Y.Color(e[0],e[1],e[2])}changeCardinalLight(e){this.worldRendererConfig.cardinalLight=e}timeUpdated(e){let i=this.getModule("starfield");i?.updateTimeOfDay&&i.updateTimeOfDay(e),this.skyboxRenderer.updateTime(e)}biomeUpdated(e){e?.temperature!==void 0&&this.skyboxRenderer.updateTemperature(e.temperature)}biomeReset(){this.skyboxRenderer.updateTemperature(U2)}getItemRenderData(e,i){return C6(e,i,this.resourcesManager,this.playerStateReactive)}async demoModel(){let e=cursorBlockRel(0,1,0).position,i=await t5();mr(i,e);let n=new Y.BoxHelper(i,16776960);i.add(n),this.realScene.add(i)}demoItem(){let e=cursorBlockRel(0,1,0).position,{mesh:i}=this.entities.getItemMesh({itemId:541},{});i.position.set(e.x+.5,e.y+.5,e.z+.5);let n=new Y.BoxHelper(i,16776960);i.add(n),this.realScene.add(i)}addDebugOverlay(){if(this.debugOverlayAdded)return;this.debugOverlayAdded=!0;let e=ue("debug-overlay");setInterval(()=>{if(e.setVisibility(this.displayAdvancedStats),this.displayAdvancedStats){let i=o=>new Intl.NumberFormat("en-US",{}).format(o),n="";n+=`C: ${i(this.renderer.info.render.calls)} `,n+=`TR: ${i(this.renderer.info.render.triangles)} `,n+=`TE: ${i(this.renderer.info.memory.textures)} `,n+=`F: ${i(this.tilesRendered)} `,n+=`B: ${i(this.blocksRendered)} `,n+=`MEM: ${this.chunkMeshManager.getEstimatedMemoryUsage().total} `;let s=this.chunkMeshManager.getStats();n+=`POOL: ${s.activeCount}/${s.poolSize} HR: ${s.hitRate}`,e.updateText(n),this.backendInfoReport=n}},200)}updatePosDataChunk(e){let[i,n,s]=e.split(",").map(l=>Math.floor(+l/16)),o=Math.abs(i-this.cameraSectionPos.x)+Math.abs(n-this.cameraSectionPos.y)+Math.abs(s-this.cameraSectionPos.z),a=this.sectionObjects[e],v=a.mesh??a.children.find(l=>l.name==="mesh");v.renderOrder=500-o}updateViewerPosition(e){this.viewerChunkPosition=e}cameraSectionPositionUpdate(){for(let e in this.sectionObjects)this.sectionObjects[e]&&this.updatePosDataChunk(e)}getDir(e,i){return e===i?0:e<i?1:-1}finishChunk(e){}handleWorkerMessage(e){if(e.type==="geometry"){let i=e.key.split(",");if(!this.loadedChunks[i[0]+","+i[2]]||!e.geometry.positions.length||!this.active)return;this.chunkMeshManager.updateSection(e.key,e.geometry),this.updatePosDataChunk(e.key)}}getSignTexture(e,i,n,s=!1){let o=de(e),a=this.chunkTextures.get(`${o[0]},${o[1]}`);a||(a={},this.chunkTextures.set(`${o[0]},${o[1]}`,a));let v=`${e.x},${e.y},${e.z}`;if(a[v])return a[v];let l=q8(this.version),c=P5(i,n,l);if(!c)return;let d=new Y.Texture(c);return d.magFilter=Y.NearestFilter,d.minFilter=Y.NearestFilter,d.needsUpdate=!0,a[v]=d,d}getCameraPosition(e){return(e??this._tmpCameraPos).set(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z)}getSectionCameraPosition(){let e=this.getCameraPosition();return new It(Math.floor(e.x/16),Math.floor(e.y/16),Math.floor(e.z/16))}updateCameraSectionPos(){let e=this.getSectionCameraPosition();this.cameraSectionPos.equals(e)||(this.cameraSectionPos=e,this.cameraSectionPositionUpdate())}setFirstPersonCamera(e,i,n){let s=this.playerStateReactive.eyeHeight;this.updateCamera(e?.offset(0,s,0)??null,i,n),this.media.tryIntersectMedia(),this.updateCameraSectionPos()}getThirdPersonCamera(e,i,n){e??(e=new Y.Vector3(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z));let s=this.playerStateReactive.perspective==="third_person_back",o=4,a=this._tpDirection.set(0,0,-1),v=this._tpPitchQuat.setFromAxisAngle(this._tpAxisX,n),l=this._tpYawQuat.setFromAxisAngle(this._tpAxisY,i),c=this._tpFinalQuat.multiplyQuaternions(l,v);a.applyQuaternion(c),s&&a.multiplyScalar(-1),this.DEBUG_RAYCAST&&this.debugRaycast(e,a,o);let d=this._tpScenePos.set(this.sceneOrigin.toSceneX(e.x),this.sceneOrigin.toSceneY(e.y),this.sceneOrigin.toSceneZ(e.z)),m=this._tpRaycaster;m.set(d,a),m.far=o;let p=Object.values(this.sectionObjects).filter(_=>_.name==="chunk"&&_.visible).filter(_=>{let C=_.children.find(H=>H.name==="mesh");if(!C)return!1;let M=this._tpChunkWorldPos;return C.getWorldPosition(M),d.distanceTo(M)<80}),g=[];for(let _ of p){let C=_.children.find(M=>M.name==="mesh");C&&g.push(C)}let y=m.intersectObjects(g,!1),E=o;return y.length>0&&(E=Math.max(.5,y[0].distance-.2)),new It(e.x+a.x*E,e.y+a.y*E,e.z+a.z*E)}debugRaycast(e,i,n){this.debugRaycastHelper&&(this.realScene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.realScene.remove(this.debugHitPoint),this.debugHitPoint=void 0);let s=new Y.Vector3(this.sceneOrigin.toSceneX(e.x),this.sceneOrigin.toSceneY(e.y),this.sceneOrigin.toSceneZ(e.z));this.debugRaycastHelper=new Y.ArrowHelper(i.clone().normalize(),s,n,16711680,n*.1,n*.05),this.realScene.add(this.debugRaycastHelper);let o=new Y.SphereGeometry(.2,8,8),a=new Y.MeshBasicMaterial({color:65280});this.debugHitPoint=new Y.Mesh(o,a),this.debugHitPoint.position.copy(s).add(i.clone().multiplyScalar(n)),this.realScene.add(this.debugHitPoint)}setCinimaticCamera(e,i,n){this.cameraWorldPos.x=e.x,this.cameraWorldPos.y=e.y,this.cameraWorldPos.z=e.z,this.sceneOrigin.update(e.x,e.y,e.z),this.cameraObject.position.set(0,0,0),this.cameraShake.setBaseRotation(n,i),this.updateCameraSectionPos()}setCinimaticFov(e){this.camera.fov=e,this.camera.updateProjectionMatrix()}updateCamera(e,i,n){if(!this.cinimaticScript.running){if(e){this.renderer.xr.isPresenting&&(e.y-=this.camera.position.y),this.currentPosTween?.stop();let s=this.displayOptions.inWorldRenderingConfig.instantCameraUpdate?0:this.playerStateUtils.isSpectatingEntity()?150:50;this.currentPosTween=new S0(this.cameraWorldPos).to({x:e.x,y:e.y,z:e.z},s).onUpdate(()=>{this.sceneOrigin.update(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),this.cameraObject.position.set(0,0,0)}).start()}if(this.playerStateUtils.isSpectatingEntity()){let s=this.cameraShake.getBaseRotation(),o=0,a=Math.PI/2;s.yaw<a&&i>Math.PI+a?o=-Math.PI*2:i<a&&s.yaw>Math.PI+a&&(o=Math.PI*2),this.currentRotTween?.stop(),this.currentRotTween=new S0(s).to({pitch:n,yaw:i+o},100).onUpdate(v=>this.cameraShake.setBaseRotation(v.pitch,v.yaw-o)).start()}else{this.currentRotTween?.stop(),this.cameraShake.setBaseRotation(n,i);let{perspective:s}=this.playerStateReactive;if(s==="third_person_back"||s==="third_person_front"){let o=new Y.Vector3(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),a=this.getThirdPersonCamera(o,i,n),v=o.distanceTo(new Y.Vector3(a.x,a.y,a.z)),l=s==="third_person_back"?v:-v;this.camera.position.set(0,0,l),s==="third_person_front"?this.camera.rotation.set(0,Math.PI,0):this.camera.rotation.set(0,0,0)}else this.camera.position.z=0,this.camera.rotation.set(0,0,0),this.debugRaycastHelper&&(this.realScene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.realScene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}this.updateCameraSectionPos()}}debugChunksVisibilityOverride(){let{chunksRenderAboveOverride:e,chunksRenderBelowOverride:i,chunksRenderDistanceOverride:n,chunksRenderAboveEnabled:s,chunksRenderBelowEnabled:o,chunksRenderDistanceEnabled:a}=this.reactiveDebugParams,v=this.getSectionHeight(),l=this.cameraSectionPos.y*v;if(this.displayOptions.inWorldRenderingConfig.enableDebugOverlay&&e!==void 0||i!==void 0||n!==void 0)for(let[c,d]of Object.entries(this.sectionObjects)){let[m,p,g]=c.split(",").map(Number),y=s&&e!==void 0?p<=l+e:o&&i!==void 0?p>=l-i:a&&n!==void 0?Math.abs(p-l)<=n:!0;d.visible=y}else for(let c of Object.values(this.sectionObjects))c.visible=!0}render(e=!1){if(this.currentRenderedFrames++,this.reactiveDebugParams.stopRendering)return;this.debugChunksVisibilityOverride();let i=performance.now();this.lastRendered=performance.now();let n=this.lastRenderTime>0?Math.min(Math.max((i-this.lastRenderTime)/1e3,0),.1):1/60;this.lastRenderTime=i,this.cursorBlock.render(),this.updateSectionOffsets();let s=this.getCameraPosition();if(this.skyboxRenderer.update(s,this.viewDistance),e||this.displayOptions.inWorldRenderingConfig.fov!==this.camera.fov){let c=this.renderer.getSize(new Y.Vector2);this.camera.aspect=c.width/c.height,this.camera.fov=this.displayOptions.inWorldRenderingConfig.fov,this.camera.updateProjectionMatrix()}this.reactiveDebugParams.disableEntities||this.entities.render();let a=this.cameraGroupVr instanceof Y.Group?this.cameraGroupVr.children.find(c=>c instanceof Y.PerspectiveCamera):this.camera;this.renderer.render(this.realScene,a),this.displayOptions.inWorldRenderingConfig.showHand&&this.playerStateReactive.gameMode!=="spectator"&&this.playerStateReactive.perspective==="first_person"&&!this.renderer.xr.isPresenting&&(this.holdingBlock.render(this.camera,this.renderer,this.ambientLight,this.directionalLight),this.holdingBlockLeft.render(this.camera,this.renderer,this.ambientLight,this.directionalLight));for(let c of this.fountains)this.sectionObjects[c.sectionId]&&!this.sectionObjects[c.sectionId].foutain&&(c.createParticles(this.sectionObjects[c.sectionId]),this.sectionObjects[c.sectionId].foutain=!0),c.render();this.waypoints.render(),this.fireworks.update();for(let c of this.onRender)c(n);let l=performance.now()-i;this.worldRendererConfig.autoLowerRenderDistance&&this.chunkMeshManager.recordRenderTime(l),this.renderTimeAvgCount++,this.renderTimeAvg=(this.renderTimeAvg*(this.renderTimeAvgCount-1)+l)/this.renderTimeAvgCount,this.renderTimeMax=Math.max(this.renderTimeMax,l)}renderHead(e,i,n,s){let o;if(s.SkullOwner?o=s.SkullOwner.Properties?.textures?.[0]?.Value:o=s.profile?.properties?.find(a=>a.name==="textures")?.value,!!o)try{let v=JSON.parse(L.from(o,"base64").toString()).textures?.SKIN?.url,{skinTexturesProxy:l}=this.worldRendererConfig;l&&(v=v?.replace("http://textures.minecraft.net/",l).replace("https://textures.minecraft.net/",l));let c=Mt(this,v,St.head),d=new Y.Group;return n&&c.position.set(0,.3125,.3125),c.position.y-=23/16,d.add(c),this.sceneOrigin.track(d),d.position.set(e.x+.5,e.y+.045,e.z+.5),d.rotation.set(0,-Y.MathUtils.degToRad(i*(n?90:45/2)),0),d.scale.set(.8,.8,.8),d}catch{}}renderSign(e,i,n,s,o){let a=this.getSignTexture(e,o,s);if(!a)return;let v=new Y.Mesh(new Y.PlaneGeometry(1,1),new Y.MeshBasicMaterial({map:a,transparent:!0}));v.renderOrder=999;let l=7/16,c=s?1.3:1;v.scale.set(1*c,l*c,1*c);let d=(s?2:1.5)/16,m=.25/16;n&&!s?v.position.set(0,0,-.5+d+m+1e-4):v.position.set(0,0,d/2+1e-4);let p=new Y.Group;p.rotation.set(0,-Y.MathUtils.degToRad(i*(n?90:45/2)),0),p.add(v);let g=(s?10:8)/16,y=(s?0:n?4.333:9.333)/16,E=g/2+y;return this.sceneOrigin.track(p),p.position.set(e.x+.5,e.y+E,e.z+.5),p}lightUpdate(e,i){for(let n=this.worldSizeParams.minY;n<this.worldSizeParams.worldHeight;n+=16)this.setSectionDirty(new It(e,n,i))}rerenderAllChunks(){for(let e of Object.keys(this.sectionObjects)){let[i,n,s]=e.split(",").map(Number);this.setSectionDirty(new It(i,n,s))}}updateShowChunksBorder(e){for(let i of Object.values(this.sectionObjects))for(let n of i.children)n.name==="helper"&&(n.visible=e)}resetWorld(){super.resetWorld(),this.chunkMeshManager.dispose(),this.chunkMeshManager=new f5(this,this.scene,this.material,this.worldSizeParams.worldHeight,this.viewDistance),this.debugRaycastHelper&&(this.realScene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.realScene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}getLoadedChunksRelative(e,i=!1){let[n,s,o]=H1(e);return Object.fromEntries(Object.entries(this.sectionObjects).map(([a,v])=>{let[l,c,d]=a.split(",").map(Number),[m,p,g]=H1({x:l,y:c,z:d});return[i?`${m-n},${p-s},${g-o}`:`${m-n},${g-o}`,v]}))}cleanChunkTextures(e,i){let n=this.chunkTextures.get(`${Math.floor(e/16)},${Math.floor(i/16)}`)??{};for(let s of Object.keys(n))n[s].dispose(),delete n[s]}readdChunks(){for(let e of Object.keys(this.sectionObjects))this.scene.remove(this.sectionObjects[e]);setTimeout(()=>{for(let e of Object.keys(this.sectionObjects))this.scene.add(this.sectionObjects[e])},500)}disableUpdates(e=this.scene.children){for(let i of e)i.matrixWorldNeedsUpdate=!1,this.disableUpdates(i.children??[])}removeColumn(e,i){super.removeColumn(e,i),this.cleanChunkTextures(e,i);let n=this.getSectionHeight(),s=this.worldMinYRender;for(let o=s;o<this.worldSizeParams.worldHeight;o+=n){let a=`${e},${o},${i}`;this.chunkMeshManager.sectionObjects[a]&&this.chunkMeshManager.releaseSection(a)}}setSectionDirty(...e){let[i]=e;this.cleanChunkTextures(i.x,i.z),super.setSectionDirty(...e)}static getRendererInfo(e){try{let i=e.getContext();return`${i.getParameter(i.getExtension("WEBGL_debug_renderer_info").UNMASKED_RENDERER_WEBGL)}`}catch{}}worldStop(){this.media.onWorldStop()}destroy(){this.chunkMeshManager.dispose(),this.disposeModules(),this.fireworksLegacy.destroy(),super.destroy(),this.skyboxRenderer.dispose(),this.fireworks.dispose()}shouldObjectVisible(e){let n=this.getSectionHeight(),s,o,a,v=this.sceneOrigin.getWorldPosition(e);v?(s=v.x,o=v.y,a=v.z):(s=this.sceneOrigin.toWorldX(e.position.x),o=this.sceneOrigin.toWorldY(e.position.y),a=this.sceneOrigin.toWorldZ(e.position.z));let l=Math.floor(s/16)*16,c=Math.floor(a/16)*16,d=Math.floor(o/n)*n,m=`${l},${c}`,p=`${l},${d},${c}`;return!!this.finishedChunks[m]||!!this.sectionObjects[p]}handleUserClick(e){this.media.handleUserClick(e)}updateSectionOffsets(){let e=performance.now();for(let[i,n]of Object.entries(this.sectionsOffsetsAnimations)){let s=(e-n.time)/1e3;n.time=e,n.currentOffsetX+=n.speedX*s,n.currentOffsetY+=n.speedY*s,n.currentOffsetZ+=n.speedZ*s,n.limitX!==void 0&&(n.speedX>0?n.currentOffsetX=Math.min(n.currentOffsetX,n.limitX):n.currentOffsetX=Math.max(n.currentOffsetX,n.limitX)),n.limitY!==void 0&&(n.speedY>0?n.currentOffsetY=Math.min(n.currentOffsetY,n.limitY):n.currentOffsetY=Math.max(n.currentOffsetY,n.limitY)),n.limitZ!==void 0&&(n.speedZ>0?n.currentOffsetZ=Math.min(n.currentOffsetZ,n.limitZ):n.currentOffsetZ=Math.max(n.currentOffsetZ,n.limitZ));let o=this.sectionObjects[i];o&&(o.position.set(n.currentOffsetX,n.currentOffsetY,n.currentOffsetZ),o.updateMatrix())}}reloadWorld(){this.entities.reloadEntities()}};x();R();T();k();x();R();T();k();x();R();T();k();x();R();T();k();function ri(r){throw new Error("Node.js process "+r+" is not supported by JSPM core outside of Node.js")}var _t=[],Te=!1,ne,A1=-1;function Z8(){!Te||!ne||(Te=!1,ne.length?_t=ne.concat(_t):A1=-1,_t.length&&ns())}function ns(){if(!Te){var r=setTimeout(Z8,0);Te=!0;for(var t=_t.length;t;){for(ne=_t,_t=[];++A1<t;)ne&&ne[A1].run();A1=-1,t=_t.length}ne=null,Te=!1,clearTimeout(r)}}function X8(r){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];_t.push(new rs(r,t)),_t.length===1&&!Te&&setTimeout(ns,0)}function rs(r,t){this.fun=r,this.array=t}rs.prototype.run=function(){this.fun.apply(null,this.array)};var $8="browser",t4="x64",e4="browser",i4={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},n4=["/usr/bin/node"],r4=[],s4="v16.8.0",o4={},a4=function(r,t){},v4=function(r){ri("binding")},l4=function(r){return 0},c4=function(){return"/"},d4=function(r){},u4={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function N0(){}var f4=N0,h4=[];function m4(r){ri("_linkedBinding")}var p4={},g4=!1,b4={};function y4(r){ri("dlopen")}function w4(){return[]}function _4(){return[]}var A4=N0,E4=N0,si=function(){return{}},x4=si,R4=si,k4=N0,T4=N0,M4=N0,S4={};function C4(r,t){if(!r)throw new Error(t||"assertion error")}var P4={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},B4=N0,I4=N0;function H4(){return!1}var z4=N0,O4=N0,D4=N0,L4=N0,F4=N0,U4=void 0,G4=void 0,W4=void 0,V4=N0,N4=2,j4=1,Y4="/bin/usr/node",Q4=9229,K4="node",J4=[],q4=N0,Ht={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};Ht.now===void 0&&(ei=Date.now(),Ht.timing&&Ht.timing.navigationStart&&(ei=Ht.timing.navigationStart),Ht.now=()=>Date.now()-ei);var ei;function Z4(){return Ht.now()/1e3}var ii=1e9;function ni(r){var t=Math.floor((Date.now()-Ht.now())*.001),e=Ht.now()*.001,i=Math.floor(e)+t,n=Math.floor(e%1*1e9);return r&&(i=i-r[0],n=n-r[1],n<0&&(i--,n+=ii)),[i,n]}ni.bigint=function(r){var t=ni(r);return typeof BigInt>"u"?t[0]*ii+t[1]:BigInt(t[0]*ii)+BigInt(t[1])};var X4=10,$4={},tv=0;function zt(){return oi}var ev=zt,iv=zt,nv=zt,rv=zt,sv=zt,ov=N0,av=zt,vv=zt;function lv(r){return[]}var oi={version:s4,versions:o4,arch:t4,platform:e4,release:u4,_rawDebug:f4,moduleLoadList:h4,binding:v4,_linkedBinding:m4,_events:$4,_eventsCount:tv,_maxListeners:X4,on:zt,addListener:ev,once:iv,off:nv,removeListener:rv,removeAllListeners:sv,emit:ov,prependListener:av,prependOnceListener:vv,listeners:lv,domain:p4,_exiting:g4,config:b4,dlopen:y4,uptime:Z4,_getActiveRequests:w4,_getActiveHandles:_4,reallyExit:A4,_kill:E4,cpuUsage:si,resourceUsage:x4,memoryUsage:R4,kill:k4,exit:T4,openStdin:M4,allowedNodeEnvironmentFlags:S4,assert:C4,features:P4,_fatalExceptions:B4,setUncaughtExceptionCaptureCallback:I4,hasUncaughtExceptionCaptureCallback:H4,emitWarning:a4,nextTick:X8,_tickCallback:z4,_debugProcess:O4,_debugEnd:D4,_startProfilerIdleNotifier:L4,_stopProfilerIdleNotifier:F4,stdout:U4,stdin:W4,stderr:G4,abort:V4,umask:l4,chdir:d4,cwd:c4,env:i4,title:$8,argv:n4,execArgv:r4,pid:N4,ppid:j4,execPath:Y4,debugPort:Q4,hrtime:ni,argv0:K4,_preload_modules:J4,setSourceMapsEnabled:q4};var ai={},ss=!1;function cv(){if(ss)return ai;ss=!0;var r=oi;function t(s){if(typeof s!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(s))}function e(s,o){for(var a="",v=0,l=-1,c=0,d,m=0;m<=s.length;++m){if(m<s.length)d=s.charCodeAt(m);else{if(d===47)break;d=47}if(d===47){if(!(l===m-1||c===1))if(l!==m-1&&c===2){if(a.length<2||v!==2||a.charCodeAt(a.length-1)!==46||a.charCodeAt(a.length-2)!==46){if(a.length>2){var p=a.lastIndexOf("/");if(p!==a.length-1){p===-1?(a="",v=0):(a=a.slice(0,p),v=a.length-1-a.lastIndexOf("/")),l=m,c=0;continue}}else if(a.length===2||a.length===1){a="",v=0,l=m,c=0;continue}}o&&(a.length>0?a+="/..":a="..",v=2)}else a.length>0?a+="/"+s.slice(l+1,m):a=s.slice(l+1,m),v=m-l-1;l=m,c=0}else d===46&&c!==-1?++c:c=-1}return a}function i(s,o){var a=o.dir||o.root,v=o.base||(o.name||"")+(o.ext||"");return a?a===o.root?a+v:a+s+v:v}var n={resolve:function(){for(var o="",a=!1,v,l=arguments.length-1;l>=-1&&!a;l--){var c;l>=0?c=arguments[l]:(v===void 0&&(v=r.cwd()),c=v),t(c),c.length!==0&&(o=c+"/"+o,a=c.charCodeAt(0)===47)}return o=e(o,!a),a?o.length>0?"/"+o:"/":o.length>0?o:"."},normalize:function(o){if(t(o),o.length===0)return".";var a=o.charCodeAt(0)===47,v=o.charCodeAt(o.length-1)===47;return o=e(o,!a),o.length===0&&!a&&(o="."),o.length>0&&v&&(o+="/"),a?"/"+o:o},isAbsolute:function(o){return t(o),o.length>0&&o.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var o,a=0;a<arguments.length;++a){var v=arguments[a];t(v),v.length>0&&(o===void 0?o=v:o+="/"+v)}return o===void 0?".":n.normalize(o)},relative:function(o,a){if(t(o),t(a),o===a||(o=n.resolve(o),a=n.resolve(a),o===a))return"";for(var v=1;v<o.length&&o.charCodeAt(v)===47;++v);for(var l=o.length,c=l-v,d=1;d<a.length&&a.charCodeAt(d)===47;++d);for(var m=a.length,p=m-d,g=c<p?c:p,y=-1,E=0;E<=g;++E){if(E===g){if(p>g){if(a.charCodeAt(d+E)===47)return a.slice(d+E+1);if(E===0)return a.slice(d+E)}else c>g&&(o.charCodeAt(v+E)===47?y=E:E===0&&(y=0));break}var w=o.charCodeAt(v+E),_=a.charCodeAt(d+E);if(w!==_)break;w===47&&(y=E)}var C="";for(E=v+y+1;E<=l;++E)(E===l||o.charCodeAt(E)===47)&&(C.length===0?C+="..":C+="/..");return C.length>0?C+a.slice(d+y):(d+=y,a.charCodeAt(d)===47&&++d,a.slice(d))},_makeLong:function(o){return o},dirname:function(o){if(t(o),o.length===0)return".";for(var a=o.charCodeAt(0),v=a===47,l=-1,c=!0,d=o.length-1;d>=1;--d)if(a=o.charCodeAt(d),a===47){if(!c){l=d;break}}else c=!1;return l===-1?v?"/":".":v&&l===1?"//":o.slice(0,l)},basename:function(o,a){if(a!==void 0&&typeof a!="string")throw new TypeError('"ext" argument must be a string');t(o);var v=0,l=-1,c=!0,d;if(a!==void 0&&a.length>0&&a.length<=o.length){if(a.length===o.length&&a===o)return"";var m=a.length-1,p=-1;for(d=o.length-1;d>=0;--d){var g=o.charCodeAt(d);if(g===47){if(!c){v=d+1;break}}else p===-1&&(c=!1,p=d+1),m>=0&&(g===a.charCodeAt(m)?--m===-1&&(l=d):(m=-1,l=p))}return v===l?l=p:l===-1&&(l=o.length),o.slice(v,l)}else{for(d=o.length-1;d>=0;--d)if(o.charCodeAt(d)===47){if(!c){v=d+1;break}}else l===-1&&(c=!1,l=d+1);return l===-1?"":o.slice(v,l)}},extname:function(o){t(o);for(var a=-1,v=0,l=-1,c=!0,d=0,m=o.length-1;m>=0;--m){var p=o.charCodeAt(m);if(p===47){if(!c){v=m+1;break}continue}l===-1&&(c=!1,l=m+1),p===46?a===-1?a=m:d!==1&&(d=1):a!==-1&&(d=-1)}return a===-1||l===-1||d===0||d===1&&a===l-1&&a===v+1?"":o.slice(a,l)},format:function(o){if(o===null||typeof o!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof o);return i("/",o)},parse:function(o){t(o);var a={root:"",dir:"",base:"",ext:"",name:""};if(o.length===0)return a;var v=o.charCodeAt(0),l=v===47,c;l?(a.root="/",c=1):c=0;for(var d=-1,m=0,p=-1,g=!0,y=o.length-1,E=0;y>=c;--y){if(v=o.charCodeAt(y),v===47){if(!g){m=y+1;break}continue}p===-1&&(g=!1,p=y+1),v===46?d===-1?d=y:E!==1&&(E=1):d!==-1&&(E=-1)}return d===-1||p===-1||E===0||E===1&&d===p-1&&d===m+1?p!==-1&&(m===0&&l?a.base=a.name=o.slice(1,p):a.base=a.name=o.slice(m,p)):(m===0&&l?(a.name=o.slice(1,d),a.base=o.slice(1,p)):(a.name=o.slice(m,d),a.base=o.slice(m,p)),a.ext=o.slice(d,p)),m>0?a.dir=o.slice(0,m-1):l&&(a.dir="/"),a},sep:"/",delimiter:":",win32:null,posix:null};return n.posix=n,ai=n,ai}var j0=cv();var rR=j0._makeLong,sR=j0.basename,oR=j0.delimiter,aR=j0.dirname,vR=j0.extname,lR=j0.format,cR=j0.isAbsolute,vi=j0.join,dR=j0.normalize,uR=j0.parse,fR=j0.posix,hR=j0.relative,mR=j0.resolve,pR=j0.sep,gR=j0.win32;import*as v0 from"three";x();R();T();k();import dv from"prismarine-world";import uv from"prismarine-chunk";var os=r=>{let t=dv(r),e=uv(r),i=new t(r).sync,n=fv(i);for(let s of n)if(s.startsWith("set")&&s!=="setColumn"){let o=i[s].bind(i);i[s]=(...a)=>{let v=a[0];v.x!==void 0&&!i.getColumnAt(v)&&i.setColumn(Math.floor(v.x/16),Math.floor(v.z/16),new e(void 0)),o(...a)}}return i};function fv(r){let t=new Set,e=r;do for(let i of Object.getOwnPropertyNames(e))typeof r[i]=="function"&&i!=="constructor"&&t.add(i);while(e=Object.getPrototypeOf(e));return[...t]}import{Vec3 as vs}from"vec3";x();R();T();k();var as="1.21.4";var li=new Date,ls=li.getMonth()===11&&li.getDate()>=24&&li.getDate()<=26,hv=["panorama_3.webp","panorama_1.webp","panorama_4.webp","panorama_5.webp","panorama_0.webp","panorama_2.webp"],E1=class{constructor(t,e,i=!1){this.documentRenderer=t;this.options=e;this.doWorldBlocksPanorama=i;f(this,"camera");f(this,"scene");f(this,"ambientLight");f(this,"directionalLight");f(this,"panoramaGroup",null);f(this,"time",0);f(this,"abortController",new AbortController);f(this,"worldRenderer");f(this,"WorldRendererClass",ie);f(this,"startTimes",new Map);this.scene=new v0.Scene,this.scene.background=new v0.Color(3294568),this.ambientLight=new v0.AmbientLight(13421772),this.scene.add(this.ambientLight),this.directionalLight=new v0.DirectionalLight(16777215,.5),this.directionalLight.position.set(1,1,.5).normalize(),this.directionalLight.castShadow=!0,this.scene.add(this.directionalLight),this.camera=new v0.PerspectiveCamera(85,this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,.05,1e3),this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0)}async start(){this.doWorldBlocksPanorama?await this.worldBlocksPanorama():this.addClassicPanorama(),this.documentRenderer.render=(t=!1)=>{t&&(this.camera.aspect=this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,this.camera.updateProjectionMatrix()),this.documentRenderer.renderer.render(this.scene,this.camera)}}async debugImageInFrontOfCamera(){let t=await Rt(vi("background","panorama_0.webp")),e=new v0.Mesh(new v0.PlaneGeometry(1e3,1e3),new v0.MeshBasicMaterial({map:t}));e.position.set(0,0,-500),e.rotation.set(0,0,0),this.scene.add(e)}addClassicPanorama(){let t=new v0.BoxGeometry(1e3,1e3,1e3),e=[],i=200;for(let o of hv)(async()=>{let{texture:v}=O5(vi("background",ls?"christmas":"",o));v.matrixAutoUpdate=!1,v.matrix.set(-1,0,1,0,1,0,0,0,1),v.wrapS=v0.ClampToEdgeWrapping,v.wrapT=v0.ClampToEdgeWrapping,v.minFilter=v0.LinearFilter,v.magFilter=v0.LinearFilter;let l=new v0.MeshBasicMaterial({map:v,transparent:!0,side:v0.DoubleSide,depthWrite:!1,opacity:0});this.startTimes.set(l,Date.now()),e.push(l)})();let n=new v0.Mesh(t,e);n.onBeforeRender=()=>{this.time+=.01,n.rotation.y=Math.PI+this.time*.01,n.rotation.z=Math.sin(-this.time*.001)*.001;for(let o of e){let a=this.startTimes.get(o);if(a){let v=Date.now()-a,l=Math.min(1,v/i);o.opacity=l}}};let s=new v0.Object3D;if(s.add(n),!ls)for(let o=0;o<20;o++){let a=new wt("1.16.4","squid").mesh;a.position.set(Math.random()*30-15,Math.random()*20-10,Math.random()*10-17),a.rotation.set(0,Math.PI+Math.random(),-Math.PI/4,"ZYX");let v=Math.random()*.01;a.children[0].onBeforeRender=()=>{a.rotation.y+=v,a.rotation.z=Math.cos(n.rotation.y*3)*Math.PI/4-Math.PI/2},s.add(a)}this.scene.add(s),this.panoramaGroup=s}async worldBlocksPanorama(){let t=as,e=new mt;if(e.currentConfig={version:t,noInventoryGui:!0},await e.updateAssetsData?.({}),this.abortController.signal.aborted)return;let i=os(t),s=ys("prismarine-block")(t),a=globalThis.mcData.blocksArray.filter(w=>{if(!w.name.includes("stained_glass"))return!1;let _=s.fromStateId(w.defaultState,0);if(_.shapes?.length!==1)return!1;let C=_.shapes[0];return C[0]===0&&C[1]===0&&C[2]===0&&C[3]===1&&C[4]===1&&C[5]===1}),v=-15,l=100,c=100;for(let w=-l;w<l;w++)for(let _=-c;_<c;_++){let C=a[Math.floor(Math.random()*a.length)];i.setBlockStateId(new vs(w,_,v),C.defaultState)}this.camera.updateProjectionMatrix(),this.camera.position.set(.5,c/2+.5,.5),this.camera.rotation.set(0,0,0);let d=new vs(...this.camera.position.toArray()),m=new jt(i,2,d);if(this.abortController.signal.aborted||(this.worldRenderer=new this.WorldRendererClass(this.documentRenderer.renderer,this.options,{version:t,worldView:m,inWorldRenderingConfig:Oe,playerStateReactive:Ln().reactive,rendererState:Gt().reactive,nonReactiveState:Gt().nonReactive,resourcesManager:e}),this.worldRenderer instanceof ie&&(this.scene=this.worldRenderer.realScene),m.init(d),await this.worldRenderer.waitForChunksToRender(),this.abortController.signal.aborted))return;let{camera:p}=this,g=p.position.x,y=p.position.y,E;document.body.addEventListener("pointermove",w=>{if(w.pointerType!=="mouse")return;let _=new v0.Vector2(w.clientX,w.clientY),C=.2,M=_.x/window.innerWidth-.5,S=-(_.y/window.innerHeight-.5);E?.stop();let H={x:g+M*C,y:y+S*C};E=new S0(p.position).to(H,0),E.start(),p.updateProjectionMatrix()},{signal:this.abortController.signal})}dispose(){this.scene.clear(),this.worldRenderer?.destroy(),this.abortController.abort()}};h5.ColorManagement.enabled=!1;globalThis.THREE=h5;var cs=r=>({updateMap:r.entities.updateMap.bind(r.entities),updateCustomBlock:r.updateCustomBlock.bind(r),getBlockInfo:r.getBlockInfo.bind(r),playEntityAnimation:r.entities.playAnimation.bind(r.entities),damageEntity:r.entities.handleDamageEvent.bind(r.entities),updatePlayerSkin:r.entities.updatePlayerSkin.bind(r.entities),changeHandSwingingState:r.changeHandSwingingState.bind(r),getHighestBlocks:r.getHighestBlocks.bind(r),reloadWorld:r.reloadWorld.bind(r),updateEntityModel:r.entities.updateEntityModel.bind(r.entities),playEntityModelAnimation:r.entities.playEntityModelAnimation.bind(r.entities),addMedia:r.media.addMedia.bind(r.media),destroyMedia:r.media.destroyMedia.bind(r.media),setControlMode:r.media.setControlMode.bind(r.media),setVideoPlaying:r.media.setVideoPlaying.bind(r.media),setVideoSeeking:r.media.setVideoSeeking.bind(r.media),setVideoVolume:r.media.setVideoVolume.bind(r.media),setVideoSpeed:r.media.setVideoSpeed.bind(r.media),handleUserClick:r.media.handleUserClick.bind(r.media),addSectionAnimation(t,e){r.sectionsOffsetsAnimations[t]=e},removeSectionAnimation(t){delete r.sectionsOffsetsAnimations[t]},shakeFromDamage:r.cameraShake.shakeFromDamage.bind(r.cameraShake),onPageInteraction:r.media.onPageInteraction.bind(r.media),downloadMesherLog:r.downloadMesherLog.bind(r),explodeFirework:r.fireworksLegacy.explode.bind(r.fireworksLegacy),explodeFireworkFacingCamera:r.fireworksLegacy.explodeFacingCamera.bind(r.fireworksLegacy),addWaypoint:r.waypoints.addWaypoint.bind(r.waypoints),removeWaypoint:r.waypoints.removeWaypoint.bind(r.waypoints),startCinimaticScript:r.cinimaticScript.startScript.bind(r.cinimaticScript),stopCinimaticScript:r.cinimaticScript.stopScript.bind(r.cinimaticScript),launchFirework:r.fireworks.launchFirework.bind(r.fireworks),setSkyboxImage:r.skyboxRenderer.setSkyboxImage.bind(r.skyboxRenderer),setRain:t=>r.toggleModule("rain",t),spawnBlockBreakParticles(t,e,i,n,s,o){r.getModule("blockBreakParticles")?.spawnBlockBreakParticles(t,e,i,n,s,o)},spawnBlockCrackParticle(t,e,i,n,s,o,a){r.getModule("blockBreakParticles")?.spawnCrackParticle(t,e,i,n,s,o,a)},async loadGeometryExport(t){let{applyWorldGeometryExport:e}=await Promise.resolve().then(()=>(N2(),D6));return e(r,t)}}),pv=[],x1=(r,...t)=>{for(let e of Object.values(globalThis.loadedMods??{}))try{e.threeJsBackendModule?.[r]?.(...t)}catch(i){let n=`[mod three.js] Error calling ${r} on ${e.name}: ${i}`;throw new Error(n)}},ds=()=>{let r,t=null,e=null,i=null,n=null,s=(c,d)=>{_0?r=M5(c,pv,globalThis):r=c,t=new Ne(r,d?.canvas),globalThis.renderer=t.renderer,globalThis.documentRenderer=t,globalThis.threeJsBackend=l,x1("default",l)},o=async()=>{if(!t)throw new Error("Document renderer not initialized");if(!i&&!e){let c={...r};e=new E1(t,c,!!D.env.SINGLE_FILE_BUILD_MODE),globalThis.panoramaRenderer=e,x1("panoramaCreated",e),await e.start(),x1("panoramaReady",e)}},a=async c=>{let m=_0?M5(c,[mt,Nt],globalThis):c;if(!t)throw new Error("Document renderer not initialized");t.nonReactiveState=m.nonReactiveState,globalThis.resourcesManager=m.resourcesManager,e&&(e.dispose(),e=null),i=new ie(t.renderer,r,m),await i.worldReadyPromise,n=new S5(m.nonReactiveState),globalThis.frameTimingCollector=n;let p=t.render;t.render=function(g){p.call(this,g),n?.markFrameStart(),m.inWorldRenderingConfig.paused||i?.render(g),n?.markFrameEnd(),n?.markFrameDisplay()},t.inWorldRenderingConfig=m.inWorldRenderingConfig,globalThis.world=i,x1("worldReady",i)},v=()=>{e&&(e.dispose(),e=null),t&&t.dispose(),i&&(i.destroy(),i=null)},l={id:"threejs",displayName:`three.js ${h5.REVISION}`,startPanorama:o,startWorld:a,disconnect:v,setRendering(c){t.setPaused(!c),i&&(i.renderingActive=c)},getDebugOverlay:()=>({get entitiesString(){return i?.entities.getDebugString()},get left(){return{"Geo Memory":i?.chunkMeshManager.getEstimatedMemoryUsage().total??"-"}}}),updateCamera(c,d,m){n?.markCameraUpdate(!c),i?.setFirstPersonCamera(c,d,m)},get soundSystem(){return i?.soundSystem},get backendMethods(){if(i)return cs(i)}};return{main:{init:s,backend:l},workerProxy(){return qn({init(c,d){s(c,{canvas:d})},updateSizeExternal(c,d,m){t?.updateSizeExternal(c,d,m)},startPanorama:o,startWorld:a,disconnect:v,setRendering:l.setRendering,updateCamera(c,d,m){let p=c?new mv(c.x,c.y,c.z):null;n?.markCameraUpdate(!p),l.updateCamera(p,d,m)},async callBackendMethod(c,...d){if(!i)throw new Error("World renderer not initialized");let p=cs(i)[c];if(!p)throw new Error(`Backend method ${String(c)} is unavailable`);return p(...d)}})}}};var R1=r=>{let{main:t}=ds();return t.init(r),t.backend};R1.id="threejs";R1.displayName="three.js Blocking";R1.description="Simple, old and stable main thread graphics backend providing balanced performance on top of WebGL2.";x();R();T();k();import*as us from"three";function gv(r){let t="threeWorker.js",e;if(D.env.SINGLE_FILE_BUILD){let i=document.getElementById("three-worker-code").textContent,n=new Blob([i],{type:"text/javascript"});e=new Worker(window.URL.createObjectURL(n))}else e=new Worker(t);return e.onmessage=({data:i})=>{r(i)},e.on&&e.on("message",i=>{e.onmessage({data:i})}),e}var k1=async r=>{let t=gv(()=>{}),e=Zn(t),i=F1();i.onSizeChanged((a,v)=>{e.updateSizeExternal(a,v,window.devicePixelRatio||1)});let n=T5(r,t);try{e.init(n,i.canvas)}catch(a){throw Ue(n),a}let s=new Proxy({},{get(a,v){if(typeof v=="string")return async(...l)=>e.callBackendMethod(v,...l)}});return{id:"threejs",displayName:`three.js ${us.REVISION}`,async startPanorama(){},async startWorld(a){let v={...We,items:"itemsArray",entities:"entitiesArray"};Z1([t],a.version,v,a.resourcesManager.currentResources.mcData),a.inWorldRenderingConfig.__syncToWorker=!0,a.playerStateReactive&&(a.playerStateReactive.__syncToWorker=!0),a.rendererState&&(a.rendererState.__syncFromWorker=!0),a.nonReactiveState&&(a.nonReactiveState.__syncFromWorker=!0),a.nonReactiveState.__syncFromWorkerInterval=200;let l=T5(a,t);try{await e.startWorld(structuredClone(l))}catch(d){throw Ue(l),d}e.updateSizeExternal(i.size.width,i.size.height,window.devicePixelRatio||1);let c=ue("fps");setInterval(()=>{let{fps:d,avgRenderTime:m,worstRenderTime:p}=a.nonReactiveState;c.updateText(`FPS: ${d.toFixed(0)} (${m.toFixed(0)}ms/${p.toFixed(0)}ms)`),a.nonReactiveState.fps=0},1e3)},disconnect(){i.destroy(),e.disconnect(),t.terminate()},setRendering(a){e.setRendering(a)},updateCamera(a,v,l){e.updateCamera(a?{x:a.x,y:a.y,z:a.z}:null,v,l)},soundSystem:void 0,backendMethods:s}};k1.id="threejs-off-thread";k1.displayName="three.js Multi-thread";k1.description=["Edge-cutting technology that uses a dedicated thread for graphics.","Slightly higher power and RAM usage.","More stable FPS (mid-range devices), but possible inputlag if TPS is low.","On low-end devices it might result in device throttling and stuttering."].join(" ");export{Vn as AppViewer,Ne as DocumentRenderer,ve as LoadedResourcesTransferrable,mt as ResourcesManager,jt as WorldView,Nt as WorldViewWorker,F1 as addCanvasForWorker,ae as chunkPos,k1 as createGraphicsBackendOffThread,R1 as createGraphicsBackendSingleThread,Kv as createWorldRendererConfig,On as defaultGraphicsBackendConfig,Oe as defaultWorldRendererConfig,Un as delayedIterator,Gt as getDefaultRendererState,Nn as getInitialPlayerState,Ws as getInitialPlayerStateRenderer,Gs as getPlayerStateUtils,_0 as isWebWorker,ks as sectionPos};
|
|
21237
21237
|
/*! Bundled license information:
|
|
21238
21238
|
|
|
21239
21239
|
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
|