sapdon 2.0.2 → 2.1.0
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.
- package/LICENSE +1 -1
- package/doc/BlockAPI.md +145 -0
- package/doc/api.md +1 -1
- package/doc/hello_sapdon/a9aad643f5609da73404d1f7f35fd5d0.png +0 -0
- package/doc/hello_sapdon/sapdon/344/275/277/347/224/250/346/225/231/347/250/213.md +159 -0
- package/examples/guidebook/build.config +33 -0
- package/examples/guidebook/dev/guidebook_BP/items/sapdon_test_guidebook.json +19 -0
- package/examples/{masterball/dev/masterball_BP/masterball_BP_1_20_20 → guidebook/dev/guidebook_BP}/manifest.json +63 -59
- package/examples/guidebook/dev/guidebook_BP/scripts/custom_components/cropComponent.js +50 -0
- package/examples/guidebook/dev/guidebook_BP/scripts/custom_components/items/gui_book.js +37 -0
- package/examples/guidebook/dev/guidebook_BP/scripts/custom_components/registry.js +20 -0
- package/examples/guidebook/dev/guidebook_BP/scripts/index.js +3 -0
- package/examples/guidebook/dev/guidebook_RP/blocks.json +3 -0
- package/examples/guidebook/dev/guidebook_RP/manifest.json +44 -0
- package/examples/guidebook/dev/guidebook_RP/models/blocks/crop.geo.json +48 -0
- package/examples/{masterball/dev/masterball_RP/masterball_RP_1_20_20.zip → guidebook/dev/guidebook_RP/pack_icon.png} +0 -0
- package/examples/guidebook/dev/guidebook_RP/textures/blocks/test_log_oak.png +0 -0
- package/examples/guidebook/dev/guidebook_RP/textures/blocks/test_log_top.png +0 -0
- package/examples/guidebook/dev/guidebook_RP/textures/flipbook_textures.json +1 -0
- package/examples/guidebook/dev/guidebook_RP/textures/item_texture.json +9 -0
- package/examples/guidebook/dev/guidebook_RP/textures/items/masterball.png +0 -0
- package/examples/guidebook/dev/guidebook_RP/textures/terrain_texture.json +14 -0
- package/examples/guidebook/dev/guidebook_RP/ui/_ui_defs.json +6 -0
- package/examples/guidebook/dev/guidebook_RP/ui/guidebook.json +581 -0
- package/examples/guidebook/dev/guidebook_RP/ui/server_form.json +91 -0
- package/examples/guidebook/main.mjs +66 -0
- package/examples/guidebook/mod.info +7 -0
- package/examples/{masterball/dev/masterball_BP/masterball_BP_1_20_20.zip → guidebook/pack_icon.png} +0 -0
- package/examples/guidebook/res/models/blocks/crop.geo.json +48 -0
- package/examples/guidebook/res/textures/blocks/test_log_oak.png +0 -0
- package/examples/guidebook/res/textures/blocks/test_log_top.png +0 -0
- package/examples/guidebook/res/textures/items/masterball.png +0 -0
- package/examples/guidebook/scripts/custom_components/cropComponent.js +50 -0
- package/examples/guidebook/scripts/custom_components/items/gui_book.js +37 -0
- package/examples/guidebook/scripts/custom_components/registry.js +20 -0
- package/examples/guidebook/scripts/index.js +3 -0
- package/examples/hello_sapdon/build.config +29 -0
- package/examples/hello_sapdon/main.mjs +3 -0
- package/examples/hello_sapdon/mod.info +7 -0
- package/examples/hello_sapdon/pack_icon.png +0 -0
- package/examples/hello_sapdon/res/models/blocks/crop.geo.json +48 -0
- package/examples/hello_sapdon/res/textures/blocks/test_log_oak.png +0 -0
- package/examples/hello_sapdon/res/textures/blocks/test_log_top.png +0 -0
- package/examples/hello_sapdon/res/textures/items/masterball.png +0 -0
- package/examples/hello_sapdon/scripts/custom_components/cropComponent.js +50 -0
- package/examples/hello_sapdon/scripts/custom_components/items/gui_book.js +37 -0
- package/examples/hello_sapdon/scripts/custom_components/registry.js +25 -0
- package/examples/hello_sapdon/scripts/index.js +0 -0
- package/examples/masterball/build.config +1 -0
- package/examples/masterball/dev/masterball_1_20_30.mcaddon +0 -0
- package/examples/masterball/dev/masterball_BP/entities/sapdon_projectile_masterball.json +56 -55
- package/examples/masterball/dev/masterball_BP/manifest.json +59 -59
- package/examples/masterball/dev/masterball_BP/pack_icon.png +0 -0
- package/examples/masterball/dev/masterball_BP/recipes/masterball.json +25 -0
- package/examples/masterball/dev/masterball_BP_1_20_30.mcpack +0 -0
- package/examples/masterball/dev/masterball_RP/attachables/sapdon_caught_masterball.json +19 -0
- package/examples/masterball/dev/masterball_RP/manifest.json +43 -43
- package/examples/masterball/dev/masterball_RP/pack_icon.png +0 -0
- package/examples/masterball/dev/masterball_RP/textures/flipbook_textures.json +1 -0
- package/examples/masterball/dev/masterball_RP/ui/_ui_defs.json +3 -0
- package/examples/masterball/dev/masterball_RP_1_20_30.mcpack +0 -0
- package/examples/masterball/main.mjs +18 -1
- package/examples/masterball/pack_icon.png +0 -0
- package/examples/mob_chest/build.config +29 -0
- package/examples/mob_chest/dev/mob_chest_BP/blocks/mob_chest_chest.json +56 -0
- package/examples/mob_chest/dev/mob_chest_BP/entities/mob_chest_chest_entity.json +79 -0
- package/examples/mob_chest/dev/mob_chest_BP/manifest.json +64 -0
- package/examples/mob_chest/dev/mob_chest_BP/pack_icon.png +0 -0
- package/examples/mob_chest/dev/mob_chest_BP/scripts/custom_components/block/block_with_entity.js +46 -0
- package/examples/mob_chest/dev/mob_chest_BP/scripts/custom_components/block/cropComponent.js +50 -0
- package/examples/mob_chest/dev/mob_chest_BP/scripts/custom_components/items/gui_book.js +37 -0
- package/examples/mob_chest/dev/mob_chest_BP/scripts/custom_components/registry.js +25 -0
- package/examples/mob_chest/dev/mob_chest_BP/scripts/index.js +4 -0
- package/examples/mob_chest/dev/mob_chest_RP/animation_controllers/mob_chest.animation_controllers.json +30 -0
- package/examples/mob_chest/dev/mob_chest_RP/animations/animation_item.animation.json +34 -0
- package/examples/mob_chest/dev/mob_chest_RP/animations/large_item.animation.json +27 -0
- package/examples/mob_chest/dev/mob_chest_RP/animations/mob_chest.animation.json +64 -0
- package/examples/mob_chest/dev/mob_chest_RP/blocks.json +13 -0
- package/examples/mob_chest/dev/mob_chest_RP/entity/mob_chest_chest_entity.json +32 -0
- package/examples/mob_chest/dev/mob_chest_RP/manifest.json +44 -0
- package/examples/mob_chest/dev/mob_chest_RP/models/blocks/crop.geo.json +48 -0
- package/examples/mob_chest/dev/mob_chest_RP/models/blocks/cube.geo.json +35 -0
- package/examples/mob_chest/dev/mob_chest_RP/models/blocks/empty.geo.json +35 -0
- package/examples/mob_chest/dev/mob_chest_RP/models/entity/mob_chest.geo.json +98 -0
- package/examples/mob_chest/dev/mob_chest_RP/pack_icon.png +0 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/blocks/entity/double_normal.png +0 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/blocks/entity/none.png +0 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/blocks/entity/normal.png +0 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/blocks/test_log_oak.png +0 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/blocks/test_log_top.png +0 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/flipbook_textures.json +1 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/item_texture.json +9 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/items/masterball.png +0 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/terrain_texture.json +23 -0
- package/examples/mob_chest/dev/mob_chest_RP/ui/_ui_defs.json +3 -0
- package/examples/mob_chest/main.mjs +31 -0
- package/examples/mob_chest/mod.info +7 -0
- package/examples/mob_chest/pack_icon.png +0 -0
- package/examples/mob_chest/res/animation_controllers/mob_chest.animation_controllers.json +30 -0
- package/examples/mob_chest/res/animations/animation_item.animation.json +34 -0
- package/examples/mob_chest/res/animations/large_item.animation.json +27 -0
- package/examples/mob_chest/res/animations/mob_chest.animation.json +64 -0
- package/examples/mob_chest/res/models/blocks/crop.geo.json +48 -0
- package/examples/mob_chest/res/models/blocks/cube.geo.json +35 -0
- package/examples/mob_chest/res/models/blocks/empty.geo.json +35 -0
- package/examples/mob_chest/res/models/entity/mob_chest.geo.json +98 -0
- package/examples/mob_chest/res/textures/blocks/entity/double_normal.png +0 -0
- package/examples/mob_chest/res/textures/blocks/entity/none.png +0 -0
- package/examples/mob_chest/res/textures/blocks/entity/normal.png +0 -0
- package/examples/mob_chest/res/textures/blocks/test_log_oak.png +0 -0
- package/examples/mob_chest/res/textures/blocks/test_log_top.png +0 -0
- package/examples/mob_chest/res/textures/items/masterball.png +0 -0
- package/examples/mob_chest/resource/cube.bbmodel +1 -0
- package/examples/mob_chest/resource/flipbook_item.bbmodel +1 -0
- package/examples/mob_chest/resource/flipbook_item.geo.bbmodel +1 -0
- package/examples/mob_chest/resource/flipbook_item.geo.json +3124 -0
- package/examples/mob_chest/resource/mob_chest.bbmodel +1 -0
- package/examples/mob_chest/scripts/custom_components/block/block_with_entity.js +46 -0
- package/examples/mob_chest/scripts/custom_components/block/cropComponent.js +50 -0
- package/examples/mob_chest/scripts/custom_components/items/gui_book.js +37 -0
- package/examples/mob_chest/scripts/custom_components/registry.js +25 -0
- package/examples/mob_chest/scripts/index.js +4 -0
- package/examples/test/build.config +29 -0
- package/examples/test/dev/test_BP/blocks/sapdon_ore_cinnabar.json +15 -15
- package/examples/test/dev/test_BP/blocks/sapdon_test_block.json +15 -15
- package/examples/test/dev/test_BP/blocks/sapdon_test_crop.json +191 -191
- package/examples/test/dev/test_BP/blocks/sapdon_wire.json +102 -102
- package/examples/test/dev/test_BP/entities/sapdon_test_projectile.json +56 -55
- package/examples/test/dev/test_BP/feature_rules/ore_cinnabar_orefeatre_rule.json +52 -52
- package/examples/test/dev/test_BP/feature_rules/overworld_underground_titanite_ore_feature.json +52 -52
- package/examples/test/dev/test_BP/features/ore_cinnabar_ore_feature.json +16 -16
- package/examples/test/dev/test_BP/features/titanite_ore_feature.json +22 -22
- package/examples/test/dev/test_BP/items/sapdon_chest.json +22 -22
- package/examples/test/dev/test_BP/items/sapdon_test_book.json +19 -0
- package/examples/test/dev/test_BP/items/sapdon_test_food.json +25 -25
- package/examples/test/dev/test_BP/items/sapdon_test_item.json +30 -30
- package/examples/test/dev/test_BP/manifest.json +63 -59
- package/examples/test/dev/test_BP/recipes/sapdon_test_furnace.json +12 -12
- package/examples/test/dev/test_BP/scripts/custom_components/cropComponent.js +1 -10
- package/examples/test/dev/test_BP/scripts/custom_components/items/gui_book.js +37 -0
- package/examples/test/dev/test_BP/scripts/custom_components/registry.js +20 -0
- package/examples/test/dev/test_BP/scripts/index.js +4 -3
- package/examples/test/dev/test_RP/attachables/sapdon_chest.json +24 -24
- package/examples/test/dev/test_RP/blocks.json +42 -42
- package/examples/test/dev/test_RP/entity/sapdon_test_projectile.json +27 -27
- package/examples/test/dev/test_RP/manifest.json +43 -43
- package/examples/test/dev/test_RP/models/blocks/arcane_workbench.geo.json +105 -105
- package/examples/test/dev/test_RP/models/blocks/jar_normal.geo.json +46 -46
- package/examples/test/dev/test_RP/models/blocks/jar_normal_0.geo.json +58 -58
- package/examples/test/dev/test_RP/models/blocks/jar_normal_1.geo.json +58 -58
- package/examples/test/dev/test_RP/models/blocks/jar_normal_2.geo.json +58 -58
- package/examples/test/dev/test_RP/models/blocks/jar_normal_3.geo.json +58 -58
- package/examples/test/dev/test_RP/models/blocks/wire.geo.json +153 -153
- package/examples/test/dev/test_RP/textures/item_texture.json +788 -788
- package/examples/test/dev/test_RP/textures/items/seals/seal_breaker.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_butcher.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_empty.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_empty_advanced.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_fill.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_fill_advanced.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_guard.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_guard_advanced.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_harvest.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_lumber.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_pickup.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_pickup_advanced.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_provider.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_use.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/wand/cap_thaumium.png.mcmeta +11 -11
- package/examples/test/dev/test_RP/textures/items/wand/cap_void.png.mcmeta +11 -11
- package/examples/test/dev/test_RP/textures/items/wand/focus_pech.png.mcmeta +2 -2
- package/examples/test/dev/test_RP/textures/items/wand/focus_portablehole.png.mcmeta +2 -2
- package/examples/test/dev/test_RP/textures/items/wand/focus_primal.png.mcmeta +2 -2
- package/examples/test/dev/test_RP/textures/items/wand/focus_shard.png.mcmeta +2 -2
- package/examples/test/dev/test_RP/textures/items/wand/focus_warding.png.mcmeta +2 -2
- package/examples/test/dev/test_RP/textures/items/wand/rod_primal_mat.png.mcmeta +44 -44
- package/examples/test/dev/test_RP/textures/terrain_texture.json +136 -136
- package/examples/test/dev/test_RP/ui/_ui_defs.json +6 -0
- package/examples/test/dev/test_RP/ui/guidebook.json +446 -0
- package/examples/test/dev/test_RP/ui/server_form.json +91 -0
- package/examples/test/main.mjs +46 -1
- package/examples/test/res/models/blocks/arcane_workbench.geo.json +105 -105
- package/examples/test/res/models/blocks/jar_normal.geo.json +46 -46
- package/examples/test/res/models/blocks/jar_normal_0.geo.json +58 -58
- package/examples/test/res/models/blocks/jar_normal_1.geo.json +58 -58
- package/examples/test/res/models/blocks/jar_normal_2.geo.json +58 -58
- package/examples/test/res/models/blocks/jar_normal_3.geo.json +58 -58
- package/examples/test/res/models/blocks/wire.geo.json +153 -153
- package/examples/test/res/textures/items/seals/seal_breaker.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_butcher.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_empty.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_empty_advanced.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_fill.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_fill_advanced.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_guard.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_guard_advanced.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_harvest.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_lumber.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_pickup.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_pickup_advanced.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_provider.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_use.png.mcmeta +5 -5
- package/examples/test/res/textures/items/wand/cap_thaumium.png.mcmeta +11 -11
- package/examples/test/res/textures/items/wand/cap_void.png.mcmeta +11 -11
- package/examples/test/res/textures/items/wand/focus_pech.png.mcmeta +2 -2
- package/examples/test/res/textures/items/wand/focus_portablehole.png.mcmeta +2 -2
- package/examples/test/res/textures/items/wand/focus_primal.png.mcmeta +2 -2
- package/examples/test/res/textures/items/wand/focus_shard.png.mcmeta +2 -2
- package/examples/test/res/textures/items/wand/focus_warding.png.mcmeta +2 -2
- package/examples/test/res/textures/items/wand/rod_primal_mat.png.mcmeta +44 -44
- package/examples/test/scripts/custom_components/cropComponent.js +1 -10
- package/examples/test/scripts/custom_components/items/gui_book.js +37 -0
- package/examples/test/scripts/custom_components/registry.js +20 -0
- package/examples/test/scripts/index.js +4 -3
- package/log.md +8 -0
- package/package.json +4 -1
- package/src/cli/build.js +210 -210
- package/src/cli/load.js +116 -112
- package/src/cli/tools/textureSet.js +114 -114
- package/src/cli/utils.js +82 -82
- package/src/core/addon/controllers/animation_controller.js +80 -0
- package/src/core/addon/entity/entity.js +52 -51
- package/src/core/block/GeometryBlock.js +8 -0
- package/src/core/block/OreBlock.js +1 -0
- package/src/core/block/TileBlock.js +117 -0
- package/src/core/block/block.js +106 -106
- package/src/core/block/blockComponent.js +557 -557
- package/src/core/block/cropBlock.js +1 -1
- package/src/core/entity/BasicEntity.js +195 -166
- package/src/core/entity/bundles/BasicBundle.js +51 -0
- package/src/core/factory/BlockFactory.js +166 -158
- package/src/core/factory/EntityFactory.js +82 -82
- package/src/core/factory/ItemFactory.js +120 -95
- package/src/core/factory/RecipeFactory.js +46 -46
- package/src/core/index.js +2 -1
- package/src/core/item/Item.js +96 -96
- package/src/core/item/ItemComponents.js +251 -235
- package/src/core/item/armor.js +117 -89
- package/src/core/item/attachable.js +33 -33
- package/src/core/item/food.js +61 -61
- package/src/core/registry.js +16 -16
- package/src/core/ui/Properties/{Grid.js → GridProp.js} +2 -2
- package/src/core/ui/Properties/Sound.js +72 -0
- package/src/core/ui/elements/Button.js +111 -0
- package/src/core/ui/elements/CollectionPanel.js +61 -0
- package/src/core/ui/elements/Grid.js +24 -0
- package/src/core/ui/elements/Image.js +4 -0
- package/src/core/ui/elements/Label.js +10 -2
- package/src/core/ui/elements/Panel.js +7 -0
- package/src/core/ui/elements/ScrollingPanel.js +68 -0
- package/src/core/ui/elements/StackPanel.js +40 -0
- package/src/core/ui/elements/UIElement.js +43 -2
- package/src/core/ui/registry/UISystemRegistry.js +35 -0
- package/src/core/ui/systems/UISystem.js +9 -5
- package/src/core/ui/systems/guidebook.js +299 -0
- package/src/core/ui/systems/server_form.js +94 -83
- package/src/templates/test_sapdon/build.config +28 -28
- package/src/templates/test_sapdon/res/animations/animation_item.animation.json +34 -0
- package/src/templates/test_sapdon/res/animations/large_item.animation.json +27 -0
- package/src/templates/test_sapdon/res/models/entity/animation/animation_item.geo.json +26 -0
- package/src/templates/test_sapdon/res/models/entity/animation/large_item.geo.json +28 -0
- package/src/templates/test_sapdon/res/textures/blocks/none.png +0 -0
- package/src/templates/test_sapdon/scripts/custom_components/cropComponent.js +50 -0
- package/src/templates/test_sapdon/scripts/custom_components/items/gui_book.js +37 -0
- package/src/templates/test_sapdon/scripts/custom_components/registry.js +25 -0
- package/examples/masterball/dev/masterball[1.20.20+].mcaddon.zip +0 -0
- package/examples/masterball/dev/masterball_BP/masterball_BP_1_20_20/entities/sapdon_projectile_masterball.json +0 -56
- package/examples/masterball/dev/masterball_BP/masterball_BP_1_20_20/items/sapdon_caught_masterball.json +0 -32
- package/examples/masterball/dev/masterball_BP/masterball_BP_1_20_20/items/sapdon_uncaught_masterball.json +0 -31
- package/examples/masterball/dev/masterball_BP/masterball_BP_1_20_20/scripts/index.js +0 -159
- package/examples/test/dev/test_BP/biomes/test_biome.json +0 -48
- package/examples/test/dev/test_BP/blocks/sapdon_block.json +0 -111
- package/examples/test/dev/test_BP/entities/sapdon_body.json +0 -118
- package/examples/test/dev/test_BP/entities/sapdon_test_entity_ctrl1.json +0 -55
- package/examples/test/dev/test_BP/entities/sapdon_test_entity_ctrl2.json +0 -61
- package/examples/test/dev/test_BP/entities/sapdon_test_entity_header.json +0 -408
- package/examples/test/dev/test_RP/entity/sapdon_body.json +0 -44
- package/examples/test/dev/test_RP/entity/sapdon_test_entity_ctrl1.json +0 -38
- package/examples/test/dev/test_RP/entity/sapdon_test_entity_ctrl2.json +0 -38
- package/examples/test/dev/test_RP/entity/sapdon_test_entity_header.json +0 -44
- package/src/cli/build.config +0 -4
- package/src/core/ui/registry/ServerUISystem.js +0 -19
- /package/examples/{masterball/dev/masterball_BP/masterball_BP_1_20_20 → guidebook/dev/guidebook_BP}/pack_icon.png +0 -0
package/src/cli/build.js
CHANGED
|
@@ -1,211 +1,211 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { checkPath, readFile, generateUUID ,saveFile,copyFileSync, copyFolder} from "./utils.js"
|
|
3
|
-
import { loadAndExecuteMod } from './load.js';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
AddonManifestHeader,
|
|
7
|
-
AddonManifestModule,
|
|
8
|
-
AddonManifest,
|
|
9
|
-
AddonManifestMetadata
|
|
10
|
-
} from '../core/addon/manifest.js';
|
|
11
|
-
|
|
12
|
-
import { fileURLToPath } from 'url';
|
|
13
|
-
|
|
14
|
-
// 获取当前文件的目录路径
|
|
15
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
-
const __dirname = path.dirname(__filename);
|
|
17
|
-
|
|
18
|
-
//读取配置文件
|
|
19
|
-
const pathConfig = JSON.parse(readFile(path.join(__dirname,"./build.config")));
|
|
20
|
-
|
|
21
|
-
//构建项目
|
|
22
|
-
export const buildProject = (projectPath,projectName) => {
|
|
23
|
-
console.log("开始构建项目");
|
|
24
|
-
console.log("项目路径:" + projectPath);
|
|
25
|
-
//检查项目是否存在
|
|
26
|
-
if(checkPath(projectPath)) {
|
|
27
|
-
console.log("项目不存在");
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
//检查项目是否有build.config文件
|
|
31
|
-
if(checkPath(path.join(projectPath,"build.config"))) {
|
|
32
|
-
console.log("项目没有build.config文件");
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//读取build.config文件
|
|
37
|
-
const buildConfigPath = path.join(projectPath,"build.config");
|
|
38
|
-
const buildConfig = JSON.parse(readFile(buildConfigPath));
|
|
39
|
-
//console.log(buildConfig);
|
|
40
|
-
|
|
41
|
-
//读取mod.info文件
|
|
42
|
-
const modInfoPath = path.join(projectPath,"mod.info");
|
|
43
|
-
const modInfo = JSON.parse(readFile(modInfoPath));
|
|
44
|
-
const min_engine_version = versionStringToArray(modInfo.min_engine_version);
|
|
45
|
-
|
|
46
|
-
const buildDirPath = path.join(projectPath,buildConfig.defaultConfig.buildDir);
|
|
47
|
-
|
|
48
|
-
const buildBehDirPath = path.join(buildDirPath,`${projectName}_BP/`);
|
|
49
|
-
const buildResDirPath = path.join(buildDirPath,`${projectName}_RP/`);
|
|
50
|
-
//生成manifest.json文件
|
|
51
|
-
//判断manifest.json是否已经生成过了,生成过了就不用生成
|
|
52
|
-
const manifestPath = path.join(buildBehDirPath,"manifest.json");
|
|
53
|
-
if(checkPath(manifestPath)){
|
|
54
|
-
const behManifest = generateBehManifest(
|
|
55
|
-
modInfo.name,
|
|
56
|
-
modInfo.description,
|
|
57
|
-
modInfo.version,
|
|
58
|
-
{
|
|
59
|
-
min_engine_version:min_engine_version,
|
|
60
|
-
},
|
|
61
|
-
buildConfig.defaultConfig.dependencies,
|
|
62
|
-
buildConfig.defaultConfig.scriptEntry
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const resManifest = generateResManifest(
|
|
66
|
-
modInfo.name,
|
|
67
|
-
modInfo.description,
|
|
68
|
-
modInfo.version,
|
|
69
|
-
{
|
|
70
|
-
min_engine_version:min_engine_version,
|
|
71
|
-
},
|
|
72
|
-
[]
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
//BP
|
|
76
|
-
saveFile(path.join(buildBehDirPath,"manifest.json"),behManifest);
|
|
77
|
-
//RP
|
|
78
|
-
saveFile(path.join(buildResDirPath,"manifest.json"),resManifest);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
//复制pack_icon.png
|
|
82
|
-
const packIconPath = path.join(projectPath,"pack_icon.png");
|
|
83
|
-
|
|
84
|
-
copyFileSync(packIconPath,path.join(buildBehDirPath,"pack_icon.png"));
|
|
85
|
-
copyFileSync(packIconPath,path.join(buildResDirPath,"pack_icon.png"));
|
|
86
|
-
|
|
87
|
-
//复制文件夹
|
|
88
|
-
const resources = buildConfig.resources;
|
|
89
|
-
resources.forEach(element => {
|
|
90
|
-
const sourcePath = path.join(projectPath,element.path);
|
|
91
|
-
copyFolder(sourcePath,buildResDirPath);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
//复制scripts文件夹
|
|
95
|
-
const scripts = buildConfig.scripts;
|
|
96
|
-
const scriptPath = path.join(buildBehDirPath,"scripts/");
|
|
97
|
-
scripts.forEach(element => {
|
|
98
|
-
const sourcePath = path.join(projectPath,element.path);
|
|
99
|
-
copyFolder(sourcePath,scriptPath);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
//只有当buildMode为development时才加载用户modjs文件
|
|
105
|
-
if(buildConfig.defaultConfig.buildMode === "development"){
|
|
106
|
-
//动态加载用户modjs文件
|
|
107
|
-
loadAndExecuteMod(path.join(projectPath,buildConfig.defaultConfig.buildEntry),buildDirPath,projectName);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
//延迟1s
|
|
111
|
-
setTimeout(()=>{
|
|
112
|
-
//将编译好的文件夹拷贝至mc
|
|
113
|
-
//console.log(path.join(pathConfig.mojangPath,`development_behavior_packs/${projectName}_BP/`));
|
|
114
|
-
copyFolder(buildBehDirPath,path.join(pathConfig.mojangPath,"development_behavior_packs/",`${projectName}_BP/`));
|
|
115
|
-
copyFolder(buildResDirPath,path.join(pathConfig.mojangPath,"development_resource_packs/",`${projectName}_RP/`));
|
|
116
|
-
},1000);
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function versionStringToArray(versionString) {
|
|
121
|
-
// 使用 split 方法将字符串按 '.' 分割成数组
|
|
122
|
-
const parts = versionString.split('.');
|
|
123
|
-
|
|
124
|
-
// 使用 map 方法将每个部分转换为数字
|
|
125
|
-
const versionArray = parts.map(part => Number(part));
|
|
126
|
-
|
|
127
|
-
return versionArray;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const generateBehManifest = (name, description, version, options = {},dependencies = [],entry) => {
|
|
131
|
-
console.log("开始生成behavior_packs/manifest.json")
|
|
132
|
-
console.log("Entry:",entry)
|
|
133
|
-
const header = new AddonManifestHeader(
|
|
134
|
-
(name+"_BP"),
|
|
135
|
-
description,
|
|
136
|
-
versionStringToArray(version),
|
|
137
|
-
generateUUID(),
|
|
138
|
-
options
|
|
139
|
-
);
|
|
140
|
-
const module = new AddonManifestModule(
|
|
141
|
-
"行为模块",
|
|
142
|
-
"data",
|
|
143
|
-
generateUUID(),
|
|
144
|
-
versionStringToArray(version)
|
|
145
|
-
);
|
|
146
|
-
const script_module = new AddonManifestModule(
|
|
147
|
-
"脚本模块",
|
|
148
|
-
"script",
|
|
149
|
-
generateUUID(),
|
|
150
|
-
versionStringToArray(version)
|
|
151
|
-
);
|
|
152
|
-
if(entry){script_module.entry = entry;}
|
|
153
|
-
|
|
154
|
-
const metadata = new AddonManifestMetadata(
|
|
155
|
-
["@sapdon"],
|
|
156
|
-
"MIT",
|
|
157
|
-
{
|
|
158
|
-
"sapdon":["
|
|
159
|
-
},
|
|
160
|
-
"addon",
|
|
161
|
-
"https://github.com/
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
const manifest = new AddonManifest(
|
|
165
|
-
2,//格式版本
|
|
166
|
-
header,
|
|
167
|
-
[module,script_module],
|
|
168
|
-
dependencies,
|
|
169
|
-
null,
|
|
170
|
-
metadata
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
return JSON.stringify(manifest, null, 2);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const generateResManifest = (name, description, version,options = {},dependencies = []) => {
|
|
177
|
-
const header = new AddonManifestHeader(
|
|
178
|
-
(name+"_RP"),
|
|
179
|
-
description,
|
|
180
|
-
versionStringToArray(version),
|
|
181
|
-
generateUUID(),
|
|
182
|
-
options
|
|
183
|
-
);
|
|
184
|
-
const module = new AddonManifestModule(
|
|
185
|
-
"资源模块",
|
|
186
|
-
"resources",
|
|
187
|
-
generateUUID(),
|
|
188
|
-
versionStringToArray(version)
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
const metadata = new AddonManifestMetadata(
|
|
192
|
-
["@sapdon"],
|
|
193
|
-
"MIT",
|
|
194
|
-
{
|
|
195
|
-
"sapdon":["
|
|
196
|
-
},
|
|
197
|
-
"addon",
|
|
198
|
-
"https://github.com/
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
const manifest = new AddonManifest(
|
|
202
|
-
2,//格式版本
|
|
203
|
-
header,
|
|
204
|
-
[module],
|
|
205
|
-
[],
|
|
206
|
-
null,
|
|
207
|
-
metadata
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
return JSON.stringify(manifest, null, 2);
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { checkPath, readFile, generateUUID ,saveFile,copyFileSync, copyFolder} from "./utils.js"
|
|
3
|
+
import { loadAndExecuteMod } from './load.js';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
AddonManifestHeader,
|
|
7
|
+
AddonManifestModule,
|
|
8
|
+
AddonManifest,
|
|
9
|
+
AddonManifestMetadata
|
|
10
|
+
} from '../core/addon/manifest.js';
|
|
11
|
+
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
|
|
14
|
+
// 获取当前文件的目录路径
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
const __dirname = path.dirname(__filename);
|
|
17
|
+
|
|
18
|
+
//读取配置文件
|
|
19
|
+
const pathConfig = JSON.parse(readFile(path.join(__dirname,"./build.config")));
|
|
20
|
+
|
|
21
|
+
//构建项目
|
|
22
|
+
export const buildProject = (projectPath,projectName) => {
|
|
23
|
+
console.log("开始构建项目");
|
|
24
|
+
console.log("项目路径:" + projectPath);
|
|
25
|
+
//检查项目是否存在
|
|
26
|
+
if(checkPath(projectPath)) {
|
|
27
|
+
console.log("项目不存在");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
//检查项目是否有build.config文件
|
|
31
|
+
if(checkPath(path.join(projectPath,"build.config"))) {
|
|
32
|
+
console.log("项目没有build.config文件");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//读取build.config文件
|
|
37
|
+
const buildConfigPath = path.join(projectPath,"build.config");
|
|
38
|
+
const buildConfig = JSON.parse(readFile(buildConfigPath));
|
|
39
|
+
//console.log(buildConfig);
|
|
40
|
+
|
|
41
|
+
//读取mod.info文件
|
|
42
|
+
const modInfoPath = path.join(projectPath,"mod.info");
|
|
43
|
+
const modInfo = JSON.parse(readFile(modInfoPath));
|
|
44
|
+
const min_engine_version = versionStringToArray(modInfo.min_engine_version);
|
|
45
|
+
|
|
46
|
+
const buildDirPath = path.join(projectPath,buildConfig.defaultConfig.buildDir);
|
|
47
|
+
|
|
48
|
+
const buildBehDirPath = path.join(buildDirPath,`${projectName}_BP/`);
|
|
49
|
+
const buildResDirPath = path.join(buildDirPath,`${projectName}_RP/`);
|
|
50
|
+
//生成manifest.json文件
|
|
51
|
+
//判断manifest.json是否已经生成过了,生成过了就不用生成
|
|
52
|
+
const manifestPath = path.join(buildBehDirPath,"manifest.json");
|
|
53
|
+
if(checkPath(manifestPath)){
|
|
54
|
+
const behManifest = generateBehManifest(
|
|
55
|
+
modInfo.name,
|
|
56
|
+
modInfo.description,
|
|
57
|
+
modInfo.version,
|
|
58
|
+
{
|
|
59
|
+
min_engine_version:min_engine_version,
|
|
60
|
+
},
|
|
61
|
+
buildConfig.defaultConfig.dependencies,
|
|
62
|
+
buildConfig.defaultConfig.scriptEntry
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const resManifest = generateResManifest(
|
|
66
|
+
modInfo.name,
|
|
67
|
+
modInfo.description,
|
|
68
|
+
modInfo.version,
|
|
69
|
+
{
|
|
70
|
+
min_engine_version:min_engine_version,
|
|
71
|
+
},
|
|
72
|
+
[]
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
//BP
|
|
76
|
+
saveFile(path.join(buildBehDirPath,"manifest.json"),behManifest);
|
|
77
|
+
//RP
|
|
78
|
+
saveFile(path.join(buildResDirPath,"manifest.json"),resManifest);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//复制pack_icon.png
|
|
82
|
+
const packIconPath = path.join(projectPath,"pack_icon.png");
|
|
83
|
+
|
|
84
|
+
copyFileSync(packIconPath,path.join(buildBehDirPath,"pack_icon.png"));
|
|
85
|
+
copyFileSync(packIconPath,path.join(buildResDirPath,"pack_icon.png"));
|
|
86
|
+
|
|
87
|
+
//复制文件夹
|
|
88
|
+
const resources = buildConfig.resources;
|
|
89
|
+
resources.forEach(element => {
|
|
90
|
+
const sourcePath = path.join(projectPath,element.path);
|
|
91
|
+
copyFolder(sourcePath,buildResDirPath);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
//复制scripts文件夹
|
|
95
|
+
const scripts = buildConfig.scripts;
|
|
96
|
+
const scriptPath = path.join(buildBehDirPath,"scripts/");
|
|
97
|
+
scripts.forEach(element => {
|
|
98
|
+
const sourcePath = path.join(projectPath,element.path);
|
|
99
|
+
copyFolder(sourcePath,scriptPath);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
//只有当buildMode为development时才加载用户modjs文件
|
|
105
|
+
if(buildConfig.defaultConfig.buildMode === "development"){
|
|
106
|
+
//动态加载用户modjs文件
|
|
107
|
+
loadAndExecuteMod(path.join(projectPath,buildConfig.defaultConfig.buildEntry),buildDirPath,projectName);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
//延迟1s
|
|
111
|
+
setTimeout(()=>{
|
|
112
|
+
//将编译好的文件夹拷贝至mc
|
|
113
|
+
//console.log(path.join(pathConfig.mojangPath,`development_behavior_packs/${projectName}_BP/`));
|
|
114
|
+
copyFolder(buildBehDirPath,path.join(pathConfig.mojangPath,"development_behavior_packs/",`${projectName}_BP/`));
|
|
115
|
+
copyFolder(buildResDirPath,path.join(pathConfig.mojangPath,"development_resource_packs/",`${projectName}_RP/`));
|
|
116
|
+
},1000);
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function versionStringToArray(versionString) {
|
|
121
|
+
// 使用 split 方法将字符串按 '.' 分割成数组
|
|
122
|
+
const parts = versionString.split('.');
|
|
123
|
+
|
|
124
|
+
// 使用 map 方法将每个部分转换为数字
|
|
125
|
+
const versionArray = parts.map(part => Number(part));
|
|
126
|
+
|
|
127
|
+
return versionArray;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const generateBehManifest = (name, description, version, options = {},dependencies = [],entry) => {
|
|
131
|
+
console.log("开始生成behavior_packs/manifest.json")
|
|
132
|
+
console.log("Entry:",entry)
|
|
133
|
+
const header = new AddonManifestHeader(
|
|
134
|
+
(name+"_BP"),
|
|
135
|
+
description,
|
|
136
|
+
versionStringToArray(version),
|
|
137
|
+
generateUUID(),
|
|
138
|
+
options
|
|
139
|
+
);
|
|
140
|
+
const module = new AddonManifestModule(
|
|
141
|
+
"行为模块",
|
|
142
|
+
"data",
|
|
143
|
+
generateUUID(),
|
|
144
|
+
versionStringToArray(version)
|
|
145
|
+
);
|
|
146
|
+
const script_module = new AddonManifestModule(
|
|
147
|
+
"脚本模块",
|
|
148
|
+
"script",
|
|
149
|
+
generateUUID(),
|
|
150
|
+
versionStringToArray(version)
|
|
151
|
+
);
|
|
152
|
+
if(entry){script_module.entry = entry;}
|
|
153
|
+
|
|
154
|
+
const metadata = new AddonManifestMetadata(
|
|
155
|
+
["@sapdon"],
|
|
156
|
+
"MIT",
|
|
157
|
+
{
|
|
158
|
+
"sapdon":["2.0.1"]
|
|
159
|
+
},
|
|
160
|
+
"addon",
|
|
161
|
+
"https://github.com/Meteage/sapdon"
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const manifest = new AddonManifest(
|
|
165
|
+
2,//格式版本
|
|
166
|
+
header,
|
|
167
|
+
[module,script_module],
|
|
168
|
+
dependencies,
|
|
169
|
+
null,
|
|
170
|
+
metadata
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
return JSON.stringify(manifest, null, 2);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const generateResManifest = (name, description, version,options = {},dependencies = []) => {
|
|
177
|
+
const header = new AddonManifestHeader(
|
|
178
|
+
(name+"_RP"),
|
|
179
|
+
description,
|
|
180
|
+
versionStringToArray(version),
|
|
181
|
+
generateUUID(),
|
|
182
|
+
options
|
|
183
|
+
);
|
|
184
|
+
const module = new AddonManifestModule(
|
|
185
|
+
"资源模块",
|
|
186
|
+
"resources",
|
|
187
|
+
generateUUID(),
|
|
188
|
+
versionStringToArray(version)
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
const metadata = new AddonManifestMetadata(
|
|
192
|
+
["@sapdon"],
|
|
193
|
+
"MIT",
|
|
194
|
+
{
|
|
195
|
+
"sapdon":["2.0.1"]
|
|
196
|
+
},
|
|
197
|
+
"addon",
|
|
198
|
+
"https://github.com/Meteage/sapdon"
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
const manifest = new AddonManifest(
|
|
202
|
+
2,//格式版本
|
|
203
|
+
header,
|
|
204
|
+
[module],
|
|
205
|
+
[],
|
|
206
|
+
null,
|
|
207
|
+
metadata
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
return JSON.stringify(manifest, null, 2);
|
|
211
211
|
}
|
package/src/cli/load.js
CHANGED
|
@@ -1,113 +1,117 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { pathToFileURL } from "url";
|
|
3
|
-
import { saveFile } from "./utils.js";
|
|
4
|
-
import { GRegistry } from "../core/registry.js";
|
|
5
|
-
import { generateBlockTextureJson, generateItemTextureJson} from "./tools/textureSet.js";
|
|
6
|
-
import { FlipbookTextures, ItemTextureManager, terrainTextureManager } from "../core/texture.js";
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
* @param {string}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
//
|
|
86
|
-
dataList.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
//
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { pathToFileURL } from "url";
|
|
3
|
+
import { saveFile } from "./utils.js";
|
|
4
|
+
import { GRegistry } from "../core/registry.js";
|
|
5
|
+
import { generateBlockTextureJson, generateItemTextureJson} from "./tools/textureSet.js";
|
|
6
|
+
import { FlipbookTextures, ItemTextureManager, terrainTextureManager } from "../core/texture.js";
|
|
7
|
+
|
|
8
|
+
import { UISystemRegistry } from "../core/ui/registry/UISystemRegistry.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 处理 blocks.json 数据
|
|
12
|
+
* @param {Object} data blocks.json 数据
|
|
13
|
+
* @returns {Object} 处理后的 blocks 数据
|
|
14
|
+
*/
|
|
15
|
+
const processBlocksData = (data) => {
|
|
16
|
+
const textures_arr = data.textures;
|
|
17
|
+
|
|
18
|
+
// 检查 textures 数组长度
|
|
19
|
+
if (textures_arr.length !== 6) {
|
|
20
|
+
console.warn(`blocks.json 的 textures 数组长度不为 6,实际长度: ${textures_arr.length}`);
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 构建 blocks 数据
|
|
25
|
+
const blocks = {};
|
|
26
|
+
blocks[data.identifier] = {
|
|
27
|
+
textures: {
|
|
28
|
+
up: textures_arr[0],
|
|
29
|
+
down: textures_arr[1],
|
|
30
|
+
east: textures_arr[2],
|
|
31
|
+
west: textures_arr[3],
|
|
32
|
+
south: textures_arr[4],
|
|
33
|
+
north: textures_arr[5]
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return blocks;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 加载并执行模组文件
|
|
42
|
+
* @param {string} modPath 模组文件路径
|
|
43
|
+
* @param {string} buildPath 构建目录路径
|
|
44
|
+
*/
|
|
45
|
+
export const loadAndExecuteMod = async (modPath, buildPath,projectName) => {
|
|
46
|
+
try {
|
|
47
|
+
// 将 modPath 解析为绝对路径
|
|
48
|
+
const absoluteModPath = path.resolve(modPath);
|
|
49
|
+
|
|
50
|
+
// 将路径转换为 file:// URL
|
|
51
|
+
const fileUrl = pathToFileURL(absoluteModPath).href;
|
|
52
|
+
|
|
53
|
+
// 动态加载 JavaScript 文件
|
|
54
|
+
await import(fileUrl);
|
|
55
|
+
|
|
56
|
+
const buildBehDirPath = path.join(buildPath,`${projectName}_BP/`);
|
|
57
|
+
const buildResDirPath = path.join(buildPath,`${projectName}_RP/`);
|
|
58
|
+
|
|
59
|
+
// 初始化 blocks.json 数据
|
|
60
|
+
const blocksJsonPath = path.join(buildPath, `${projectName}_RP`,"blocks.json");
|
|
61
|
+
const blocks = {"format_version": "1.20.20"};
|
|
62
|
+
|
|
63
|
+
//生成item_texture.json
|
|
64
|
+
const item_texture_dir = path.join(buildResDirPath,"textures/items");
|
|
65
|
+
const item_texture_json_path = path.join(buildResDirPath,"textures/item_texture.json")
|
|
66
|
+
generateItemTextureJson(item_texture_dir,item_texture_json_path,projectName,ItemTextureManager.getItemTextures());
|
|
67
|
+
|
|
68
|
+
//生成terrain_texture.json
|
|
69
|
+
const terrain_texture_dir = path.join(buildResDirPath,"textures/blocks")
|
|
70
|
+
const terrain_texture_json_path = path.join(buildResDirPath,"textures/terrain_texture.json")
|
|
71
|
+
generateBlockTextureJson(terrain_texture_dir,terrain_texture_json_path,projectName,terrainTextureManager.getTerrainTextures());
|
|
72
|
+
|
|
73
|
+
//生成flipbook_textures.json
|
|
74
|
+
const flipbook_textures_path = path.join(buildResDirPath,"textures/flipbook_textures.json")
|
|
75
|
+
saveFile(flipbook_textures_path,JSON.stringify(FlipbookTextures.flipbook_textures,null,2));
|
|
76
|
+
|
|
77
|
+
//_ui_defs.json
|
|
78
|
+
const ui_def = UISystemRegistry.getUIdefList();
|
|
79
|
+
saveFile(path.join(buildResDirPath,"ui/_ui_defs.json"),JSON.stringify({"ui_defs": ui_def},null,2));
|
|
80
|
+
|
|
81
|
+
UISystemRegistry.getUISystemList().forEach((ui_system)=>{
|
|
82
|
+
saveFile(path.join(buildResDirPath,ui_system.path,`${ui_system.name}.json`),JSON.stringify(ui_system.toJson(),null,2))
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
// 从全局注册表中获取数据
|
|
86
|
+
const dataList = GRegistry.getDataList();
|
|
87
|
+
//console.log("dataList:", dataList);
|
|
88
|
+
|
|
89
|
+
// 遍历数据并保存到相应的目录
|
|
90
|
+
dataList.forEach(({ name, root, path: dataPath, data }) => {
|
|
91
|
+
// 处理 blocks.json 数据
|
|
92
|
+
if (dataPath === "blocks/") {
|
|
93
|
+
const processedBlocks = processBlocksData(data);
|
|
94
|
+
Object.assign(blocks, processedBlocks);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 根据数据类型确定根目录
|
|
98
|
+
const rootPath = root === "behavior" ? `${projectName}_BP`: `${projectName}_RP`;
|
|
99
|
+
const buildRootPath = path.join(buildPath, rootPath);
|
|
100
|
+
|
|
101
|
+
// 拼接文件路径
|
|
102
|
+
const filePath = path.join(buildRootPath, dataPath, `${name}.json`);
|
|
103
|
+
|
|
104
|
+
// 保存文件
|
|
105
|
+
saveFile(filePath, JSON.stringify(data.toJson(), null, 2));
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// 保存 blocks.json
|
|
109
|
+
console.log("保存 blocks.json 文件:", blocksJsonPath);
|
|
110
|
+
saveFile(blocksJsonPath, JSON.stringify(blocks, null, 2));
|
|
111
|
+
|
|
112
|
+
console.log(`已加载并执行 ${modPath} 文件!`);
|
|
113
|
+
} catch (err) {
|
|
114
|
+
console.error(`加载或执行 ${modPath} 失败:${err.message}`);
|
|
115
|
+
console.error(err.stack); // 打印堆栈跟踪以便调试
|
|
116
|
+
}
|
|
113
117
|
};
|