sapdon 3.2.2 → 3.3.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 (68) hide show
  1. package/README.md +245 -121
  2. package/doc/dev/architecture.md +415 -0
  3. package/doc/dev/cli.md +467 -0
  4. package/doc/dev/core.md +717 -0
  5. package/doc/dev/oc.md +582 -0
  6. package/doc/user/api/biome.md +558 -0
  7. package/doc/user/api/block.md +945 -0
  8. package/doc/user/api/entity.md +685 -0
  9. package/doc/user/api/extra.md +231 -0
  10. package/doc/user/api/item.md +896 -0
  11. package/doc/user/api/recipe.md +427 -0
  12. package/doc/user/api/texture.md +181 -0
  13. package/doc/user/config/build-config.md +84 -0
  14. package/doc/user/config/mod-info.md +33 -0
  15. package/doc/user/faq.md +160 -0
  16. package/doc/user/quick-start.md +108 -0
  17. package/doc/user/tutorials/block.md +463 -0
  18. package/doc/user/tutorials/entity.md +356 -0
  19. package/doc/user/tutorials/item.md +449 -0
  20. package/doc/user/tutorials/recipe.md +278 -0
  21. package/package.json +4 -3
  22. package/prod/cli/index.js +1 -1
  23. package/prod/cli/start.js +1 -1458
  24. package/prod/core/index.d.ts +3290 -2150
  25. package/prod/core/index.js +1 -59015
  26. package/prod/core/package.json +7 -0
  27. package/prod/oc/index.d.ts +348 -108
  28. package/prod/oc/index.js +1 -1
  29. package/prod/oc/package.json +7 -0
  30. package/prod/utils/index.d.ts +20 -2
  31. package/prod/utils/index.js +1 -1
  32. package/prod/utils/package.json +7 -0
  33. package/doc/BlockAPI.md +0 -145
  34. package/doc/api.md +0 -128
  35. package/doc/oc/index.md +0 -0
  36. package/doc/sapdon-ts.md +0 -64
  37. package/src/templates/js_sapdon/build.config +0 -23
  38. package/src/templates/js_sapdon/main.mjs +0 -4
  39. package/src/templates/js_sapdon/mod.info +0 -7
  40. package/src/templates/js_sapdon/pack_icon.png +0 -0
  41. package/src/templates/js_sapdon/package.json +0 -20
  42. package/src/templates/js_sapdon/res/animations/animation_item.animation.json +0 -34
  43. package/src/templates/js_sapdon/res/animations/large_item.animation.json +0 -27
  44. package/src/templates/js_sapdon/res/models/blocks/crop.geo.json +0 -48
  45. package/src/templates/js_sapdon/res/models/entity/animation/animation_item.geo.json +0 -26
  46. package/src/templates/js_sapdon/res/models/entity/animation/large_item.geo.json +0 -28
  47. package/src/templates/js_sapdon/res/textures/blocks/none.png +0 -0
  48. package/src/templates/js_sapdon/res/textures/blocks/test_log_oak.png +0 -0
  49. package/src/templates/js_sapdon/res/textures/blocks/test_log_top.png +0 -0
  50. package/src/templates/js_sapdon/res/textures/items/masterball.png +0 -0
  51. package/src/templates/js_sapdon/scripts/custom_components/cropComponent.js +0 -50
  52. package/src/templates/js_sapdon/scripts/custom_components/items/gui_book.js +0 -37
  53. package/src/templates/js_sapdon/scripts/custom_components/registry.js +0 -25
  54. package/src/templates/js_sapdon/scripts/index.js +0 -0
  55. package/src/templates/ts_sapdon/build.config +0 -23
  56. package/src/templates/ts_sapdon/main.ts +0 -11
  57. package/src/templates/ts_sapdon/mod.info +0 -7
  58. package/src/templates/ts_sapdon/pack_icon.png +0 -0
  59. package/src/templates/ts_sapdon/package.json +0 -20
  60. package/src/templates/ts_sapdon/res/models/blocks/crop.geo.json +0 -48
  61. package/src/templates/ts_sapdon/res/textures/blocks/test_log_oak.png +0 -0
  62. package/src/templates/ts_sapdon/res/textures/blocks/test_log_top.png +0 -0
  63. package/src/templates/ts_sapdon/res/textures/items/masterball.png +0 -0
  64. package/src/templates/ts_sapdon/scripts/components/cropComponent.ts +0 -44
  65. package/src/templates/ts_sapdon/scripts/components/items/guiBook.ts +0 -36
  66. package/src/templates/ts_sapdon/scripts/components/registry.ts +0 -24
  67. package/src/templates/ts_sapdon/scripts/index.ts +0 -7
  68. package/src/templates/ts_sapdon/tsconfig.json +0 -117
@@ -0,0 +1,427 @@
1
+ # 配方系统 API 参考
2
+
3
+ ---
4
+
5
+ ## RecipeAPI
6
+
7
+ 工厂函数集合,用于创建各类配方并自动注册到游戏系统。
8
+
9
+ ```typescript
10
+ import { RecipeAPI, registry } from '@sapdon/core'
11
+ ```
12
+
13
+ 所有注册器方法均返回配方实例,支持链式调用。完成后调用 `registry.submit()` 提交数据。
14
+
15
+ ---
16
+
17
+ ### registerSimpleFurnace
18
+
19
+ 快速创建熔炉配方(自动设置 `furnace` 标签)。
20
+
21
+ ```typescript
22
+ RecipeAPI.registerSimpleFurnace(
23
+ identifier: string,
24
+ output: string,
25
+ input: string
26
+ ): AddonRecipeFurnace
27
+ ```
28
+
29
+ **示例**
30
+
31
+ ```typescript
32
+ RecipeAPI.registerSimpleFurnace('sapdon:smelt_ore', 'minecraft:iron_ingot', 'minecraft:iron_ore')
33
+ ```
34
+
35
+ ---
36
+
37
+ ### registerFurnace
38
+
39
+ 创建熔炉配方实例,返回 `AddonRecipeFurnace` 用于链式配置。
40
+
41
+ ```typescript
42
+ RecipeAPI.registerFurnace(identifier: string): AddonRecipeFurnace
43
+ ```
44
+
45
+ **示例**
46
+
47
+ ```typescript
48
+ RecipeAPI.registerFurnace('sapdon:smelt_gold')
49
+ .input('minecraft:gold_ore', 0, 1)
50
+ .output('minecraft:gold_ingot')
51
+ .tags(['furnace'])
52
+ ```
53
+
54
+ ---
55
+
56
+ ### registerSimpleShaped
57
+
58
+ 快速创建有序工作台配方(自动设置 `crafting_table` 标签)。
59
+
60
+ ```typescript
61
+ RecipeAPI.registerSimpleShaped(
62
+ identifier: string,
63
+ output: string,
64
+ pattern: string[],
65
+ key: Record<string, any>
66
+ ): AddonRecipeShaped
67
+ ```
68
+
69
+ **示例**
70
+
71
+ ```typescript
72
+ RecipeAPI.registerSimpleShaped(
73
+ 'sapdon:sword',
74
+ 'sapdon:sword',
75
+ [' X ', ' X ', ' Y '],
76
+ { X: { item: 'minecraft:iron_ingot' }, Y: { item: 'minecraft:stick' } }
77
+ )
78
+ ```
79
+
80
+ ---
81
+
82
+ ### registerShaped
83
+
84
+ 创建有序配方实例,返回 `AddonRecipeShaped` 用于链式配置。
85
+
86
+ ```typescript
87
+ RecipeAPI.registerShaped(identifier: string): AddonRecipeShaped
88
+ ```
89
+
90
+ **示例**
91
+
92
+ ```typescript
93
+ RecipeAPI.registerShaped('sapdon:armor')
94
+ .key({ X: { item: 'minecraft:diamond' } })
95
+ .pattern(['XXX', 'X X', ' '])
96
+ .output({ item: 'sapdon:armor', count: 1 })
97
+ .tags(['crafting_table'])
98
+ ```
99
+
100
+ ---
101
+
102
+ ### registerSimpleShapeless
103
+
104
+ 快速创建无序工作台配方(自动设置 `crafting_table` 标签)。
105
+
106
+ ```typescript
107
+ RecipeAPI.registerSimpleShapeless(
108
+ identifier: string,
109
+ output: string,
110
+ ingredients: any[]
111
+ ): AddonRecipeShapeless
112
+ ```
113
+
114
+ **示例**
115
+
116
+ ```typescript
117
+ RecipeAPI.registerSimpleShapeless(
118
+ 'sapdon:alloy',
119
+ 'sapdon:alloy_ingot',
120
+ [{ item: 'minecraft:iron_ingot' }, { item: 'minecraft:gold_ingot' }]
121
+ )
122
+ ```
123
+
124
+ ---
125
+
126
+ ### registerShapeless
127
+
128
+ 创建无序配方实例,返回 `AddonRecipeShapeless` 用于链式配置。
129
+
130
+ ```typescript
131
+ RecipeAPI.registerShapeless(identifier: string): AddonRecipeShapeless
132
+ ```
133
+
134
+ **示例**
135
+
136
+ ```typescript
137
+ RecipeAPI.registerShapeless('sapdon:mixture')
138
+ .ingredients([{ item: 'minecraft:diamond' }, { item: 'minecraft:emerald' }])
139
+ .output({ item: 'sapdon:mixture', count: 2 })
140
+ .tags(['crafting_table'])
141
+ ```
142
+
143
+ ---
144
+
145
+ ## AddonRecipe 基类
146
+
147
+ 所有配方类型继承自 `AddonRecipe`。
148
+
149
+ ```typescript
150
+ import { AddonRecipe } from '@sapdon/core'
151
+ ```
152
+
153
+ ### 方法
154
+
155
+ | 方法 | 返回 | 说明 |
156
+ |------|------|------|
157
+ | `identifier(id: string)` | `this` | 设置配方标识符 |
158
+ | `tags(tags: string[])` | `this` | 设置配方标签数组(覆盖) |
159
+ | `getId(): string` | `string` | 获取配方标识符 |
160
+
161
+ ---
162
+
163
+ ## AddonRecipeShaped
164
+
165
+ 有序配方类,继承自 `AddonRecipe`。
166
+
167
+ ```typescript
168
+ import { AddonRecipeShaped } from '@sapdon/core'
169
+ ```
170
+
171
+ ### 方法
172
+
173
+ | 方法 | 返回 | 说明 |
174
+ |------|------|------|
175
+ | `assumeSymmetry(): void` | 无 | 启用对称假设,未定义键的字符自动视为相同 |
176
+ | `key(key: Record<string, any>)` | `this` | 设置字符到物品的键映射 |
177
+ | `pattern(pattern: string[])` | `this` | 设置 3 行图案数组 |
178
+ | `priority(priority: number)` | `this` | 设置优先级(数值越小优先级越高) |
179
+ | `output(item: string \| object)` | `this` | 设置输出,支持字符串或 `{ item, count }` |
180
+ | `tags(tags: string[])` | `this` | 继承自 `AddonRecipe`,设置配方标签 |
181
+
182
+ **示例**
183
+
184
+ ```typescript
185
+ const recipe = new AddonRecipeShaped_1_20()
186
+ recipe
187
+ .identifier('sapdon:example')
188
+ .key({ A: { item: 'minecraft:iron_ingot' } })
189
+ .pattern(['AAA', 'A A', 'AAA'])
190
+ .output({ item: 'sapdon:example', count: 8 })
191
+ .assumeSymmetry()
192
+ .tags(['crafting_table'])
193
+ ```
194
+
195
+ ### 版本化类
196
+
197
+ | 类 | format_version |
198
+ |------|------|
199
+ | `AddonRecipeShaped_1_12` | `1.12` |
200
+ | `AddonRecipeShaped_1_17` | `1.17` |
201
+ | `AddonRecipeShaped_1_19` | `1.19` |
202
+ | `AddonRecipeShaped_1_20` | `1.20` |
203
+
204
+ ---
205
+
206
+ ## AddonRecipeShapeless
207
+
208
+ 无序配方类,继承自 `AddonRecipe`。
209
+
210
+ ```typescript
211
+ import { AddonRecipeShapeless } from '@sapdon/core'
212
+ ```
213
+
214
+ ### 方法
215
+
216
+ | 方法 | 返回 | 说明 |
217
+ |------|------|------|
218
+ | `static create(ver, def)` | `AddonRecipeShapeless` | 静态工厂方法 |
219
+ | `priority(priority: number)` | `this` | 设置优先级 |
220
+ | `ingredients(ingredients: any[])` | `this` | 设置原料数组 |
221
+ | `output(item: string \| object)` | `this` | 设置输出,支持字符串或 `{ item, count }` |
222
+ | `tags(tags: string[])` | `this` | 继承自 `AddonRecipe`,设置配方标签 |
223
+
224
+ **示例**
225
+
226
+ ```typescript
227
+ const recipe = new AddonRecipeShapeless_1_17()
228
+ recipe
229
+ .identifier('sapdon:example')
230
+ .ingredients([
231
+ { item: 'minecraft:iron_ingot' },
232
+ { tag: 'minecraft:planks' }
233
+ ])
234
+ .output({ item: 'sapdon:example', count: 4 })
235
+ .tags(['crafting_table'])
236
+ ```
237
+
238
+ ### 版本化类
239
+
240
+ | 类 | format_version |
241
+ |------|------|
242
+ | `AddonRecipeShapeless_1_12` | `1.12` |
243
+ | `AddonRecipeShapeless_1_17` | `1.17` |
244
+
245
+ ---
246
+
247
+ ## AddonRecipeFurnace
248
+
249
+ 熔炉配方类,继承自 `AddonRecipe`。
250
+
251
+ ```typescript
252
+ import { AddonRecipeFurnace } from '@sapdon/core'
253
+ ```
254
+
255
+ ### 方法
256
+
257
+ | 方法 | 返回 | 说明 |
258
+ |------|------|------|
259
+ | `static create(ver, def)` | `AddonRecipeFurnace` | 静态工厂方法 |
260
+ | `input(item: string, data?, count?)` | `this` | 设置输入物品,可选副损伤值(data)和数量 |
261
+ | `output(item: string)` | `this` | 设置输出物品 |
262
+ | `tags(tags: string[])` | `this` | 继承自 `AddonRecipe`,设置配方标签 |
263
+
264
+ **示例**
265
+
266
+ ```typescript
267
+ const recipe = new AddonRecipeFurnace_1_17()
268
+ recipe
269
+ .identifier('sapdon:smelt_ore')
270
+ .input('minecraft:iron_ore', 0)
271
+ .output('minecraft:iron_ingot')
272
+ .tags(['furnace'])
273
+ ```
274
+
275
+ ### 版本化类
276
+
277
+ | 类 | format_version |
278
+ |------|------|
279
+ | `AddonRecipeFurnace_1_12` | `1.12` |
280
+ | `AddonRecipeFurnace_1_17` | `1.17` |
281
+
282
+ ---
283
+
284
+ ## RecipeTags
285
+
286
+ 配方标签常量,用于指定配方适用的方块。
287
+
288
+ ```typescript
289
+ import { RecipeTags } from '@sapdon/core'
290
+ ```
291
+
292
+ | 常量 | 值 | 说明 |
293
+ |------|-----|------|
294
+ | `RecipeTags.Furnace` | `"furnace"` | 熔炉配方 |
295
+ | `RecipeTags.smoker` | `"smoker"` | 烟熏炉配方 |
296
+ | `RecipeTags.Campfire` | `"campfire"` | 篝火烹饪配方 |
297
+ | `RecipeTags.SoulCampfire` | `"soul_campfire"` | 灵魂篝火烹饪配方 |
298
+ | `RecipeTags.CraftingTable` | `"crafting_table"` | 工作台合成配方 |
299
+
300
+ > 注意:`RecipeTags.smoker` 首字母小写,与其余常量命名不一致。
301
+
302
+ **示例**
303
+
304
+ ```typescript
305
+ // 同时适用于熔炉和烟熏炉
306
+ recipe.tags([RecipeTags.Furnace, RecipeTags.smoker])
307
+ ```
308
+
309
+ ---
310
+
311
+ ## RecipeInputTags
312
+
313
+ 物品输入标签常量,用于原料的 `tag` 字段实现宽匹配。
314
+
315
+ ```typescript
316
+ import { RecipeInputTags } from '@sapdon/core'
317
+ ```
318
+
319
+ | 常量 | 值 | 说明 |
320
+ |------|-----|------|
321
+ | `RecipeInputTags.Armor` | `"minecraft:is_armor"` | 盔甲类物品 |
322
+ | `RecipeInputTags.Arrows` | `"minecraft:arrow"` | 箭 |
323
+ | `RecipeInputTags.Banners` | `"minecraft:banner"` | 旗帜 |
324
+ | `RecipeInputTags.Boats` | `"minecraft:boats"` | 船 |
325
+ | `RecipeInputTags.BookshelfBooks` | `"minecraft:bookshelf_books"` | 书架用书 |
326
+ | `RecipeInputTags.ChainmailTier` | `"minecraft:chainmail_tier"` | 锁链级装备 |
327
+ | `RecipeInputTags.ChestBoat` | `"minecraft:chest_boat"` | 带箱子的船 |
328
+ | `RecipeInputTags.Coals` | `"minecraft:coals"` | 煤炭类 |
329
+ | `RecipeInputTags.Cooked` | `"minecraft:is_cooked"` | 已烹饪食物 |
330
+ | `RecipeInputTags.CrimsonStems` | `"minecraft:crimson_stems"` | 绯红菌柄 |
331
+ | `RecipeInputTags.DiamondTier` | `"minecraft:diamond_tier"` | 钻石级装备 |
332
+ | `RecipeInputTags.Digger` | `"minecraft:digger"` | 挖掘工具 |
333
+ | `RecipeInputTags.Door` | `"minecraft:door"` | 门 |
334
+ | `RecipeInputTags.Fish` | `"minecraft:is_fish"` | 鱼类 |
335
+ | `RecipeInputTags.Food` | `"minecraft:is_food"` | 食物类 |
336
+ | `RecipeInputTags.GoldenTier` | `"minecraft:golden_tier"` | 金质装备 |
337
+ | `RecipeInputTags.HangingActor` | `"minecraft:hanging_actor"` | 悬挂实体 |
338
+ | `RecipeInputTags.HangingSign` | `"minecraft:hanging_sign"` | 悬挂告示牌 |
339
+ | `RecipeInputTags.Hatchet` | `"minecraft:is_axe"` | 斧 |
340
+ | `RecipeInputTags.Hoe` | `"minecraft:is_hoe"` | 锄 |
341
+ | `RecipeInputTags.HorseArmor` | `"minecraft:horse_armor"` | 马铠 |
342
+ | `RecipeInputTags.IronTier` | `"minecraft:iron_tier"` | 铁质装备 |
343
+ | `RecipeInputTags.LeatherTier` | `"minecraft:leather_tier"` | 皮革装备 |
344
+ | `RecipeInputTags.LecternBooks` | `"minecraft:lectern_books"` | 讲台用书 |
345
+ | `RecipeInputTags.Logs` | `"minecraft:logs"` | 原木类 |
346
+ | `RecipeInputTags.LogsThatBurn` | `"minecraft:logs_that_burn"` | 可燃原木 |
347
+ | `RecipeInputTags.MangroveLogs` | `"minecraft:mangrove_logs"` | 红树木 |
348
+ | `RecipeInputTags.Meat` | `"minecraft:is_meat"` | 肉类 |
349
+ | `RecipeInputTags.Minecart` | `"minecraft:is_minecart"` | 矿车 |
350
+ | `RecipeInputTags.MusicDiscs` | `"minecraft:music_disc"` | 唱片 |
351
+ | `RecipeInputTags.NetheriteTier` | `"minecraft:netherite_tier"` | 下界合金级装备 |
352
+ | `RecipeInputTags.Pickaxe` | `"minecraft:is_pickaxe"` | 镐 |
353
+ | `RecipeInputTags.PiglinLoved` | `"minecraft:piglin_loved"` | 猪灵喜爱物品 |
354
+ | `RecipeInputTags.PiglinRepellents` | `"minecraft:piglin_repellents"` | 猪灵驱退物品 |
355
+ | `RecipeInputTags.Planks` | `"minecraft:planks"` | 木板 |
356
+ | `RecipeInputTags.Sand` | `"minecraft:sand"` | 沙子 |
357
+ | `RecipeInputTags.Shovel` | `"minecraft:is_shovel"` | 锹 |
358
+ | `RecipeInputTags.Sign` | `"minecraft:sign"` | 告示牌 |
359
+ | `RecipeInputTags.SoulFireBaseBlocks` | `"minecraft:soul_fire_base_blocks"` | 灵魂火基底 |
360
+ | `RecipeInputTags.SpawnEgg` | `"minecraft:spawn_egg"` | 刷怪蛋 |
361
+ | `RecipeInputTags.StoneBricks` | `"minecraft:stone_bricks"` | 石砖 |
362
+ | `RecipeInputTags.StoneCraftingMaterials` | `"minecraft:stone_crafting_materials"` | 石质合成材料 |
363
+ | `RecipeInputTags.StoneTier` | `"minecraft:stone_tier"` | 石质装备 |
364
+ | `RecipeInputTags.StoneToolMaterials` | `"minecraft:stone_tool_materials"` | 石质工具材料 |
365
+ | `RecipeInputTags.Sword` | `"minecraft:is_sword"` | 剑 |
366
+ | `RecipeInputTags.Tool` | `"minecraft:is_tool"` | 工具 |
367
+ | `RecipeInputTags.VibrationDamper` | `"minecraft:vibration_damper"` | 振动阻尼 |
368
+ | `RecipeInputTags.WarpedStems` | `"minecraft:warped_stems"` | 诡异菌柄 |
369
+ | `RecipeInputTags.WoodenSlabs` | `"minecraft:wooden_slabs"` | 木台阶 |
370
+ | `RecipeInputTags.WoodenTier` | `"minecraft:wooden_tier"` | 木质装备 |
371
+ | `RecipeInputTags.Wool` | `"minecraft:wool"` | 羊毛 |
372
+
373
+ **示例**
374
+
375
+ ```typescript
376
+ import { RecipeAPI, registry, RecipeInputTags } from '@sapdon/core'
377
+
378
+ // 使用标签匹配所有木板
379
+ RecipeAPI.registerShapeless('sapdon:framed_plank')
380
+ .ingredients([
381
+ { tag: RecipeInputTags.Planks },
382
+ { tag: RecipeInputTags.Planks },
383
+ { tag: RecipeInputTags.Planks }
384
+ ])
385
+ .output('sapdon:framed_plank')
386
+ .tags(['crafting_table'])
387
+ ```
388
+
389
+ ---
390
+
391
+ ## 类型汇总
392
+
393
+ ```typescript
394
+ // 工厂
395
+ RecipeAPI.registerSimpleFurnace(id, output, input)
396
+ RecipeAPI.registerFurnace(id)
397
+ RecipeAPI.registerSimpleShaped(id, output, pattern, key)
398
+ RecipeAPI.registerShaped(id)
399
+ RecipeAPI.registerSimpleShapeless(id, output, ingredients)
400
+ RecipeAPI.registerShapeless(id)
401
+
402
+ // 有序配方
403
+ class AddonRecipeShaped extends AddonRecipe
404
+ assumeSymmetry(): void
405
+ key(map): this
406
+ pattern(rows): this
407
+ priority(num): this
408
+ output(item): this
409
+ tags(tags[]): this // 继承
410
+
411
+ // 无序配方
412
+ class AddonRecipeShapeless extends AddonRecipe
413
+ priority(num): this
414
+ ingredients(items): this
415
+ output(item): this
416
+ tags(tags[]): this // 继承
417
+
418
+ // 熔炉配方
419
+ class AddonRecipeFurnace extends AddonRecipe
420
+ input(item, data?, count?): this
421
+ output(item): this
422
+ tags(tags[]): this // 继承
423
+
424
+ // 标签常量
425
+ RecipeTags = { Furnace, smoker, Campfire, SoulCampfire, CraftingTable }
426
+ RecipeInputTags = { Armor, Food, Logs, Planks, ... }
427
+ ```
@@ -0,0 +1,181 @@
1
+ # 纹理系统 API 参考
2
+
3
+ 本文档涵盖 Sapdon 框架的纹理系统 API,包括物品纹理、方块纹理和翻书纹理(Flipbook Textures)。
4
+
5
+ ---
6
+
7
+ ## ItemTextureManager
8
+
9
+ 物品纹理管理器,用于注册和管理物品纹理。所有方法均为静态方法。
10
+
11
+ ### 方法
12
+
13
+ #### `ItemTextureManager.registerTexture(name, path)`
14
+
15
+ 注册一个物品纹理。
16
+
17
+ | 参数 | 类型 | 说明 |
18
+ |------|------|------|
19
+ | `name` | `string` | 纹理名称,如 `"masterball"` |
20
+ | `path` | `string` | 纹理路径,如 `"textures/items/masterball"` |
21
+
22
+ ```javascript
23
+ import { ItemTextureManager } from "@sapdon/core";
24
+
25
+ ItemTextureManager.registerTexture("masterball", "textures/items/masterball");
26
+ ItemTextureManager.registerTexture("ruby_sword", "textures/items/ruby_sword");
27
+ ```
28
+
29
+ #### `ItemTextureManager.registerTextureData(name, data)`
30
+
31
+ 注册一个带有完整数据结构的物品纹理,允许传入包含 `textures` 字段的对象。
32
+
33
+ | 参数 | 类型 | 说明 |
34
+ |------|------|------|
35
+ | `name` | `string` | 纹理名称 |
36
+ | `data` | `object` | 纹理数据对象,至少包含 `{ textures: string \| string[] }` |
37
+
38
+ ```javascript
39
+ ItemTextureManager.registerTextureData("ruby_ingot", {
40
+ textures: "textures/items/ruby_ingot"
41
+ });
42
+ ```
43
+
44
+ #### `ItemTextureManager.getItemTextures()`
45
+
46
+ 返回所有已注册的物品纹理的键值对对象。等价于 `Object.fromEntries(item_texture_sets)`。
47
+
48
+ ```javascript
49
+ const textures = ItemTextureManager.getItemTextures();
50
+ // 输出: { masterball: { textures: "textures/items/masterball" }, ... }
51
+ ```
52
+
53
+ #### `ItemTextureManager.toObject()`
54
+
55
+ 与 `getItemTextures()` 行为相同,返回当前所有已注册纹理的纯对象表示。
56
+
57
+ ```javascript
58
+ const obj = ItemTextureManager.toObject();
59
+ ```
60
+
61
+ ### 自动注册
62
+
63
+ 每次调用 `registerTexture` 或 `registerTextureData` 时,会自动调用 `GRegistry.register("item_texture", "resource", "textures/", this)`,将当前管理器注册到全局注册表中。当执行 `registry.submit()` 时,框架会调用 `toObject()` 获取最终数据并生成 JSON 文件。
64
+
65
+ ---
66
+
67
+ ## TerrainTextureManager
68
+
69
+ 方块纹理管理器,用于注册和管理方块(地形)纹理。API 与 `ItemTextureManager` 完全一致。
70
+
71
+ ### 方法
72
+
73
+ #### `TerrainTextureManager.registerTexture(name, path)`
74
+
75
+ 注册一个方块纹理。
76
+
77
+ ```javascript
78
+ import { TerrainTextureManager } from "@sapdon/core";
79
+
80
+ TerrainTextureManager.registerTexture("ruby_block", "textures/blocks/ruby_block");
81
+ TerrainTextureManager.registerTexture("ruby_ore", "textures/blocks/ruby_ore");
82
+ ```
83
+
84
+ #### `TerrainTextureManager.registerTextureData(name, data)`
85
+
86
+ 注册一个带有完整数据结构的方块纹理。
87
+
88
+ ```javascript
89
+ TerrainTextureManager.registerTextureData("sapdon_stone", {
90
+ textures: "textures/blocks/sapdon_stone"
91
+ });
92
+ ```
93
+
94
+ #### `TerrainTextureManager.getTerrainTextures()`
95
+
96
+ 返回所有已注册的方块纹理键值对对象。
97
+
98
+ #### `TerrainTextureManager.toObject()`
99
+
100
+ 返回当前所有已注册方块纹理的纯对象表示。
101
+
102
+ ---
103
+
104
+ ## FlipbookTextures
105
+
106
+ 翻书纹理管理器,用于注册动画纹理(逐帧切换的纹理)。它是一个纯对象,不是类。
107
+
108
+ ### 方法
109
+
110
+ #### `FlipbookTextures.registerFlipbookTexture(atlas_tile, texture, ticks_per_frame, options)`
111
+
112
+ 注册一个翻书纹理。
113
+
114
+ | 参数 | 类型 | 说明 |
115
+ |------|------|------|
116
+ | `atlas_tile` | `string` | 对应的图块名称,与方块纹理名称对应 |
117
+ | `texture` | `string` | 翻书纹理路径 |
118
+ | `ticks_per_frame` | `number` | 每帧持续的 tick 数(20 ticks = 1 秒) |
119
+ | `options` | `object` | 可选参数,会被合并到纹理对象中 |
120
+
121
+ 可选参数 `options` 包含的字段(对应 Minecraft 的 `flipbook_textures.json`):
122
+
123
+ | 字段 | 类型 | 说明 |
124
+ |------|------|------|
125
+ | `atlas_index` | `number` | 纹理图集中的索引 |
126
+ | `atlas_tile_variant` | `number` | 图块变体 |
127
+ | `replicate` | `number` | 复制次数 |
128
+ | `blend_frames` | `boolean` | 是否混合帧过渡 |
129
+
130
+ ```javascript
131
+ import { FlipbookTextures } from "@sapdon/core";
132
+
133
+ FlipbookTextures.registerFlipbookTexture(
134
+ "sapdon_lamp",
135
+ "textures/blocks/sapdon_lamp_animated",
136
+ 4,
137
+ { blend_frames: true }
138
+ );
139
+ ```
140
+
141
+ #### `FlipbookTextures.toObject()`
142
+
143
+ 返回翻书纹理数组。
144
+
145
+ ```javascript
146
+ const flipbookData = FlipbookTextures.toObject();
147
+ // 输出: [ { atlas_tile: "sapdon_lamp", flipbook_texture: "textures/blocks/sapdon_lamp_animated", ticks_per_frame: 4, blend_frames: true } ]
148
+ ```
149
+
150
+ ---
151
+
152
+ ## 与 GRegistry 的集成
153
+
154
+ 所有纹理管理器在调用注册方法时,会自动调用 `GRegistry.register()` 注册自身。构建时调用 `registry.submit()` 后,框架会遍历注册数据,调用每个管理器的 `toObject()` 方法获取最终 JSON 结构,然后写入对应的资源包文件。
155
+
156
+ 典型流程:
157
+
158
+ ```javascript
159
+ import { ItemTextureManager, TerrainTextureManager, FlipbookTextures } from "@sapdon/core";
160
+ import { registry } from "@sapdon/core";
161
+
162
+ // 注册纹理
163
+ ItemTextureManager.registerTexture("ruby_ingot", "textures/items/ruby_ingot");
164
+ TerrainTextureManager.registerTexture("ruby_block", "textures/blocks/ruby_block");
165
+ FlipbookTextures.registerFlipbookTexture("ruby_lamp", "textures/blocks/ruby_lamp_anim", 2);
166
+
167
+ // 提交注册数据,触发 JSON 生成
168
+ registry.submit();
169
+ ```
170
+
171
+ ---
172
+
173
+ ## 生成的 JSON 文件
174
+
175
+ 构建完成后,框架会根据注册数据自动生成以下文件到资源包目录:
176
+
177
+ | 文件名 | 来源 | 示例 |
178
+ |--------|------|------|
179
+ | `textures/item_texture.json` | `ItemTextureManager` | `{ "resource_pack_name": "...", "texture_data": { "ruby_ingot": { "textures": "textures/items/ruby_ingot" } } }` |
180
+ | `textures/terrain_texture.json` | `TerrainTextureManager` | `{ "resource_pack_name": "...", "texture_data": { "ruby_block": { "textures": "textures/blocks/ruby_block" } } }` |
181
+ | `textures/flipbook_textures.json` | `FlipbookTextures` | `[ { "atlas_tile": "ruby_lamp", "flipbook_texture": "textures/blocks/ruby_lamp_anim", "ticks_per_frame": 2 } ]` |
@@ -0,0 +1,84 @@
1
+ # build.config 配置参考
2
+
3
+ `build.config` 是项目的构建配置文件,位于项目根目录,支持 `//` 和 `/* */` 注释。
4
+
5
+ ## 完整字段
6
+
7
+ ```jsonc
8
+ {
9
+ "formatVersion": 2,
10
+ "buildOptions": {
11
+ "useHMR": true, // 是否启用热更新
12
+ "buildMode": "development", // "development" | "production"
13
+ "buildEntry": "main.ts", // Addon 构建入口文件
14
+ "useJs": false, // 是否使用 JavaScript
15
+ "scriptEntry": "scripts/main.ts", // Script API 入口
16
+ "scriptOutput": "scripts/index.js", // Script API 输出路径(相对于 buildDir)
17
+ "buildDir": "dev/", // 构建输出目录
18
+ "dependencies": [
19
+ {
20
+ "module_name": "@minecraft/server",
21
+ "version": "2.0.0"
22
+ }
23
+ ],
24
+ "resource": {
25
+ "path": "res/", // 资源文件目录
26
+ "resourceHints": true // 是否生成资源提示文件
27
+ }
28
+ },
29
+ "versionType": "release" // "release" | "beta"
30
+ }
31
+ ```
32
+
33
+ ## 字段说明
34
+
35
+ ### formatVersion
36
+ 配置格式版本,当前为 `2`。v1 配置会在读取时自动迁移。
37
+
38
+ ### buildMode
39
+
40
+ | 值 | 说明 |
41
+ |----|------|
42
+ | `development` | **完整构建**:运行 `main.ts` → 根据代码生成所有 JSON → 打包脚本 → 同步到 Minecraft 目录。Script API 输出带 sourcemap,不压缩。 |
43
+ | `production` | **仅同步**:跳过 `main.ts` 执行和 JSON 生成,将已有 `dev/` 目录直接同步到 Minecraft 目录。适合直接编辑 JSON 文件测试时使用。 |
44
+
45
+ > 注意:`production` 模式不会运行 `main.ts`,也不会生成物品/实体/方块/配方的 JSON 文件。确保 `dev/` 目录已有正确的 JSON 文件(通常从一次 `development` 构建中获得)。
46
+
47
+ ### buildEntry
48
+ 构建入口文件路径(相对项目根目录)。文件中的 `registry.submit()` 会将注册数据提交到构建系统。
49
+
50
+ ### scriptEntry / scriptOutput
51
+ - `scriptEntry` — Script API 源码入口,会打包为单个文件
52
+ - `scriptOutput` — 打包后的输出路径,相对于 `buildDir/<name>_BP/`
53
+
54
+ ### buildDir
55
+ 构建输出目录,内容结构:
56
+
57
+ ```
58
+ <buildDir>/
59
+ ├── <projectName>_BP/ # 行为包
60
+ └── <projectName>_RP/ # 资源包
61
+ ```
62
+
63
+ ### dependencies
64
+ manifest.json 中的依赖声明。常见模块:
65
+
66
+ | 模块名 | 说明 |
67
+ |--------|------|
68
+ | `@minecraft/server` | 核心 Script API |
69
+ | `@minecraft/server-ui` | 表单 UI API |
70
+ | `@minecraft/server-net` | 网络 API |
71
+ | `@minecraft/server-admin` | 管理 API |
72
+
73
+ ### resource
74
+ - `path` — 资源文件夹路径,内容会复制到 RP 根目录
75
+ - `resourceHints` — 设为 `true` 时生成 `res.hint.ts`,提供类型安全的资源引用
76
+
77
+ ### versionType
78
+
79
+ | 值 | Minecraft 路径 |
80
+ |----|---------------|
81
+ | `release` | `%USERPROFILE%/AppData/Roaming/Minecraft Bedrock/...` |
82
+ | `beta` | `%USERPROFILE%/AppData/Local/Packages/Microsoft.MinecraftWindowsBeta_.../LocalState/...` |
83
+
84
+ 可通过环境变量 `MC_PATH` 或 `MC_BETA_PATH` 覆盖。