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
package/doc/BlockAPI.md DELETED
@@ -1,145 +0,0 @@
1
- # 方块工厂类 (BlockAPI) API 文档
2
-
3
- ## 类描述
4
-
5
- `BlockAPI` 是一个工厂函数集合,用于创建和管理多种类型的游戏方块,并自动注册到游戏系统中。支持基础方块、旋转方块、几何方块、矿物方块和作物方块的创建。
6
-
7
- ---
8
-
9
- ## BlockAPI 工厂函数
10
-
11
- ### `createBasicBlock(identifier, category, textures_arr, options = {})`
12
-
13
- 创建基础方块。
14
-
15
- #### 参数
16
-
17
- - `identifier` (string): 方块的唯一标识符,格式为"命名空间:名称" (例:"my_mod:stone_block")。
18
- - `category` (string): 在创造模式物品栏的分类,可选值: "construction", "nature", "equipment", "items", and "none"。
19
- - `textures_arr` (string[]): 6面纹理数组,顺序为 [上, 下, 东, 西, 南, 北]
20
- - `options` (Object): 可选参数,默认为空。
21
- - `group` (string): 分组名称,默认 "construction"。
22
- - `hide_in_command` (boolean): 是否在命令中隐藏,默认 `false`。
23
-
24
- #### 返回值
25
-
26
- - `BasicBlock`: 基础方块实例
27
-
28
- ---
29
-
30
- ### `createBlock(identifier, category, variantDatas, options = {})`
31
-
32
- 创建含变体状态的标准方块。
33
-
34
- #### 参数
35
-
36
- - `identifier` (string): 方块的唯一标识符。
37
- - `category` (string): 在创造模式物品栏的分类,可选值: "construction", "nature", "equipment", "items", and "none"
38
- - `variantDatas` (Array): 变体数据数组,每个元素包含:
39
- - `stateTag` (number): 状态标签 0-15 最大15
40
- - `textures` (string[]): 对应状态的6面,纹理顺序为 [上, 下, 东, 西, 南, 北]
41
- - `options` (Object): 可选参数,默认为空。
42
- - `options.group` (string): 分组,默认为 "construction"。
43
- - `options.hide_in_command` (boolean): 是否在命令中隐藏,默认为 false。
44
- - `ambient_occlusion` (boolean): 环境光遮蔽,默认 `false`
45
- - `face_dimming` (boolean): 面亮度衰减,默认 `false`
46
- - `render_method` (string): 渲染模式,可选 "opaque"/"blend"/"alpha_test"
47
-
48
- #### 返回值
49
-
50
- - `Block`: 标准方块实例
51
-
52
- ---
53
-
54
- ### `createRotatableBlock(identifier, category, textures_arr, options = {})`
55
-
56
- 创建支持多方向旋转的方块。
57
-
58
- #### 参数
59
-
60
- - `identifier` (string): 矿物方块的唯一标识符。
61
- - `category` (string): 在创造模式物品栏的分类,可选值:"construction", "nature", "equipment", "items", and "none"
62
- - `textures_arr` (string[]): 6面纹理数组,顺序为 [上, 下, 东, 西, 南, 北]。
63
- - `options` (Object): 可选参数,默认为空。
64
- - `options.group` (string): 分组,默认为 "construction"。
65
- - `options.hide_in_command` (boolean): 是否在命令中隐藏,默认为 false。
66
- - `options.rotationType` (string): 旋转类型,默认为 "cardinal"。
67
- - `options.yRotationOffset` (number): 初始旋转偏移量,默认为 180。
68
-
69
- #### 返回值
70
-
71
- - `RotatableBlock`: 旋转方块实例
72
-
73
- ---
74
-
75
- ### `createGeometryBlock(identifier, category, geometry, material_instances, options = {})`
76
-
77
- 创建自定义几何模型方块。
78
-
79
- #### 参数
80
-
81
- - `identifier` (string): 方块的唯一标识符。
82
- - `category` (string): 在创造模式物品栏的分类,可选值:"construction", "nature", "equipment","items" and "none"。
83
- - `geometry` (string): 几何模型标识符 (例:"geometry.custom_model")。
84
- - `material_instances` (Object): 材质实例配置。
85
- - 撰写文档者不晓得具体内容应该填啥
86
- - `options` (Object): 可选参数,默认为空。
87
- - `options.group` (string): 分组,默认为 "construction"。
88
- - `options.hide_in_command` (boolean): 是否在命令中隐藏,默认为 false。
89
-
90
- #### 返回值
91
-
92
- - `GeometryBlock`: 自定义几何模型方块实例
93
-
94
- ---
95
-
96
- ### `createOreBlock(identifier, category, textures_arr, options = {})`
97
-
98
- 创建矿物生成方块。
99
-
100
- #### 参数
101
-
102
- - `identifier` (string): 矿物方块的唯一标识符。
103
- - `category` (string): 在创造模式物品栏的分类,可选值:"construction", "nature", "equipment", "items" and "none"。
104
- - `textures_arr` (string[]): 6面纹理数组,顺序为 [上, 下, 东, 西, 南, 北]。
105
- - `options` (Object): 可选参数,默认为空。
106
- - `options.group` (string): 分组,默认为 "construction"。
107
- - `options.hide_in_command` (boolean): 是否在命令中隐藏,默认为 false。
108
-
109
- #### 返回值
110
-
111
- - `OreBlock`: 矿物方块实例
112
-
113
- ---
114
-
115
- ### `createCropBlock(identifier, category, variantDatas, options = {})`
116
-
117
- 创建农作物方块。
118
-
119
- #### 参数
120
-
121
- - `identifier` (string): 作物方块的唯一标识符。
122
- - `category` (string): 在创造模式物品栏的分类,可选值:"construction", "nature", "equipment", "items" and "none"。
123
- - `variantDatas` (Array): 变体数据数组,每个元素包含:
124
- - `stateTag` (number): 状态标签 0-15 最大15
125
- - `textures` (string[]): 对应状态的6面纹理
126
- - `options` (Object): 可选参数,默认为空。
127
- - `options.group` (string): 分组,默认为 "construction"。
128
- - `options.hide_in_command` (boolean): 是否在命令中隐藏,默认为 false。
129
- - `options.ambient_occlusion` (boolean): 是否应用环境光遮蔽,默认为 false。
130
- - `options.face_dimming` (boolean): 是否根据面的方向进行亮度调整,默认为 false。
131
- - `options.render_method` (string): 渲染方法,默认为 "alpha_test"。
132
-
133
- #### 返回值
134
-
135
- - `CropBlock`: 作物方块实例
136
-
137
- ---
138
-
139
- ## 版本兼容性
140
-
141
- | 功能 | 最低版本 | 依赖组件 |
142
- |------|---------|---------|
143
- | 几何方块 | 1.16.20 | minecraft:geometry |
144
- | 矿脉生成 | 1.18.30 | ore_feature |
145
- | 动态碰撞箱 | 1.17.10 | permutation |
package/doc/api.md DELETED
@@ -1,128 +0,0 @@
1
- # 物品类 (Item) 和 ItemAPI 工厂函数 API 文档
2
-
3
- ## 类描述
4
- `Item` 类用于创建一个物品对象,该对象可以包含多种组件,并且可以转换为 JSON 格式,用于在特定的游戏中定义物品。`ItemAPI` 是一个工厂函数集合,用于简化物品的创建过程,支持创建普通物品、食物、可附着物品以及胸甲护甲等。
5
-
6
- ## Item 类
7
-
8
- ### 构造函数
9
- ### `constructor(identifier, category, texture, options = {})`
10
- 创建一个新的物品实例。
11
-
12
- #### 参数
13
- - `identifier` (string): 物品的唯一标识符。由命名空间与名字组成,例如"hello_sapdon:my_item"
14
- - `category` (string): 物品所属的菜单栏分类,可选值包括:"construction", "nature", "equipment", "items", 和 "none"。
15
- - `texture` (string): 物品的纹理。
16
- - `options` (Object): 可选参数配置对象。默认为空对象。
17
- - `group` (string): 分组名称。
18
- - `hide_in_command` (boolean): 是否在命令中隐藏物品。默认为 `false`。
19
- - `max_stack_size` (number): 物品的最大堆叠数量。默认为 `64`。
20
-
21
- #### 抛出异常
22
- - 当 `identifier`, `category`, 或 `texture` 参数缺失或不是字符串时,抛出 `Error`。
23
-
24
- ### 方法
25
-
26
- ### `addComponent(componentMap)`
27
- 向物品添加新的组件。
28
-
29
- ##### 参数
30
- - `componentMap` (Map): 组件的 Map 对象。
31
-
32
- ##### 抛出异常
33
- - 当 `componentMap` 参数缺失或不是 Map 实例时,抛出 `Error`。
34
-
35
- ### `removeComponent(key)`
36
- 从物品中移除一个组件。
37
-
38
- ##### 参数
39
- - `key` (string): 组件的名称。
40
-
41
- ##### 抛出异常
42
- - 当 `key` 参数缺失或不是字符串时,抛出 `Error`。
43
-
44
- ### `@Serializer` 装饰器
45
- 将物品转换为 Addon JSON 对象,以便在游戏中定义物品。
46
-
47
- ##### 返回值
48
- - `Object`: JSON 格式的物品对象。
49
-
50
- ##### 内部实现
51
- 根据物品的属性和组件,创建一个 `AddonItem` 实例,并返回其 JSON 表示。这个 JSON 对象可以被游戏引擎解析,用于定义游戏中的物品。
52
-
53
- ---
54
-
55
- ## ItemAPI 工厂函数
56
-
57
- `ItemAPI` 是一个用于创建和管理游戏物品的工厂函数集合,提供了多种方法来创建不同类型的物品。
58
-
59
- ### `createItem(identifier, category, texture, options = {})`
60
- 创建一个普通物品。
61
-
62
- #### 参数
63
- - `identifier` (string): 物品的唯一标识符。
64
- - `category` (string): 物品在创造菜单中的分类,可选值包括:"construction", "nature", "equipment", "items"。
65
- - `texture` (string): 物品的纹理。
66
- - `options` (Object): 额外选项配置对象。默认为空对象。
67
- - `group` (string): 物品的分组。
68
- - `hide_in_command` (boolean): 是否在命令中隐藏物品。默认为 `false`。
69
-
70
- #### 抛出异常
71
- - 当 `identifier`, `category`, 或 `texture` 参数缺失或为空时,抛出 `Error`。
72
-
73
- #### 返回值
74
- - `Item`: 创建的普通物品对象。
75
-
76
- ### `createFood(identifier, category, texture, options = {})`
77
- 创建一个食物物品。
78
-
79
- #### 参数
80
- - `identifier` (string): 食物的唯一标识符。
81
- - `category` (string): 食物在创造菜单中的分类。
82
- - `texture` (string): 食物的纹理。
83
- - `options` (Object): 额外选项配置对象。默认为空对象。
84
- - `group` (string): 食物的分组。
85
- - `hide_in_command` (boolean): 是否在命令中隐藏食物。默认为 `false`。
86
- - `animation` (string): 食用时的动画。默认为 `"eat"`。
87
- - `canAlwaysEat` (boolean): 是否总是可以食用。默认为 `false`。
88
- - `nutrition` (number): 食物的营养价值。默认为 `0`。
89
- - `saturationModifier` (number): 饱和度修正值。默认为 `1`。
90
-
91
- #### 抛出异常
92
- - 当 `identifier`, `category`, 或 `texture` 参数缺失或为空时,抛出 `Error`。
93
-
94
- #### 返回值
95
- - `Food`: 创建的食物物品对象。
96
-
97
- ### `createAttachable(identifier, texture, material, options = {})`
98
- 创建一个可附着物品。
99
-
100
- #### 参数
101
- - `identifier` (string): 可附着物品的唯一标识符。
102
- - `texture` (string): 可附着物品的纹理。
103
- - `material` (string): 可附着物品的材质。
104
- - `options` (Object): 额外选项配置对象。默认为空对象。
105
-
106
- #### 抛出异常
107
- - 当 `identifier`, `texture`, 或 `material` 参数缺失或为空时,抛出 `Error`。
108
-
109
- #### 返回值
110
- - `Attachable`: 创建的可附着物品对象。
111
-
112
- ### `createChestplateArmor(identifier, item_texture, texture_path, options = {})`
113
- 创建一个胸甲护甲物品。
114
-
115
- #### 参数
116
- - `identifier` (string): 胸甲的唯一标识符。
117
- - `item_texture` (string): 胸甲的纹理。
118
- - `texture_path` (string): 胸甲的纹理路径。
119
- - `options` (Object): 额外选项配置对象。默认为空对象。
120
-
121
- #### 返回值
122
- - `Chestplate`: 创建的胸甲护甲物品对象。
123
-
124
- ---
125
-
126
- ## 内部实现
127
- - `ItemAPI` 使用 `GRegistry` 来注册物品和可附着物品的行为和资源路径。
128
- - 每个方法在创建物品后,会调用 `registerItem` 函数将物品注册到全局注册表中,以便游戏引擎能够识别和加载这些物品。
package/doc/oc/index.md DELETED
File without changes
package/doc/sapdon-ts.md DELETED
@@ -1,64 +0,0 @@
1
- # sapdon with typescript
2
- 在使用脚手架创建项目时,默认使用的语言将会是 `ts`
3
-
4
- 但这并不意味着你需要手动去调整 tsconfig 和打包工具,我们提供了一套默认能用的ts设置
5
-
6
- ## 和 js 版本相比有什么区别?
7
- ts版本拥有更好的类型提示,更严格的类型检查,也可以直接使用node_modules里的库(只能是js/ts)
8
-
9
- ## 听起来太酷了我们开始吧!
10
- 比如我们需要注册一个物品,可能你会想去找它在哪,但在ts版本中,你只需要 `@sapdon/core` 就可以了
11
-
12
- ```ts
13
- import { ItemAPI } from '@sapdon/core'
14
- ```
15
-
16
- 如果你需要更高级的功能,比如你需要一个ts打包器,或者添加命令行的功能,你可以使用 `@sapdon/cli`
17
-
18
- ## 从js迁移到ts
19
- js 的 `main.mjs` 包含了一些预定义的代码:
20
- ```js
21
- import { registry } from '@sapdon/core'
22
-
23
- // 进行注册后需进行一次提交, 通知开发服务器更新文件
24
- registry.setup()
25
- ```
26
- 如果需要从js迁移到ts,删除 `startDevServer` 那行即可(不删也没事)
27
-
28
-
29
- ## OC (Object - Component)
30
- sapdon通过 `@sapdon/oc` 为sapi提供了一些高级功能, 比如:
31
- - 实体组件系统
32
- - 组件间通信
33
-
34
- 传统的书写方式是通过事件和tick回调来实现功能, 而OC提供了更适合游戏的组件化开发方式
35
-
36
- ```ts
37
- import { world, system } from '@minecraft/server'
38
- import { oc, CustomComponent } from '@sapdon/oc'
39
-
40
- world.afterEvents.worldInitialize.subscribe(oc.start)
41
-
42
- class MyComponent extends CustomComponent {
43
- onTick() {
44
- world.sendMessage('tick')
45
- }
46
- }
47
- ```
48
-
49
- 是的, 我们得到了一个MyComponent, 它每刻都会给玩家发送 'tick'
50
- 但是如果你进入游戏, 会发现它毫无作用, 没错! 因为我们还没有把它到绑定在实体身上!
51
-
52
- ```ts
53
- const manager = oc.addEntity(id)
54
- manager.attachComponent(new MyComponent())
55
- ```
56
-
57
- 这样就可以了, 我们已经把MyComponent绑定到了entityId为id的实体身上
58
-
59
- 你也可以动态增删改查组件! 这很方便!
60
-
61
- 如果你想看它到底是怎么回事,可以从 `examples/oc-core` 开始了解
62
-
63
- ## [Object - Component](./oc/index.md)
64
- 关于 `@sapdon/oc` 的一切
@@ -1,23 +0,0 @@
1
- {
2
- "formatVersion": 2,
3
- "buildOptions": {
4
- "useHMR": true, // 热更新
5
- "buildMode": "development", // 开发模式 'development' | 'production', production模式下会压缩代码
6
- "buildEntry": "main.mjs", // Addon构建入口文件
7
- "useJs": true, // 是否使用js文件
8
- "scriptEntry": "scripts/index.js", // ScriptApi脚本入口文件
9
- "scriptOutput": "scripts/index.js", // ScriptApi脚本输出文件 (在 buildDir 目录下)
10
- "buildDir": "dev/", // 构建输出目录
11
- "dependencies": [
12
- {
13
- "module_name": "@minecraft/server",
14
- "version": "1.17.0"
15
- }
16
- ],
17
- "resource": {
18
- "path": "res/", // 资源文件目录
19
- "resourceHints": true // 是否生成资源提示文件
20
- }
21
- },
22
- "versionType": "release" // mc游戏版本, 会影响开发文件路径
23
- }
@@ -1,4 +0,0 @@
1
- import { registry } from '@sapdon/core'
2
-
3
- // 提交所有注册
4
- registry.submit()
@@ -1,7 +0,0 @@
1
- {
2
- "name":"mod名字",
3
- "authors":["作者1","作者2"],
4
- "version":"0.0.1",
5
- "min_engine_version":"1.19.50",
6
- "description":"mod介绍",
7
- }
@@ -1,20 +0,0 @@
1
- {
2
- "name": "sapdon",
3
- "version": "1.0.0",
4
- "main": "main.mjs",
5
- "scripts": {
6
- "build": "sapdon build ./",
7
- "postinstall": "sapdon lib"
8
- },
9
- "keywords": [
10
- "bedrock",
11
- "addon"
12
- ],
13
- "author": "",
14
- "license": "ISC",
15
- "type": "module",
16
- "devDependencies": {
17
- "@minecraft/server": "^1.17.0",
18
- "@minecraft/server-ui": "^1.3.0"
19
- }
20
- }
@@ -1,34 +0,0 @@
1
- {
2
- "format_version": "1.8.0",
3
- "animations": {
4
- "animation.animation_item.default": {
5
- "loop": true,
6
- "bones": {
7
- "body": {
8
- "position": [0, 8, 0]
9
- },
10
- "rightitem": {
11
- "rotation": [-80, 0, 0],
12
- "position": [0, -3, 2]
13
- }
14
- }
15
- },
16
- "animation.animation_item.rotating": {
17
- "loop": true,
18
- "animation_length": 10,
19
- "bones": {
20
- "body": {
21
- "rotation": {
22
- "0.0": [0, 0, 0],
23
- "10.0": [0, 360, 0]
24
- },
25
- "position": [0, 8, 0]
26
- },
27
- "rightitem": {
28
- "rotation": [-80, 0, 0],
29
- "position": [0, -3, 2]
30
- }
31
- }
32
- }
33
- }
34
- }
@@ -1,27 +0,0 @@
1
- {
2
- "format_version": "1.10.0",
3
- "animations": {
4
- "animation.large_item.hold": {
5
- "loop": true,
6
- "bones": {
7
- "rightitem": {
8
- "position": [
9
- "c.is_first_person ? -6 : 1",
10
- "c.is_first_person ? 0 : -1",
11
- "c.is_first_person ? -1 : -6"
12
- ],
13
- "rotation": [
14
- "c.is_first_person ? 45 : 15",
15
- "c.is_first_person ? -15 : 0",
16
- "c.is_first_person ? 30 : -165"
17
- ],
18
- "scale": [
19
- "c.is_first_person ? 1 : 0.5",
20
- "c.is_first_person ? 1 : 0.5",
21
- "c.is_first_person ? 1 : 0.5"
22
- ]
23
- }
24
- }
25
- }
26
- }
27
- }
@@ -1,48 +0,0 @@
1
- {
2
- "format_version": "1.21.20",
3
- "minecraft:geometry": [
4
- {
5
- "description": {
6
- "identifier": "geometry.crop",
7
- "texture_width": 16,
8
- "texture_height": 16
9
- },
10
- "bones": [
11
- {
12
- "name": "crop",
13
- "pivot": [0, 0, 0],
14
- "cubes": [
15
- {
16
- "origin": [-8, -1, -4],
17
- "size": [16, 16, 0],
18
- "uv": {
19
- "south": { "uv": [0, 0], "uv_size": [16, 16] }
20
- }
21
- },
22
- {
23
- "origin": [-8, -1, 4],
24
- "size": [16, 16, 0],
25
- "uv": {
26
- "north": { "uv": [0, 0], "uv_size": [16, 16] }
27
- }
28
- },
29
- {
30
- "origin": [4, -1, -8],
31
- "size": [0, 16, 16],
32
- "uv": {
33
- "east": { "uv": [16, 0], "uv_size": [-16, 16] }
34
- }
35
- },
36
- {
37
- "origin": [-4, -1, -8],
38
- "size": [0, 16, 16],
39
- "uv": {
40
- "west": { "uv": [16, 0], "uv_size": [-16, 16] }
41
- }
42
- }
43
- ]
44
- }
45
- ]
46
- }
47
- ]
48
- }
@@ -1,26 +0,0 @@
1
- {
2
- "format_version": "1.12.0",
3
- "minecraft:geometry": [
4
- {
5
- "description": {
6
- "identifier": "geometry.animation_item",
7
- "texture_width": 32,
8
- "texture_height": 32,
9
- "visible_bounds_width": 5,
10
- "visible_bounds_height": 3.5,
11
- "visible_bounds_offset": [0, 1.25, 0]
12
- },
13
- "bones": [
14
- {
15
- "name": "body",
16
- "pivot": [0, 0, 0]
17
- },
18
- {
19
- "name": "rightitem",
20
- "parent": "body",
21
- "pivot": [-0.3, 8, 0]
22
- }
23
- ]
24
- }
25
- ]
26
- }
@@ -1,28 +0,0 @@
1
- {
2
- "format_version": "1.16.0",
3
- "minecraft:geometry": [
4
- {
5
- "description": {
6
- "identifier": "geometry.large_item",
7
- "texture_width": 16,
8
- "texture_height": 16,
9
- "visible_bounds_width": 2,
10
- "visible_bounds_height": 1.5,
11
- "visible_bounds_offset": [0, 0.25, 0]
12
- },
13
- "bones": [
14
- {
15
- "name": "rightitem",
16
- "pivot": [0, 0, 0],
17
- "texture_meshes": [
18
- {
19
- "texture": "default",
20
- "position": [0, 0, 0],
21
- "local_pivot": [8, 0, 8]
22
- }
23
- ]
24
- }
25
- ]
26
- }
27
- ]
28
- }
@@ -1,50 +0,0 @@
1
- import { EquipmentSlot, GameMode, world } from "@minecraft/server";
2
-
3
- /**
4
- * @param {number} min The minimum integer
5
- * @param {number} max The maximum integer
6
- * @returns {number} A random integer between the `min` and `max` parameters (inclusive)
7
- */
8
- const randomInt = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
9
-
10
- const maxGrowth = 3;
11
-
12
- /** @type {import("@minecraft/server").BlockCustomComponent} */
13
- export const CustomCropGrowthBlockComponent = {
14
- onRandomTick({ block }) {
15
- const growthChance = 1 / 3;
16
- if (Math.random() > growthChance) return;
17
-
18
- const growth = block.permutation.getState("sapdon:block_variant_tag");
19
- block.setPermutation(block.permutation.withState("sapdon:block_variant_tag", growth + 1));
20
- },
21
- onPlayerInteract({ block, dimension, player }) {
22
- if (!player) return;
23
-
24
- const equippable = player.getComponent("minecraft:equippable");
25
- if (!equippable) return;
26
-
27
- const mainhand = equippable.getEquipmentSlot(EquipmentSlot.Mainhand);
28
- if (!mainhand.hasItem() || mainhand.typeId !== "minecraft:bone_meal") return;
29
-
30
- if (player.getGameMode() === GameMode.creative) {
31
- // Grow crop fully
32
- block.setPermutation(block.permutation.withState("sapdon:block_variant_tag", maxGrowth));
33
- } else {
34
- let growth = block.permutation.getState("sapdon:block_variant_tag");
35
-
36
- // Add random amount of growth
37
- growth += randomInt(1, maxGrowth - growth);
38
- block.setPermutation(block.permutation.withState("sapdon:block_variant_tag", growth));
39
-
40
- // Decrement stack
41
- if (mainhand.amount > 1) mainhand.amount--;
42
- else mainhand.setItem(undefined);
43
- }
44
-
45
- // Play effects
46
- const effectLocation = block.center();
47
- dimension.playSound("item.bone_meal.use", effectLocation);
48
- dimension.spawnParticle("minecraft:crop_growth_emitter", effectLocation);
49
- },
50
- };
@@ -1,37 +0,0 @@
1
- import { world } from "@minecraft/server";
2
- import { ActionFormData} from "@minecraft/server-ui";
3
-
4
- const item_ui_list ={
5
- "thaumcraft:thaumonomicon":"guidebook"
6
- };
7
-
8
- var page_index = 0;
9
- /** @type {import("@minecraft/server").ItemCustomComponent} */
10
- export const GuiBookItemComponent = {
11
- onUse({itemStack,source}){
12
- if(source.typeId != "minecraft:player") return
13
- showGuidebook(source,item_ui_list[itemStack.typeId])
14
- }
15
- }
16
-
17
- function showGuidebook(target,ui){
18
- const form = new ActionFormData()
19
- .title(ui)
20
- .body("page_index"+ page_index)
21
- .button("test1")
22
- .button("test2")
23
-
24
- form.show(target).then((response) => {
25
- if (response.selection === 0) {
26
- page_index--;
27
- world.sendMessage("上一页")
28
- showGuidebook(target,ui)
29
-
30
- }
31
- else if (response.selection === 1) {
32
- page_index++;
33
- world.sendMessage("下一页")
34
- showGuidebook(target,ui)
35
- }
36
- });
37
- }