sapdon 3.0.2 → 3.0.3

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.
Files changed (208) hide show
  1. package/dist/cli/build.d.ts +7 -0
  2. package/dist/cli/build.js +234 -0
  3. package/dist/cli/dev-server/client.d.ts +2 -0
  4. package/dist/cli/dev-server/client.js +21 -0
  5. package/dist/cli/dev-server/config.d.ts +3 -0
  6. package/dist/cli/dev-server/config.js +3 -0
  7. package/dist/cli/dev-server/handles.d.ts +4 -0
  8. package/dist/cli/dev-server/handles.js +5 -0
  9. package/dist/cli/dev-server/hmr.d.ts +1 -0
  10. package/dist/cli/dev-server/hmr.js +13 -0
  11. package/dist/cli/dev-server/index.d.ts +4 -0
  12. package/dist/cli/dev-server/index.js +17 -0
  13. package/dist/cli/dev-server/server.d.ts +14 -0
  14. package/dist/cli/dev-server/server.js +59 -0
  15. package/dist/cli/dev-server/syncFiles.d.ts +3 -0
  16. package/dist/cli/dev-server/syncFiles.js +37 -0
  17. package/dist/cli/index.d.ts +23 -0
  18. package/dist/cli/index.js +1 -0
  19. package/dist/cli/init.d.ts +9 -0
  20. package/dist/cli/init.js +80 -0
  21. package/dist/cli/load.d.ts +3 -0
  22. package/dist/cli/load.js +94 -0
  23. package/dist/cli/start.d.ts +2 -0
  24. package/dist/cli/start.js +2 -0
  25. package/dist/cli/tools/textureSet.d.ts +13 -0
  26. package/dist/cli/tools/textureSet.js +103 -0
  27. package/dist/cli/utils.d.ts +13 -0
  28. package/dist/cli/utils.js +89 -0
  29. package/dist/core/addon/biome.d.ts +22 -0
  30. package/dist/core/addon/biome.js +27 -0
  31. package/dist/core/addon/block/block.d.ts +41 -0
  32. package/dist/core/addon/block/block.js +46 -0
  33. package/dist/core/addon/controllers/animationController.d.ts +43 -0
  34. package/dist/core/addon/controllers/animationController.js +73 -0
  35. package/dist/core/addon/entity/clientEntity.d.ts +107 -0
  36. package/dist/core/addon/entity/clientEntity.js +149 -0
  37. package/dist/core/addon/entity/entity.d.ts +42 -0
  38. package/dist/core/addon/entity/entity.js +50 -0
  39. package/dist/core/addon/feature/oreFeature.d.ts +19 -0
  40. package/dist/core/addon/feature/oreFeature.js +24 -0
  41. package/dist/core/addon/featureRule.d.ts +20 -0
  42. package/dist/core/addon/featureRule.js +25 -0
  43. package/dist/core/addon/item/attachable.d.ts +94 -0
  44. package/dist/core/addon/item/attachable.js +134 -0
  45. package/dist/core/addon/item/item.d.ts +19 -0
  46. package/dist/core/addon/item/item.js +26 -0
  47. package/dist/core/addon/manifest.d.ts +49 -0
  48. package/dist/core/addon/manifest.js +65 -0
  49. package/dist/core/addon/menuCategory.d.ts +6 -0
  50. package/dist/core/addon/menuCategory.js +7 -0
  51. package/dist/core/addon/recipe/baseRecipe.d.ts +12 -0
  52. package/dist/core/addon/recipe/baseRecipe.js +23 -0
  53. package/dist/core/addon/recipe/data.d.ts +66 -0
  54. package/dist/core/addon/recipe/data.js +74 -0
  55. package/dist/core/addon/recipe/furnace.d.ts +17 -0
  56. package/dist/core/addon/recipe/furnace.js +43 -0
  57. package/dist/core/addon/recipe/shaped.d.ts +26 -0
  58. package/dist/core/addon/recipe/shaped.js +53 -0
  59. package/dist/core/addon/recipe/shapeless.d.ts +18 -0
  60. package/dist/core/addon/recipe/shapeless.js +36 -0
  61. package/dist/core/biome/biome.d.ts +14 -0
  62. package/dist/core/biome/biome.js +23 -0
  63. package/dist/core/biome/biomeComponent.d.ts +46 -0
  64. package/dist/core/biome/biomeComponent.js +77 -0
  65. package/dist/core/block/basicBlock.d.ts +48 -0
  66. package/dist/core/block/basicBlock.js +105 -0
  67. package/dist/core/block/block.d.ts +32 -0
  68. package/dist/core/block/block.js +92 -0
  69. package/dist/core/block/blockComponent.d.ts +187 -0
  70. package/dist/core/block/blockComponent.js +500 -0
  71. package/dist/core/block/cropBlock.d.ts +4 -0
  72. package/dist/core/block/cropBlock.js +27 -0
  73. package/dist/core/block/geometryBlock.d.ts +12 -0
  74. package/dist/core/block/geometryBlock.js +16 -0
  75. package/dist/core/block/oreBlock.d.ts +9 -0
  76. package/dist/core/block/oreBlock.js +25 -0
  77. package/dist/core/block/rotatableBlock.d.ts +27 -0
  78. package/dist/core/block/rotatableBlock.js +107 -0
  79. package/dist/core/block/tileBlock.d.ts +17 -0
  80. package/dist/core/block/tileBlock.js +125 -0
  81. package/dist/core/entity/basicEntity.d.ts +111 -0
  82. package/dist/core/entity/basicEntity.js +170 -0
  83. package/dist/core/entity/behavior/followMob.d.ts +12 -0
  84. package/dist/core/entity/behavior/followMob.js +35 -0
  85. package/dist/core/entity/behavior/followParent.d.ts +7 -0
  86. package/dist/core/entity/behavior/followParent.js +15 -0
  87. package/dist/core/entity/behavior/randomStroll.d.ts +31 -0
  88. package/dist/core/entity/behavior/randomStroll.js +63 -0
  89. package/dist/core/entity/behavior/tempt.d.ts +73 -0
  90. package/dist/core/entity/behavior/tempt.js +134 -0
  91. package/dist/core/entity/bundles/basicBundle.d.ts +13 -0
  92. package/dist/core/entity/bundles/basicBundle.js +45 -0
  93. package/dist/core/entity/clientEntity.d.ts +20 -0
  94. package/dist/core/entity/clientEntity.js +37 -0
  95. package/dist/core/entity/componets/entityComponet.d.ts +202 -0
  96. package/dist/core/entity/componets/entityComponet.js +347 -0
  97. package/dist/core/entity/data/nativeEntityData.d.ts +9 -0
  98. package/dist/core/entity/data/nativeEntityData.js +38 -0
  99. package/dist/core/entity/entity.d.ts +15 -0
  100. package/dist/core/entity/entity.js +18 -0
  101. package/dist/core/entity/nativeEntity.d.ts +8 -0
  102. package/dist/core/entity/nativeEntity.js +28 -0
  103. package/dist/core/entity/navigation/walk.d.ts +23 -0
  104. package/dist/core/entity/navigation/walk.js +56 -0
  105. package/dist/core/entity/projectile.d.ts +3 -0
  106. package/dist/core/entity/projectile.js +7 -0
  107. package/dist/core/factory/biomeFactory.d.ts +4 -0
  108. package/dist/core/factory/biomeFactory.js +13 -0
  109. package/dist/core/factory/blockFactory.d.ts +34 -0
  110. package/dist/core/factory/blockFactory.js +143 -0
  111. package/dist/core/factory/entityFactory.d.ts +17 -0
  112. package/dist/core/factory/entityFactory.js +75 -0
  113. package/dist/core/factory/featureFactory.d.ts +6 -0
  114. package/dist/core/factory/featureFactory.js +23 -0
  115. package/dist/core/factory/itemExtra.d.ts +8 -0
  116. package/dist/core/factory/itemExtra.js +9 -0
  117. package/dist/core/factory/itemFactory.d.ts +27 -0
  118. package/dist/core/factory/itemFactory.js +112 -0
  119. package/dist/core/factory/recipeFactory.d.ts +18 -0
  120. package/dist/core/factory/recipeFactory.js +39 -0
  121. package/dist/core/factory/uiFactory.d.ts +12 -0
  122. package/dist/core/factory/uiFactory.js +32 -0
  123. package/dist/core/feature/oreFeature.d.ts +10 -0
  124. package/dist/core/feature/oreFeature.js +11 -0
  125. package/dist/core/feature-rule/condition/biomeFilter.d.ts +26 -0
  126. package/dist/core/feature-rule/condition/biomeFilter.js +36 -0
  127. package/dist/core/feature-rule/condition/featureConditions.d.ts +27 -0
  128. package/dist/core/feature-rule/condition/featureConditions.js +37 -0
  129. package/dist/core/feature-rule/distribution/coordinateDistribution.d.ts +17 -0
  130. package/dist/core/feature-rule/distribution/coordinateDistribution.js +23 -0
  131. package/dist/core/feature-rule/distribution/featureDistribution.d.ts +31 -0
  132. package/dist/core/feature-rule/distribution/featureDistribution.js +41 -0
  133. package/dist/core/feature-rule/featureRule.d.ts +17 -0
  134. package/dist/core/feature-rule/featureRule.js +26 -0
  135. package/dist/core/index.d.ts +2062 -0
  136. package/dist/core/index.js +1 -0
  137. package/dist/core/item/armor.d.ts +21 -0
  138. package/dist/core/item/armor.js +90 -0
  139. package/dist/core/item/attachable.d.ts +6 -0
  140. package/dist/core/item/attachable.js +26 -0
  141. package/dist/core/item/food.d.ts +24 -0
  142. package/dist/core/item/food.js +38 -0
  143. package/dist/core/item/item.d.ts +36 -0
  144. package/dist/core/item/item.js +69 -0
  145. package/dist/core/item/itemComponents.d.ts +113 -0
  146. package/dist/core/item/itemComponents.js +225 -0
  147. package/dist/core/registry.d.ts +12 -0
  148. package/dist/core/registry.js +16 -0
  149. package/dist/core/texture.d.ts +18 -0
  150. package/dist/core/texture.js +38 -0
  151. package/dist/core/ui/buttonMapping.d.ts +97 -0
  152. package/dist/core/ui/buttonMapping.js +132 -0
  153. package/dist/core/ui/dataBindingObject.d.ts +97 -0
  154. package/dist/core/ui/dataBindingObject.js +134 -0
  155. package/dist/core/ui/elements/button.d.ts +21 -0
  156. package/dist/core/ui/elements/button.js +101 -0
  157. package/dist/core/ui/elements/collectionPanel.d.ts +12 -0
  158. package/dist/core/ui/elements/collectionPanel.js +53 -0
  159. package/dist/core/ui/elements/grid.d.ts +8 -0
  160. package/dist/core/ui/elements/grid.js +33 -0
  161. package/dist/core/ui/elements/image.d.ts +13 -0
  162. package/dist/core/ui/elements/image.js +55 -0
  163. package/dist/core/ui/elements/label.d.ts +14 -0
  164. package/dist/core/ui/elements/label.js +61 -0
  165. package/dist/core/ui/elements/panel.d.ts +11 -0
  166. package/dist/core/ui/elements/panel.js +49 -0
  167. package/dist/core/ui/elements/scrollingPanel.d.ts +14 -0
  168. package/dist/core/ui/elements/scrollingPanel.js +59 -0
  169. package/dist/core/ui/elements/stackPanel.d.ts +14 -0
  170. package/dist/core/ui/elements/stackPanel.js +37 -0
  171. package/dist/core/ui/elements/uiElement.d.ts +53 -0
  172. package/dist/core/ui/elements/uiElement.js +129 -0
  173. package/dist/core/ui/properties/control.d.ts +214 -0
  174. package/dist/core/ui/properties/control.js +286 -0
  175. package/dist/core/ui/properties/dataBinding.d.ts +6 -0
  176. package/dist/core/ui/properties/dataBinding.js +16 -0
  177. package/dist/core/ui/properties/factory.d.ts +37 -0
  178. package/dist/core/ui/properties/factory.js +62 -0
  179. package/dist/core/ui/properties/gridProp.d.ts +65 -0
  180. package/dist/core/ui/properties/gridProp.js +90 -0
  181. package/dist/core/ui/properties/input.d.ts +97 -0
  182. package/dist/core/ui/properties/input.js +134 -0
  183. package/dist/core/ui/properties/layout.d.ts +105 -0
  184. package/dist/core/ui/properties/layout.js +145 -0
  185. package/dist/core/ui/properties/scrollView.d.ts +105 -0
  186. package/dist/core/ui/properties/scrollView.js +145 -0
  187. package/dist/core/ui/properties/sound.d.ts +47 -0
  188. package/dist/core/ui/properties/sound.js +66 -0
  189. package/dist/core/ui/properties/sprite.d.ts +161 -0
  190. package/dist/core/ui/properties/sprite.js +222 -0
  191. package/dist/core/ui/properties/text.d.ts +135 -0
  192. package/dist/core/ui/properties/text.js +187 -0
  193. package/dist/core/ui/registry/uiSystemRegistry.d.ts +8 -0
  194. package/dist/core/ui/registry/uiSystemRegistry.js +26 -0
  195. package/dist/core/ui/systems/chest.d.ts +5 -0
  196. package/dist/core/ui/systems/chest.js +21 -0
  197. package/dist/core/ui/systems/containerUISystem.d.ts +67 -0
  198. package/dist/core/ui/systems/containerUISystem.js +214 -0
  199. package/dist/core/ui/systems/guidebook.d.ts +9 -0
  200. package/dist/core/ui/systems/guidebook.js +206 -0
  201. package/dist/core/ui/systems/serverForm.d.ts +13 -0
  202. package/dist/core/ui/systems/serverForm.js +116 -0
  203. package/dist/core/ui/systems/system.d.ts +16 -0
  204. package/dist/core/ui/systems/system.js +37 -0
  205. package/dist/oc/index.d.ts +142 -0
  206. package/dist/oc/index.js +1 -0
  207. package/doc/sapdon-ts.md +35 -1
  208. package/package.json +6 -8
@@ -0,0 +1 @@
1
+ import t from"fs";import e from"path";import{fileURLToPath as i}from"url";class r{static setTick(t,e){return(new Map).set("minecraft:tick",{interval_range:t,looping:e})}static setCustomComponents(t){return(new Map).set("minecraft:custom_components",[...t])}static setTransformation(t=[0,0,0],e=[1,1,1],i=[0,0,0],r=[0,0,0],s=[0,0,0]){const n=(t,e)=>{if(!Array.isArray(t)||3!==t.length||!t.every((t=>"number"==typeof t&&!isNaN(t))))throw new Error(`${e} 必须是一个包含 3 个有效数字的数组`)};n(t,"translation"),n(e,"scale"),n(i,"scale_pivot"),n(r,"rotation"),n(s,"rotation_pivot");const o={translation:t,scale:e,scale_pivot:i,rotation:r,rotation_pivot:s},a=new Map;return a.set("minecraft:transformation",o),a}static setBreathability(t){if("solid"!==t&&"air"!==t)throw new Error('breathability must be either "solid" or "air"');return(new Map).set("minecraft:breathability",t)}static setCollisionBoxEnabled(t){if("boolean"!=typeof t)throw new Error("enabled must be a boolean");return(new Map).set("minecraft:collision_box",t)}static setCollisionBoxCustom(t,e){if(!Array.isArray(t)||3!==t.length)throw new Error("origin must be an array of 3 numbers");if(!Array.isArray(e)||3!==e.length)throw new Error("size must be an array of 3 numbers");const[i,r,s]=t,[n,o,a]=e;if(i<-8||i>8||r<0||r>16||s<-8||s>8)throw new Error("origin must be in the range (-8, 0, -8) to (8, 16, 8)");if(i+n<-8||i+n>8||r+o<0||r+o>16||s+a<-8||s+a>8)throw new Error("origin + size must be in the range (-8, 0, -8) to (8, 16, 8)");return(new Map).set("minecraft:collision_box",{origin:t,size:e})}static setCraftingTable(t,e){if(!Array.isArray(t)||t.length>64)throw new Error("craftingTags must be an array with a maximum of 64 tags");for(const e of t)if("string"!=typeof e||e.length>64)throw new Error("each crafting tag must be a string with a maximum of 64 characters");if(e&&"string"!=typeof e)throw new Error("tableName must be a string");return(new Map).set("minecraft:crafting_table",{crafting_tags:t,table_name:e})}static setDestructibleByExplosionEnabled(t){if("boolean"!=typeof t)throw new Error("enabled must be a boolean");return(new Map).set("minecraft:destructible_by_explosion",t)}static setDestructibleByExplosionCustom(t){if("number"!=typeof t)throw new Error("explosionResistance must be a number");return(new Map).set("minecraft:destructible_by_explosion",{explosion_resistance:t})}static setDestructibleByMiningEnabled(t){if("boolean"!=typeof t)throw new Error("enabled must be a boolean");return(new Map).set("minecraft:destructible_by_mining",t)}static setDestructibleByMiningCustom(t,e){if("number"!=typeof t)throw new Error("secondsToDestroy must be a number");if(e&&Array.isArray(e))for(const t of e){if("number"!=typeof t.destroy_speed)throw new Error("destroy_speed must be a number");if(!t.item)throw new Error("item is required in item_specific_speeds")}return(new Map).set("minecraft:destructible_by_mining",{seconds_to_destroy:t,item_specific_speeds:e})}static setDisplayName(t){if("string"!=typeof t)throw new Error("displayName must be a string");return(new Map).set("minecraft:display_name",t)}static setFlammableEnabled(t){if("boolean"!=typeof t)throw new Error("enabled must be a boolean");return(new Map).set("minecraft:flammable",t)}static setFlammableCustom(t,e){if("number"!=typeof t||t<0)throw new Error("catchChanceModifier must be a number greater than or equal to 0");if("number"!=typeof e||e<0)throw new Error("destroyChanceModifier must be a number greater than or equal to 0");return(new Map).set("minecraft:flammable",{catch_chance_modifier:t,destroy_chance_modifier:e})}static setFriction(t){if("number"!=typeof t||t<0||t>.9)throw new Error("friction must be a number between 0.0 and 0.9");return(new Map).set("minecraft:friction",t)}static setGeometry(t,e){if("string"!=typeof t)throw new Error("identifier must be a string");return(new Map).set("minecraft:geometry",{identifier:t,bone_visibility:e})}static setItemVisual(t,e){if("string"!=typeof t)throw new Error("geometry must be a string");if(!e||"object"!=typeof e)throw new Error("materialInstances must be an object");return(new Map).set("minecraft:item_visual",{geometry:t,material_instances:e})}static setLightDampening(t){if("number"!=typeof t||t<0||t>15)throw new Error("lightDampening must be a number between 0 and 15");return(new Map).set("minecraft:light_dampening",t)}static setLightEmission(t){if("number"!=typeof t||t<0||t>15)throw new Error("lightEmission must be a number between 0 and 15");return(new Map).set("minecraft:light_emission",t)}static setLiquidDetection(t,e,i,r){if("boolean"!=typeof t)throw new Error("canContainLiquid must be a boolean");if(e&&"water"!==e)throw new Error('liquidType must be "water"');if(i&&!["blocking","broken","popped","no_reaction"].includes(i))throw new Error('onLiquidTouches must be one of: "blocking", "broken", "popped", "no_reaction"');const s=["up","down","north","south","east","west"];if(r&&Array.isArray(r))for(const t of r)if(!s.includes(t))throw new Error('stopsLiquidFlowingFromDirection must be one of: "up", "down", "north", "south", "east", "west"');return(new Map).set("minecraft:liquid_detection",{can_contain_liquid:t,liquid_type:e,on_liquid_touches:i,stops_liquid_flowing_from_direction:r})}static setLoot(t){if("string"!=typeof t||t.length>256)throw new Error("path must be a string with a maximum length of 256 characters");return(new Map).set("minecraft:loot",t)}static setMapColor(t){if("string"==typeof t){if(!/^#[0-9A-Fa-f]{6}$/.test(t))throw new Error('mapColor must be a valid hex string (e.g., "#FFFFFF")')}else{if(!Array.isArray(t))throw new Error("mapColor must be a hex string or an RGB array");if(3!==t.length||t.some((t=>"number"!=typeof t||t<0||t>255)))throw new Error("mapColor must be a valid RGB array (e.g., [255, 255, 255])")}return(new Map).set("minecraft:map_color",t)}static setMaterialInstances(t){if(!t||"object"!=typeof t)throw new Error("instances must be an object");if(!t["*"])throw new Error('material_instances must include a "*" material instance');for(const[e,i]of Object.entries(t))if("object"==typeof i){if(!i.texture||"string"!=typeof i.texture)throw new Error(`material instance "${e}" must have a texture`);if(void 0!==i.ambient_occlusion&&"boolean"!=typeof i.ambient_occlusion&&"number"!=typeof i.ambient_occlusion)throw new Error(`ambient_occlusion in material instance "${e}" must be a boolean or number`);if(void 0!==i.face_dimming&&"boolean"!=typeof i.face_dimming)throw new Error(`face_dimming in material instance "${e}" must be a boolean`);if(i.render_method&&!["opaque","double_sided","blend","alpha_test","alpha_test_single_sided"].includes(i.render_method))throw new Error(`render_method in material instance "${e}" must be one of: opaque, double_sided, blend, alpha_test, alpha_test_single_sided`)}else if("string"!=typeof i)throw new Error(`material instance "${e}" must be an object or a string`);return(new Map).set("minecraft:material_instances",t)}static setPlacementFilter(t){if(!Array.isArray(t)||0===t.length||t.length>64)throw new Error("conditions must be an array with 1 to 64 elements");for(const e of t){if(e.allowed_faces&&Array.isArray(e.allowed_faces)){const t=["up","down","north","south","east","west","side","all"];for(const i of e.allowed_faces)if(!t.includes(i))throw new Error(`allowed_faces must be one of: ${t.join(", ")}`)}if(e.block_filter&&Array.isArray(e.block_filter))for(const t of e.block_filter)if("string"!=typeof t){if("object"!=typeof t||null===t)throw new Error("block_filter must be a string or a BlockDescriptor object");if(t.tags&&"string"!=typeof t.tags)throw new Error("tags in block_filter must be a string");if(t.name&&"string"!=typeof t.name)throw new Error("name in block_filter must be a string");if(t.states&&"object"!=typeof t.states)throw new Error("states in block_filter must be an object")}if(!e.allowed_faces&&!e.block_filter)throw new Error("each condition must have at least one of allowed_faces or block_filter")}return(new Map).set("minecraft:placement_filter",{conditions:t})}static setRedstoneConductivity(t,e){if("boolean"!=typeof t)throw new Error("allowsWireToStepDown must be a boolean");if("boolean"!=typeof e)throw new Error("redstoneConductor must be a boolean");return(new Map).set("minecraft:redstone_conductivity",{allows_wire_to_step_down:t,redstone_conductor:e})}static setSelectionBoxEnabled(t){if("boolean"!=typeof t)throw new Error("enabled must be a boolean");return(new Map).set("minecraft:selection_box",t)}static setSelectionBoxCustom(t,e){if(!Array.isArray(t)||3!==t.length)throw new Error("origin must be an array of 3 numbers");if(!Array.isArray(e)||3!==e.length)throw new Error("size must be an array of 3 numbers");const[i,r,s]=t,[n,o,a]=e;if(i<-8||i>8||r<0||r>16||s<-8||s>8)throw new Error("origin must be in the range (-8, 0, -8) to (8, 16, 8)");if(i+n<-8||i+n>8||r+o<0||r+o>16||s+a<-8||s+a>8)throw new Error("origin + size must be in the range (-8, 0, -8) to (8, 16, 8)");return(new Map).set("minecraft:selection_box",{origin:t,size:e})}static combineComponents(...t){return new Map(t.flatMap((t=>[...t])))}static toJSON(t){return Object.fromEntries(t)}}class s{constructor(t,e,i){this.category=t,this.group=e,this.is_hidden_in_commands=i}}class n{constructor(t,e){this.format_version=t,this.definitions=e}toJson(){return{format_version:this.format_version,"minecraft:block":this.definitions}}}class o{constructor(t,e,i=[]){this.description=t,this.components=e,this.permutations=i}}class a{constructor(t,e,i,r){this.identifier=t,this.traits=e,this.states=i,this.menu_category=r}}class c{constructor(t,e,i,r={}){if(!t||"string"!=typeof t)throw new Error("identifier is required and must be a string");if(!e||"string"!=typeof e)throw new Error("category is required and must be a string");if(!Array.isArray(i))throw new Error("textures_arr must be an array ");if(6!==i.length)for(let t=i.length;t<6;t++)i.push(i[0]);const{hide_in_command:s=!1}=r;this.identifier=t,this.category=e,this.textures=i,this.group=r.group,this.hide_in_command=s,this.traits=new Map,this.states=new Map,this.components=new Map,this.permutations=[]}getId(){return this.identifier}registerTrait(t,e){return this.traits.set(t,e),this}registerState(t,e){return this.states.set(t,e),this}addComponent(t){if(!(t&&t instanceof Map))throw new Error("componentMap is required and must be a Map");for(const[e,i]of t.entries())this.components.set(e,i);return this}removeComponent(t){if(!t||"string"!=typeof t)throw new Error("key is required and must be a string");return this.components.delete(t),this}addPermutation(t,e){if(!t||"string"!=typeof t)throw new Error("condition is required and must be a string");if(!(e&&e instanceof Map))throw new Error("componentMap is required and must be a Map");return this.permutations.push({condition:t,components:Object.fromEntries(e)}),this}toJson(){return new n("1.21.50",new o(new a(this.identifier,Object.fromEntries(this.traits),Object.fromEntries(this.states),new s(this.category,this.group,this.hide_in_command)),Object.fromEntries(this.components),this.permutations)).toJson()}}class h extends c{constructor(t,e,i,r={}){if(console.log("options:",r),!Array.isArray(i)||0===i.length)throw new Error("variantDatas 必须是一个非空数组");super(t,e,i[0].textures,r),this.options=r,this.variantDatas=i,this.#t()}#t(){this.registerState("sapdon:block_variant_tag",{values:{min:0,max:this.variantDatas.length>1?this.variantDatas.length-1:1}}),this.variantDatas.forEach(((t,e)=>{const i=this.#e(t.textures,this.options),s=`q.block_state('sapdon:block_variant_tag') == ${e}`;this.addPermutation(s,r.setMaterialInstances(i))}))}#e(t){const e={},i=["*","up","down","north","south","east","west"];return t.forEach(((t,r)=>{e[i[r]]={texture:t,ambient_occlusion:this.options.ambient_occlusion||!0,face_dimming:this.options.face_dimming||!0,render_method:this.options.render_method||"alpha_test"}})),e}addVariantComponent(t,e){if(t<0||t>=this.variantDatas.length)throw new Error("variantIndex 必须在 0 到 variantDatas.length-1 之间");const i=`q.block_state('sapdon:block_variant_tag') == ${t}`;return this.addPermutation(i,e),this}}class u extends h{constructor(t,e,i,s={}){super(t,e,i,s),this.stageNum=i.length,this.addComponent(r.combineComponents(r.setCollisionBoxEnabled(!1),r.setGeometry("geometry.crop"),r.setLightEmission(0),r.setPlacementFilter([{allowed_faces:["up"],block_filter:["minecraft:farmland"]}])));for(let t=0;t<this.stageNum;t++)this.addVariantComponent(t,r.setSelectionBoxCustom([-8,0,-8],[16,(t+1)*this.stageNum/16,16]))}}class l extends c{constructor(t,e,i,s,n={}){super(t,e,[s["*"].texture],n),this.addComponent(r.combineComponents(r.setGeometry(i),r.setMaterialInstances(s)))}}class d{constructor(t,e){this.format_version=t,this.definition=e}toJson(){return{format_version:this.format_version,"minecraft:ore_feature":this.definition}}}class m{constructor(t){this.identifier=t}}class p{constructor(t,e,i){this.description=t,this.count=e,this.replace_rules=i}}class f{constructor(t,e,i){this.identifier=t,this.count=e,this.replace_rules=i}toJson(){return new d("1.17.0",new p(new m(this.identifier),this.count,this.replace_rules)).toJson()}}class _{constructor(){this.filters=[]}addLogicGroup(t,e){return this.filters.push({[t]:e}),this}addSimpleCondition(t,e,i){return this.filters.push({test:t,operator:e,value:i}),this}toJson(){return this.filters}}class w{constructor(t="uniform",e=[0,16]){this.distribution=t,this.extent=e}toJson(){return{distribution:this.distribution,extent:this.extent}}}class b{constructor(t,e){this.format_version=t,this.denifition=e}toJson(){return{format_version:this.format_version,"minecraft:feature_rules":this.denifition}}}class g{constructor(t,e,i){this.description=t,this.conditions=e,this.distribution=i}}class y{constructor(t,e){this.identifier=t,this.places_feature=e}}class x{constructor(){this.conditions={placement_pass:"underground_pass","minecraft:biome_filter":[]}}setPlacementPass(t){return this.conditions.placement_pass=t,this}setBiomeFilter(t){return this.conditions["minecraft:biome_filter"]=t.toJson(),this}toJson(){return this.conditions}}class E{constructor(){this.distribution={iterations:10,coordinate_eval_order:"zyx",x:(new w).toJson(),y:(new w).toJson(),z:(new w).toJson()}}setIterations(t){return this.distribution.iterations=t,this}setAxisDistribution(t,e){return this.distribution[t]=e.toJson(),this}toJson(){return this.distribution}}class v{constructor(t,e){this.identifier=t,this.places_feature=e,this.condition=new x,this.distribution=new E}setPlacementPass(t){this.condition.setPlacementPass(t)}setBiomeFilter(t){this.condition.setBiomeFilter(t)}setIterations(t){this.distribution.setIterations(t)}setAxisDistribution(t,e){this.distribution.setAxisDistribution(t,e)}toJson(){return new b("1.13.0",new g(new y(this.identifier,this.places_feature),this.condition.toJson(),this.distribution.toJson())).toJson()}}class C{constructor(t,e,i,r={}){this.block=new c(t,e,i,r),this.feature=new f(`${t}_ore_feature`,6,[{places_block:t,may_replace:["minecraft:stone"]}]),this.feature_rules=new v(`${t}_orefeatre_rule`,`${t}_ore_feature`),this.feature_rules.condition.setPlacementPass("underground_pass").setBiomeFilter((new _).addLogicGroup("any_of",[{test:"has_biome_tag",operator:"==",value:"overworld"},{test:"has_biome_tag",operator:"==",value:"overworld_generation"}])),this.feature_rules.distribution.setIterations(10).setAxisDistribution("x",new w("uniform",[0,16])).setAxisDistribution("y",new w("uniform",[0,64])).setAxisDistribution("z",new w("uniform",[0,16]))}}const k={CARDINAL:"cardinal",FACING:"facing",BLOCK_FACE:"block_face",LOG:"log"};class M extends c{constructor(t,e,i,r={}){super(t,e,i,r);const{rotationType:s=k.CARDINAL,yRotationOffset:n=180}=r;this.#i(s,n)}#i(t,e){switch(t){case k.CARDINAL:this.registerTrait("minecraft:placement_direction",{enabled_states:["minecraft:cardinal_direction"],y_rotation_offset:e}),this.#r();break;case k.FACING:this.registerTrait("minecraft:placement_direction",{enabled_states:["minecraft:facing_direction"]}),this.#s();break;case k.BLOCK_FACE:this.registerTrait("minecraft:placement_position",{enabled_states:["minecraft:block_face"]}),this.#n();break;case k.LOG:this.registerTrait("minecraft:placement_position",{enabled_states:["minecraft:block_face"]}),this.#o();break;default:throw new Error(`Unknown rotation type: ${t}`)}}#r(){this.addPermutation("q.block_state('minecraft:cardinal_direction') == 'north'",r.setTransformation([0,0,0],[1,1,1],[0,0,0],[0,0,0])).addPermutation("q.block_state('minecraft:cardinal_direction') == 'south'",r.setTransformation([0,0,0],[1,1,1],[0,0,0],[0,90,0])).addPermutation("q.block_state('minecraft:cardinal_direction') == 'east'",r.setTransformation([0,0,0],[1,1,1],[0,0,0],[0,180,0])).addPermutation("q.block_state('minecraft:cardinal_direction') == 'west'",r.setTransformation([0,0,0],[1,1,1],[0,0,0],[0,-90,0]))}#s(){this.addPermutation("q.block_state('minecraft:facing_direction') == 'down'",r.setTransformation([0,0,0],[1,1,1],[0,0,0],[-90,0,0])).addPermutation("q.block_state('minecraft:facing_direction') == 'up'",r.setTransformation([0,0,0],[1,1,1],[0,0,0],[90,0,0])).addPermutation("q.block_state('minecraft:facing_direction') == 'north'",r.setTransformation([0,0,0],[1,1,1],[0,0,0],[0,0,0])).addPermutation("q.block_state('minecraft:facing_direction') == 'west'",r.setTransformation([0,0,0],[1,1,1],[0,0,0],[0,90,0])).addPermutation("q.block_state('minecraft:facing_direction') == 'south'",r.setTransformation([0,0,0],[1,1,1],[0,0,0],[0,180,0])).addPermutation("q.block_state('minecraft:facing_direction') == 'east'",r.setTransformation([0,0,0],[1,1,1],[0,0,0],[0,-90,0]))}#n(){this.addPermutation("q.block_state('minecraft:block_face') == 'down'",r.setTransformation([0,0,0],[1,1,1],[-90,0,0],[0,0,0])).addPermutation("q.block_state('minecraft:block_face') == 'up'",r.setTransformation([0,0,0],[1,1,1],[90,0,0],[0,0,0])).addPermutation("q.block_state('minecraft:block_face') == 'north'",r.setTransformation([0,0,0],[1,1,1],[0,0,0],[0,0,0])).addPermutation("q.block_state('minecraft:block_face') == 'south'",r.setTransformation([0,0,0],[1,1,1],[0,180,0],[0,90,0])).addPermutation("q.block_state('minecraft:block_face') == 'east'",r.setTransformation([0,0,0],[1,1,1],[0,90,0],[0,180,0])).addPermutation("q.block_state('minecraft:block_face') == 'west'",r.setTransformation([0,0,0],[1,1,1],[0,-90,0],[0,-90,0]))}#o(){this.addPermutation("q.block_state('minecraft:block_face') == 'west' || q.block_state('minecraft:block_face') == 'east'",r.setTransformation([0,0,0],[1,1,1],[0,0,90],[0,0,0])).addPermutation("q.block_state('minecraft:block_face') == 'down' || q.block_state('minecraft:block_face') == 'up'",r.setTransformation([0,0,0],[1,1,1],[0,0,0],[0,0,0])).addPermutation("q.block_state('minecraft:block_face') == 'north' || q.block_state('minecraft:block_face') == 'south'",r.setTransformation([0,0,0],[1,1,1],[90,0,0],[0,0,0]))}}class P{static dataList=[];static register(t,e,i,r){P.dataList.push({name:t,root:e,path:i,data:r})}static getDataList(){return[...P.dataList]}}const B=t=>{if(!t||!t.identifier)throw new Error("无效的方块对象或缺少 identifier。");const e=t.identifier.replace(":","_");P.register(e,"behavior","blocks/",t)},T={createBasicBlock:function(t,e,i,r={}){if(!t||!e||!i)throw new Error("必须提供 identifier、category 和长度为 6 的 textures_arr。");const s=new c(t,e,i,{hide_in_command:!1,...r});return B(s),s},createBlock:function(t,e,i,r={}){if(!t||!e||!i||0===i.length)throw new Error("必须提供 identifier、category 和 variantDatas。");const s=new h(t,e,i,{hide_in_command:!1,ambient_occlusion:!1,face_dimming:!1,render_method:"alpha_test",...r});return B(s),s},createRotatableBlock:function(t,e,i,r={}){if(!t||!e||!i)throw new Error("必须提供 identifier、category 和 textures_arr。");const s=new M(t,e,i,{hide_in_command:!1,rotationType:"cardinal",yRotationOffset:180,...r});return B(s),s},createGeometryBlock:function(t,e,i,r,s={}){if(!(t&&e&&i&&r))throw new Error("必须提供 identifier、category、geometry 和 material_instances。");const n=new l(t,e,i,r,s);return B(n),n},createOreBlock(t,e,i,r={}){const s=new C(t,e,i,r);return B(s.block),(t=>{const e=t.identifier.split(":")[t.identifier.split(":").length-1];P.register(e,"behavior","features/",t)})(s.feature),(t=>{const e=t.identifier.split(":")[t.identifier.split(":").length-1];P.register(e,"behavior","feature_rules/",t)})(s.feature_rules),s},createCropBlock:function(t,e,i,r={}){if(!t||!e||!i||0===i.length)throw new Error("必须提供 identifier、category 和 variantDatas。");const s=new u(t,e,i,{hide_in_command:!1,ambient_occlusion:!0,face_dimming:!0,render_method:"alpha_test",...r});return B(s),s}};class S{constructor(t,e){this.format_version=t,this.definitions=e}toJson(){return{format_version:this.format_version,"minecraft:entity":this.definitions}}}class A{constructor(t,e={},i={},r={}){this.description=t,this.components=e,this.component_groups=i,this.events=r}}class O{constructor(t,e=!1,i=!1,r={},s){this.identifier=t,this.is_spawnable=e,this.is_summonable=i,this.properties=r,this.runtime_identifier=s}}class D{constructor(t,e={},i={}){if("string"!=typeof t||!t)throw new Error("identifier must be a non-empty string.");if(e.runtime_identifier&&"string"!=typeof e.runtime_identifier)throw new Error("runtime_identifier must be a string.");this.identifier=t,this.is_spawnable=e.is_spawnable??!0,this.is_summonable=e.is_summonable??!0,this.runtime_identifier=e.runtime_identifier,this.properties=new Map(Object.entries(i.description&&i.description.properties||{})),this.components=new Map(Object.entries(i.components||{})),this.component_groups=new Map(Object.entries(i.component_groups||{})),this.events=new Map(Object.entries(i.events||{}))}addProperty(t,e){return this.properties.set(t,e),this}removeProperty(t){return this.properties.delete(t),this}clearProperties(){return this.properties.clear(),this}addEvent(t,e){if(!(e instanceof Map))throw new Error("eventMap must be an instance of Map.");return this.events.set(t,e),this}removeEvent(t){return this.events.delete(t),this}clearEvents(){return this.events.clear(),this}addComponentGroup(t,e){if(!(e instanceof Map))throw new Error("componentMap must be an instance of Map.");return this.component_groups.set(t,e),this}removeComponentGroup(t){return this.component_groups.delete(t),this}clearComponentGroups(){return this.component_groups.clear(),this}addComponent(t){if(!(t instanceof Map))throw new Error("componentMap must be an instance of Map.");for(const[e,i]of t)this.components.set(e,i);return this}removeComponent(t){return this.components.delete(t),this}clearComponents(){return this.components.clear(),this}clearAll(){return this.components.clear(),this.component_groups.clear(),this.events.clear(),this}toJson(){return new S("1.16.0",new A(new O(this.identifier,this.is_spawnable,this.is_summonable,Object.fromEntries(this.properties),this.runtime_identifier),Object.fromEntries(this.components),Object.fromEntries(this.component_groups),Object.fromEntries(this.events))).toJson()}}class N{constructor(t,e){this.format_version=t,this.definitions=e}toJson(){return{format_version:this.format_version,"minecraft:client_entity":this.definitions}}}class F{constructor(t){this.description=t}}class I{constructor(t,e){this.identifier=t,this.min_engine_version=e}addMaterial(t,e){return null==this.materials&&(this.materials={}),this.materials[t]=e,this}addTexture(t,e){return null==this.textures&&(this.textures={}),this.textures[t]=e,this}addGeometry(t,e){return null==this.geometry&&(this.geometry={}),this.geometry[t]=e,this}addAnimation(t,e){return null==this.animations&&(this.animations={}),this.animations[t]=e,this}addAnimationController(t,e){return null==this.animation_controllers&&(this.animation_controllers=[]),this.animation_controllers.push({[t]:e}),this}addRenderController(t){return null==this.render_controllers&&(this.render_controllers=[]),this.render_controllers.push(t),this}addLocator(t,e){return null==this.locators&&(this.locators={}),this.locators[t]=e,this}setSpawnEgg(t,e){return this.spawn_egg={texture:t,texture_index:e},this}setScript(t,e){return null==this.scripts&&(this.scripts={}),this.scripts[t]=e,this}}class z extends I{constructor(t,e={}){super(t);Object.keys(e).forEach((t=>{"identifier"!==t&&(this[t]=e[t])}))}toJson(){return new N("1.10.0",new F(this)).toJson()}}class q{constructor(t,e,i,r,s={}){this.identifier=t,this.entity=new D(t,s,i),this.client_entity=new z(t,r).addTexture("default",e)}}const j=e.dirname(i(import.meta.url));class R{static behDataPath=e.join(j,"data_bp.json");static resDataPath=e.join(j,"data_rp.json");static behData=null;static resData=null;static loadDataSync(e){try{const i=t.readFileSync(e,"utf8");return JSON.parse(i)}catch(t){return console.error(`Failed to load data from $$${e}:`,t),{}}}static reloadDataSync(){this.behData=this.loadDataSync(this.behDataPath),this.resData=this.loadDataSync(this.resDataPath)}static getDataById(t,e){if("string"!=typeof t||"string"!=typeof e)throw new Error("type and id must be strings");return this.behData&&this.resData||this.reloadDataSync(),"beh"===t?this.behData[e]||null:this.resData[e]||null}}class L{constructor(t,e,i={}){try{const r=R.getDataById("beh",e)?.["minecraft:entity"];if(!r)throw new Error(`Behavior data not found for proto_id: ${e}`);const s=R.getDataById("res",e)?.["minecraft:client_entity"]?.description;if(!s)throw new Error(`Resource data not found for proto_id: ${e}`);i.runtime_identifier=e,this.identifier=t,this.entity=new D(t,i,r),this.client_entity=new z(t,s)}catch(e){throw console.error(`Failed to create NativeEntity ${t}:`,e),e}}}class G extends L{constructor(t,e,i={}){super(t,"minecraft:snowball",i),this.client_entity.addTexture("default",e)}}const J=(t,e)=>{t&&Object.keys(t).length>0&&P.register(t.identifier.replace(":","_"),"behavior","entities/",t),e&&Object.keys(e).length>0&&P.register(e.identifier.replace(":","_"),"resource","entity/",e)},$={createNativeEntity:function(t,e,i={}){if(!t||!e)throw new Error("必须提供 identifier、proto_id 和 texture。");const r=new L(t,e,i);return J(r.entity,r.client_entity),{behavior:r.entity,resource:r.client_entity}},createEntity:function(t,e,i,r,s={}){if(!t||!e)throw new Error("必须提供 identifier 和 texture。");const n=new q(t,e,i,r,s);return J(n.entity,n.client_entity),{behavior:n.entity,resource:n.client_entity}},createProjectile:function(t,e,i={}){if(!t||!e)throw new Error("必须提供 identifier 和 texture。");const r=new G(t,e,i);return J(r.entity,r.client_entity),{behavior:r.entity,resource:r.client_entity}}},V={createOreFeature:function(t,e,i){const r=new f(t,e,i);return(t=>{const e=t.identifier.split(":")[t.identifier.split(":").length-1];P.register(e,"behavior","features/",t)})(r),r},createFeatureRules:function(t,e){const i=new v(t,e);return(t=>{const e=t.identifier.split(":")[t.identifier.split(":").length-1];P.register(e,"behavior","feature_rules/",t)})(i),i}};class U{constructor(t,e){this.format_version=t,this.definitions=e}toJson(){return{format_version:this.format_version,"minecraft:attachable":this.definitions}}}class H{constructor(t){this.description=t}}class W{constructor(t){this.identifier=t}addMaterial(t,e){return null==this.materials&&(this.materials={}),this.materials[t]=e,this}addTexture(t,e){return null==this.textures&&(this.textures={}),this.textures[t]=e,this}addGeometry(t,e){return null==this.geometry&&(this.geometry={}),this.geometry[t]=e,this}addAnimation(t,e){return null==this.animations&&(this.animations={}),this.animations[t]=e,this}addAnimationController(t,e){return null==this.animation_controllers&&(this.animation_controllers=[]),this.animation_controllers.push({[t]:e}),this}addRenderController(t){return null==this.render_controllers&&(this.render_controllers=[]),this.render_controllers.push(t),this}addLocator(t,e){return null==this.locators&&(this.locators={}),this.locators[t]=e,this}setScript(t,e){return null==this.scripts&&(this.scripts={}),this.scripts[t]=e,this}}class K extends W{constructor(t){super(t)}getId(){return this.identifier}toJson(){return new U("1.8.0",new H(this)).toJson()}}class Z{static setDurability(t,e=0,i=100){return(new Map).set("minecraft:durability",{damage_chance:{min:e,max:i},max_durability:t})}static setBlockPlacer(t,e,i){return(new Map).set("minecraft:block_placer",{block:t,replace_block_item:e,use_on:i})}static setCustomComponents(t){return(new Map).set("minecraft:custom_components",[...t])}static setThrowable(t=!1,e=1,i=0,r=1,s=0,n=!1){return(new Map).set("minecraft:throwable",{do_swing_animation:t,launch_power_scale:e,max_draw_duration:i,max_launch_power:r,min_draw_duration:s,scale_power_by_draw_duration:n})}static setDisplayName(t){if("string"!=typeof t)throw new Error("显示名称必须是字符串类型");return(new Map).set("minecraft:display_name",{value:t})}static setFoodComponent(t,e,i,r){return(new Map).set("minecraft:food",{can_always_eat:t,nutrition:e||0,saturation_modifier:i||.6,using_converts_to:r||void 0})}static setFuel(t){if("number"!=typeof t||t<.05)throw new Error("燃料持续时间必须是一个大于或等于 0.05 的数字");return(new Map).set("minecraft:fuel",{duration:t})}static setGlint(t){if("boolean"!=typeof t)throw new Error("附魔光效值必须是布尔类型");return(new Map).set("minecraft:glint",t)}static setHandEquipped(t){if("boolean"!=typeof t)throw new Error("手持渲染方式值必须是布尔类型");return(new Map).set("minecraft:hand_equipped",t)}static setIcon(t){if("string"!=typeof t)throw new Error("图标纹理必须是字符串类型");return(new Map).set("minecraft:icon",t)}static setMaxStackSize(t=64){if("number"!=typeof t||t<=0||!Number.isInteger(t))throw new Error("最大堆叠数量必须是正整数");return(new Map).set("minecraft:max_stack_size",t)}static setProjectile(t,e){const i={};if(void 0!==t){if("number"!=typeof t||t<0)throw new Error("minimumCriticalPower 必须是非负数");i.minimum_critical_power=t}if(void 0!==e){if("string"!=typeof e)throw new Error("projectileEntity 必须是字符串类型");i.projectile_entity=e}return(new Map).set("minecraft:projectile",i)}static setUseModifiers(t,e){const i={};if(void 0!==t){if("number"!=typeof t)throw new Error("movementModifier 必须是数字类型");i.movement_modifier=t}if(void 0!==e){if("number"!=typeof e||e<0)throw new Error("useDuration 必须是非负数");i.use_duration=e}return(new Map).set("minecraft:use_modifiers",i)}static setWearable(t=0,e){const i={protection:t};if(void 0!==e){if("string"!=typeof e)throw new Error("slot 必须是字符串类型");i.slot=e}return(new Map).set("minecraft:wearable",i)}static setUseAnimation(t){if("string"!=typeof t)throw new Error("animation 必须是字符串类型");return(new Map).set("minecraft:use_animation",t)}static combineComponents(...t){return new Map(t.flatMap((t=>[...t])))}static toJSON(t){return Object.fromEntries(t)}}class Q{constructor(t,e){this.format_version=t,this.definitions=e}toJson(){return{format_version:this.format_version,"minecraft:item":this.definitions}}}class X{constructor(t,e){this.description=t,this.components=e}}class Y{constructor(t,e){this.identifier=t,this.menu_category=e}}class tt{constructor(t,e,i,r={}){if(!t||"string"!=typeof t)throw new Error("identifier is required and must be a string");if(!e||"string"!=typeof e)throw new Error("category is required and must be a string");if(!i||"string"!=typeof i)throw new Error("texture is required and must be a string");const{group:s,hide_in_command:n=!1,max_stack_size:o=64}=r;this.identifier=t,this.category=e,this.texture=i,this.group=s,this.hide_in_command=n,this.components=new Map,this.addComponent(Z.combineComponents(Z.setIcon(this.texture),Z.setMaxStackSize(o)))}addComponent(t){if(!(t&&t instanceof Map))throw new Error("componentMap is required and must be a Map");for(const[e,i]of t.entries())this.components.set(e,i);return this}removeComponent(t){if(!t||"string"!=typeof t)throw new Error("key is required and must be a string");return this.components.delete(t),this}toJson(){return new Q("1.21.40",new X(new Y(this.identifier,new s(this.category,this.group,this.hide_in_command)),Object.fromEntries(this.components))).toJson()}}class et{constructor(t,e,i,r,s={}){this.identifier=t,s.group="minecraft:itemGroup.name.chestplate",this.item=new tt(t,e,i,s),this.attachable=new K(t),this.attachable.addTexture("default",r).addMaterial("default","armor").addMaterial("enchanted","armor_enchanted").addTexture("default",r).addTexture("enchanted","textures/misc/enchanted_actor_glint").addRenderController("controller.render.armor").addGeometry("default","geometry.player.armor.chestplate").setScript("parent_setup","v.chest_layer_visible = 0.0;")}setArrachableGeometry(t,e){return this.attachable.addGeometry(t,e),this}}class it extends et{constructor(t,e,i,r={}){super(t,"equipment",e,i,r),r.group="minecraft:itemGroup.name.chestplate",this.attachable.addGeometry("default","geometry.player.armor.chestplate").setScript("parent_setup","v.chest_layer_visible = 0.0;"),this.item.addComponent(Z.combineComponents(Z.setDisplayName("我的自定义胸甲"),Z.setMaxStackSize(1),Z.setWearable(5,"slot.armor.chest")))}}class rt extends et{constructor(t,e,i,r={}){super(t,"equipment",e,i,r),r.group="minecraft:itemGroup.name.boots",this.attachable.addGeometry("default","geometry.player.armor.boots").setScript("parent_setup","v.boot_layer_visible = 0.0;"),this.item.addComponent(Z.combineComponents(Z.setDisplayName("我的自定义靴子"),Z.setMaxStackSize(1),Z.setWearable(4,"slot.armor.feet")))}}class st extends et{constructor(t,e,i,r={}){super(t,"equipment",e,i,r),r.group="minecraft:itemGroup.name.leggings",this.attachable.addGeometry("default","geometry.player.armor.leggings").setScript("parent_setup","v.leg_layer_visible = 0.0;"),this.item.addComponent(Z.combineComponents(Z.setDisplayName("我的自定义裤子"),Z.setMaxStackSize(1),Z.setWearable(6,"slot.armor.legs")))}}class nt extends et{constructor(t,e,i,r={}){super(t,"equipment",e,i,r),r.group="minecraft:itemGroup.name.helmet",this.attachable.addGeometry("default","geometry.player.armor.helmet").setScript("parent_setup","v.helmet_layer_visible = 0.0;"),this.item.addComponent(Z.combineComponents(Z.setDisplayName("我的自定义头盔"),Z.setMaxStackSize(1),Z.setWearable(3,"slot.armor.head")))}}class ot extends tt{constructor(t,e,i,r={}){super(t,e,i,r);const{animation:s="eat",movement:n=1,useDuration:o=1,canAlwaysEat:a=!1,nutrition:c=0,saturationModifier:h=1}=r;if("number"!=typeof c||c<0)throw new Error("nutrition 必须是一个非负数");if("number"!=typeof h||h<=0)throw new Error("saturationModifier 必须是一个正数");if("string"!=typeof s)throw new Error("animation 必须是字符串类型");if("boolean"!=typeof a)throw new Error("canAlwaysEat 必须是布尔类型");this.addComponent(Z.combineComponents(Z.setUseModifiers(n,o),Z.setFoodComponent(a,c,h),Z.setUseAnimation(s)))}}const at=(t,e)=>{t&&Object.keys(t).length>0&&P.register(t.identifier.replace(":","_"),"behavior","items/",t),e&&Object.keys(e).length>0&&P.register(e.identifier.replace(":","_"),"resource","attachables/",e)},ct={createItem:function(t,e,i,r={}){if(!t||!e||!i)throw new Error("必须提供 identifier、category 和 texture。");const s=new tt(t,e,i,r);let n={};return!0===r.hide_in_command&&(n=new K(t).addMaterial("default","entity_alphatest").addMaterial("enchanted","entity_alphatest_glint").addTexture("default",`textures/items/${i}`).addTexture("enchanted","textures/misc/enchanted_item_glint").addGeometry("default","geometry.large_item")),at(s,n),s},createFood:function(t,e,i,r={}){if(!t||!e||!i)throw new Error("必须提供 identifier、category 和 texture。");const s=new ot(t,e,i,{animation:"eat",canAlwaysEat:!1,nutrition:0,saturationModifier:1,...r});return at(s,{}),s},createAttachable:function(t,e,i,r={}){if(!t||!e||!i)throw new Error("必须提供 identifier、texture 和 material。");const s=new K(t);return s.addTexture("default",e),s.addMaterial("default",i),at({},s),s},createChestplateArmor:function(t,e,i,r={}){const s=new it(t,e,i,r);return at(s.item,s.attachable),s},createHelmetArmor:function(t,e,i,r={}){const s=new nt(t,e,i,r);return at(s.item,s.attachable),s},createBootArmor:function(t,e,i,r={}){const s=new rt(t,e,i,r);return at(s.item,s.attachable),s},createLeggingsArmor:function(t,e,i,r={}){const s=new st(t,e,i,r);return at(s.item,s.attachable),s}},ht="furnace",ut="crafting_table",lt="minecraft:recipe_furnace",dt="minecraft:recipe_shaped",mt="minecraft:recipe_shapeless";class pt{constructor(t,e,i={}){this.format_version=t,this.recipe_type=e,this.definitions=i}getId(){return this.definitions.description.identifier}identifier(t){return this.definitions.description={identifier:t},this}tags(t){return this.definitions.tags=t,this}toJson(){var t={format_version:this.format_version};return t[this.recipe_type]=this.definitions,t}}class ft extends pt{constructor(t,e){super(t,lt,e)}static create(t,e){return new ft(t,e)}input(t,e,i){var r;return e||i?(r={item:t},e&&(r.data=e),i&&(r.count=i)):r=t,this.definitions.input=r,this}output(t){return this.definitions.output=t,this}}class _t extends ft{constructor(t={}){super("1.17",t)}}class wt extends pt{constructor(t,e){super(t,dt,e)}assumeSymmetry(){this.definitions.assume_symmetry=!0}key(t){return this.definitions.key=t,this}pattern(t){return this.definitions.pattern=t,this}priority(t){return this.definitions.priority=t,this}output(t){return this.definitions.result="string"==typeof t?{item:t}:t,this}static create(t,e){return new wt(t,e)}}class bt extends wt{constructor(t){super("1.20",dt,t)}}class gt extends pt{constructor(t,e){super(t,mt,e)}static create(t,e){return new gt(t,e)}priority(t){return this.definitions.priority=t,this}ingredients(t){return this.definitions.ingredients=t,this}output(t){return this.definitions.result="string"==typeof t?{item:t}:t,this}}class yt extends gt{constructor(t){super("1.17",t)}}const xt=new class{registerRecipe(t){P.register(t.getId().replace(":","_"),"behavior","recipes/",t)}registerSimpleFurnace(t,e,i){return this.registerFurnace(t).tags([ht]).input(i).output(e)}registerFurnace(t){const e=(new _t).identifier(t);return this.registerRecipe(e),e}registerSimpleShaped(t,e,i,r){return this.registerShaped(t).tags([ut]).pattern(i).key(r).output(e)}registerShaped(t){const e=(new bt).identifier(t);return this.registerRecipe(e),e}registerSimpleShapeless(t,e,i){return this.registerShapeless(t).tags([ut]).ingredients(i).output(e)}registerShapeless(t){const e=(new yt).identifier(t);return this.registerRecipe(e),e}};class Et{static item_texture_sets=new Map;static getItemTextureSet(){return this.item_texture_sets}static getItemTextures(){return Object.fromEntries(this.item_texture_sets)}static registerTextureData(t,e){this.item_texture_sets.set(t,e)}static registerTexture(t,e){this.registerTextureData(t,{textures:e})}}class vt{static terrain_texture_sets=new Map;static getTerrainTextureSet(){return this.terrain_texture_sets}static getTerrainTextures(){return Object.fromEntries(this.terrain_texture_sets)}static registerTextureData(t,e){this.terrain_texture_sets.set(t,e)}static registerTexture(t,e){this.registerTextureData(t,{textures:e})}}const Ct={flipbook_textures:[],registerFlipbookTexture(t,e,i,r={}){const s={atlas_tile:t,flipbook_texture:e,ticks_per_frame:i};Object.assign(s,r),this.flipbook_textures.push(s)}};class kt{constructor(){}setIgnored(t=!1){return this.ignored=t,this}setBindingType(t){return this.binding_type=t,this}setBindingName(t){return this.binding_name=t,this}setBindingNameOverride(t){return this.binding_name_override=t,this}setBindingCollectionName(t){return this.binding_collection_name=t,this}setBindingCollectionPrefix(t){return this.binding_collection_prefix=t,this}setBindingCondition(t){return this.binding_condition=t,this}setSourceControlName(t){return this.source_control_name=t,this}setSourcePropertyName(t){return this.source_property_name=t,this}setTargetPropertyName(t){return this.target_property_name=t,this}setResolveSiblingScope(t=!1){return this.resolve_sibling_scope=t,this}}class Mt{constructor(){}setGridDimensions(t){return this.grid_dimensions=t,this}setMaximumGridItems(t){return this.maximum_grid_items=t,this}setGridDimensionBinding(t){return this.grid_dimension_binding=t,this}setGridRescalingType(t="none"){return this.grid_rescaling_type=t,this}setGridFillDirection(t="none"){return this.grid_fill_direction=t,this}setGridItemTemplate(t){return this.grid_item_template=t,this}setPrecachedGridItemCount(t){return this.precached_grid_item_count=t,this}}class Pt{constructor(){}setVisible(t=!0){return this.visible=t,this}setEnabled(t=!0){return this.enabled=t,this}setLayer(t=0){return this.layer=t,this}setAlpha(t=1){return this.alpha=t,this}setPropagateAlpha(t=!1){return this.propagate_alpha=t,this}setClipsChildren(t=!1){return this.clips_children=t,this}setAllowClipping(t=!0){return this.allow_clipping=t,this}setClipOffset(t=[0,0]){return this.clip_offset=t,this}setClipStateChangeEvent(t){return this.clip_state_change_event=t,this}setEnableScissorTest(t=!1){return this.enable_scissor_test=t,this}setPropertyBag(t){return this.property_bag=t,this}setSelected(t=!1){return this.selected=t,this}setUseChildAnchors(t=!1){return this.use_child_anchors=t,this}addControl(t){return this.controls||(this.controls=[]),this.controls.push(t),this}setAnimations(t){return this.anims=t,this}setDisableAnimFastForward(t=!1){return this.disable_anim_fast_forward=t,this}setAnimationResetName(t){return this.animation_reset_name=t,this}setIgnored(t=!1){return this.ignored=t,this}setVariables(t){return this.variables=t,this}setModifications(t){return this.modifications=t,this}setGridPosition(t){return this.grid_position=t,this}setCollectionIndex(t){return this.collection_index=t,this}}class Bt{constructor(){}setBinding(t){return this.bindings||(this.bindings=[]),this.binding=t,this}addDataBinding(t){return this.bindings||(this.bindings=[]),this.bindings.push(t),this}}class Tt{constructor(){}setName(t){return this.factory||(this.factory={}),this.factory.name=t,this}setControlName(t){return this.factory||(this.factory={}),this.factory.control_name=t,this}setControlIds(t){return this.factory||(this.factory={}),this.factory.control_ids=t,this}addControlId(t,e){return this.factory||(this.factory={}),this.factory.control_ids[t]=e,this}}class St{constructor(){}setSize(t=["default","default"]){return this.size=t,this}setMaxSize(t=["default","default"]){return this.max_size=t,this}setMinSize(t=["default","default"]){return this.min_size=t,this}setOffset(t=[0,0]){return this.offset=t,this}setAnchorFrom(t="center"){return this.anchor_from=t,this}setAnchorTo(t="center"){return this.anchor_to=t,this}setInheritMaxSiblingWidth(t=!1){return this.inherit_max_sibling_width=t,this}setInheritMaxSiblingHeight(t=!1){return this.inherit_max_sibling_height=t,this}setUseAnchoredOffset(t=!1){return this.use_anchored_offset=t,this}setContained(t=!1){return this.contained=t,this}setDraggable(t){return this.draggable=t,this}setFollowsCursor(t=!1){return this.follows_cursor=t,this}}class At{constructor(t,e,i){this.type=e,this.id=i?`${t}@${i}`:t,this.name=t,this.control=new Pt,this.properties=(new Map).set("type",e),this.variables=new Map,this.modifications=[]}enableDebug(){return this.control.addControl({debug_board:{type:"image",texture:"textures/ui/focus_border_white",nineslice_size:1,size:["100%","100%"]}}),this}setControl(t){return this.control=t,this}addControl(t){return t instanceof At?this.control.addControl(t.serialize()):this.control.addControl(t),this}addControls(t){for(let e in t)this.addControl(t[e]);return this}addVariable(t,e){return this.variables.set(`$${t}`,e),this}addProp(t,e){return this.properties.set(t,e),this}addModification(t){return this.modifications.push({array_name:t.array_name,operation:t.operation,value:t.value}),this.addProp("modifications",this.modifications),this}serialize(){const t=Object.fromEntries(this.properties);return Object.assign(t,Object.fromEntries(this.variables)),{[this.id]:t}}}class Ot{static OPERATION=Object.freeze({INSERT_BACK:"insert_back",INSERT_FRONT:"insert_front",INSERT_AFTER:"insert_after",INSERT_BEFORE:"insert_before",MOVE_BACK:"move_back",MOVE_FRONT:"move_front",MOVE_AFTER:"move_after",MOVE_BEFORE:"move_before",SWAP:"swap",REPLACE:"replace",REMOVE:"remove"})}class Dt extends At{constructor(t,e){super(t,"collection_panel",e),this.control=new Pt,this.layout=new St,this.dataBinding=new Bt,this.factory=new Tt}setCollectionName(t){return this.addProp("collection_name",t),this}setLayout(t){return this.layout=t,this}serialize(){for(const t in this.layout)this.layout.hasOwnProperty(t)&&this.properties.set(t,this.layout[t]);for(const t in this.dataBinding)this.dataBinding.hasOwnProperty(t)&&this.properties.set(t,this.dataBinding[t]);for(const t in this.factory)this.factory.hasOwnProperty(t)&&this.properties.set(t,this.factory[t]);for(const t in this.control)this.control.hasOwnProperty(t)&&this.properties.set(t,this.control[t]);return super.serialize()}}class Nt extends At{constructor(t,e){super(t,"panel",e),this.control=new Pt,this.layout=new St,this.dataBinding=new Bt,this.factory=new Tt}setLayout(t){return this.layout=t,this}serialize(){for(const t in this.layout)this.layout.hasOwnProperty(t)&&this.properties.set(t,this.layout[t]);for(const t in this.dataBinding)this.dataBinding.hasOwnProperty(t)&&this.properties.set(t,this.dataBinding[t]);for(const t in this.factory)this.factory.hasOwnProperty(t)&&this.properties.set(t,this.factory[t]);for(const t in this.control)this.control.hasOwnProperty(t)&&this.properties.set(t,this.control[t]);return super.serialize()}}class Ft extends Dt{constructor(t,e){super(t,e),this.gridNum=0,this.grid=new Mt}setGridProp(t){return this.grid=t,this}addGridItem(t,e){const i=new Nt(`grid_item_${this.gridNum}`);return i.addProp("grid_position",t),i.addControl(e),this.addControl(i),this.gridNum++,this}serialize(){for(const t in this.grid)this.grid.hasOwnProperty(t)&&this.properties.set(t,this.grid[t]);return this.properties.set("type","grid"),super.serialize()}}class It{constructor(){}setTexture(t){return this.texture=t,this}setAllowDebugMissingTexture(t=!0){return this.allow_debug_missing_texture=t,this}setUV(t){return this.uv=t,this}setUVSize(t){return this.uv_size=t,this}setTextureFileSystem(t="InUserPackage"){return this.texture_file_system=t,this}setNineSliceSize(t){return this.nineslice_size=t,this}setTiled(t){return this.tiled=t,this}setTiledScale(t=[1,1]){return this.tiled_scale=t,this}setClipDirection(t){return this.clip_direction=t,this}setClipRatio(t){return this.clip_ratio=t,this}setClipPixelPerfect(t=!1){return this.clip_pixelperfect=t,this}setKeepRatio(t=!0){return this.keep_ratio=t,this}setBilinear(t=!1){return this.bilinear=t,this}setFill(t=!1){return this.fill=t,this}setFitToWidth(t=!1){return this.$fit_to_width=t,this}setZipFolder(t){return this.zip_folder=t,this}setGrayscale(t=!1){return this.grayscale=t,this}setForceTextureReload(t=!1){return this.force_texture_reload=t,this}setBaseSize(t){return this.base_size=t,this}}class zt extends At{constructor(t,e){super(t,"image",e),this.sprite=new It,this.control=new Pt,this.layout=new St,this.dataBinding=new Bt,this.factory=new Tt}setSprite(t){return this.sprite=t,this}serialize(){for(const t in this.sprite)this.sprite.hasOwnProperty(t)&&this.properties.set(t,this.sprite[t]);for(const t in this.layout)this.layout.hasOwnProperty(t)&&this.properties.set(t,this.layout[t]);for(const t in this.dataBinding)this.dataBinding.hasOwnProperty(t)&&this.properties.set(t,this.dataBinding[t]);for(const t in this.factory)this.factory.hasOwnProperty(t)&&this.properties.set(t,this.factory[t]);for(const t in this.control)this.control.hasOwnProperty(t)&&this.properties.set(t,this.control[t]);return super.serialize()}}class qt{constructor(){}setText(t=""){return this.text=t,this}setColor(t=[1,1,1]){return this.color=t,this}setLockedColor(t){return this.locked_color=t,this}setShadow(t=!1){return this.shadow=t,this}setHideHyphen(t=!1){return this.hide_hyphen=t,this}setNotifyOnEllipses(t){return this.notify_on_ellipses=t,this}addNotifyOnEllipses(t){return this.notify_on_ellipses.push(t),this}setEnableProfanityFilter(t=!1){return this.enable_profanity_filter=t,this}setLockedAlpha(t){return this.locked_alpha=t,this}setFontSize(t="normal"){return this.font_size=t,this}setFontScaleFactor(t=1){return this.font_scale_factor=t,this}setLocalize(t=!1){return this.localize=t,this}setLinePadding(t){return this.line_padding=t,this}setFontType(t="default"){return this.font_type=t,this}setBackupFontType(t="default"){return this.backup_font_type=t,this}setTextAlignment(t){return this.text_alignment=t,this}}class jt extends At{constructor(t,e){super(t,"label",e),this.text=new qt,this.control=new Pt,this.layout=new St,this.dataBinding=new Bt,this.factory=new Tt}setLayout(t){return this.layout=t,this}setText(t){return this.text=t,this}serialize(){for(const t in this.text)this.text.hasOwnProperty(t)&&this.properties.set(t,this.text[t]);for(const t in this.layout)this.layout.hasOwnProperty(t)&&this.properties.set(t,this.layout[t]);for(const t in this.dataBinding)this.dataBinding.hasOwnProperty(t)&&this.properties.set(t,this.dataBinding[t]);for(const t in this.factory)this.factory.hasOwnProperty(t)&&this.properties.set(t,this.factory[t]);for(const t in this.control)this.control.hasOwnProperty(t)&&this.properties.set(t,this.control[t]);return super.serialize()}}class Rt extends Nt{constructor(t,e){super(t,e),this.type="stack_panel",this.orientation="vertical",this.stackNum=0,this.setLayout((new St).setSize(["100%","100%"]))}addStack(t,e,i=!1){const r=new Nt(`stack${this.stackNum}`).setLayout((new St).setSize(t)).addControl(e);return i&&r.enableDebug(),this.addControl(r),this.stackNum++,this}setOrientation(t){return this.orientation=t,this}serialize(){return this.properties.set("type","stack_panel"),this.properties.set("orientation",this.orientation),super.serialize()}}class Lt{static#a=new Map;static#c=[];static registerUISystem(t){const e=t.path+t.name+".json";this.#a.set(e,t)}static getUISystemList(){return Array.from(this.#a.values())}static addOuterUIdefs(t){if(!Array.isArray(t))throw new Error("参数必须是一个数组");this.#c=this.#c.concat(t)}static getUIdefList(){return this.#c.concat(Array.from(this.#a.keys())).filter((t=>"ui/server_form"!==t))}}class Gt{constructor(t,e){this.identifier=t,this.namespace=t.split(":")[0],this.name=t.split(":")[1],this.path=e,this.elements=new Map,this.animations=new Map,Lt.registerUISystem(this)}addElement(t){return this.elements.set(t.id,t),this}getElement(t){return this.elements.get(t)}addAnimation(t,e){this.animations.set(t,e)}getAnimation(t){return this.animations.get(t)}toJson(){const t={namespace:this.namespace};return this.elements.forEach(((e,i)=>{t[i]=e.serialize()[e.id]})),t}}class Jt{constructor(){}setButtonMappings(t){return this.button_mappings=t,this}setModal(t=!1){return this.modal=t,this}setInlineModal(t=!1){return this.inline_modal=t,this}setAlwaysListenToInput(t=!1){return this.always_listen_to_input=t,this}setAlwaysHandlePointer(t=!1){return this.always_handle_pointer=t,this}setAlwaysHandleControllerDirection(t=!1){return this.always_handle_controller_direction=t,this}setHoverEnabled(t=!1){return this.hover_enabled=t,this}setPreventTouchInput(t=!1){return this.prevent_touch_input=t,this}setConsumeEvent(t=!1){return this.consume_event=t,this}setConsumeHoverEvents(t=!1){return this.consume_hover_events=t,this}setGestureTrackingButton(t){return this.gesture_tracking_button=t,this}}class $t{constructor(){}setSoundName(t){return this.sound_name=t,this}setSoundVolume(t=1){return this.sound_volume=t,this}setSoundPitch(t=1){return this.sound_pitch=t,this}setSounds(t){return this.sounds=t,this}addSound(t){return this.sounds.push(t),this}}const Vt=new Gt("server_form:server_form","ui/"),Ut=new class extends At{constructor(t,e){super(t,"button",e),this.input=new Jt,this.sound=new $t,this.control=new Pt,this.layout=new St,this.dataBinding=new Bt,this.factory=new Tt}setDefaultControl(t){return this.addProp("default_control",t),this}setHoverControl(t){return this.addProp("hover_control",t),this}setPressedControl(t){return this.addProp("pressed_control",t),this}setLockedControl(t){return this.addProp("locked_control",t),this}setInput(t){return this.input=t,this}setSound(t){return this.sound=t,this}setLayout(t){return this.layout=t,this}serialize(){for(const t in this.layout)this.layout.hasOwnProperty(t)&&this.properties.set(t,this.layout[t]);for(const t in this.input)this.input.hasOwnProperty(t)&&this.properties.set(t,this.input[t]);for(const t in this.sound)this.sound.hasOwnProperty(t)&&this.properties.set(t,this.sound[t]);for(const t in this.dataBinding)this.dataBinding.hasOwnProperty(t)&&this.properties.set(t,this.dataBinding[t]);for(const t in this.factory)this.factory.hasOwnProperty(t)&&this.properties.set(t,this.factory[t]);for(const t in this.control)this.control.hasOwnProperty(t)&&this.properties.set(t,this.control[t]);return super.serialize()}}("sapdon_form_button_template","common.button");Ut.addVariable("pressed_button_name","button.form_button_click"),Ut.addVariable("default_texture|default","textures/gui/newgui/buttons/borderless/light"),Ut.addVariable("hover_texture|default","textures/gui/newgui/buttons/borderless/lighthover"),Ut.addVariable("pressed_texture|default","textures/gui/newgui/buttons/borderless/lightpressed"),Ut.addVariable("binding_button_text|default",""),Ut.dataBinding.addDataBinding((new kt).setBindingType("collection_details").setBindingCollectionName("form_buttons")),Ut.dataBinding.addDataBinding((new kt).setBindingType("collection").setBindingCollectionName("form_buttons").setBindingName("#form_button_text")),Ut.dataBinding.addDataBinding((new kt).setBindingType("view").setSourcePropertyName("($binding_button_text = #form_button_text)").setTargetPropertyName("#visible")),Ut.addControls([new zt("default").setSprite((new It).setTexture("$default_texture")),new zt("hover").setSprite((new It).setTexture("$hover_texture")),new zt("pressed").setSprite((new It).setTexture("$pressed_texture"))]);const Ht=new Nt("sapdon_form_button_factory");Ht.addProp("type","collection_panel"),Ht.factory.setName("buttons").setControlName("sapdon_form_button_template"),Ht.addProp("collection_name","form_buttons"),Ht.dataBinding.addDataBinding((new kt).setBindingName("#form_button_length").setBindingNameOverride("#collection_length")),Vt.addElement(Ut),Vt.addElement(Ht);class Wt{static#h=new Map;static#u=[];static addBindingTitle(t){this.#u.push(t)}static getBindingTitleList(){return this.#u.concat(Array.from(this.#h.keys()))}static getBindingContentList(){return Array.from(this.#h.values())}static bindingTitlewithContent(t,e){this.#h.set(t,e),this.#l()}static#l(){const t=this.getBindingTitleList().map((t=>(console.log("title_name",t),`'${t}'`))).join("-"),e=new At("long_form").addModification({array_name:"bindings",operation:Ot.OPERATION.INSERT_BACK,value:[(new kt).setBindingName("#title_text"),(new kt).setBindingType("view").setSourcePropertyName(`((#title_text - ${t}) = #title_text)`).setTargetPropertyName("#visible")]}),i=new Nt("custom_server_form_factory");i.factory.setName("server_form_factory").setControlIds({long_form:"@server_form.custom_root_panel"});const r=new At("main_screen_content").addModification({array_name:"controls",operation:Ot.OPERATION.INSERT_BACK,value:[i.serialize()]}),s=new Nt("custom_ui_template");s.dataBinding.addDataBinding((new kt).setBindingName("#title_text")).addDataBinding((new kt).setBindingType("view").setSourcePropertyName("(#title_text = $binding_text)").setTargetPropertyName("#visible")),s.control.addControl(new At("main",void 0,"$main_content").serialize());const n=new Nt("custom_form_root");n.dataBinding.addDataBinding((new kt).setBindingType("view").setSourceControlName("custom_root_panel").setSourcePropertyName(`(not ((#title_text - ${t}) = #title_text))`).setTargetPropertyName("#visible")),this.#h.forEach(((t,e)=>{n.control.addControl(new At("custom_ui_"+e,void 0,"custom_ui_template").addVariable("main_content",t).addVariable("binding_text",e).serialize())}));const o=new Nt("custom_root_panel");o.dataBinding.addDataBinding((new kt).setBindingName("#title_text")),o.control.addControl(n.serialize()),Vt.addElement(s).addElement(e).addElement(o).addElement(r)}}var Kt;!function(t){t.Commands="commands",t.Construction="construction",t.Equipment="equipment",t.Nature="nature",t.Items="items",t.None="none"}(Kt||(Kt={}));export{T as BlockAPI,r as BlockComponent,kt as DataBindingObject,$ as EntityAPI,V as FeatureAPI,Ct as FlipbookTextures,P as GRegistry,Ft as Grid,zt as Image,ct as ItemAPI,Kt as ItemCategory,Z as ItemComponent,Et as ItemTextureManager,jt as Label,Nt as Panel,xt as RecipeAPI,Vt as ServerFormSystem,Wt as ServerUISystem,Rt as StackPanel,At as UIElement,Gt as UISystem,Lt as UISystemRegistry,vt as terrainTextureManager};
@@ -0,0 +1,21 @@
1
+ export class Armor {
2
+ constructor(identifier: any, category: any, item_texture: any, texture_path: any, options?: {});
3
+ identifier: any;
4
+ item: Item;
5
+ attachable: Attachable;
6
+ setArrachableGeometry(key: any, geometry: any): this;
7
+ }
8
+ export class Chestplate extends Armor {
9
+ constructor(identifier: any, item_texture: any, texture_path: any, options?: {});
10
+ }
11
+ export class Boot extends Armor {
12
+ constructor(identifier: any, item_texture: any, texture_path: any, options?: {});
13
+ }
14
+ export class Leggings extends Armor {
15
+ constructor(identifier: any, item_texture: any, texture_path: any, options?: {});
16
+ }
17
+ export class Helmet extends Armor {
18
+ constructor(identifier: any, item_texture: any, texture_path: any, options?: {});
19
+ }
20
+ import { Item } from "./item.js";
21
+ import { Attachable } from "./attachable.js";
@@ -0,0 +1,90 @@
1
+ import { Attachable } from "./attachable.js";
2
+ import { Item } from "./item.js";
3
+ import { ItemComponent } from "./itemComponents.js";
4
+ // 定义 Armor 基类
5
+ export class Armor {
6
+ constructor(identifier, category, item_texture, texture_path, options = {}) {
7
+ this.identifier = identifier;
8
+ //默认分组
9
+ options["group"] = "minecraft:itemGroup.name.chestplate";
10
+ // 创建物品
11
+ this.item = new Item(identifier, category, item_texture, options);
12
+ // 创建附加物
13
+ this.attachable = new Attachable(identifier);
14
+ // 配置附加物
15
+ this.attachable
16
+ .addTexture("default", texture_path) // 添加默认纹理
17
+ .addMaterial("default", "armor") // 添加默认材质
18
+ .addMaterial("enchanted", "armor_enchanted") // 添加附魔材质
19
+ .addTexture("default", texture_path)
20
+ .addTexture("enchanted", "textures/misc/enchanted_actor_glint") // 添加附魔纹理
21
+ .addRenderController("controller.render.armor") // 添加渲染控制器
22
+ //默认类型 胸甲
23
+ .addGeometry("default", "geometry.player.armor.chestplate") // 添加几何模型
24
+ .setScript("parent_setup", "v.chest_layer_visible = 0.0;"); // 设置脚本
25
+ }
26
+ setArrachableGeometry(key, geometry) {
27
+ this.attachable.addGeometry(key, geometry);
28
+ return this;
29
+ }
30
+ }
31
+ // 扩展 Armor 类,实现胸甲
32
+ export class Chestplate extends Armor {
33
+ constructor(identifier, item_texture, texture_path, options = {}) {
34
+ super(identifier, "equipment", item_texture, texture_path, options);
35
+ options["group"] = "minecraft:itemGroup.name.chestplate";
36
+ //头盔专属
37
+ this.attachable.addGeometry("default", "geometry.player.armor.chestplate") // 添加几何模型
38
+ .setScript("parent_setup", "v.chest_layer_visible = 0.0;"); // 设置脚本
39
+ // 自定义胸甲物品
40
+ this.item.addComponent(ItemComponent.combineComponents(ItemComponent.setDisplayName("我的自定义胸甲"), // 设置显示名称
41
+ ItemComponent.setMaxStackSize(1), // 设置最大堆叠数量
42
+ ItemComponent.setWearable(5, "slot.armor.chest") // 设置为可穿戴,并指定装备槽
43
+ ));
44
+ }
45
+ }
46
+ // 扩展 Armor 类,实现靴子
47
+ export class Boot extends Armor {
48
+ constructor(identifier, item_texture, texture_path, options = {}) {
49
+ super(identifier, "equipment", item_texture, texture_path, options);
50
+ options["group"] = "minecraft:itemGroup.name.boots";
51
+ //头盔专属
52
+ this.attachable.addGeometry("default", "geometry.player.armor.boots") // 添加几何模型
53
+ .setScript("parent_setup", "v.boot_layer_visible = 0.0;"); // 设置脚本
54
+ // 自定义靴子物品
55
+ this.item.addComponent(ItemComponent.combineComponents(ItemComponent.setDisplayName("我的自定义靴子"), // 设置显示名称
56
+ ItemComponent.setMaxStackSize(1), // 设置最大堆叠数量
57
+ ItemComponent.setWearable(4, "slot.armor.feet") // 设置为可穿戴,并指定装备槽
58
+ ));
59
+ }
60
+ }
61
+ // 扩展 Armor 类,实现裤子
62
+ export class Leggings extends Armor {
63
+ constructor(identifier, item_texture, texture_path, options = {}) {
64
+ super(identifier, "equipment", item_texture, texture_path, options);
65
+ options["group"] = "minecraft:itemGroup.name.leggings";
66
+ //头盔专属
67
+ this.attachable.addGeometry("default", "geometry.player.armor.leggings") // 添加几何模型
68
+ .setScript("parent_setup", "v.leg_layer_visible = 0.0;"); // 设置脚本
69
+ // 自定义裤子物品
70
+ this.item.addComponent(ItemComponent.combineComponents(ItemComponent.setDisplayName("我的自定义裤子"), // 设置显示名称
71
+ ItemComponent.setMaxStackSize(1), // 设置最大堆叠数量
72
+ ItemComponent.setWearable(6, "slot.armor.legs") // 设置为可穿戴,并指定装备槽
73
+ ));
74
+ }
75
+ }
76
+ // 扩展 Armor 类,实现头盔
77
+ export class Helmet extends Armor {
78
+ constructor(identifier, item_texture, texture_path, options = {}) {
79
+ super(identifier, "equipment", item_texture, texture_path, options);
80
+ options["group"] = "minecraft:itemGroup.name.helmet";
81
+ //头盔专属
82
+ this.attachable.addGeometry("default", "geometry.player.armor.helmet") // 添加几何模型
83
+ .setScript("parent_setup", "v.helmet_layer_visible = 0.0;"); // 设置脚本
84
+ // 自定义头盔物品
85
+ this.item.addComponent(ItemComponent.combineComponents(ItemComponent.setDisplayName("我的自定义头盔"), // 设置显示名称
86
+ ItemComponent.setMaxStackSize(1), // 设置最大堆叠数量
87
+ ItemComponent.setWearable(3, "slot.armor.head") // 设置为可穿戴,并指定装备槽
88
+ ));
89
+ }
90
+ }
@@ -0,0 +1,6 @@
1
+ export class Attachable extends AddonAttachableDescription {
2
+ constructor(identifier: any);
3
+ getId(): string;
4
+ toJson(): Object;
5
+ }
6
+ import { AddonAttachableDescription } from "../addon/item/attachable.js";
@@ -0,0 +1,26 @@
1
+ import { AddonAttachable, AddonAttachableDefinition, AddonAttachableDescription } from "../addon/item/attachable.js";
2
+ export class Attachable extends AddonAttachableDescription {
3
+ constructor(identifier) {
4
+ super(identifier);
5
+ }
6
+ getId() {
7
+ return this.identifier;
8
+ }
9
+ toJson() {
10
+ const entity = new AddonAttachable("1.8.0", new AddonAttachableDefinition(this));
11
+ return entity.toJson();
12
+ }
13
+ }
14
+ /*
15
+ const attachable = new Attachable("test")
16
+ attachable.addMaterial("default", "armor")
17
+ attachable.addMaterial("enchanted","armor_enchanted")
18
+ attachable.addTexture("default","textures/models/armor/custom_main")
19
+ attachable.addTexture("enchanted", "textures/misc/enchanted_actor_glint")
20
+ attachable.addGeometry("default", "geometry.player.armor.chestplate")
21
+ attachable.addRenderController("controller.render.armor")
22
+ attachable.setScript("parent_setup","v.chest_layer_visible = 0.0;")
23
+
24
+ console.log(JSON.stringify(attachable.toJson(),null,2))
25
+ debugger
26
+ */
@@ -0,0 +1,24 @@
1
+ export class Food extends Item {
2
+ /**
3
+ * 物品类
4
+ * @param {string} identifier 物品唯一标识符
5
+ * @param {string} category 菜单栏分类 可选:"construction", "nature", "equipment", "items", and "none"
6
+ * @param {string} texture 物品纹理
7
+ * @param {Object} options 可选参数
8
+ * @param {string} options.group 分组
9
+ * @param {boolean} options.hide_in_command 是否在命令中隐藏,默认为 false
10
+ * @param {string} options.animation 使用动画,默认为 "eat"
11
+ * @param {boolean} options.canAlwaysEat 是否总是可以食用,默认为 false
12
+ * @param {number} options.nutrition 营养价值,默认为 0
13
+ * @param {number} options.saturationModifier 饱和度修正值,默认为 1
14
+ */
15
+ constructor(identifier: string, category: string, texture: string, options?: {
16
+ group: string;
17
+ hide_in_command: boolean;
18
+ animation: string;
19
+ canAlwaysEat: boolean;
20
+ nutrition: number;
21
+ saturationModifier: number;
22
+ });
23
+ }
24
+ import { Item } from "./item.js";
@@ -0,0 +1,38 @@
1
+ import { ItemComponent } from "./itemComponents.js";
2
+ import { Item } from "./item.js";
3
+ export class Food extends Item {
4
+ /**
5
+ * 物品类
6
+ * @param {string} identifier 物品唯一标识符
7
+ * @param {string} category 菜单栏分类 可选:"construction", "nature", "equipment", "items", and "none"
8
+ * @param {string} texture 物品纹理
9
+ * @param {Object} options 可选参数
10
+ * @param {string} options.group 分组
11
+ * @param {boolean} options.hide_in_command 是否在命令中隐藏,默认为 false
12
+ * @param {string} options.animation 使用动画,默认为 "eat"
13
+ * @param {boolean} options.canAlwaysEat 是否总是可以食用,默认为 false
14
+ * @param {number} options.nutrition 营养价值,默认为 0
15
+ * @param {number} options.saturationModifier 饱和度修正值,默认为 1
16
+ */
17
+ constructor(identifier, category, texture, options = {}) {
18
+ // 继承父类
19
+ super(identifier, category, texture, options);
20
+ // 解构 options 并设置默认值
21
+ const { animation = "eat", movement = 1, useDuration = 1, canAlwaysEat = false, nutrition = 0, saturationModifier = 1, } = options;
22
+ // 参数验证
23
+ if (typeof nutrition !== "number" || nutrition < 0) {
24
+ throw new Error('nutrition 必须是一个非负数');
25
+ }
26
+ if (typeof saturationModifier !== "number" || saturationModifier <= 0) {
27
+ throw new Error('saturationModifier 必须是一个正数');
28
+ }
29
+ if (typeof animation !== "string") {
30
+ throw new Error('animation 必须是字符串类型');
31
+ }
32
+ if (typeof canAlwaysEat !== "boolean") {
33
+ throw new Error('canAlwaysEat 必须是布尔类型');
34
+ }
35
+ // 添加组件
36
+ this.addComponent(ItemComponent.combineComponents(ItemComponent.setUseModifiers(movement, useDuration), ItemComponent.setFoodComponent(canAlwaysEat, nutrition, saturationModifier), ItemComponent.setUseAnimation(animation)));
37
+ }
38
+ }
@@ -0,0 +1,36 @@
1
+ export class Item {
2
+ /**
3
+ * 物品类
4
+ * @param {string} identifier 物品唯一标识符
5
+ * @param {string} category 菜单栏分类 可选:"construction", "nature", "equipment", "items", and "none"
6
+ * @param {string} texture 物品纹理
7
+ * @param {Object} options 可选参数
8
+ * @param {string} options.group 分组
9
+ * @param {boolean} options.hide_in_command 是否在命令中隐藏,默认为 false
10
+ */
11
+ constructor(identifier: string, category: string, texture: string, options?: {
12
+ group: string;
13
+ hide_in_command: boolean;
14
+ });
15
+ identifier: string;
16
+ category: string;
17
+ texture: string;
18
+ group: string;
19
+ hide_in_command: boolean;
20
+ components: Map<any, any>;
21
+ /**
22
+ * 添加组件
23
+ * @param {Map} componentMap 组件 Map
24
+ */
25
+ addComponent(componentMap: Map<any, any>): this;
26
+ /**
27
+ * 移除组件
28
+ * @param {string} key 组件名称
29
+ */
30
+ removeComponent(key: string): this;
31
+ /**
32
+ * 将物品转换为 JSON 格式
33
+ * @returns {Object} JSON 格式的物品对象
34
+ */
35
+ toJson(): Object;
36
+ }
@@ -0,0 +1,69 @@
1
+ import { ItemComponent } from "./itemComponents.js";
2
+ import { AddonItem, AddonItemDefinition, AddonItemDescription } from "../addon/item/item.js";
3
+ import { AddonMenuCategory } from "../addon/menuCategory.js";
4
+ export class Item {
5
+ /**
6
+ * 物品类
7
+ * @param {string} identifier 物品唯一标识符
8
+ * @param {string} category 菜单栏分类 可选:"construction", "nature", "equipment", "items", and "none"
9
+ * @param {string} texture 物品纹理
10
+ * @param {Object} options 可选参数
11
+ * @param {string} options.group 分组
12
+ * @param {boolean} options.hide_in_command 是否在命令中隐藏,默认为 false
13
+ */
14
+ constructor(identifier, category, texture, options = {}) {
15
+ // 参数校验
16
+ if (!identifier || typeof identifier !== "string") {
17
+ throw new Error("identifier is required and must be a string");
18
+ }
19
+ if (!category || typeof category !== "string") {
20
+ throw new Error("category is required and must be a string");
21
+ }
22
+ if (!texture || typeof texture !== "string") {
23
+ throw new Error("texture is required and must be a string");
24
+ }
25
+ const { group, hide_in_command = false, max_stack_size = 64, } = options;
26
+ this.identifier = identifier;
27
+ this.category = category;
28
+ this.texture = texture;
29
+ this.group = group;
30
+ this.hide_in_command = hide_in_command;
31
+ this.components = new Map();
32
+ // 初始化默认组件
33
+ this.addComponent(ItemComponent.combineComponents(ItemComponent.setIcon(this.texture), ItemComponent.setMaxStackSize(max_stack_size)));
34
+ }
35
+ /**
36
+ * 添加组件
37
+ * @param {Map} componentMap 组件 Map
38
+ */
39
+ addComponent(componentMap) {
40
+ if (!componentMap || !(componentMap instanceof Map)) {
41
+ throw new Error("componentMap is required and must be a Map");
42
+ }
43
+ for (const [key, value] of componentMap.entries()) {
44
+ this.components.set(key, value);
45
+ }
46
+ return this;
47
+ }
48
+ /**
49
+ * 移除组件
50
+ * @param {string} key 组件名称
51
+ */
52
+ removeComponent(key) {
53
+ if (!key || typeof key !== "string") {
54
+ throw new Error("key is required and must be a string");
55
+ }
56
+ this.components.delete(key);
57
+ return this;
58
+ }
59
+ /**
60
+ * 将物品转换为 JSON 格式
61
+ * @returns {Object} JSON 格式的物品对象
62
+ */
63
+ toJson() {
64
+ const item = new AddonItem("1.21.40", // 格式版本
65
+ new AddonItemDefinition(new AddonItemDescription(this.identifier, new AddonMenuCategory(this.category, this.group, this.hide_in_command)), Object.fromEntries(this.components) // 将 Map 转换为普通对象
66
+ ));
67
+ return item.toJson();
68
+ }
69
+ }
@@ -0,0 +1,113 @@
1
+ export class ItemComponent {
2
+ /**
3
+ * 物品的耐久度组件
4
+ * @param {number} max_durability 最大耐久
5
+ * @param {number} damage_chance_min 损坏最小几率
6
+ * @param {number} damage_chance_max 损坏最大几率
7
+ * @returns {ItemComponent}
8
+ */
9
+ static setDurability(max_durability: number, damage_chance_min?: number, damage_chance_max?: number): ItemComponent;
10
+ static setBlockPlacer(block: any, replace_block_item: any, use_on: any): Map<any, any>;
11
+ /**
12
+ *
13
+ * @param {Array} custom_components
14
+ * @returns
15
+ */
16
+ static setCustomComponents(custom_components: any[]): Map<any, any>;
17
+ /**
18
+ * 设置物品的可投掷组件。
19
+ * @param {Boolean} doSwingAnimation - 是否使用挥动动画。
20
+ * @param {Number} launchPowerScale - 投掷力量的缩放比例。
21
+ * @param {Number} maxDrawDuration - 最大蓄力时间。
22
+ * @param {Number} maxLaunchPower - 最大投掷力量。
23
+ * @param {Number} minDrawDuration - 最小蓄力时间。
24
+ * @param {Boolean} scalePowerByDrawDuration - 投掷力量是否随蓄力时间增加。
25
+ * @returns {Map} - 新的组件集合。
26
+ */
27
+ static setThrowable(doSwingAnimation?: boolean, launchPowerScale?: number, maxDrawDuration?: number, maxLaunchPower?: number, minDrawDuration?: number, scalePowerByDrawDuration?: boolean): Map<any, any>;
28
+ /**
29
+ * 设置物品的显示名称。
30
+ * @param {String} displayName - 显示名称或本地化键。
31
+ * @returns {Map} - 新的组件集合。
32
+ */
33
+ static setDisplayName(displayName: string): Map<any, any>;
34
+ /**
35
+ * 设置物品的食物组件。
36
+ * @param {Boolean} canAlwaysEat - 是否随时可以食用。
37
+ * @param {Number} nutrition - 营养值。
38
+ * @param {Number} saturationModifier - 饱和度修正值。
39
+ * @param {String} [usingConvertsTo] - 食用后转换的目标物品。
40
+ * @returns {Map} - 新的组件集合。
41
+ */
42
+ static setFoodComponent(canAlwaysEat: boolean, nutrition: number, saturationModifier: number, usingConvertsTo?: string): Map<any, any>;
43
+ /**
44
+ * 设置物品的燃料组件。
45
+ * @param {Number} duration - 燃料燃烧的持续时间(秒),最小值为 0.05。
46
+ * @returns {Map} - 新的组件集合。
47
+ */
48
+ static setFuel(duration: number): Map<any, any>;
49
+ /**
50
+ * 设置物品的附魔光效组件。
51
+ * @param {Boolean} hasGlint - 是否显示附魔光效。
52
+ * @returns {Map} - 新的组件集合。
53
+ */
54
+ static setGlint(hasGlint: boolean): Map<any, any>;
55
+ /**
56
+ * 设置物品的手持渲染方式组件。
57
+ * @param {Boolean} isHandEquipped - 是否像工具一样渲染。
58
+ * @returns {Map} - 新的组件集合。
59
+ */
60
+ static setHandEquipped(isHandEquipped: boolean): Map<any, any>;
61
+ /**
62
+ * 设置物品的图标组件。
63
+ * @param {String} texture - 图标纹理名称。
64
+ * @returns {Map} - 新的组件集合。
65
+ */
66
+ static setIcon(texture: string): Map<any, any>;
67
+ /**
68
+ * 设置物品的最大堆叠数量组件。
69
+ * @param {Number} maxStackSize - 最大堆叠数量,默认值为 64。
70
+ * @returns {Map} - 新的组件集合。
71
+ */
72
+ static setMaxStackSize(maxStackSize?: number): Map<any, any>;
73
+ /**
74
+ * 设置物品的投射物组件。
75
+ * @param {Number} [minimumCriticalPower] - 投射物需要蓄力多久才能造成暴击。
76
+ * @param {String} [projectileEntity] - 作为投射物发射的实体名称。
77
+ * @returns {Map} - 新的组件集合。
78
+ */
79
+ static setProjectile(minimumCriticalPower?: number, projectileEntity?: string): Map<any, any>;
80
+ /**
81
+ * 设置物品的使用修饰组件。
82
+ * @param {Number} [movementModifier] - 使用物品时玩家移动速度的缩放值。
83
+ * @param {Number} [useDuration] - 物品使用所需的时间(秒)。
84
+ * @returns {Map} - 新的组件集合。
85
+ */
86
+ static setUseModifiers(movementModifier?: number, useDuration?: number): Map<any, any>;
87
+ /**
88
+ * 设置物品的可穿戴组件。
89
+ * @param {Number} [protection=0] - 物品提供的保护值。
90
+ * @param {String} [slot] - 物品可以穿戴的槽位(如 "head"、"chest" 等)。
91
+ * @returns {Map} - 新的组件集合。
92
+ */
93
+ static setWearable(protection?: number, slot?: string): Map<any, any>;
94
+ /**
95
+ * 设置物品的使用动画组件。
96
+ * @param {String} animation - 物品使用时的动画类型(如 "eat"、"drink" 等)。
97
+ * @returns {Map} - 新的组件集合。
98
+ * @throws {Error} - 如果 animation 不是字符串类型。
99
+ */
100
+ static setUseAnimation(animation: string): Map<any, any>;
101
+ /**
102
+ * 将多个组件集合合并为一个。
103
+ * @param {...Map} componentMaps - 多个组件集合。
104
+ * @returns {Map} - 合并后的组件集合。
105
+ */
106
+ static combineComponents(...componentMaps: Map<any, any>[]): Map<any, any>;
107
+ /**
108
+ * 获取当前组件的 JSON 表示。
109
+ * @param {Map} components - 组件集合。
110
+ * @returns {Object} - 组件的 JSON 对象。
111
+ */
112
+ static toJSON(components: Map<any, any>): Object;
113
+ }