sapdon 3.0.2 → 3.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/README.md +3 -2
- package/dist/cli/build.d.ts +7 -0
- package/dist/cli/build.js +236 -0
- package/dist/cli/dev-server/client.d.ts +2 -0
- package/dist/cli/dev-server/client.js +21 -0
- package/dist/cli/dev-server/config.d.ts +3 -0
- package/dist/cli/dev-server/config.js +3 -0
- package/dist/cli/dev-server/handles.d.ts +4 -0
- package/dist/cli/dev-server/handles.js +5 -0
- package/dist/cli/dev-server/hmr.d.ts +1 -0
- package/dist/cli/dev-server/hmr.js +13 -0
- package/dist/cli/dev-server/index.d.ts +4 -0
- package/dist/cli/dev-server/index.js +17 -0
- package/dist/cli/dev-server/server.d.ts +14 -0
- package/dist/cli/dev-server/server.js +59 -0
- package/dist/cli/dev-server/syncFiles.d.ts +3 -0
- package/dist/cli/dev-server/syncFiles.js +45 -0
- package/dist/cli/index.d.ts +20 -0
- package/dist/cli/index.js +90 -0
- package/dist/cli/init.d.ts +9 -0
- package/dist/cli/init.js +80 -0
- package/dist/cli/load.d.ts +3 -0
- package/dist/cli/load.js +94 -0
- package/dist/cli/start.d.ts +2 -0
- package/dist/cli/start.js +1398 -0
- package/dist/cli/tools/textureSet.d.ts +13 -0
- package/dist/cli/tools/textureSet.js +103 -0
- package/dist/cli/utils.d.ts +13 -0
- package/dist/cli/utils.js +89 -0
- package/dist/core/addon/biome.d.ts +22 -0
- package/dist/core/addon/biome.js +27 -0
- package/dist/core/addon/block/block.d.ts +41 -0
- package/dist/core/addon/block/block.js +46 -0
- package/dist/core/addon/controllers/animationController.d.ts +43 -0
- package/dist/core/addon/controllers/animationController.js +73 -0
- package/dist/core/addon/controllers/render_controllers.js +162 -0
- package/dist/core/addon/entity/clientEntity.d.ts +107 -0
- package/dist/core/addon/entity/clientEntity.js +149 -0
- package/dist/core/addon/entity/entity.d.ts +42 -0
- package/dist/core/addon/entity/entity.js +50 -0
- package/dist/core/addon/feature/oreFeature.d.ts +19 -0
- package/dist/core/addon/feature/oreFeature.js +24 -0
- package/dist/core/addon/featureRule.d.ts +20 -0
- package/dist/core/addon/featureRule.js +25 -0
- package/dist/core/addon/item/attachable.d.ts +94 -0
- package/dist/core/addon/item/attachable.js +134 -0
- package/dist/core/addon/item/item.d.ts +19 -0
- package/dist/core/addon/item/item.js +26 -0
- package/dist/core/addon/manifest.d.ts +49 -0
- package/dist/core/addon/manifest.js +65 -0
- package/dist/core/addon/menuCategory.d.ts +6 -0
- package/dist/core/addon/menuCategory.js +7 -0
- package/dist/core/addon/recipe/baseRecipe.d.ts +12 -0
- package/dist/core/addon/recipe/baseRecipe.js +23 -0
- package/dist/core/addon/recipe/data.d.ts +66 -0
- package/dist/core/addon/recipe/data.js +74 -0
- package/dist/core/addon/recipe/furnace.d.ts +17 -0
- package/dist/core/addon/recipe/furnace.js +43 -0
- package/dist/core/addon/recipe/shaped.d.ts +26 -0
- package/dist/core/addon/recipe/shaped.js +53 -0
- package/dist/core/addon/recipe/shapeless.d.ts +18 -0
- package/dist/core/addon/recipe/shapeless.js +36 -0
- package/dist/core/biome/biome.d.ts +14 -0
- package/dist/core/biome/biome.js +23 -0
- package/dist/core/biome/biomeComponent.d.ts +46 -0
- package/dist/core/biome/biomeComponent.js +77 -0
- package/dist/core/block/basicBlock.d.ts +48 -0
- package/dist/core/block/basicBlock.js +105 -0
- package/dist/core/block/block.d.ts +32 -0
- package/dist/core/block/block.js +92 -0
- package/dist/core/block/blockComponent.d.ts +187 -0
- package/dist/core/block/blockComponent.js +500 -0
- package/dist/core/block/cropBlock.d.ts +4 -0
- package/dist/core/block/cropBlock.js +27 -0
- package/dist/core/block/geometryBlock.d.ts +12 -0
- package/dist/core/block/geometryBlock.js +16 -0
- package/dist/core/block/oreBlock.d.ts +9 -0
- package/dist/core/block/oreBlock.js +25 -0
- package/dist/core/block/rotatableBlock.d.ts +27 -0
- package/dist/core/block/rotatableBlock.js +107 -0
- package/dist/core/block/tileBlock.d.ts +17 -0
- package/dist/core/block/tileBlock.js +125 -0
- package/dist/core/entity/basicEntity.d.ts +111 -0
- package/dist/core/entity/basicEntity.js +170 -0
- package/dist/core/entity/behavior/followMob.d.ts +12 -0
- package/dist/core/entity/behavior/followMob.js +35 -0
- package/dist/core/entity/behavior/followParent.d.ts +7 -0
- package/dist/core/entity/behavior/followParent.js +15 -0
- package/dist/core/entity/behavior/randomStroll.d.ts +31 -0
- package/dist/core/entity/behavior/randomStroll.js +63 -0
- package/dist/core/entity/behavior/tempt.d.ts +73 -0
- package/dist/core/entity/behavior/tempt.js +134 -0
- package/dist/core/entity/bundles/BasicMoveBundle.js +8 -0
- package/dist/core/entity/bundles/basicBundle.d.ts +13 -0
- package/dist/core/entity/bundles/basicBundle.js +38 -0
- package/dist/core/entity/clientEntity.d.ts +20 -0
- package/dist/core/entity/clientEntity.js +37 -0
- package/dist/core/entity/componets/entityComponet.d.ts +202 -0
- package/dist/core/entity/componets/entityComponet.js +354 -0
- package/dist/core/entity/data/nativeEntityData.d.ts +9 -0
- package/dist/core/entity/data/nativeEntityData.js +38 -0
- package/dist/core/entity/dummyEntity.js +14 -0
- package/dist/core/entity/entity.d.ts +15 -0
- package/dist/core/entity/entity.js +11 -0
- package/dist/core/entity/nativeEntity.d.ts +8 -0
- package/dist/core/entity/nativeEntity.js +28 -0
- package/dist/core/entity/navigation/walk.d.ts +23 -0
- package/dist/core/entity/navigation/walk.js +56 -0
- package/dist/core/entity/projectile.d.ts +3 -0
- package/dist/core/entity/projectile.js +7 -0
- package/dist/core/factory/biomeFactory.d.ts +4 -0
- package/dist/core/factory/biomeFactory.js +13 -0
- package/dist/core/factory/blockFactory.d.ts +34 -0
- package/dist/core/factory/blockFactory.js +143 -0
- package/dist/core/factory/entityFactory.d.ts +17 -0
- package/dist/core/factory/entityFactory.js +75 -0
- package/dist/core/factory/featureFactory.d.ts +6 -0
- package/dist/core/factory/featureFactory.js +23 -0
- package/dist/core/factory/itemExtra.d.ts +8 -0
- package/dist/core/factory/itemExtra.js +9 -0
- package/dist/core/factory/itemFactory.d.ts +27 -0
- package/dist/core/factory/itemFactory.js +112 -0
- package/dist/core/factory/recipeFactory.d.ts +18 -0
- package/dist/core/factory/recipeFactory.js +39 -0
- package/dist/core/factory/uiFactory.d.ts +12 -0
- package/dist/core/factory/uiFactory.js +32 -0
- package/dist/core/feature/oreFeature.d.ts +10 -0
- package/dist/core/feature/oreFeature.js +11 -0
- package/dist/core/feature-rule/condition/biomeFilter.d.ts +26 -0
- package/dist/core/feature-rule/condition/biomeFilter.js +36 -0
- package/dist/core/feature-rule/condition/featureConditions.d.ts +27 -0
- package/dist/core/feature-rule/condition/featureConditions.js +37 -0
- package/dist/core/feature-rule/distribution/coordinateDistribution.d.ts +17 -0
- package/dist/core/feature-rule/distribution/coordinateDistribution.js +23 -0
- package/dist/core/feature-rule/distribution/featureDistribution.d.ts +31 -0
- package/dist/core/feature-rule/distribution/featureDistribution.js +41 -0
- package/dist/core/feature-rule/featureRule.d.ts +17 -0
- package/dist/core/feature-rule/featureRule.js +26 -0
- package/dist/core/index.d.ts +2241 -0
- package/dist/core/index.js +1 -0
- package/dist/core/item/armor.d.ts +21 -0
- package/dist/core/item/armor.js +90 -0
- package/dist/core/item/attachable.d.ts +6 -0
- package/dist/core/item/attachable.js +26 -0
- package/dist/core/item/food.d.ts +24 -0
- package/dist/core/item/food.js +38 -0
- package/dist/core/item/item.d.ts +36 -0
- package/dist/core/item/item.js +69 -0
- package/dist/core/item/itemComponents.d.ts +113 -0
- package/dist/core/item/itemComponents.js +225 -0
- package/dist/core/registry.d.ts +12 -0
- package/dist/core/registry.js +17 -0
- package/dist/core/texture.d.ts +18 -0
- package/dist/core/texture.js +38 -0
- package/dist/core/ui/buttonMapping.d.ts +97 -0
- package/dist/core/ui/buttonMapping.js +132 -0
- package/dist/core/ui/dataBindingObject.d.ts +97 -0
- package/dist/core/ui/dataBindingObject.js +134 -0
- package/dist/core/ui/elements/button.d.ts +21 -0
- package/dist/core/ui/elements/button.js +101 -0
- package/dist/core/ui/elements/collectionPanel.d.ts +12 -0
- package/dist/core/ui/elements/collectionPanel.js +53 -0
- package/dist/core/ui/elements/grid.d.ts +8 -0
- package/dist/core/ui/elements/grid.js +33 -0
- package/dist/core/ui/elements/image.d.ts +13 -0
- package/dist/core/ui/elements/image.js +55 -0
- package/dist/core/ui/elements/label.d.ts +14 -0
- package/dist/core/ui/elements/label.js +61 -0
- package/dist/core/ui/elements/panel.d.ts +11 -0
- package/dist/core/ui/elements/panel.js +49 -0
- package/dist/core/ui/elements/scrollingPanel.d.ts +14 -0
- package/dist/core/ui/elements/scrollingPanel.js +59 -0
- package/dist/core/ui/elements/stackPanel.d.ts +14 -0
- package/dist/core/ui/elements/stackPanel.js +37 -0
- package/dist/core/ui/elements/uiElement.d.ts +53 -0
- package/dist/core/ui/elements/uiElement.js +129 -0
- package/dist/core/ui/properties/control.d.ts +214 -0
- package/dist/core/ui/properties/control.js +286 -0
- package/dist/core/ui/properties/dataBinding.d.ts +6 -0
- package/dist/core/ui/properties/dataBinding.js +16 -0
- package/dist/core/ui/properties/factory.d.ts +37 -0
- package/dist/core/ui/properties/factory.js +62 -0
- package/dist/core/ui/properties/gridProp.d.ts +65 -0
- package/dist/core/ui/properties/gridProp.js +90 -0
- package/dist/core/ui/properties/input.d.ts +97 -0
- package/dist/core/ui/properties/input.js +134 -0
- package/dist/core/ui/properties/layout.d.ts +105 -0
- package/dist/core/ui/properties/layout.js +145 -0
- package/dist/core/ui/properties/scrollView.d.ts +105 -0
- package/dist/core/ui/properties/scrollView.js +145 -0
- package/dist/core/ui/properties/sound.d.ts +47 -0
- package/dist/core/ui/properties/sound.js +66 -0
- package/dist/core/ui/properties/sprite.d.ts +161 -0
- package/dist/core/ui/properties/sprite.js +222 -0
- package/dist/core/ui/properties/text.d.ts +135 -0
- package/dist/core/ui/properties/text.js +187 -0
- package/dist/core/ui/registry/uiSystemRegistry.d.ts +8 -0
- package/dist/core/ui/registry/uiSystemRegistry.js +26 -0
- package/dist/core/ui/systems/chest.d.ts +5 -0
- package/dist/core/ui/systems/chest.js +21 -0
- package/dist/core/ui/systems/containerUISystem.d.ts +67 -0
- package/dist/core/ui/systems/containerUISystem.js +214 -0
- package/dist/core/ui/systems/guidebook.d.ts +9 -0
- package/dist/core/ui/systems/guidebook.js +206 -0
- package/dist/core/ui/systems/serverForm.d.ts +13 -0
- package/dist/core/ui/systems/serverForm.js +116 -0
- package/dist/core/ui/systems/system.d.ts +16 -0
- package/dist/core/ui/systems/system.js +37 -0
- package/dist/oc/actor.js +44 -0
- package/dist/oc/core.js +201 -0
- package/dist/oc/index.d.ts +142 -0
- package/dist/oc/index.js +1 -0
- package/dist/oc/input.js +67 -0
- package/dist/oc/optional.js +31 -0
- package/doc/oc/index.md +0 -0
- package/doc/sapdon-ts.md +41 -5
- package/package.json +6 -8
- package/doc/cli.md +0 -24
- /package/doc/hello_sapdon/{sapdon/344/275/277/347/224/250/346/225/231/347/250/213.md" → hello_sapdon.md} +0 -0
package/dist/cli/init.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { pathNotExist, copyFolder, saveFile } from './utils.js';
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import cp from "child_process";
|
|
6
|
+
import os from "os";
|
|
7
|
+
// 获取当前文件的路径
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
// 获取当前文件的目录
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
const templateMapping = {
|
|
12
|
+
js: 'test_sapdon',
|
|
13
|
+
ts: 'ts_sapdon'
|
|
14
|
+
};
|
|
15
|
+
export function initMojangPath(projectPath) {
|
|
16
|
+
const mojangPath = path.join(os.homedir(), "AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/");
|
|
17
|
+
const betaPath = path.join(os.homedir(), "AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/");
|
|
18
|
+
const buildConfigPath = path.join(projectPath, './build.config');
|
|
19
|
+
const buildConfig = JSON.parse(fs.readFileSync(buildConfigPath));
|
|
20
|
+
buildConfig.mojangPath = mojangPath;
|
|
21
|
+
buildConfig.betaPath = betaPath;
|
|
22
|
+
saveFile(buildConfigPath, JSON.stringify(buildConfig, null, 2));
|
|
23
|
+
}
|
|
24
|
+
export const initProject = (projectPath, data) => {
|
|
25
|
+
console.log(1, data);
|
|
26
|
+
//检查项目目录是否存在
|
|
27
|
+
//如果不存在则创建项目目录
|
|
28
|
+
//从模板下载项目文件
|
|
29
|
+
//根据用户输入的项目信息生成项目配置文件
|
|
30
|
+
//根据用户选择是否生成脚本文件,生成脚本文件
|
|
31
|
+
if (!pathNotExist(projectPath)) {
|
|
32
|
+
console.log("项目名称已存在,创建项目目录失败");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
//模版目录
|
|
36
|
+
const templateDir = path.join(__dirname, `../../src/templates/${templateMapping[data.language || 'js']}`);
|
|
37
|
+
copyFolder(templateDir, projectPath);
|
|
38
|
+
//生成模组介绍文件
|
|
39
|
+
saveFile(path.join(projectPath, "mod.info"), JSON.stringify(data, null, 2));
|
|
40
|
+
//执行npm i
|
|
41
|
+
cp.execSync('npm i', { cwd: projectPath, stdio: 'inherit' });
|
|
42
|
+
};
|
|
43
|
+
export const initNPMProject = (projectPath, data) => {
|
|
44
|
+
//检查项目文件是否存在
|
|
45
|
+
//如果不存在则创建项目
|
|
46
|
+
//从模板下载项目文件
|
|
47
|
+
//根据用户输入的项目信息生成项目配置文件
|
|
48
|
+
//根据用户选择是否生成脚本文件,生成脚本文件
|
|
49
|
+
if (!pathNotExist(path.join(projectPath, "mod.info")) || !pathNotExist(path.join(projectPath, "main.mjs")) || !pathNotExist(path.join(projectPath, "scripts")) || !pathNotExist(path.join(projectPath, "build.config"))) {
|
|
50
|
+
console.log("项目已存在...");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
//模版目录
|
|
54
|
+
const templateDir = path.join(__dirname, "../templates/test_sapdon");
|
|
55
|
+
copyFolder(templateDir, projectPath);
|
|
56
|
+
//生成模组介绍文件
|
|
57
|
+
saveFile(path.join(projectPath, "mod.info"), JSON.stringify(data, null, 2));
|
|
58
|
+
};
|
|
59
|
+
// 读取package.json文件并提取信息
|
|
60
|
+
export const readPackageJson = (dir) => {
|
|
61
|
+
const packageJsonPath = path.join(dir, 'package.json');
|
|
62
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
63
|
+
try {
|
|
64
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
65
|
+
return {
|
|
66
|
+
name: path.basename(dir),
|
|
67
|
+
description: packageJson.description || "A new sapdon project",
|
|
68
|
+
author: packageJson.author || "Sapdon",
|
|
69
|
+
version: packageJson.version || "1.0.0"
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
console.error("读取package.json文件时出错:", error);
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export function processBlocksData(data: Object): Object;
|
|
2
|
+
export function generateAddonClient(modPath: any, buildPath: any, projectName: any): Promise<void>;
|
|
3
|
+
export function generateAddon(GRegistry: any, UISystemRegistry: any): (modPath: any, buildPath: any, projectName: any) => Promise<void>;
|
package/dist/cli/load.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { saveFile } from "./utils.js";
|
|
3
|
+
import { generateBlockTextureJson, generateItemTextureJson } from "./tools/textureSet.js";
|
|
4
|
+
import { FlipbookTextures, ItemTextureManager, terrainTextureManager } from "../core/texture.js";
|
|
5
|
+
import { writeAddon } from './dev-server/client.js';
|
|
6
|
+
/**
|
|
7
|
+
* 处理 blocks.json 数据
|
|
8
|
+
* @param {Object} data blocks.json 数据
|
|
9
|
+
* @returns {Object} 处理后的 blocks 数据
|
|
10
|
+
*/
|
|
11
|
+
export const processBlocksData = (data) => {
|
|
12
|
+
const textures_arr = data.textures;
|
|
13
|
+
// 检查 textures 数组长度
|
|
14
|
+
if (textures_arr.length !== 6) {
|
|
15
|
+
console.warn(`blocks.json 的 textures 数组长度不为 6,实际长度: ${textures_arr.length}`);
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
// 构建 blocks 数据
|
|
19
|
+
const blocks = {};
|
|
20
|
+
blocks[data.identifier] = {
|
|
21
|
+
textures: {
|
|
22
|
+
up: textures_arr[0],
|
|
23
|
+
down: textures_arr[1],
|
|
24
|
+
east: textures_arr[2],
|
|
25
|
+
west: textures_arr[3],
|
|
26
|
+
south: textures_arr[4],
|
|
27
|
+
north: textures_arr[5]
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return blocks;
|
|
31
|
+
};
|
|
32
|
+
export const generateAddonClient = async (modPath, buildPath, projectName) => {
|
|
33
|
+
writeAddon(modPath, buildPath, projectName);
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Server
|
|
37
|
+
* 加载并执行模组文件
|
|
38
|
+
* @param {string} modPath 模组文件路径
|
|
39
|
+
* @param {string} buildPath 构建目录路径
|
|
40
|
+
* @param {string} projectName 项目名
|
|
41
|
+
*/
|
|
42
|
+
export const generateAddon = (GRegistry, UISystemRegistry) => async (modPath, buildPath, projectName) => {
|
|
43
|
+
try {
|
|
44
|
+
const buildBehDirPath = path.join(buildPath, `${projectName}_BP`);
|
|
45
|
+
const buildResDirPath = path.join(buildPath, `${projectName}_RP`);
|
|
46
|
+
const resDir = name => path.join(buildResDirPath, name);
|
|
47
|
+
// 初始化 blocks.json 数据
|
|
48
|
+
const blocksJsonPath = path.join(buildBehDirPath, "blocks.json");
|
|
49
|
+
const blocks = { "format_version": "1.20.20" };
|
|
50
|
+
//生成item_texture.json
|
|
51
|
+
const item_texture_dir = resDir("textures/items");
|
|
52
|
+
const item_texture_json_path = resDir("textures/item_texture.json");
|
|
53
|
+
generateItemTextureJson(item_texture_dir, item_texture_json_path, projectName, ItemTextureManager.getItemTextures());
|
|
54
|
+
//生成terrain_texture.json
|
|
55
|
+
const terrain_texture_dir = resDir("textures/blocks");
|
|
56
|
+
const terrain_texture_json_path = resDir("textures/terrain_texture.json");
|
|
57
|
+
generateBlockTextureJson(terrain_texture_dir, terrain_texture_json_path, projectName, terrainTextureManager.getTerrainTextures());
|
|
58
|
+
//生成flipbook_textures.json
|
|
59
|
+
const flipbook_textures_path = resDir("textures/flipbook_textures.json");
|
|
60
|
+
saveFile(flipbook_textures_path, JSON.stringify(FlipbookTextures.flipbook_textures, null, 2));
|
|
61
|
+
//_ui_defs.json
|
|
62
|
+
const ui_def = UISystemRegistry.getUIdefList();
|
|
63
|
+
saveFile(resDir("ui/_ui_defs.json"), JSON.stringify({ "ui_defs": ui_def }, null, 2));
|
|
64
|
+
UISystemRegistry.getUISystemList().forEach((ui_system) => {
|
|
65
|
+
saveFile(resDir(ui_system.path, `${ui_system.name}.json`), JSON.stringify(ui_system.toJson(), null, 2));
|
|
66
|
+
});
|
|
67
|
+
// 从全局注册表中获取数据
|
|
68
|
+
const dataList = GRegistry.getDataList();
|
|
69
|
+
// console.log("dataList:", dataList)
|
|
70
|
+
// 遍历数据并保存到相应的目录
|
|
71
|
+
dataList.forEach(({ name, root, path: dataPath, data }) => {
|
|
72
|
+
// 处理 blocks.json 数据
|
|
73
|
+
if (dataPath === "blocks/") {
|
|
74
|
+
const processedBlocks = processBlocksData(data);
|
|
75
|
+
Object.assign(blocks, processedBlocks);
|
|
76
|
+
}
|
|
77
|
+
// 根据数据类型确定根目录
|
|
78
|
+
const rootPath = root === "behavior" ? `${projectName}_BP` : `${projectName}_RP`;
|
|
79
|
+
const buildRootPath = path.join(buildPath, rootPath);
|
|
80
|
+
// 拼接文件路径
|
|
81
|
+
const filePath = path.join(buildRootPath, dataPath, `${name}.json`);
|
|
82
|
+
// 保存文件
|
|
83
|
+
saveFile(filePath, JSON.stringify(data.toJson(), null, 2));
|
|
84
|
+
});
|
|
85
|
+
// 保存 blocks.json
|
|
86
|
+
console.log("保存 blocks.json 文件:", blocksJsonPath);
|
|
87
|
+
saveFile(blocksJsonPath, JSON.stringify(blocks, null, 2));
|
|
88
|
+
console.log(`已加载并执行 ${modPath} 文件!`);
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
console.error(`加载或执行 ${modPath} 失败:${err.message}`);
|
|
92
|
+
console.error(err.stack); // 打印堆栈跟踪以便调试
|
|
93
|
+
}
|
|
94
|
+
};
|