sapdon 3.5.1 → 3.5.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 (45) hide show
  1. package/README.md +6 -4
  2. package/doc/guidebook.md +1 -1
  3. package/doc/user/faq.md +3 -15
  4. package/doc/user/quick-start.md +6 -2
  5. package/package.json +1 -1
  6. package/prod/cli/start.js +1 -1
  7. package/prod/core/index.d.ts +1 -1
  8. package/prod/templates/js_sapdon/build.config +24 -0
  9. package/prod/templates/js_sapdon/main.mjs +4 -0
  10. package/prod/templates/js_sapdon/mod.info +7 -0
  11. package/prod/templates/js_sapdon/pack_icon.png +0 -0
  12. package/prod/templates/js_sapdon/package.json +21 -0
  13. package/prod/templates/js_sapdon/res/animations/animation_item.animation.json +34 -0
  14. package/prod/templates/js_sapdon/res/animations/large_item.animation.json +27 -0
  15. package/prod/templates/js_sapdon/res/models/blocks/crop.geo.json +48 -0
  16. package/prod/templates/js_sapdon/res/models/blocks/flipbook_item.geo.json +3160 -0
  17. package/prod/templates/js_sapdon/res/models/entity/animation/animation_item.geo.json +26 -0
  18. package/prod/templates/js_sapdon/res/models/entity/animation/large_item.geo.json +28 -0
  19. package/prod/templates/js_sapdon/res/textures/blocks/none.png +0 -0
  20. package/prod/templates/js_sapdon/res/textures/blocks/test_log_oak.png +0 -0
  21. package/prod/templates/js_sapdon/res/textures/blocks/test_log_top.png +0 -0
  22. package/prod/templates/js_sapdon/res/textures/items/masterball.png +0 -0
  23. package/prod/templates/js_sapdon/scripts/custom_components/cropComponent.js +50 -0
  24. package/prod/templates/js_sapdon/scripts/custom_components/items/gui_book.js +37 -0
  25. package/prod/templates/js_sapdon/scripts/custom_components/registry.js +25 -0
  26. package/prod/templates/js_sapdon/scripts/index.js +1 -0
  27. package/prod/templates/ts_sapdon/build.config +24 -0
  28. package/prod/templates/ts_sapdon/main.ts +15 -0
  29. package/prod/templates/ts_sapdon/mod.info +7 -0
  30. package/prod/templates/ts_sapdon/pack_icon.png +0 -0
  31. package/prod/templates/ts_sapdon/package.json +21 -0
  32. package/prod/templates/ts_sapdon/res/animations/animation_item.animation.json +34 -0
  33. package/prod/templates/ts_sapdon/res/animations/large_item.animation.json +27 -0
  34. package/prod/templates/ts_sapdon/res/models/blocks/crop.geo.json +48 -0
  35. package/prod/templates/ts_sapdon/res/models/blocks/flipbook_item.geo.json +3160 -0
  36. package/prod/templates/ts_sapdon/res/models/entity/animation/animation_item.geo.json +26 -0
  37. package/prod/templates/ts_sapdon/res/models/entity/animation/large_item.geo.json +28 -0
  38. package/prod/templates/ts_sapdon/res/models/entity/dummy.geo.json +24 -0
  39. package/prod/templates/ts_sapdon/res/models/entity/falling_block.geo.json +35 -0
  40. package/prod/templates/ts_sapdon/res/textures/blocks/none.png +0 -0
  41. package/prod/templates/ts_sapdon/res/textures/blocks/test_log_oak.png +0 -0
  42. package/prod/templates/ts_sapdon/res/textures/blocks/test_log_top.png +0 -0
  43. package/prod/templates/ts_sapdon/res/textures/items/masterball.png +0 -0
  44. package/prod/templates/ts_sapdon/scripts/index.ts +14 -0
  45. package/prod/templates/ts_sapdon/tsconfig.json +117 -0
@@ -0,0 +1,26 @@
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
+ }
@@ -0,0 +1,28 @@
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
+ }
@@ -0,0 +1,50 @@
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
+ };
@@ -0,0 +1,37 @@
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
+ }
@@ -0,0 +1,25 @@
1
+
2
+ import { BlockWithEntityComponent } from "./block/block_with_entity.js";
3
+ import { CustomCropGrowthBlockComponent } from "./cropComponent.js";
4
+ import { GuiBookItemComponent } from "./items/gui_book.js";
5
+ import { world } from "@minecraft/server";
6
+
7
+ export const registerCustomItemComponent = ()=>{
8
+ world.beforeEvents.worldInitialize.subscribe(({ itemComponentRegistry }) => {
9
+ itemComponentRegistry.registerCustomComponent("sapdon:guibook",GuiBookItemComponent);
10
+ });
11
+ }
12
+
13
+ export const registerCustomBlockComponent = ()=>{
14
+ world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
15
+ blockComponentRegistry.registerCustomComponent(
16
+ "sapdon:block_with_entity",
17
+ BlockWithEntityComponent
18
+ );
19
+ blockComponentRegistry.registerCustomComponent(
20
+ "sapdon:crop_growth",
21
+ CustomCropGrowthBlockComponent
22
+ );
23
+ });
24
+ }
25
+
@@ -0,0 +1 @@
1
+ import './custom_components/index.js'
@@ -0,0 +1,24 @@
1
+ {
2
+ "formatVersion": 2,
3
+ "buildOptions": {
4
+ "useHMR": true, // 热更新
5
+ "keepServer": false, // 构建完成后是否保持服务器常开. true=常开(配合useHMR), false=默认自动退出
6
+ "buildMode": "dev", // 开发模式 'dev' | 'prod' | 'debug'. prod=压缩代码, debug=仅同步dev/
7
+ "buildEntry": "main.ts", // Addon构建入口文件
8
+ "useJs": false, // 是否使用js文件
9
+ "scriptEntry": "scripts/index.ts", // ScriptApi脚本入口文件
10
+ "scriptOutput": "scripts/index.js", // ScriptApi脚本输出文件 (在 buildDir 目录下)
11
+ "buildDir": "dev/", // 构建输出目录
12
+ "dependencies": [
13
+ {
14
+ "module_name": "@minecraft/server",
15
+ "version": "1.18.0-beta"
16
+ }
17
+ ],
18
+ "resource": {
19
+ "path": "res/", // 资源文件目录
20
+ "resourceHints": true // 是否生成资源提示文件
21
+ }
22
+ },
23
+ "versionType": "release" // mc游戏版本, 会影响开发文件路径
24
+ }
@@ -0,0 +1,15 @@
1
+ import { ItemCategory, ItemAPI, ItemComponent, BlockAPI, BlockComponent, registry } from '@sapdon/core'
2
+
3
+ ItemAPI.createItem('test:stick', ItemCategory.Items, 'stick')
4
+ .addComponent(ItemComponent.combineComponents(
5
+ ItemComponent.setDisplayName('Stick'),
6
+ ItemComponent.setThrowable(true),
7
+ ItemComponent.setIcon('stick'),
8
+ ))
9
+
10
+ BlockAPI.createBasicBlock('test:block', 'construction', ['block_texture'])
11
+ .addComponent(BlockComponent.setFriction(0.6))
12
+ .addComponent(BlockComponent.setMapColor('#888888'))
13
+
14
+ // 提交所有注册
15
+ registry.submit()
@@ -0,0 +1,7 @@
1
+ {
2
+ "name":"mod名字",
3
+ "authors":["作者1","作者2"],
4
+ "version":"0.0.1",
5
+ "min_engine_version":"1.19.50",
6
+ "description":"mod介绍"
7
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "ts-sapdon",
3
+ "version": "1.0.0",
4
+ "main": "main.ts",
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
+ "sapdon": "^3.5.2",
18
+ "@minecraft/server": "^1.17.0",
19
+ "@minecraft/server-ui": "^1.3.0"
20
+ }
21
+ }
@@ -0,0 +1,34 @@
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
+ }
@@ -0,0 +1,27 @@
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
+ }
@@ -0,0 +1,48 @@
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
+ }