sapdon 3.0.2 → 3.0.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.
- package/dist/cli/build.d.ts +7 -0
- package/dist/cli/build.js +234 -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 +37 -0
- package/dist/cli/index.d.ts +23 -0
- package/dist/cli/index.js +1 -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 +2 -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/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/basicBundle.d.ts +13 -0
- package/dist/core/entity/bundles/basicBundle.js +45 -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 +347 -0
- package/dist/core/entity/data/nativeEntityData.d.ts +9 -0
- package/dist/core/entity/data/nativeEntityData.js +38 -0
- package/dist/core/entity/entity.d.ts +15 -0
- package/dist/core/entity/entity.js +18 -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 +2062 -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 +16 -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/index.d.ts +142 -0
- package/dist/oc/index.js +1 -0
- package/doc/sapdon-ts.md +35 -1
- package/package.json +6 -8
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { BasicBlock } from "../block/basicBlock.js";
|
|
2
|
+
import { Block } from "../block/block.js";
|
|
3
|
+
import { CropBlock } from "../block/cropBlock.js";
|
|
4
|
+
import { GeometryBlock } from "../block/geometryBlock.js";
|
|
5
|
+
import { OreBlock } from "../block/oreBlock.js";
|
|
6
|
+
import { RotatableBlock } from "../block/rotatableBlock.js";
|
|
7
|
+
import { GRegistry } from "../registry.js";
|
|
8
|
+
/**
|
|
9
|
+
* 注册方块到注册表中。
|
|
10
|
+
* @param {Block} block - 要注册的方块对象。
|
|
11
|
+
*/
|
|
12
|
+
const registerBlock = (block) => {
|
|
13
|
+
if (!block || !block.identifier) {
|
|
14
|
+
throw new Error("无效的方块对象或缺少 identifier。");
|
|
15
|
+
}
|
|
16
|
+
const block_name = block.identifier.replace(":", "_");
|
|
17
|
+
GRegistry.register(block_name, "behavior", "blocks/", block);
|
|
18
|
+
};
|
|
19
|
+
const registerFeature = (feature) => {
|
|
20
|
+
const feature_name = feature.identifier.split(":")[feature.identifier.split(":").length - 1];
|
|
21
|
+
GRegistry.register(feature_name, "behavior", "features/", feature);
|
|
22
|
+
};
|
|
23
|
+
const registerFeatureRule = (feature_rule) => {
|
|
24
|
+
const feature_rule_name = feature_rule.identifier.split(":")[feature_rule.identifier.split(":").length - 1];
|
|
25
|
+
GRegistry.register(feature_rule_name, "behavior", "feature_rules/", feature_rule);
|
|
26
|
+
};
|
|
27
|
+
export const BlockAPI = {
|
|
28
|
+
/**
|
|
29
|
+
* 创建一个基础方块。
|
|
30
|
+
* @param {string} identifier - 方块的唯一标识符。
|
|
31
|
+
* @param {string} category - 方块的分类(如 "construction")。
|
|
32
|
+
* @param {Array} textures_arr - 纹理数组,顺序为 [上, 下, 东, 西, 南, 北]。
|
|
33
|
+
* @param {Object} options - 可选参数。
|
|
34
|
+
* @param {string} options.group - 分组,默认为 "construction"。
|
|
35
|
+
* @param {boolean} options.hide_in_command - 是否在命令中隐藏,默认为 false。
|
|
36
|
+
* @returns {BasicBlock} 创建的基础方块对象。
|
|
37
|
+
*/
|
|
38
|
+
createBasicBlock: function (identifier, category, textures_arr, options = {}) {
|
|
39
|
+
if (!identifier || !category || !textures_arr) {
|
|
40
|
+
throw new Error("必须提供 identifier、category 和长度为 6 的 textures_arr。");
|
|
41
|
+
}
|
|
42
|
+
const block = new BasicBlock(identifier, category, textures_arr, {
|
|
43
|
+
hide_in_command: false,
|
|
44
|
+
...options, // 用传入的选项覆盖默认值
|
|
45
|
+
});
|
|
46
|
+
registerBlock(block); // 调用注册方法
|
|
47
|
+
return block;
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* 创建一个普通方块。
|
|
51
|
+
* @param {string} identifier - 方块的唯一标识符。
|
|
52
|
+
* @param {string} category - 方块的分类(如 "construction")。
|
|
53
|
+
* @param {Array} variantDatas - 方块的变体数据,包含每个变体的状态标签和纹理。
|
|
54
|
+
* @param {Object} options - 可选参数。
|
|
55
|
+
* @param {string} options.group - 分组,默认为 "construction"。
|
|
56
|
+
* @param {boolean} options.hide_in_command - 是否在命令中隐藏,默认为 false。
|
|
57
|
+
* @param {boolean} options.ambient_occlusion - 是否应用环境光遮蔽,默认为 false。
|
|
58
|
+
* @param {boolean} options.face_dimming - 是否根据面的方向进行亮度调整,默认为 false。
|
|
59
|
+
* @param {string} options.render_method - 渲染方法,默认为 "alpha_test"。
|
|
60
|
+
* @returns {Block} 创建的方块对象。
|
|
61
|
+
*/
|
|
62
|
+
createBlock: function (identifier, category, variantDatas, options = {}) {
|
|
63
|
+
if (!identifier || !category || !variantDatas || variantDatas.length === 0) {
|
|
64
|
+
throw new Error("必须提供 identifier、category 和 variantDatas。");
|
|
65
|
+
}
|
|
66
|
+
const block = new Block(identifier, category, variantDatas, {
|
|
67
|
+
hide_in_command: false,
|
|
68
|
+
ambient_occlusion: false,
|
|
69
|
+
face_dimming: false,
|
|
70
|
+
render_method: "alpha_test",
|
|
71
|
+
...options, // 用传入的选项覆盖默认值
|
|
72
|
+
});
|
|
73
|
+
registerBlock(block); // 调用注册方法
|
|
74
|
+
return block;
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* 创建一个可旋转方块。
|
|
78
|
+
* @param {string} identifier - 方块的唯一标识符。
|
|
79
|
+
* @param {string} category - 方块的分类(如 "construction")。
|
|
80
|
+
* @param {Array} textures_arr - 纹理数组,顺序为 [上, 下, 东, 西, 南, 北]。
|
|
81
|
+
* @param {Object} options - 可选参数。
|
|
82
|
+
* @param {string} options.group - 分组,默认为 "construction"。
|
|
83
|
+
* @param {boolean} options.hide_in_command - 是否在命令中隐藏,默认为 false。
|
|
84
|
+
* @param {string} options.rotationType - 旋转类型,默认为 "cardinal"。
|
|
85
|
+
* @param {number} options.yRotationOffset - 初始旋转偏移量,默认为 180。
|
|
86
|
+
* @returns {RotatableBlock} 创建的可旋转方块对象。
|
|
87
|
+
*/
|
|
88
|
+
createRotatableBlock: function (identifier, category, textures_arr, options = {}) {
|
|
89
|
+
if (!identifier || !category || !textures_arr) {
|
|
90
|
+
throw new Error("必须提供 identifier、category 和 textures_arr。");
|
|
91
|
+
}
|
|
92
|
+
const block = new RotatableBlock(identifier, category, textures_arr, {
|
|
93
|
+
hide_in_command: false,
|
|
94
|
+
rotationType: "cardinal",
|
|
95
|
+
yRotationOffset: 180,
|
|
96
|
+
...options, // 用传入的选项覆盖默认值
|
|
97
|
+
});
|
|
98
|
+
registerBlock(block); // 调用注册方法
|
|
99
|
+
return block;
|
|
100
|
+
},
|
|
101
|
+
createGeometryBlock: function (identifier, category, geometry, material_instances, options = {}) {
|
|
102
|
+
if (!identifier || !category || !geometry || !material_instances) {
|
|
103
|
+
throw new Error("必须提供 identifier、category、geometry 和 material_instances。");
|
|
104
|
+
}
|
|
105
|
+
const block = new GeometryBlock(identifier, category, geometry, material_instances, options);
|
|
106
|
+
registerBlock(block); // 调用注册方法
|
|
107
|
+
return block;
|
|
108
|
+
},
|
|
109
|
+
createOreBlock(identifier, category, textures_arr, options = {}) {
|
|
110
|
+
const ore_block = new OreBlock(identifier, category, textures_arr, options);
|
|
111
|
+
registerBlock(ore_block.block); // 调用注册方法
|
|
112
|
+
registerFeature(ore_block.feature); // 调用注册方法
|
|
113
|
+
registerFeatureRule(ore_block.feature_rules); // 调用注册方法
|
|
114
|
+
return ore_block;
|
|
115
|
+
},
|
|
116
|
+
/**
|
|
117
|
+
* 创建一个作物方块。
|
|
118
|
+
* @param {string} identifier - 方块的唯一标识符。
|
|
119
|
+
* @param {string} category - 方块的分类(如 "construction")。
|
|
120
|
+
* @param {Array} variantDatas - 方块的变体数据,包含每个变体的状态标签和纹理。
|
|
121
|
+
* @param {Object} options - 可选参数。
|
|
122
|
+
* @param {string} options.group - 分组,默认为 "construction"。
|
|
123
|
+
* @param {boolean} options.hide_in_command - 是否在命令中隐藏,默认为 false。
|
|
124
|
+
* @param {boolean} options.ambient_occlusion - 是否应用环境光遮蔽,默认为 false。
|
|
125
|
+
* @param {boolean} options.face_dimming - 是否根据面的方向进行亮度调整,默认为 false。
|
|
126
|
+
* @param {string} options.render_method - 渲染方法,默认为 "alpha_test"。
|
|
127
|
+
* @returns {CropBlock} 创建的方块对象。
|
|
128
|
+
*/
|
|
129
|
+
createCropBlock: function (identifier, category, variantDatas, options = {}) {
|
|
130
|
+
if (!identifier || !category || !variantDatas || variantDatas.length === 0) {
|
|
131
|
+
throw new Error("必须提供 identifier、category 和 variantDatas。");
|
|
132
|
+
}
|
|
133
|
+
const block = new CropBlock(identifier, category, variantDatas, {
|
|
134
|
+
hide_in_command: false,
|
|
135
|
+
ambient_occlusion: true,
|
|
136
|
+
face_dimming: true,
|
|
137
|
+
render_method: "alpha_test",
|
|
138
|
+
...options, // 用传入的选项覆盖默认值
|
|
139
|
+
});
|
|
140
|
+
registerBlock(block); // 调用注册方法
|
|
141
|
+
return block;
|
|
142
|
+
},
|
|
143
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function registerEntity(behData: any, resData: any): void;
|
|
2
|
+
export namespace EntityAPI {
|
|
3
|
+
function createNativeEntity(identifier: string, proto_id: string, options?: Object): {
|
|
4
|
+
behavior: BasicEntity;
|
|
5
|
+
resource: ClientEntity;
|
|
6
|
+
};
|
|
7
|
+
function createEntity(identifier: string, texture: string, behData: Object, resData: Object, options?: Object): {
|
|
8
|
+
behavior: BasicEntity;
|
|
9
|
+
resource: ClientEntity;
|
|
10
|
+
};
|
|
11
|
+
function createProjectile(identifier: string, texture: string, options?: Object): {
|
|
12
|
+
behavior: BasicEntity;
|
|
13
|
+
resource: ClientEntity;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
import { BasicEntity } from "../entity/basicEntity.js";
|
|
17
|
+
import { ClientEntity } from "../entity/clientEntity.js";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { BasicEntity } from "../entity/basicEntity.js";
|
|
2
|
+
import { ClientEntity } from "../entity/clientEntity.js";
|
|
3
|
+
import { Entity } from "../entity/entity.js";
|
|
4
|
+
import { NativeEntity } from "../entity/nativeEntity.js";
|
|
5
|
+
import { Projectile } from "../entity/projectile.js";
|
|
6
|
+
import { GRegistry } from "../registry.js";
|
|
7
|
+
export const registerEntity = (behData, resData) => {
|
|
8
|
+
// 如果 behData 存在且不为空,则注册行为数据
|
|
9
|
+
if (behData && Object.keys(behData).length > 0) {
|
|
10
|
+
GRegistry.register(behData.identifier.replace(":", "_"), "behavior", "entities/", behData);
|
|
11
|
+
}
|
|
12
|
+
// 如果 resData 存在且不为空,则注册资源数据
|
|
13
|
+
if (resData && Object.keys(resData).length > 0) {
|
|
14
|
+
GRegistry.register(resData.identifier.replace(":", "_"), "resource", "entity/", resData);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export const EntityAPI = {
|
|
18
|
+
/**
|
|
19
|
+
* 创建一个原生实体。
|
|
20
|
+
* @param {string} identifier - 实体的唯一标识符。
|
|
21
|
+
* @param {string} proto_id - 实体的原型 ID。
|
|
22
|
+
* @param {string} texture - 实体的纹理。
|
|
23
|
+
* @param {Object} options - 额外选项。
|
|
24
|
+
* @returns {{ behavior: BasicEntity, resource: ClientEntity }} 包含行为数据和资源数据的对象。
|
|
25
|
+
*/
|
|
26
|
+
createNativeEntity: function (identifier, proto_id, options = {}) {
|
|
27
|
+
if (!identifier || !proto_id) {
|
|
28
|
+
throw new Error("必须提供 identifier、proto_id 和 texture。");
|
|
29
|
+
}
|
|
30
|
+
const nativeEntity = new NativeEntity(identifier, proto_id, options);
|
|
31
|
+
registerEntity(nativeEntity.entity, nativeEntity.client_entity);
|
|
32
|
+
return {
|
|
33
|
+
behavior: nativeEntity.entity,
|
|
34
|
+
resource: nativeEntity.client_entity,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* 创建一个普通实体。
|
|
39
|
+
* @param {string} identifier - 实体的唯一标识符。
|
|
40
|
+
* @param {string} texture - 实体的纹理。
|
|
41
|
+
* @param {Object} behData - 实体的行为数据。
|
|
42
|
+
* @param {Object} resData - 实体的资源数据。
|
|
43
|
+
* @param {Object} options - 额外选项。
|
|
44
|
+
* @returns {{ behavior: BasicEntity, resource: ClientEntity }} 包含行为数据和资源数据的对象。
|
|
45
|
+
*/
|
|
46
|
+
createEntity: function (identifier, texture, behData, resData, options = {}) {
|
|
47
|
+
if (!identifier || !texture) {
|
|
48
|
+
throw new Error("必须提供 identifier 和 texture。");
|
|
49
|
+
}
|
|
50
|
+
const entity = new Entity(identifier, texture, behData, resData, options);
|
|
51
|
+
registerEntity(entity.entity, entity.client_entity);
|
|
52
|
+
return {
|
|
53
|
+
behavior: entity.entity,
|
|
54
|
+
resource: entity.client_entity,
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* 创建一个投射物实体。
|
|
59
|
+
* @param {string} identifier - 投射物的唯一标识符。
|
|
60
|
+
* @param {string} texture - 投射物的纹理。
|
|
61
|
+
* @param {Object} options - 额外选项。
|
|
62
|
+
* @returns {{ behavior: BasicEntity, resource: ClientEntity }} 包含行为数据和资源数据的对象。
|
|
63
|
+
*/
|
|
64
|
+
createProjectile: function (identifier, texture, options = {}) {
|
|
65
|
+
if (!identifier || !texture) {
|
|
66
|
+
throw new Error("必须提供 identifier 和 texture。");
|
|
67
|
+
}
|
|
68
|
+
const entity = new Projectile(identifier, texture, options);
|
|
69
|
+
registerEntity(entity.entity, entity.client_entity);
|
|
70
|
+
return {
|
|
71
|
+
behavior: entity.entity,
|
|
72
|
+
resource: entity.client_entity,
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export namespace FeatureAPI {
|
|
2
|
+
function createOreFeature(identifier: any, count: any, replace_rules: any): OreFeature;
|
|
3
|
+
function createFeatureRules(identifier: any, places_feature: any): FeatureRule;
|
|
4
|
+
}
|
|
5
|
+
import { OreFeature } from "../feature/oreFeature.js";
|
|
6
|
+
import { FeatureRule } from "../feature-rule/featureRule.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { OreFeature } from "../feature/oreFeature.js";
|
|
2
|
+
import { FeatureRule } from "../feature-rule/featureRule.js";
|
|
3
|
+
import { GRegistry } from "../registry.js";
|
|
4
|
+
const registerFeature = (feature) => {
|
|
5
|
+
const feature_name = feature.identifier.split(":")[feature.identifier.split(":").length - 1];
|
|
6
|
+
GRegistry.register(feature_name, "behavior", "features/", feature);
|
|
7
|
+
};
|
|
8
|
+
const registerFeatureRule = (feature_rule) => {
|
|
9
|
+
const feature_rule_name = feature_rule.identifier.split(":")[feature_rule.identifier.split(":").length - 1];
|
|
10
|
+
GRegistry.register(feature_rule_name, "behavior", "feature_rules/", feature_rule);
|
|
11
|
+
};
|
|
12
|
+
export const FeatureAPI = {
|
|
13
|
+
createOreFeature: function (identifier, count, replace_rules) {
|
|
14
|
+
const feature = new OreFeature(identifier, count, replace_rules);
|
|
15
|
+
registerFeature(feature);
|
|
16
|
+
return feature;
|
|
17
|
+
},
|
|
18
|
+
createFeatureRules: function (identifier, places_feature) {
|
|
19
|
+
const feature_rules = new FeatureRule(identifier, places_feature);
|
|
20
|
+
registerFeatureRule(feature_rules);
|
|
21
|
+
return feature_rules;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export var ItemCategory;
|
|
2
|
+
(function (ItemCategory) {
|
|
3
|
+
ItemCategory["Commands"] = "commands";
|
|
4
|
+
ItemCategory["Construction"] = "construction";
|
|
5
|
+
ItemCategory["Equipment"] = "equipment";
|
|
6
|
+
ItemCategory["Nature"] = "nature";
|
|
7
|
+
ItemCategory["Items"] = "items";
|
|
8
|
+
ItemCategory["None"] = "none";
|
|
9
|
+
})(ItemCategory || (ItemCategory = {}));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export namespace ItemAPI {
|
|
2
|
+
function createItem(identifier: string, category: string, texture: string, options?: {
|
|
3
|
+
group: string;
|
|
4
|
+
hight_resolution: boolean;
|
|
5
|
+
hide_in_command: boolean;
|
|
6
|
+
}): Item;
|
|
7
|
+
function createFood(identifier: string, category: string, texture: string, options?: {
|
|
8
|
+
group: string;
|
|
9
|
+
hide_in_command: boolean;
|
|
10
|
+
animation: string;
|
|
11
|
+
canAlwaysEat: boolean;
|
|
12
|
+
nutrition: number;
|
|
13
|
+
saturationModifier: number;
|
|
14
|
+
}): Food;
|
|
15
|
+
function createAttachable(identifier: string, texture: string, material: string, options?: Object): Attachable;
|
|
16
|
+
function createChestplateArmor(identifier: any, item_texture: any, texture_path: any, options?: {}): Chestplate;
|
|
17
|
+
function createHelmetArmor(identifier: any, item_texture: any, texture_path: any, options?: {}): Helmet;
|
|
18
|
+
function createBootArmor(identifier: any, item_texture: any, texture_path: any, options?: {}): Boot;
|
|
19
|
+
function createLeggingsArmor(identifier: any, item_texture: any, texture_path: any, options?: {}): Leggings;
|
|
20
|
+
}
|
|
21
|
+
import { Item } from "../item/item.js";
|
|
22
|
+
import { Food } from "../item/food.js";
|
|
23
|
+
import { Attachable } from "../item/attachable.js";
|
|
24
|
+
import { Chestplate } from "../item/armor.js";
|
|
25
|
+
import { Helmet } from "../item/armor.js";
|
|
26
|
+
import { Boot } from "../item/armor.js";
|
|
27
|
+
import { Leggings } from "../item/armor.js";
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Boot, Chestplate, Helmet, Leggings } from "../item/armor.js";
|
|
2
|
+
import { Attachable } from "../item/attachable.js";
|
|
3
|
+
import { Food } from "../item/food.js";
|
|
4
|
+
import { Item } from "../item/item.js";
|
|
5
|
+
import { GRegistry } from "../registry.js";
|
|
6
|
+
const registerItem = (itemData, attachableData) => {
|
|
7
|
+
// 如果 itemData 存在且不为空,则注册
|
|
8
|
+
if (itemData && Object.keys(itemData).length > 0) {
|
|
9
|
+
GRegistry.register(itemData.identifier.replace(":", "_"), "behavior", "items/", itemData);
|
|
10
|
+
}
|
|
11
|
+
// 如果 attachableData 存在且不为空,则注册
|
|
12
|
+
if (attachableData && Object.keys(attachableData).length > 0) {
|
|
13
|
+
GRegistry.register(attachableData.identifier.replace(":", "_"), "resource", "attachables/", attachableData);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
// 物品创建的工厂函数
|
|
17
|
+
export const ItemAPI = {
|
|
18
|
+
/**
|
|
19
|
+
* 创建一个普通物品。
|
|
20
|
+
* @param {string} identifier - 物品的唯一标识符。
|
|
21
|
+
* @param {string} category - 物品在创造菜单中的分类(如 "construction", "nature")。
|
|
22
|
+
* @param {string} texture - 物品的纹理。
|
|
23
|
+
* @param {Object} options - 额外选项。
|
|
24
|
+
* @param {string} options.group - 物品的分组。
|
|
25
|
+
* @param {boolean} options.hight_resolution -是否是高分辨率
|
|
26
|
+
* @param {boolean} options.hide_in_command - 是否在命令中隐藏物品。
|
|
27
|
+
* @returns {Item} 创建的物品。
|
|
28
|
+
*/
|
|
29
|
+
createItem: function (identifier, category, texture, options = {}) {
|
|
30
|
+
if (!identifier || !category || !texture) {
|
|
31
|
+
throw new Error("必须提供 identifier、category 和 texture。");
|
|
32
|
+
}
|
|
33
|
+
const item = new Item(identifier, category, texture, options);
|
|
34
|
+
let attachable = {};
|
|
35
|
+
if (options.hide_in_command === true) {
|
|
36
|
+
attachable = new Attachable(identifier)
|
|
37
|
+
.addMaterial("default", "entity_alphatest")
|
|
38
|
+
.addMaterial("enchanted", "entity_alphatest_glint")
|
|
39
|
+
.addTexture("default", `textures/items/${texture}`)
|
|
40
|
+
.addTexture("enchanted", "textures/misc/enchanted_item_glint")
|
|
41
|
+
.addGeometry("default", "geometry.large_item");
|
|
42
|
+
}
|
|
43
|
+
registerItem(item, attachable);
|
|
44
|
+
return item;
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* 创建一个食物物品。
|
|
48
|
+
* @param {string} identifier - 食物的唯一标识符。
|
|
49
|
+
* @param {string} category - 食物在创造菜单中的分类。
|
|
50
|
+
* @param {string} texture - 食物的纹理。
|
|
51
|
+
* @param {Object} options - 额外选项。
|
|
52
|
+
* @param {string} options.group - 食物的分组。
|
|
53
|
+
* @param {boolean} options.hide_in_command - 是否在命令中隐藏食物。
|
|
54
|
+
* @param {string} options.animation - 食用时的动画(默认:"eat")。
|
|
55
|
+
* @param {boolean} options.canAlwaysEat - 是否总是可以食用。
|
|
56
|
+
* @param {number} options.nutrition - 食物的营养价值。
|
|
57
|
+
* @param {number} options.saturationModifier - 饱和度修正值。
|
|
58
|
+
* @returns {Food} 创建的食物物品。
|
|
59
|
+
*/
|
|
60
|
+
createFood: function (identifier, category, texture, options = {}) {
|
|
61
|
+
if (!identifier || !category || !texture) {
|
|
62
|
+
throw new Error("必须提供 identifier、category 和 texture。");
|
|
63
|
+
}
|
|
64
|
+
const food = new Food(identifier, category, texture, {
|
|
65
|
+
animation: "eat",
|
|
66
|
+
canAlwaysEat: false,
|
|
67
|
+
nutrition: 0,
|
|
68
|
+
saturationModifier: 1,
|
|
69
|
+
...options, // 用传入的选项覆盖默认值
|
|
70
|
+
});
|
|
71
|
+
registerItem(food, {});
|
|
72
|
+
return food;
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* 创建一个可附着物品。
|
|
76
|
+
* @param {string} identifier - 可附着物品的唯一标识符。
|
|
77
|
+
* @param {string} texture - 可附着物品的纹理。
|
|
78
|
+
* @param {string} material - 可附着物品的材质。
|
|
79
|
+
* @param {Object} options - 额外选项。
|
|
80
|
+
* @returns {Attachable} 创建的可附着物品。
|
|
81
|
+
*/
|
|
82
|
+
createAttachable: function (identifier, texture, material, options = {}) {
|
|
83
|
+
if (!identifier || !texture || !material) {
|
|
84
|
+
throw new Error("必须提供 identifier、texture 和 material。");
|
|
85
|
+
}
|
|
86
|
+
const attachable = new Attachable(identifier);
|
|
87
|
+
attachable.addTexture("default", texture);
|
|
88
|
+
attachable.addMaterial("default", material);
|
|
89
|
+
registerItem({}, attachable);
|
|
90
|
+
return attachable;
|
|
91
|
+
},
|
|
92
|
+
createChestplateArmor: function (identifier, item_texture, texture_path, options = {}) {
|
|
93
|
+
const item = new Chestplate(identifier, item_texture, texture_path, options);
|
|
94
|
+
registerItem(item.item, item.attachable);
|
|
95
|
+
return item;
|
|
96
|
+
},
|
|
97
|
+
createHelmetArmor: function (identifier, item_texture, texture_path, options = {}) {
|
|
98
|
+
const item = new Helmet(identifier, item_texture, texture_path, options);
|
|
99
|
+
registerItem(item.item, item.attachable);
|
|
100
|
+
return item;
|
|
101
|
+
},
|
|
102
|
+
createBootArmor: function (identifier, item_texture, texture_path, options = {}) {
|
|
103
|
+
const item = new Boot(identifier, item_texture, texture_path, options);
|
|
104
|
+
registerItem(item.item, item.attachable);
|
|
105
|
+
return item;
|
|
106
|
+
},
|
|
107
|
+
createLeggingsArmor: function (identifier, item_texture, texture_path, options = {}) {
|
|
108
|
+
const item = new Leggings(identifier, item_texture, texture_path, options);
|
|
109
|
+
registerItem(item.item, item.attachable);
|
|
110
|
+
return item;
|
|
111
|
+
},
|
|
112
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const RecipeAPI: RecipeRegistry;
|
|
2
|
+
declare class RecipeRegistry {
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {AddonRecipeFurnace_1_17} recipe
|
|
6
|
+
*/
|
|
7
|
+
registerRecipe(recipe: AddonRecipeFurnace_1_17): void;
|
|
8
|
+
registerSimpleFurnace(identifier: any, output: any, input: any): AddonRecipeFurnace_1_17;
|
|
9
|
+
registerFurnace(identifier: any): AddonRecipeFurnace_1_17;
|
|
10
|
+
registerSimpleShaped(identifier: any, output: any, pattern: any, key: any): AddonRecipeShaped_1_20;
|
|
11
|
+
registerShaped(identifier: any): AddonRecipeShaped_1_20;
|
|
12
|
+
registerSimpleShapeless(identifier: any, output: any, ingredients: any): AddonRecipeShapeless_1_17;
|
|
13
|
+
registerShapeless(identifier: any): AddonRecipeShapeless_1_17;
|
|
14
|
+
}
|
|
15
|
+
import { AddonRecipeFurnace_1_17 } from "../addon/recipe/furnace.js";
|
|
16
|
+
import { AddonRecipeShaped_1_20 } from "../addon/recipe/shaped.js";
|
|
17
|
+
import { AddonRecipeShapeless_1_17 } from "../addon/recipe/shapeless.js";
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { RecipeTags } from "../addon/recipe/data.js";
|
|
2
|
+
import { AddonRecipeFurnace_1_17 } from "../addon/recipe/furnace.js";
|
|
3
|
+
import { AddonRecipeShaped_1_20 } from "../addon/recipe/shaped.js";
|
|
4
|
+
import { AddonRecipeShapeless_1_17 } from "../addon/recipe/shapeless.js";
|
|
5
|
+
import { GRegistry } from "../registry.js";
|
|
6
|
+
class RecipeRegistry {
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {AddonRecipeFurnace_1_17} recipe
|
|
10
|
+
*/
|
|
11
|
+
registerRecipe(recipe) {
|
|
12
|
+
GRegistry.register(recipe.getId().replace(":", "_"), "behavior", "recipes/", recipe);
|
|
13
|
+
}
|
|
14
|
+
registerSimpleFurnace(identifier, output, input) {
|
|
15
|
+
return this.registerFurnace(identifier).tags([RecipeTags.Furnace]).input(input).output(output);
|
|
16
|
+
}
|
|
17
|
+
registerFurnace(identifier) {
|
|
18
|
+
const recipe = new AddonRecipeFurnace_1_17().identifier(identifier);
|
|
19
|
+
this.registerRecipe(recipe);
|
|
20
|
+
return recipe;
|
|
21
|
+
}
|
|
22
|
+
registerSimpleShaped(identifier, output, pattern, key) {
|
|
23
|
+
return this.registerShaped(identifier).tags([RecipeTags.CraftingTable]).pattern(pattern).key(key).output(output);
|
|
24
|
+
}
|
|
25
|
+
registerShaped(identifier) {
|
|
26
|
+
const recipe = new AddonRecipeShaped_1_20().identifier(identifier);
|
|
27
|
+
this.registerRecipe(recipe);
|
|
28
|
+
return recipe;
|
|
29
|
+
}
|
|
30
|
+
registerSimpleShapeless(identifier, output, ingredients) {
|
|
31
|
+
return this.registerShapeless(identifier).tags([RecipeTags.CraftingTable]).ingredients(ingredients).output(output);
|
|
32
|
+
}
|
|
33
|
+
registerShapeless(identifier) {
|
|
34
|
+
const recipe = new AddonRecipeShapeless_1_17().identifier(identifier);
|
|
35
|
+
this.registerRecipe(recipe);
|
|
36
|
+
return recipe;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export const RecipeAPI = new RecipeRegistry();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export namespace UiAPI {
|
|
2
|
+
function createUISystem(identifier: any, path: any): UISystem;
|
|
3
|
+
function createUIElement(id: any, type: any, template: any): UIElement;
|
|
4
|
+
function createPanel(id: any, template: any): Panel;
|
|
5
|
+
function createImage(id: any, template: any): Image;
|
|
6
|
+
function createLabel(id: any, template: any): Label;
|
|
7
|
+
}
|
|
8
|
+
import { UISystem } from "../ui/systems/system.js";
|
|
9
|
+
import { UIElement } from "../ui/elements/uiElement.js";
|
|
10
|
+
import { Panel } from "../ui/elements/panel.js";
|
|
11
|
+
import { Image } from "../ui/elements/image.js";
|
|
12
|
+
import { Label } from "../ui/elements/label.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { GRegistry } from "../registry.js";
|
|
2
|
+
import { Image } from "../ui/elements/image.js";
|
|
3
|
+
import { Label } from "../ui/elements/label.js";
|
|
4
|
+
import { Panel } from "../ui/elements/panel.js";
|
|
5
|
+
import { UIElement } from "../ui/elements/uiElement.js";
|
|
6
|
+
import { UISystem } from "../ui/systems/system.js";
|
|
7
|
+
const registerUIsystem = (ui_system) => {
|
|
8
|
+
GRegistry.register(ui_system.name, "behavior", ui_system.path, ui_system);
|
|
9
|
+
};
|
|
10
|
+
export const UiAPI = {
|
|
11
|
+
createUISystem(identifier, path) {
|
|
12
|
+
const ui_system = new UISystem(identifier, path);
|
|
13
|
+
registerUIsystem(ui_system);
|
|
14
|
+
return ui_system;
|
|
15
|
+
},
|
|
16
|
+
createUIElement(id, type, template) {
|
|
17
|
+
const ui_element = new UIElement(id, type, template);
|
|
18
|
+
return ui_element;
|
|
19
|
+
},
|
|
20
|
+
createPanel(id, template) {
|
|
21
|
+
const panel = new Panel(id, template);
|
|
22
|
+
return panel;
|
|
23
|
+
},
|
|
24
|
+
createImage(id, template) {
|
|
25
|
+
const image = new Image(id, template);
|
|
26
|
+
return image;
|
|
27
|
+
},
|
|
28
|
+
createLabel(id, template) {
|
|
29
|
+
const label = new Label(id, template);
|
|
30
|
+
return label;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AddonOreFeature, AddonOreFeatureDefinition, AddonOreFeatureDescription } from "../addon/feature/oreFeature.js";
|
|
2
|
+
export class OreFeature {
|
|
3
|
+
constructor(identifier, count, replace_rules) {
|
|
4
|
+
this.identifier = identifier;
|
|
5
|
+
this.count = count;
|
|
6
|
+
this.replace_rules = replace_rules;
|
|
7
|
+
}
|
|
8
|
+
toJson() {
|
|
9
|
+
return new AddonOreFeature("1.17.0", new AddonOreFeatureDefinition(new AddonOreFeatureDescription(this.identifier), this.count, this.replace_rules)).toJson();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表示生物群系过滤条件的类
|
|
3
|
+
*/
|
|
4
|
+
export class BiomeFilter {
|
|
5
|
+
filters: any[];
|
|
6
|
+
/**
|
|
7
|
+
* 添加一个逻辑条件组(如 any_of, all_of)
|
|
8
|
+
* @param {"any_of" | "all_of"} logicType - 逻辑类型
|
|
9
|
+
* @param {Array<Object>} conditions - 条件数组
|
|
10
|
+
* @returns {BiomeFilter} 返回自身以支持链式调用
|
|
11
|
+
*/
|
|
12
|
+
addLogicGroup(logicType: "any_of" | "all_of", conditions: Array<Object>): BiomeFilter;
|
|
13
|
+
/**
|
|
14
|
+
* 添加一个简单条件(如 has_biome_tag)
|
|
15
|
+
* @param {string} test - 测试类型(如 "has_biome_tag")
|
|
16
|
+
* @param {"==" | "!="} operator - 操作符
|
|
17
|
+
* @param {string} value - 目标值(如 "overworld")
|
|
18
|
+
* @returns {BiomeFilter} 返回自身以支持链式调用
|
|
19
|
+
*/
|
|
20
|
+
addSimpleCondition(test: string, operator: "==" | "!=", value: string): BiomeFilter;
|
|
21
|
+
/**
|
|
22
|
+
* 转换为 JSON 格式
|
|
23
|
+
* @returns {Array<Object>} 返回生物群系过滤条件数组
|
|
24
|
+
*/
|
|
25
|
+
toJson(): Array<Object>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表示生物群系过滤条件的类
|
|
3
|
+
*/
|
|
4
|
+
export class BiomeFilter {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.filters = [];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 添加一个逻辑条件组(如 any_of, all_of)
|
|
10
|
+
* @param {"any_of" | "all_of"} logicType - 逻辑类型
|
|
11
|
+
* @param {Array<Object>} conditions - 条件数组
|
|
12
|
+
* @returns {BiomeFilter} 返回自身以支持链式调用
|
|
13
|
+
*/
|
|
14
|
+
addLogicGroup(logicType, conditions) {
|
|
15
|
+
this.filters.push({ [logicType]: conditions });
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 添加一个简单条件(如 has_biome_tag)
|
|
20
|
+
* @param {string} test - 测试类型(如 "has_biome_tag")
|
|
21
|
+
* @param {"==" | "!="} operator - 操作符
|
|
22
|
+
* @param {string} value - 目标值(如 "overworld")
|
|
23
|
+
* @returns {BiomeFilter} 返回自身以支持链式调用
|
|
24
|
+
*/
|
|
25
|
+
addSimpleCondition(test, operator, value) {
|
|
26
|
+
this.filters.push({ test, operator, value });
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 转换为 JSON 格式
|
|
31
|
+
* @returns {Array<Object>} 返回生物群系过滤条件数组
|
|
32
|
+
*/
|
|
33
|
+
toJson() {
|
|
34
|
+
return this.filters;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表示功能规则生成条件的类
|
|
3
|
+
*/
|
|
4
|
+
export class FeatureConditions {
|
|
5
|
+
conditions: {
|
|
6
|
+
placement_pass: string;
|
|
7
|
+
"minecraft:biome_filter": never[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* 设置生成阶段(placement_pass)
|
|
11
|
+
* @param {string} pass - 生成阶段标识符(如 "underground_pass")
|
|
12
|
+
* @returns {FeatureConditions} 返回自身以支持链式调用
|
|
13
|
+
*/
|
|
14
|
+
setPlacementPass(pass: string): FeatureConditions;
|
|
15
|
+
/**
|
|
16
|
+
* 设置生物群系过滤器
|
|
17
|
+
* @param {BiomeFilter} biomeFilter - 生物群系过滤条件对象
|
|
18
|
+
* @returns {FeatureConditions} 返回自身以支持链式调用
|
|
19
|
+
*/
|
|
20
|
+
setBiomeFilter(biomeFilter: BiomeFilter): FeatureConditions;
|
|
21
|
+
/**
|
|
22
|
+
* 转换为 JSON 格式
|
|
23
|
+
* @returns {Object} 返回生成条件对象
|
|
24
|
+
*/
|
|
25
|
+
toJson(): Object;
|
|
26
|
+
}
|
|
27
|
+
import { BiomeFilter } from "./biomeFilter.js";
|