sapdon 3.0.0 → 3.0.2

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 (206) hide show
  1. package/README.md +9 -7
  2. package/doc/cli.md +24 -0
  3. package/doc/sapdon-ts.md +17 -5
  4. package/package.json +2 -2
  5. package/dist/cli/build.d.ts +0 -7
  6. package/dist/cli/build.js +0 -232
  7. package/dist/cli/dev-server/client.d.ts +0 -2
  8. package/dist/cli/dev-server/client.js +0 -20
  9. package/dist/cli/dev-server/config.d.ts +0 -3
  10. package/dist/cli/dev-server/config.js +0 -3
  11. package/dist/cli/dev-server/hmr.d.ts +0 -1
  12. package/dist/cli/dev-server/hmr.js +0 -13
  13. package/dist/cli/dev-server/index.d.ts +0 -3
  14. package/dist/cli/dev-server/index.js +0 -11
  15. package/dist/cli/dev-server/server.d.ts +0 -6
  16. package/dist/cli/dev-server/server.js +0 -50
  17. package/dist/cli/dev-server/syncFiles.d.ts +0 -3
  18. package/dist/cli/dev-server/syncFiles.js +0 -36
  19. package/dist/cli/index.d.ts +0 -1
  20. package/dist/cli/index.js +0 -1
  21. package/dist/cli/init.d.ts +0 -9
  22. package/dist/cli/init.js +0 -80
  23. package/dist/cli/load.d.ts +0 -3
  24. package/dist/cli/load.js +0 -94
  25. package/dist/cli/start.d.ts +0 -2
  26. package/dist/cli/start.js +0 -156
  27. package/dist/cli/tools/textureSet.d.ts +0 -13
  28. package/dist/cli/tools/textureSet.js +0 -103
  29. package/dist/cli/utils.d.ts +0 -13
  30. package/dist/cli/utils.js +0 -89
  31. package/dist/core/addon/biome.d.ts +0 -22
  32. package/dist/core/addon/biome.js +0 -27
  33. package/dist/core/addon/block/block.d.ts +0 -41
  34. package/dist/core/addon/block/block.js +0 -46
  35. package/dist/core/addon/controllers/animationController.d.ts +0 -43
  36. package/dist/core/addon/controllers/animationController.js +0 -73
  37. package/dist/core/addon/entity/clientEntity.d.ts +0 -107
  38. package/dist/core/addon/entity/clientEntity.js +0 -149
  39. package/dist/core/addon/entity/entity.d.ts +0 -42
  40. package/dist/core/addon/entity/entity.js +0 -50
  41. package/dist/core/addon/feature/oreFeature.d.ts +0 -19
  42. package/dist/core/addon/feature/oreFeature.js +0 -24
  43. package/dist/core/addon/featureRule.d.ts +0 -20
  44. package/dist/core/addon/featureRule.js +0 -25
  45. package/dist/core/addon/item/attachable.d.ts +0 -94
  46. package/dist/core/addon/item/attachable.js +0 -134
  47. package/dist/core/addon/item/item.d.ts +0 -19
  48. package/dist/core/addon/item/item.js +0 -26
  49. package/dist/core/addon/manifest.d.ts +0 -49
  50. package/dist/core/addon/manifest.js +0 -65
  51. package/dist/core/addon/menuCategory.d.ts +0 -6
  52. package/dist/core/addon/menuCategory.js +0 -7
  53. package/dist/core/addon/recipe/baseRecipe.d.ts +0 -12
  54. package/dist/core/addon/recipe/baseRecipe.js +0 -23
  55. package/dist/core/addon/recipe/data.d.ts +0 -66
  56. package/dist/core/addon/recipe/data.js +0 -74
  57. package/dist/core/addon/recipe/furnace.d.ts +0 -17
  58. package/dist/core/addon/recipe/furnace.js +0 -43
  59. package/dist/core/addon/recipe/shaped.d.ts +0 -26
  60. package/dist/core/addon/recipe/shaped.js +0 -53
  61. package/dist/core/addon/recipe/shapeless.d.ts +0 -18
  62. package/dist/core/addon/recipe/shapeless.js +0 -36
  63. package/dist/core/biome/biome.d.ts +0 -14
  64. package/dist/core/biome/biome.js +0 -23
  65. package/dist/core/biome/biomeComponent.d.ts +0 -46
  66. package/dist/core/biome/biomeComponent.js +0 -77
  67. package/dist/core/block/basicBlock.d.ts +0 -48
  68. package/dist/core/block/basicBlock.js +0 -105
  69. package/dist/core/block/block.d.ts +0 -32
  70. package/dist/core/block/block.js +0 -92
  71. package/dist/core/block/blockComponent.d.ts +0 -187
  72. package/dist/core/block/blockComponent.js +0 -500
  73. package/dist/core/block/cropBlock.d.ts +0 -4
  74. package/dist/core/block/cropBlock.js +0 -27
  75. package/dist/core/block/geometryBlock.d.ts +0 -12
  76. package/dist/core/block/geometryBlock.js +0 -16
  77. package/dist/core/block/oreBlock.d.ts +0 -9
  78. package/dist/core/block/oreBlock.js +0 -25
  79. package/dist/core/block/rotatableBlock.d.ts +0 -27
  80. package/dist/core/block/rotatableBlock.js +0 -107
  81. package/dist/core/block/tileBlock.d.ts +0 -17
  82. package/dist/core/block/tileBlock.js +0 -125
  83. package/dist/core/entity/basicEntity.d.ts +0 -111
  84. package/dist/core/entity/basicEntity.js +0 -170
  85. package/dist/core/entity/behavior/followMob.d.ts +0 -12
  86. package/dist/core/entity/behavior/followMob.js +0 -35
  87. package/dist/core/entity/behavior/followParent.d.ts +0 -7
  88. package/dist/core/entity/behavior/followParent.js +0 -15
  89. package/dist/core/entity/behavior/randomStroll.d.ts +0 -31
  90. package/dist/core/entity/behavior/randomStroll.js +0 -63
  91. package/dist/core/entity/behavior/tempt.d.ts +0 -73
  92. package/dist/core/entity/behavior/tempt.js +0 -134
  93. package/dist/core/entity/bundles/basicBundle.d.ts +0 -13
  94. package/dist/core/entity/bundles/basicBundle.js +0 -45
  95. package/dist/core/entity/clientEntity.d.ts +0 -20
  96. package/dist/core/entity/clientEntity.js +0 -37
  97. package/dist/core/entity/componets/entityComponet.d.ts +0 -202
  98. package/dist/core/entity/componets/entityComponet.js +0 -347
  99. package/dist/core/entity/data/nativeEntityData.d.ts +0 -9
  100. package/dist/core/entity/data/nativeEntityData.js +0 -38
  101. package/dist/core/entity/entity.d.ts +0 -15
  102. package/dist/core/entity/entity.js +0 -18
  103. package/dist/core/entity/nativeEntity.d.ts +0 -8
  104. package/dist/core/entity/nativeEntity.js +0 -28
  105. package/dist/core/entity/navigation/walk.d.ts +0 -23
  106. package/dist/core/entity/navigation/walk.js +0 -56
  107. package/dist/core/entity/projectile.d.ts +0 -3
  108. package/dist/core/entity/projectile.js +0 -7
  109. package/dist/core/factory/biomeFactory.d.ts +0 -4
  110. package/dist/core/factory/biomeFactory.js +0 -13
  111. package/dist/core/factory/blockFactory.d.ts +0 -34
  112. package/dist/core/factory/blockFactory.js +0 -143
  113. package/dist/core/factory/entityFactory.d.ts +0 -17
  114. package/dist/core/factory/entityFactory.js +0 -75
  115. package/dist/core/factory/featureFactory.d.ts +0 -6
  116. package/dist/core/factory/featureFactory.js +0 -23
  117. package/dist/core/factory/itemExtra.d.ts +0 -8
  118. package/dist/core/factory/itemExtra.js +0 -9
  119. package/dist/core/factory/itemFactory.d.ts +0 -27
  120. package/dist/core/factory/itemFactory.js +0 -112
  121. package/dist/core/factory/recipeFactory.d.ts +0 -18
  122. package/dist/core/factory/recipeFactory.js +0 -39
  123. package/dist/core/factory/uiFactory.d.ts +0 -11
  124. package/dist/core/factory/uiFactory.js +0 -32
  125. package/dist/core/feature/oreFeature.d.ts +0 -10
  126. package/dist/core/feature/oreFeature.js +0 -11
  127. package/dist/core/feature-rule/condition/biomeFilter.d.ts +0 -26
  128. package/dist/core/feature-rule/condition/biomeFilter.js +0 -36
  129. package/dist/core/feature-rule/condition/featureConditions.d.ts +0 -27
  130. package/dist/core/feature-rule/condition/featureConditions.js +0 -37
  131. package/dist/core/feature-rule/distribution/coordinateDistribution.d.ts +0 -17
  132. package/dist/core/feature-rule/distribution/coordinateDistribution.js +0 -23
  133. package/dist/core/feature-rule/distribution/featureDistribution.d.ts +0 -31
  134. package/dist/core/feature-rule/distribution/featureDistribution.js +0 -41
  135. package/dist/core/feature-rule/featureRule.d.ts +0 -17
  136. package/dist/core/feature-rule/featureRule.js +0 -26
  137. package/dist/core/index.d.ts +0 -24
  138. package/dist/core/index.js +0 -21
  139. package/dist/core/item/armor.d.ts +0 -21
  140. package/dist/core/item/armor.js +0 -90
  141. package/dist/core/item/attachable.d.ts +0 -6
  142. package/dist/core/item/attachable.js +0 -26
  143. package/dist/core/item/food.d.ts +0 -24
  144. package/dist/core/item/food.js +0 -38
  145. package/dist/core/item/item.d.ts +0 -36
  146. package/dist/core/item/item.js +0 -69
  147. package/dist/core/item/itemComponents.d.ts +0 -113
  148. package/dist/core/item/itemComponents.js +0 -225
  149. package/dist/core/registry.d.ts +0 -12
  150. package/dist/core/registry.js +0 -16
  151. package/dist/core/texture.d.ts +0 -18
  152. package/dist/core/texture.js +0 -38
  153. package/dist/core/ui/buttonMapping.d.ts +0 -97
  154. package/dist/core/ui/buttonMapping.js +0 -132
  155. package/dist/core/ui/dataBindingObject.d.ts +0 -97
  156. package/dist/core/ui/dataBindingObject.js +0 -134
  157. package/dist/core/ui/elements/button.d.ts +0 -21
  158. package/dist/core/ui/elements/button.js +0 -101
  159. package/dist/core/ui/elements/collectionPanel.d.ts +0 -12
  160. package/dist/core/ui/elements/collectionPanel.js +0 -53
  161. package/dist/core/ui/elements/grid.d.ts +0 -8
  162. package/dist/core/ui/elements/grid.js +0 -33
  163. package/dist/core/ui/elements/image.d.ts +0 -13
  164. package/dist/core/ui/elements/image.js +0 -55
  165. package/dist/core/ui/elements/label.d.ts +0 -14
  166. package/dist/core/ui/elements/label.js +0 -61
  167. package/dist/core/ui/elements/panel.d.ts +0 -11
  168. package/dist/core/ui/elements/panel.js +0 -49
  169. package/dist/core/ui/elements/scrollingPanel.d.ts +0 -14
  170. package/dist/core/ui/elements/scrollingPanel.js +0 -59
  171. package/dist/core/ui/elements/stackPanel.d.ts +0 -14
  172. package/dist/core/ui/elements/stackPanel.js +0 -37
  173. package/dist/core/ui/elements/uiElement.d.ts +0 -53
  174. package/dist/core/ui/elements/uiElement.js +0 -129
  175. package/dist/core/ui/properties/control.d.ts +0 -214
  176. package/dist/core/ui/properties/control.js +0 -286
  177. package/dist/core/ui/properties/dataBinding.d.ts +0 -6
  178. package/dist/core/ui/properties/dataBinding.js +0 -16
  179. package/dist/core/ui/properties/factory.d.ts +0 -37
  180. package/dist/core/ui/properties/factory.js +0 -62
  181. package/dist/core/ui/properties/gridProp.d.ts +0 -65
  182. package/dist/core/ui/properties/gridProp.js +0 -90
  183. package/dist/core/ui/properties/input.d.ts +0 -97
  184. package/dist/core/ui/properties/input.js +0 -134
  185. package/dist/core/ui/properties/layout.d.ts +0 -105
  186. package/dist/core/ui/properties/layout.js +0 -145
  187. package/dist/core/ui/properties/scrollView.d.ts +0 -105
  188. package/dist/core/ui/properties/scrollView.js +0 -145
  189. package/dist/core/ui/properties/sound.d.ts +0 -47
  190. package/dist/core/ui/properties/sound.js +0 -66
  191. package/dist/core/ui/properties/sprite.d.ts +0 -161
  192. package/dist/core/ui/properties/sprite.js +0 -222
  193. package/dist/core/ui/properties/text.d.ts +0 -135
  194. package/dist/core/ui/properties/text.js +0 -187
  195. package/dist/core/ui/registry/uiSystemRegistry.d.ts +0 -8
  196. package/dist/core/ui/registry/uiSystemRegistry.js +0 -26
  197. package/dist/core/ui/systems/chest.d.ts +0 -4
  198. package/dist/core/ui/systems/chest.js +0 -21
  199. package/dist/core/ui/systems/containerUISystem.d.ts +0 -64
  200. package/dist/core/ui/systems/containerUISystem.js +0 -206
  201. package/dist/core/ui/systems/guidebook.d.ts +0 -8
  202. package/dist/core/ui/systems/guidebook.js +0 -206
  203. package/dist/core/ui/systems/serverForm.d.ts +0 -12
  204. package/dist/core/ui/systems/serverForm.js +0 -116
  205. package/dist/core/ui/systems/system.d.ts +0 -16
  206. package/dist/core/ui/systems/system.js +0 -37
@@ -1,113 +0,0 @@
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>): any;
113
- }
@@ -1,225 +0,0 @@
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, damage_chance_min = 0, damage_chance_max = 100) {
10
- return new Map().set("minecraft:durability", {
11
- "damage_chance": {
12
- "min": damage_chance_min,
13
- "max": damage_chance_max
14
- },
15
- "max_durability": max_durability
16
- });
17
- }
18
- static setBlockPlacer(block, replace_block_item, use_on) {
19
- return new Map().set("minecraft:block_placer", {
20
- block: block,
21
- replace_block_item: replace_block_item,
22
- use_on: use_on
23
- });
24
- }
25
- /**
26
- *
27
- * @param {Array} custom_components
28
- * @returns
29
- */
30
- static setCustomComponents(custom_components) {
31
- return new Map().set("minecraft:custom_components", [...custom_components]);
32
- }
33
- /**
34
- * 设置物品的可投掷组件。
35
- * @param {Boolean} doSwingAnimation - 是否使用挥动动画。
36
- * @param {Number} launchPowerScale - 投掷力量的缩放比例。
37
- * @param {Number} maxDrawDuration - 最大蓄力时间。
38
- * @param {Number} maxLaunchPower - 最大投掷力量。
39
- * @param {Number} minDrawDuration - 最小蓄力时间。
40
- * @param {Boolean} scalePowerByDrawDuration - 投掷力量是否随蓄力时间增加。
41
- * @returns {Map} - 新的组件集合。
42
- */
43
- static setThrowable(doSwingAnimation = false, launchPowerScale = 1.0, maxDrawDuration = 0.0, maxLaunchPower = 1.0, minDrawDuration = 0.0, scalePowerByDrawDuration = false) {
44
- return new Map().set("minecraft:throwable", {
45
- do_swing_animation: doSwingAnimation,
46
- launch_power_scale: launchPowerScale,
47
- max_draw_duration: maxDrawDuration,
48
- max_launch_power: maxLaunchPower,
49
- min_draw_duration: minDrawDuration,
50
- scale_power_by_draw_duration: scalePowerByDrawDuration,
51
- });
52
- }
53
- /**
54
- * 设置物品的显示名称。
55
- * @param {String} displayName - 显示名称或本地化键。
56
- * @returns {Map} - 新的组件集合。
57
- */
58
- static setDisplayName(displayName) {
59
- if (typeof displayName !== "string") {
60
- throw new Error('显示名称必须是字符串类型');
61
- }
62
- return new Map().set("minecraft:display_name", { value: displayName });
63
- }
64
- /**
65
- * 设置物品的食物组件。
66
- * @param {Boolean} canAlwaysEat - 是否随时可以食用。
67
- * @param {Number} nutrition - 营养值。
68
- * @param {Number} saturationModifier - 饱和度修正值。
69
- * @param {String} [usingConvertsTo] - 食用后转换的目标物品。
70
- * @returns {Map} - 新的组件集合。
71
- */
72
- static setFoodComponent(canAlwaysEat, nutrition, saturationModifier, usingConvertsTo) {
73
- return new Map().set("minecraft:food", {
74
- can_always_eat: canAlwaysEat,
75
- nutrition: nutrition || 0,
76
- saturation_modifier: saturationModifier || 0.6,
77
- using_converts_to: usingConvertsTo || undefined,
78
- });
79
- }
80
- /**
81
- * 设置物品的燃料组件。
82
- * @param {Number} duration - 燃料燃烧的持续时间(秒),最小值为 0.05。
83
- * @returns {Map} - 新的组件集合。
84
- */
85
- static setFuel(duration) {
86
- if (typeof duration !== "number" || duration < 0.05) {
87
- throw new Error('燃料持续时间必须是一个大于或等于 0.05 的数字');
88
- }
89
- return new Map().set("minecraft:fuel", { duration });
90
- }
91
- /**
92
- * 设置物品的附魔光效组件。
93
- * @param {Boolean} hasGlint - 是否显示附魔光效。
94
- * @returns {Map} - 新的组件集合。
95
- */
96
- static setGlint(hasGlint) {
97
- if (typeof hasGlint !== "boolean") {
98
- throw new Error('附魔光效值必须是布尔类型');
99
- }
100
- return new Map().set("minecraft:glint", hasGlint);
101
- }
102
- /**
103
- * 设置物品的手持渲染方式组件。
104
- * @param {Boolean} isHandEquipped - 是否像工具一样渲染。
105
- * @returns {Map} - 新的组件集合。
106
- */
107
- static setHandEquipped(isHandEquipped) {
108
- if (typeof isHandEquipped !== "boolean") {
109
- throw new Error('手持渲染方式值必须是布尔类型');
110
- }
111
- return new Map().set("minecraft:hand_equipped", isHandEquipped);
112
- }
113
- /**
114
- * 设置物品的图标组件。
115
- * @param {String} texture - 图标纹理名称。
116
- * @returns {Map} - 新的组件集合。
117
- */
118
- static setIcon(texture) {
119
- if (typeof texture !== "string") {
120
- throw new Error('图标纹理必须是字符串类型');
121
- }
122
- return new Map().set("minecraft:icon", texture);
123
- }
124
- /**
125
- * 设置物品的最大堆叠数量组件。
126
- * @param {Number} maxStackSize - 最大堆叠数量,默认值为 64。
127
- * @returns {Map} - 新的组件集合。
128
- */
129
- static setMaxStackSize(maxStackSize = 64) {
130
- if (typeof maxStackSize !== "number" || maxStackSize <= 0 || !Number.isInteger(maxStackSize)) {
131
- throw new Error('最大堆叠数量必须是正整数');
132
- }
133
- return new Map().set("minecraft:max_stack_size", maxStackSize);
134
- }
135
- /**
136
- * 设置物品的投射物组件。
137
- * @param {Number} [minimumCriticalPower] - 投射物需要蓄力多久才能造成暴击。
138
- * @param {String} [projectileEntity] - 作为投射物发射的实体名称。
139
- * @returns {Map} - 新的组件集合。
140
- */
141
- static setProjectile(minimumCriticalPower, projectileEntity) {
142
- const projectileComponent = {};
143
- if (minimumCriticalPower !== undefined) {
144
- if (typeof minimumCriticalPower !== "number" || minimumCriticalPower < 0) {
145
- throw new Error('minimumCriticalPower 必须是非负数');
146
- }
147
- projectileComponent.minimum_critical_power = minimumCriticalPower;
148
- }
149
- if (projectileEntity !== undefined) {
150
- if (typeof projectileEntity !== "string") {
151
- throw new Error('projectileEntity 必须是字符串类型');
152
- }
153
- projectileComponent.projectile_entity = projectileEntity;
154
- }
155
- return new Map().set("minecraft:projectile", projectileComponent);
156
- }
157
- /**
158
- * 设置物品的使用修饰组件。
159
- * @param {Number} [movementModifier] - 使用物品时玩家移动速度的缩放值。
160
- * @param {Number} [useDuration] - 物品使用所需的时间(秒)。
161
- * @returns {Map} - 新的组件集合。
162
- */
163
- static setUseModifiers(movementModifier, useDuration) {
164
- const useModifiersComponent = {};
165
- if (movementModifier !== undefined) {
166
- if (typeof movementModifier !== "number") {
167
- throw new Error('movementModifier 必须是数字类型');
168
- }
169
- useModifiersComponent.movement_modifier = movementModifier;
170
- }
171
- if (useDuration !== undefined) {
172
- if (typeof useDuration !== "number" || useDuration < 0) {
173
- throw new Error('useDuration 必须是非负数');
174
- }
175
- useModifiersComponent.use_duration = useDuration;
176
- }
177
- return new Map().set("minecraft:use_modifiers", useModifiersComponent);
178
- }
179
- /**
180
- * 设置物品的可穿戴组件。
181
- * @param {Number} [protection=0] - 物品提供的保护值。
182
- * @param {String} [slot] - 物品可以穿戴的槽位(如 "head"、"chest" 等)。
183
- * @returns {Map} - 新的组件集合。
184
- */
185
- static setWearable(protection = 0, slot) {
186
- const wearableComponent = { protection };
187
- if (slot !== undefined) {
188
- if (typeof slot !== "string") {
189
- throw new Error('slot 必须是字符串类型');
190
- }
191
- wearableComponent.slot = slot;
192
- }
193
- return new Map().set("minecraft:wearable", wearableComponent);
194
- }
195
- /**
196
- * 设置物品的使用动画组件。
197
- * @param {String} animation - 物品使用时的动画类型(如 "eat"、"drink" 等)。
198
- * @returns {Map} - 新的组件集合。
199
- * @throws {Error} - 如果 animation 不是字符串类型。
200
- */
201
- static setUseAnimation(animation) {
202
- // 检查 animation 是否为字符串
203
- if (typeof animation !== "string") {
204
- throw new Error('animation 必须是字符串类型');
205
- }
206
- // 返回包含动画设置的 Map 对象
207
- return new Map().set("minecraft:use_animation", animation);
208
- }
209
- /**
210
- * 将多个组件集合合并为一个。
211
- * @param {...Map} componentMaps - 多个组件集合。
212
- * @returns {Map} - 合并后的组件集合。
213
- */
214
- static combineComponents(...componentMaps) {
215
- return new Map(componentMaps.flatMap(map => [...map]));
216
- }
217
- /**
218
- * 获取当前组件的 JSON 表示。
219
- * @param {Map} components - 组件集合。
220
- * @returns {Object} - 组件的 JSON 对象。
221
- */
222
- static toJSON(components) {
223
- return Object.fromEntries(components);
224
- }
225
- }
@@ -1,12 +0,0 @@
1
- export class GRegistry {
2
- static dataList: any[];
3
- /**
4
- * 生成注册器
5
- * @param {string} name 文件名字
6
- * @param {string} root 根目录,如 "behavior"、"resource" 等
7
- * @param {string} path 数据的路径,如 "blocks/"、"items/"、"recipes/" 等
8
- * @param {string} data 实例 必须包含 toJson 方法
9
- */
10
- static register(name: string, root: string, path: string, data: string): void;
11
- static getDataList(): any[];
12
- }
@@ -1,16 +0,0 @@
1
- export class GRegistry {
2
- static dataList = [];
3
- /**
4
- * 生成注册器
5
- * @param {string} name 文件名字
6
- * @param {string} root 根目录,如 "behavior"、"resource" 等
7
- * @param {string} path 数据的路径,如 "blocks/"、"items/"、"recipes/" 等
8
- * @param {string} data 实例 必须包含 toJson 方法
9
- */
10
- static register(name, root, path, data) {
11
- GRegistry.dataList.push({ name, root, path, data });
12
- }
13
- static getDataList() {
14
- return [...GRegistry.dataList];
15
- }
16
- }
@@ -1,18 +0,0 @@
1
- export class ItemTextureManager {
2
- static item_texture_sets: Map<any, any>;
3
- static getItemTextureSet(): Map<any, any>;
4
- static getItemTextures(): any;
5
- static registerTextureData(texture_name: any, texture_data: any): void;
6
- static registerTexture(texture_name: any, texture_path: any): void;
7
- }
8
- export class terrainTextureManager {
9
- static terrain_texture_sets: Map<any, any>;
10
- static getTerrainTextureSet(): Map<any, any>;
11
- static getTerrainTextures(): any;
12
- static registerTextureData(texture_name: any, texture_data: any): void;
13
- static registerTexture(texture_name: any, texture_path: any): void;
14
- }
15
- export namespace FlipbookTextures {
16
- let flipbook_textures: any[];
17
- function registerFlipbookTexture(atlas_tile: any, texture: any, ticks_per_frame: any, options?: {}): void;
18
- }
@@ -1,38 +0,0 @@
1
- export class ItemTextureManager {
2
- static item_texture_sets = new Map();
3
- static getItemTextureSet() {
4
- return this.item_texture_sets;
5
- }
6
- static getItemTextures() {
7
- return Object.fromEntries(this.item_texture_sets);
8
- }
9
- static registerTextureData(texture_name, texture_data) {
10
- this.item_texture_sets.set(texture_name, texture_data);
11
- }
12
- static registerTexture(texture_name, texture_path) {
13
- this.registerTextureData(texture_name, { textures: texture_path });
14
- }
15
- }
16
- export class terrainTextureManager {
17
- static terrain_texture_sets = new Map();
18
- static getTerrainTextureSet() {
19
- return this.terrain_texture_sets;
20
- }
21
- static getTerrainTextures() {
22
- return Object.fromEntries(this.terrain_texture_sets);
23
- }
24
- static registerTextureData(texture_name, texture_data) {
25
- this.terrain_texture_sets.set(texture_name, texture_data);
26
- }
27
- static registerTexture(texture_name, texture_path) {
28
- this.registerTextureData(texture_name, { textures: texture_path });
29
- }
30
- }
31
- export const FlipbookTextures = {
32
- flipbook_textures: [],
33
- registerFlipbookTexture(atlas_tile, texture, ticks_per_frame, options = {}) {
34
- const flipbook_texture = { "atlas_tile": atlas_tile, "flipbook_texture": texture, ticks_per_frame };
35
- Object.assign(flipbook_texture, options);
36
- this.flipbook_textures.push(flipbook_texture);
37
- }
38
- };
@@ -1,97 +0,0 @@
1
- /**
2
- * ButtonMapping 类
3
- *
4
- * 该类表示按钮映射配置,用于定义输入事件的映射关系。
5
- *
6
- * 属性:
7
- * - ignored: boolean - 是否忽略映射(默认值:false)
8
- * - from_button_id: string - 触发事件的按钮 ID
9
- * - to_button_id: string - 事件触发时执行的按钮 ID
10
- * - mapping_type: enum - 映射类型(可能值:global, pressed, double_pressed, focused)
11
- * - scope: enum - 映射范围(可能值:view, controller)
12
- * - input_mode_condition: enum - 输入模式条件(可能值:not_gaze, not_gamepad, gamepad_and_not_gaze)
13
- * - ignore_input_scope: boolean - 是否忽略输入范围
14
- * - consume_event: boolean - 是否消耗事件
15
- * - handle_select: boolean - 是否处理选择事件
16
- * - handle_deselect: boolean - 是否处理取消选择事件
17
- * - button_up_right_of_first_refusal: boolean - 是否在首次拒绝后处理按钮释放事件
18
- */
19
- export class ButtonMapping {
20
- ignored: boolean;
21
- from_button_id: string;
22
- to_button_id: string;
23
- mapping_type: string;
24
- scope: string;
25
- input_mode_condition: string;
26
- ignore_input_scope: boolean;
27
- consume_event: boolean;
28
- handle_select: boolean;
29
- handle_deselect: boolean;
30
- button_up_right_of_first_refusal: boolean;
31
- /**
32
- * 设置是否忽略映射。
33
- * @param {boolean} ignored - 是否忽略映射(默认值:false)
34
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
35
- */
36
- setIgnored(ignored?: boolean): ButtonMapping;
37
- /**
38
- * 设置触发事件的按钮 ID。
39
- * @param {string} fromButtonId - 触发事件的按钮 ID
40
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
41
- */
42
- setFromButtonId(fromButtonId: string): ButtonMapping;
43
- /**
44
- * 设置事件触发时执行的按钮 ID。
45
- * @param {string} toButtonId - 事件触发时执行的按钮 ID
46
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
47
- */
48
- setToButtonId(toButtonId: string): ButtonMapping;
49
- /**
50
- * 设置映射类型。
51
- * @param {string} mappingType - 映射类型(可能值:global, pressed, double_pressed, focused)
52
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
53
- */
54
- setMappingType(mappingType: string): ButtonMapping;
55
- /**
56
- * 设置映射范围。
57
- * @param {string} scope - 映射范围(可能值:view, controller)
58
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
59
- */
60
- setScope(scope: string): ButtonMapping;
61
- /**
62
- * 设置输入模式条件。
63
- * @param {string} condition - 输入模式条件(可能值:not_gaze, not_gamepad, gamepad_and_not_gaze)
64
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
65
- */
66
- setInputModeCondition(condition: string): ButtonMapping;
67
- /**
68
- * 设置是否忽略输入范围。
69
- * @param {boolean} ignore - 是否忽略输入范围
70
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
71
- */
72
- setIgnoreInputScope(ignore?: boolean): ButtonMapping;
73
- /**
74
- * 设置是否消耗事件。
75
- * @param {boolean} consume - 是否消耗事件
76
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
77
- */
78
- setConsumeEvent(consume?: boolean): ButtonMapping;
79
- /**
80
- * 设置是否处理选择事件。
81
- * @param {boolean} handle - 是否处理选择事件
82
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
83
- */
84
- setHandleSelect(handle?: boolean): ButtonMapping;
85
- /**
86
- * 设置是否处理取消选择事件。
87
- * @param {boolean} handle - 是否处理取消选择事件
88
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
89
- */
90
- setHandleDeselect(handle?: boolean): ButtonMapping;
91
- /**
92
- * 设置是否在首次拒绝后处理按钮释放事件。
93
- * @param {boolean} handle - 是否处理按钮释放事件
94
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
95
- */
96
- setButtonUpRightOfFirstRefusal(handle?: boolean): ButtonMapping;
97
- }
@@ -1,132 +0,0 @@
1
- /**
2
- * ButtonMapping 类
3
- *
4
- * 该类表示按钮映射配置,用于定义输入事件的映射关系。
5
- *
6
- * 属性:
7
- * - ignored: boolean - 是否忽略映射(默认值:false)
8
- * - from_button_id: string - 触发事件的按钮 ID
9
- * - to_button_id: string - 事件触发时执行的按钮 ID
10
- * - mapping_type: enum - 映射类型(可能值:global, pressed, double_pressed, focused)
11
- * - scope: enum - 映射范围(可能值:view, controller)
12
- * - input_mode_condition: enum - 输入模式条件(可能值:not_gaze, not_gamepad, gamepad_and_not_gaze)
13
- * - ignore_input_scope: boolean - 是否忽略输入范围
14
- * - consume_event: boolean - 是否消耗事件
15
- * - handle_select: boolean - 是否处理选择事件
16
- * - handle_deselect: boolean - 是否处理取消选择事件
17
- * - button_up_right_of_first_refusal: boolean - 是否在首次拒绝后处理按钮释放事件
18
- */
19
- export class ButtonMapping {
20
- constructor() {
21
- this.ignored = false;
22
- this.from_button_id = '';
23
- this.to_button_id = '';
24
- this.mapping_type = null;
25
- this.scope = null;
26
- this.input_mode_condition = null;
27
- this.ignore_input_scope = false;
28
- this.consume_event = false;
29
- this.handle_select = false;
30
- this.handle_deselect = false;
31
- this.button_up_right_of_first_refusal = false;
32
- }
33
- /**
34
- * 设置是否忽略映射。
35
- * @param {boolean} ignored - 是否忽略映射(默认值:false)
36
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
37
- */
38
- setIgnored(ignored = false) {
39
- this.ignored = ignored;
40
- return this;
41
- }
42
- /**
43
- * 设置触发事件的按钮 ID。
44
- * @param {string} fromButtonId - 触发事件的按钮 ID
45
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
46
- */
47
- setFromButtonId(fromButtonId) {
48
- this.from_button_id = fromButtonId;
49
- return this;
50
- }
51
- /**
52
- * 设置事件触发时执行的按钮 ID。
53
- * @param {string} toButtonId - 事件触发时执行的按钮 ID
54
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
55
- */
56
- setToButtonId(toButtonId) {
57
- this.to_button_id = toButtonId;
58
- return this;
59
- }
60
- /**
61
- * 设置映射类型。
62
- * @param {string} mappingType - 映射类型(可能值:global, pressed, double_pressed, focused)
63
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
64
- */
65
- setMappingType(mappingType) {
66
- this.mapping_type = mappingType;
67
- return this;
68
- }
69
- /**
70
- * 设置映射范围。
71
- * @param {string} scope - 映射范围(可能值:view, controller)
72
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
73
- */
74
- setScope(scope) {
75
- this.scope = scope;
76
- return this;
77
- }
78
- /**
79
- * 设置输入模式条件。
80
- * @param {string} condition - 输入模式条件(可能值:not_gaze, not_gamepad, gamepad_and_not_gaze)
81
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
82
- */
83
- setInputModeCondition(condition) {
84
- this.input_mode_condition = condition;
85
- return this;
86
- }
87
- /**
88
- * 设置是否忽略输入范围。
89
- * @param {boolean} ignore - 是否忽略输入范围
90
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
91
- */
92
- setIgnoreInputScope(ignore = false) {
93
- this.ignore_input_scope = ignore;
94
- return this;
95
- }
96
- /**
97
- * 设置是否消耗事件。
98
- * @param {boolean} consume - 是否消耗事件
99
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
100
- */
101
- setConsumeEvent(consume = false) {
102
- this.consume_event = consume;
103
- return this;
104
- }
105
- /**
106
- * 设置是否处理选择事件。
107
- * @param {boolean} handle - 是否处理选择事件
108
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
109
- */
110
- setHandleSelect(handle = false) {
111
- this.handle_select = handle;
112
- return this;
113
- }
114
- /**
115
- * 设置是否处理取消选择事件。
116
- * @param {boolean} handle - 是否处理取消选择事件
117
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
118
- */
119
- setHandleDeselect(handle = false) {
120
- this.handle_deselect = handle;
121
- return this;
122
- }
123
- /**
124
- * 设置是否在首次拒绝后处理按钮释放事件。
125
- * @param {boolean} handle - 是否处理按钮释放事件
126
- * @returns {ButtonMapping} 返回当前实例以支持链式调用
127
- */
128
- setButtonUpRightOfFirstRefusal(handle = false) {
129
- this.button_up_right_of_first_refusal = handle;
130
- return this;
131
- }
132
- }