sapdon 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -7
- package/doc/cli.md +24 -0
- package/doc/sapdon-ts.md +17 -5
- package/package.json +2 -2
- package/dist/cli/build.d.ts +0 -7
- package/dist/cli/build.js +0 -232
- package/dist/cli/dev-server/client.d.ts +0 -2
- package/dist/cli/dev-server/client.js +0 -20
- package/dist/cli/dev-server/config.d.ts +0 -3
- package/dist/cli/dev-server/config.js +0 -3
- package/dist/cli/dev-server/hmr.d.ts +0 -1
- package/dist/cli/dev-server/hmr.js +0 -13
- package/dist/cli/dev-server/index.d.ts +0 -3
- package/dist/cli/dev-server/index.js +0 -11
- package/dist/cli/dev-server/server.d.ts +0 -6
- package/dist/cli/dev-server/server.js +0 -50
- package/dist/cli/dev-server/syncFiles.d.ts +0 -3
- package/dist/cli/dev-server/syncFiles.js +0 -36
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +0 -1
- package/dist/cli/init.d.ts +0 -9
- package/dist/cli/init.js +0 -80
- package/dist/cli/load.d.ts +0 -3
- package/dist/cli/load.js +0 -94
- package/dist/cli/start.d.ts +0 -2
- package/dist/cli/start.js +0 -156
- package/dist/cli/tools/textureSet.d.ts +0 -13
- package/dist/cli/tools/textureSet.js +0 -103
- package/dist/cli/utils.d.ts +0 -13
- package/dist/cli/utils.js +0 -89
- package/dist/core/addon/biome.d.ts +0 -22
- package/dist/core/addon/biome.js +0 -27
- package/dist/core/addon/block/block.d.ts +0 -41
- package/dist/core/addon/block/block.js +0 -46
- package/dist/core/addon/controllers/animationController.d.ts +0 -43
- package/dist/core/addon/controllers/animationController.js +0 -73
- package/dist/core/addon/entity/clientEntity.d.ts +0 -107
- package/dist/core/addon/entity/clientEntity.js +0 -149
- package/dist/core/addon/entity/entity.d.ts +0 -42
- package/dist/core/addon/entity/entity.js +0 -50
- package/dist/core/addon/feature/oreFeature.d.ts +0 -19
- package/dist/core/addon/feature/oreFeature.js +0 -24
- package/dist/core/addon/featureRule.d.ts +0 -20
- package/dist/core/addon/featureRule.js +0 -25
- package/dist/core/addon/item/attachable.d.ts +0 -94
- package/dist/core/addon/item/attachable.js +0 -134
- package/dist/core/addon/item/item.d.ts +0 -19
- package/dist/core/addon/item/item.js +0 -26
- package/dist/core/addon/manifest.d.ts +0 -49
- package/dist/core/addon/manifest.js +0 -65
- package/dist/core/addon/menuCategory.d.ts +0 -6
- package/dist/core/addon/menuCategory.js +0 -7
- package/dist/core/addon/recipe/baseRecipe.d.ts +0 -12
- package/dist/core/addon/recipe/baseRecipe.js +0 -23
- package/dist/core/addon/recipe/data.d.ts +0 -66
- package/dist/core/addon/recipe/data.js +0 -74
- package/dist/core/addon/recipe/furnace.d.ts +0 -17
- package/dist/core/addon/recipe/furnace.js +0 -43
- package/dist/core/addon/recipe/shaped.d.ts +0 -26
- package/dist/core/addon/recipe/shaped.js +0 -53
- package/dist/core/addon/recipe/shapeless.d.ts +0 -18
- package/dist/core/addon/recipe/shapeless.js +0 -36
- package/dist/core/biome/biome.d.ts +0 -14
- package/dist/core/biome/biome.js +0 -23
- package/dist/core/biome/biomeComponent.d.ts +0 -46
- package/dist/core/biome/biomeComponent.js +0 -77
- package/dist/core/block/basicBlock.d.ts +0 -48
- package/dist/core/block/basicBlock.js +0 -105
- package/dist/core/block/block.d.ts +0 -32
- package/dist/core/block/block.js +0 -92
- package/dist/core/block/blockComponent.d.ts +0 -187
- package/dist/core/block/blockComponent.js +0 -500
- package/dist/core/block/cropBlock.d.ts +0 -4
- package/dist/core/block/cropBlock.js +0 -27
- package/dist/core/block/geometryBlock.d.ts +0 -12
- package/dist/core/block/geometryBlock.js +0 -16
- package/dist/core/block/oreBlock.d.ts +0 -9
- package/dist/core/block/oreBlock.js +0 -25
- package/dist/core/block/rotatableBlock.d.ts +0 -27
- package/dist/core/block/rotatableBlock.js +0 -107
- package/dist/core/block/tileBlock.d.ts +0 -17
- package/dist/core/block/tileBlock.js +0 -125
- package/dist/core/entity/basicEntity.d.ts +0 -111
- package/dist/core/entity/basicEntity.js +0 -170
- package/dist/core/entity/behavior/followMob.d.ts +0 -12
- package/dist/core/entity/behavior/followMob.js +0 -35
- package/dist/core/entity/behavior/followParent.d.ts +0 -7
- package/dist/core/entity/behavior/followParent.js +0 -15
- package/dist/core/entity/behavior/randomStroll.d.ts +0 -31
- package/dist/core/entity/behavior/randomStroll.js +0 -63
- package/dist/core/entity/behavior/tempt.d.ts +0 -73
- package/dist/core/entity/behavior/tempt.js +0 -134
- package/dist/core/entity/bundles/basicBundle.d.ts +0 -13
- package/dist/core/entity/bundles/basicBundle.js +0 -45
- package/dist/core/entity/clientEntity.d.ts +0 -20
- package/dist/core/entity/clientEntity.js +0 -37
- package/dist/core/entity/componets/entityComponet.d.ts +0 -202
- package/dist/core/entity/componets/entityComponet.js +0 -347
- package/dist/core/entity/data/nativeEntityData.d.ts +0 -9
- package/dist/core/entity/data/nativeEntityData.js +0 -38
- package/dist/core/entity/entity.d.ts +0 -15
- package/dist/core/entity/entity.js +0 -18
- package/dist/core/entity/nativeEntity.d.ts +0 -8
- package/dist/core/entity/nativeEntity.js +0 -28
- package/dist/core/entity/navigation/walk.d.ts +0 -23
- package/dist/core/entity/navigation/walk.js +0 -56
- package/dist/core/entity/projectile.d.ts +0 -3
- package/dist/core/entity/projectile.js +0 -7
- package/dist/core/factory/biomeFactory.d.ts +0 -4
- package/dist/core/factory/biomeFactory.js +0 -13
- package/dist/core/factory/blockFactory.d.ts +0 -34
- package/dist/core/factory/blockFactory.js +0 -143
- package/dist/core/factory/entityFactory.d.ts +0 -17
- package/dist/core/factory/entityFactory.js +0 -75
- package/dist/core/factory/featureFactory.d.ts +0 -6
- package/dist/core/factory/featureFactory.js +0 -23
- package/dist/core/factory/itemExtra.d.ts +0 -8
- package/dist/core/factory/itemExtra.js +0 -9
- package/dist/core/factory/itemFactory.d.ts +0 -27
- package/dist/core/factory/itemFactory.js +0 -112
- package/dist/core/factory/recipeFactory.d.ts +0 -18
- package/dist/core/factory/recipeFactory.js +0 -39
- package/dist/core/factory/uiFactory.d.ts +0 -11
- package/dist/core/factory/uiFactory.js +0 -32
- package/dist/core/feature/oreFeature.d.ts +0 -10
- package/dist/core/feature/oreFeature.js +0 -11
- package/dist/core/feature-rule/condition/biomeFilter.d.ts +0 -26
- package/dist/core/feature-rule/condition/biomeFilter.js +0 -36
- package/dist/core/feature-rule/condition/featureConditions.d.ts +0 -27
- package/dist/core/feature-rule/condition/featureConditions.js +0 -37
- package/dist/core/feature-rule/distribution/coordinateDistribution.d.ts +0 -17
- package/dist/core/feature-rule/distribution/coordinateDistribution.js +0 -23
- package/dist/core/feature-rule/distribution/featureDistribution.d.ts +0 -31
- package/dist/core/feature-rule/distribution/featureDistribution.js +0 -41
- package/dist/core/feature-rule/featureRule.d.ts +0 -17
- package/dist/core/feature-rule/featureRule.js +0 -26
- package/dist/core/index.d.ts +0 -24
- package/dist/core/index.js +0 -21
- package/dist/core/item/armor.d.ts +0 -21
- package/dist/core/item/armor.js +0 -90
- package/dist/core/item/attachable.d.ts +0 -6
- package/dist/core/item/attachable.js +0 -26
- package/dist/core/item/food.d.ts +0 -24
- package/dist/core/item/food.js +0 -38
- package/dist/core/item/item.d.ts +0 -36
- package/dist/core/item/item.js +0 -69
- package/dist/core/item/itemComponents.d.ts +0 -113
- package/dist/core/item/itemComponents.js +0 -225
- package/dist/core/registry.d.ts +0 -12
- package/dist/core/registry.js +0 -16
- package/dist/core/texture.d.ts +0 -18
- package/dist/core/texture.js +0 -38
- package/dist/core/ui/buttonMapping.d.ts +0 -97
- package/dist/core/ui/buttonMapping.js +0 -132
- package/dist/core/ui/dataBindingObject.d.ts +0 -97
- package/dist/core/ui/dataBindingObject.js +0 -134
- package/dist/core/ui/elements/button.d.ts +0 -21
- package/dist/core/ui/elements/button.js +0 -101
- package/dist/core/ui/elements/collectionPanel.d.ts +0 -12
- package/dist/core/ui/elements/collectionPanel.js +0 -53
- package/dist/core/ui/elements/grid.d.ts +0 -8
- package/dist/core/ui/elements/grid.js +0 -33
- package/dist/core/ui/elements/image.d.ts +0 -13
- package/dist/core/ui/elements/image.js +0 -55
- package/dist/core/ui/elements/label.d.ts +0 -14
- package/dist/core/ui/elements/label.js +0 -61
- package/dist/core/ui/elements/panel.d.ts +0 -11
- package/dist/core/ui/elements/panel.js +0 -49
- package/dist/core/ui/elements/scrollingPanel.d.ts +0 -14
- package/dist/core/ui/elements/scrollingPanel.js +0 -59
- package/dist/core/ui/elements/stackPanel.d.ts +0 -14
- package/dist/core/ui/elements/stackPanel.js +0 -37
- package/dist/core/ui/elements/uiElement.d.ts +0 -53
- package/dist/core/ui/elements/uiElement.js +0 -129
- package/dist/core/ui/properties/control.d.ts +0 -214
- package/dist/core/ui/properties/control.js +0 -286
- package/dist/core/ui/properties/dataBinding.d.ts +0 -6
- package/dist/core/ui/properties/dataBinding.js +0 -16
- package/dist/core/ui/properties/factory.d.ts +0 -37
- package/dist/core/ui/properties/factory.js +0 -62
- package/dist/core/ui/properties/gridProp.d.ts +0 -65
- package/dist/core/ui/properties/gridProp.js +0 -90
- package/dist/core/ui/properties/input.d.ts +0 -97
- package/dist/core/ui/properties/input.js +0 -134
- package/dist/core/ui/properties/layout.d.ts +0 -105
- package/dist/core/ui/properties/layout.js +0 -145
- package/dist/core/ui/properties/scrollView.d.ts +0 -105
- package/dist/core/ui/properties/scrollView.js +0 -145
- package/dist/core/ui/properties/sound.d.ts +0 -47
- package/dist/core/ui/properties/sound.js +0 -66
- package/dist/core/ui/properties/sprite.d.ts +0 -161
- package/dist/core/ui/properties/sprite.js +0 -222
- package/dist/core/ui/properties/text.d.ts +0 -135
- package/dist/core/ui/properties/text.js +0 -187
- package/dist/core/ui/registry/uiSystemRegistry.d.ts +0 -8
- package/dist/core/ui/registry/uiSystemRegistry.js +0 -26
- package/dist/core/ui/systems/chest.d.ts +0 -4
- package/dist/core/ui/systems/chest.js +0 -21
- package/dist/core/ui/systems/containerUISystem.d.ts +0 -64
- package/dist/core/ui/systems/containerUISystem.js +0 -206
- package/dist/core/ui/systems/guidebook.d.ts +0 -8
- package/dist/core/ui/systems/guidebook.js +0 -206
- package/dist/core/ui/systems/serverForm.d.ts +0 -12
- package/dist/core/ui/systems/serverForm.js +0 -116
- package/dist/core/ui/systems/system.d.ts +0 -16
- package/dist/core/ui/systems/system.js +0 -37
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
export class RandomStrollBehavior {
|
|
2
|
-
/**
|
|
3
|
-
* 随机漫步行为
|
|
4
|
-
* @param {number} priority 优先级
|
|
5
|
-
* @param {number} interval 间隔
|
|
6
|
-
* @param {number} speed_multiplier 速度倍数
|
|
7
|
-
*/
|
|
8
|
-
constructor(priority, interval, speed_multiplier) {
|
|
9
|
-
// 参数验证
|
|
10
|
-
if (typeof priority !== "number" || priority < 0) {
|
|
11
|
-
throw new Error("priority 必须是一个非负数");
|
|
12
|
-
}
|
|
13
|
-
if (typeof interval !== "number" || interval <= 0) {
|
|
14
|
-
throw new Error("interval 必须是一个正数");
|
|
15
|
-
}
|
|
16
|
-
if (typeof speed_multiplier !== "number" || speed_multiplier <= 0) {
|
|
17
|
-
throw new Error("speed_multiplier 必须是一个正数");
|
|
18
|
-
}
|
|
19
|
-
// 初始化属性
|
|
20
|
-
this.priority = priority;
|
|
21
|
-
this.interval = interval;
|
|
22
|
-
this.speed_multiplier = speed_multiplier;
|
|
23
|
-
this.xz_dist = 10; // 默认水平距离
|
|
24
|
-
this.y_dist = 7; // 默认垂直距离
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* 设置水平距离
|
|
28
|
-
* @param {number} xz_dist 水平距离
|
|
29
|
-
* @returns {EntityBehaviorRandomStroll} 返回当前实例以支持链式调用
|
|
30
|
-
*/
|
|
31
|
-
setXZDist(xz_dist) {
|
|
32
|
-
if (typeof xz_dist !== "number" || xz_dist < 1) {
|
|
33
|
-
throw new Error("xz_dist 必须是一个至少为 1 的整数");
|
|
34
|
-
}
|
|
35
|
-
this.xz_dist = xz_dist;
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* 设置垂直距离
|
|
40
|
-
* @param {number} y_dist 垂直距离
|
|
41
|
-
* @returns {EntityBehaviorRandomStroll} 返回当前实例以支持链式调用
|
|
42
|
-
*/
|
|
43
|
-
setYDist(y_dist) {
|
|
44
|
-
if (typeof y_dist !== "number" || y_dist < 1) {
|
|
45
|
-
throw new Error("y_dist 必须是一个至少为 1 的整数");
|
|
46
|
-
}
|
|
47
|
-
this.y_dist = y_dist;
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* 将组件转换为 JSON 对象
|
|
52
|
-
* @returns {Object} minecraft:behavior.random_stroll 组件的 JSON 对象
|
|
53
|
-
*/
|
|
54
|
-
toJSON() {
|
|
55
|
-
return new Map().set("minecraft:behavior.random_stroll", {
|
|
56
|
-
priority: this.priority,
|
|
57
|
-
interval: this.interval,
|
|
58
|
-
speed_multiplier: this.speed_multiplier,
|
|
59
|
-
xz_dist: this.xz_dist,
|
|
60
|
-
y_dist: this.y_dist,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
export class TemptBehavior {
|
|
2
|
-
/**
|
|
3
|
-
* 创建 minecraft:behavior.tempt 组件。
|
|
4
|
-
* @param {number} priority 行为的优先级
|
|
5
|
-
*/
|
|
6
|
-
constructor(priority: number);
|
|
7
|
-
priority: number;
|
|
8
|
-
can_get_scared: boolean;
|
|
9
|
-
can_tempt_vertically: boolean;
|
|
10
|
-
can_tempt_while_ridden: boolean;
|
|
11
|
-
items: any[];
|
|
12
|
-
sound_interval: {
|
|
13
|
-
range_min: number;
|
|
14
|
-
range_max: number;
|
|
15
|
-
};
|
|
16
|
-
speed_multiplier: number;
|
|
17
|
-
tempt_sound: string;
|
|
18
|
-
within_radius: number;
|
|
19
|
-
/**
|
|
20
|
-
* 设置是否会被吓跑。
|
|
21
|
-
* @param {boolean} canGetScared 是否会被吓跑
|
|
22
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
23
|
-
*/
|
|
24
|
-
canGetScared(canGetScared: boolean): Tempt;
|
|
25
|
-
/**
|
|
26
|
-
* 设置是否考虑垂直距离。
|
|
27
|
-
* @param {boolean} canTemptVertically 是否考虑垂直距离
|
|
28
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
29
|
-
*/
|
|
30
|
-
canTemptVertically(canTemptVertically: boolean): Tempt;
|
|
31
|
-
/**
|
|
32
|
-
* 设置是否在被骑乘时被吸引。
|
|
33
|
-
* @param {boolean} canTemptWhileRidden 是否在被骑乘时被吸引
|
|
34
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
35
|
-
*/
|
|
36
|
-
canTemptWhileRidden(canTemptWhileRidden: boolean): Tempt;
|
|
37
|
-
/**
|
|
38
|
-
* 设置吸引实体的物品列表。
|
|
39
|
-
* @param {Array} items 吸引实体的物品列表
|
|
40
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
41
|
-
*/
|
|
42
|
-
setItems(items: any[]): Tempt;
|
|
43
|
-
/**
|
|
44
|
-
* 设置播放吸引声音的随机间隔时间。
|
|
45
|
-
* @param {number} min 最小间隔时间
|
|
46
|
-
* @param {number} max 最大间隔时间
|
|
47
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
48
|
-
*/
|
|
49
|
-
setSoundInterval(min: number, max: number): Tempt;
|
|
50
|
-
/**
|
|
51
|
-
* 设置移动速度倍数。
|
|
52
|
-
* @param {number} speedMultiplier 移动速度倍数
|
|
53
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
54
|
-
*/
|
|
55
|
-
setSpeedMultiplier(speedMultiplier: number): Tempt;
|
|
56
|
-
/**
|
|
57
|
-
* 设置吸引时播放的声音。
|
|
58
|
-
* @param {string} temptSound 吸引时播放的声音
|
|
59
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
60
|
-
*/
|
|
61
|
-
setTemptSound(temptSound: string): Tempt;
|
|
62
|
-
/**
|
|
63
|
-
* 设置吸引的最大距离。
|
|
64
|
-
* @param {number} withinRadius 吸引的最大距离
|
|
65
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
66
|
-
*/
|
|
67
|
-
setWithinRadius(withinRadius: number): Tempt;
|
|
68
|
-
/**
|
|
69
|
-
* 将组件转换为 JSON 对象。
|
|
70
|
-
* @returns {Object} minecraft:behavior.tempt 组件的 JSON 对象
|
|
71
|
-
*/
|
|
72
|
-
toJSON(): any;
|
|
73
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
export class TemptBehavior {
|
|
2
|
-
/**
|
|
3
|
-
* 创建 minecraft:behavior.tempt 组件。
|
|
4
|
-
* @param {number} priority 行为的优先级
|
|
5
|
-
*/
|
|
6
|
-
constructor(priority) {
|
|
7
|
-
if (typeof priority !== "number" || priority < 0) {
|
|
8
|
-
throw new Error("priority 必须是一个非负数");
|
|
9
|
-
}
|
|
10
|
-
this.priority = priority;
|
|
11
|
-
this.can_get_scared = false;
|
|
12
|
-
this.can_tempt_vertically = false;
|
|
13
|
-
this.can_tempt_while_ridden = false;
|
|
14
|
-
this.items = [];
|
|
15
|
-
this.sound_interval = { range_min: 0.0, range_max: 0.0 };
|
|
16
|
-
this.speed_multiplier = 1.0;
|
|
17
|
-
this.tempt_sound = null;
|
|
18
|
-
this.within_radius = 0.0;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* 设置是否会被吓跑。
|
|
22
|
-
* @param {boolean} canGetScared 是否会被吓跑
|
|
23
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
24
|
-
*/
|
|
25
|
-
canGetScared(canGetScared) {
|
|
26
|
-
if (typeof canGetScared !== "boolean") {
|
|
27
|
-
throw new Error("canGetScared 必须是布尔类型");
|
|
28
|
-
}
|
|
29
|
-
this.can_get_scared = canGetScared;
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* 设置是否考虑垂直距离。
|
|
34
|
-
* @param {boolean} canTemptVertically 是否考虑垂直距离
|
|
35
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
36
|
-
*/
|
|
37
|
-
canTemptVertically(canTemptVertically) {
|
|
38
|
-
if (typeof canTemptVertically !== "boolean") {
|
|
39
|
-
throw new Error("canTemptVertically 必须是布尔类型");
|
|
40
|
-
}
|
|
41
|
-
this.can_tempt_vertically = canTemptVertically;
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* 设置是否在被骑乘时被吸引。
|
|
46
|
-
* @param {boolean} canTemptWhileRidden 是否在被骑乘时被吸引
|
|
47
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
48
|
-
*/
|
|
49
|
-
canTemptWhileRidden(canTemptWhileRidden) {
|
|
50
|
-
if (typeof canTemptWhileRidden !== "boolean") {
|
|
51
|
-
throw new Error("canTemptWhileRidden 必须是布尔类型");
|
|
52
|
-
}
|
|
53
|
-
this.can_tempt_while_ridden = canTemptWhileRidden;
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* 设置吸引实体的物品列表。
|
|
58
|
-
* @param {Array} items 吸引实体的物品列表
|
|
59
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
60
|
-
*/
|
|
61
|
-
setItems(items) {
|
|
62
|
-
if (!Array.isArray(items) || items.length === 0) {
|
|
63
|
-
throw new Error("items 必须是一个非空数组");
|
|
64
|
-
}
|
|
65
|
-
this.items = items;
|
|
66
|
-
return this;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* 设置播放吸引声音的随机间隔时间。
|
|
70
|
-
* @param {number} min 最小间隔时间
|
|
71
|
-
* @param {number} max 最大间隔时间
|
|
72
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
73
|
-
*/
|
|
74
|
-
setSoundInterval(min, max) {
|
|
75
|
-
if (typeof min !== "number" || typeof max !== "number" || min < 0 || max < 0) {
|
|
76
|
-
throw new Error("min 和 max 必须是非负数");
|
|
77
|
-
}
|
|
78
|
-
this.sound_interval = { range_min: min, range_max: max };
|
|
79
|
-
return this;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* 设置移动速度倍数。
|
|
83
|
-
* @param {number} speedMultiplier 移动速度倍数
|
|
84
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
85
|
-
*/
|
|
86
|
-
setSpeedMultiplier(speedMultiplier) {
|
|
87
|
-
if (typeof speedMultiplier !== "number" || speedMultiplier <= 0) {
|
|
88
|
-
throw new Error("speedMultiplier 必须是一个正数");
|
|
89
|
-
}
|
|
90
|
-
this.speed_multiplier = speedMultiplier;
|
|
91
|
-
return this;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* 设置吸引时播放的声音。
|
|
95
|
-
* @param {string} temptSound 吸引时播放的声音
|
|
96
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
97
|
-
*/
|
|
98
|
-
setTemptSound(temptSound) {
|
|
99
|
-
if (typeof temptSound !== "string") {
|
|
100
|
-
throw new Error("temptSound 必须是字符串");
|
|
101
|
-
}
|
|
102
|
-
this.tempt_sound = temptSound;
|
|
103
|
-
return this;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* 设置吸引的最大距离。
|
|
107
|
-
* @param {number} withinRadius 吸引的最大距离
|
|
108
|
-
* @returns {Tempt} 返回当前实例以支持链式调用
|
|
109
|
-
*/
|
|
110
|
-
setWithinRadius(withinRadius) {
|
|
111
|
-
if (typeof withinRadius !== "number" || withinRadius < 0) {
|
|
112
|
-
throw new Error("withinRadius 必须是一个非负数");
|
|
113
|
-
}
|
|
114
|
-
this.within_radius = withinRadius;
|
|
115
|
-
return this;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* 将组件转换为 JSON 对象。
|
|
119
|
-
* @returns {Object} minecraft:behavior.tempt 组件的 JSON 对象
|
|
120
|
-
*/
|
|
121
|
-
toJSON() {
|
|
122
|
-
return new Map().set("minecraft:behavior.tempt", {
|
|
123
|
-
priority: this.priority,
|
|
124
|
-
can_get_scared: this.can_get_scared,
|
|
125
|
-
can_tempt_vertically: this.can_tempt_vertically,
|
|
126
|
-
can_tempt_while_ridden: this.can_tempt_while_ridden,
|
|
127
|
-
items: this.items,
|
|
128
|
-
sound_interval: this.sound_interval,
|
|
129
|
-
speed_multiplier: this.speed_multiplier,
|
|
130
|
-
tempt_sound: this.tempt_sound,
|
|
131
|
-
within_radius: this.within_radius,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export class BasicBundle {
|
|
2
|
-
/**
|
|
3
|
-
* 添加组件到捆绑包
|
|
4
|
-
* @param {Map} componentMap 组件
|
|
5
|
-
* @returns {BasicBundle} 返回捆绑包对象
|
|
6
|
-
*/
|
|
7
|
-
addComponent(componentMap: Map<any, any>): BasicBundle;
|
|
8
|
-
addComponents(components: any): void;
|
|
9
|
-
removeComponent(name: any): this;
|
|
10
|
-
serialize(): Map<any, any>;
|
|
11
|
-
#private;
|
|
12
|
-
}
|
|
13
|
-
export const BasicMovementBundle: BasicBundle;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { EntityComponent } from "../componets/entityComponet.js";
|
|
2
|
-
export class BasicBundle {
|
|
3
|
-
//私有属性 存储组件
|
|
4
|
-
#components = new Map();
|
|
5
|
-
/**
|
|
6
|
-
* 捆绑包 捆绑包是一个附带有一些实体组件的集合,能够方便地将这些组件添加到一个实体上。
|
|
7
|
-
*/
|
|
8
|
-
constructor() {
|
|
9
|
-
//空构造函数
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 添加组件到捆绑包
|
|
13
|
-
* @param {Map} componentMap 组件
|
|
14
|
-
* @returns {BasicBundle} 返回捆绑包对象
|
|
15
|
-
*/
|
|
16
|
-
addComponent(componentMap) {
|
|
17
|
-
if (!(componentMap instanceof Map)) {
|
|
18
|
-
throw new Error("componentMap must be an instance of Map.");
|
|
19
|
-
}
|
|
20
|
-
for (const [key, value] of componentMap) {
|
|
21
|
-
this.#components.set(key, value);
|
|
22
|
-
}
|
|
23
|
-
return this; // 支持链式调用
|
|
24
|
-
}
|
|
25
|
-
addComponents(components) {
|
|
26
|
-
components.forEach(component_map => {
|
|
27
|
-
this.addComponent(component_map);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
removeComponent(name) {
|
|
31
|
-
this.#components.delete(name);
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
//序列化
|
|
35
|
-
serialize() {
|
|
36
|
-
return this.#components;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//移动捆绑包
|
|
40
|
-
export const BasicMovementBundle = new BasicBundle();
|
|
41
|
-
MovementBundle.addComponents([
|
|
42
|
-
//speed
|
|
43
|
-
EntityComponent.setMovement(0.2),
|
|
44
|
-
EntityComponent.setMovementBasic()
|
|
45
|
-
]);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ClientEntity 类,用于表示客户端实体。
|
|
3
|
-
* 继承自 AddonClientEntityDescription,并扩展了实体的数据加载和 JSON 序列化功能。
|
|
4
|
-
*/
|
|
5
|
-
export class ClientEntity extends AddonClientEntityDescription {
|
|
6
|
-
/**
|
|
7
|
-
* 构造函数,用于创建一个客户端实体实例。
|
|
8
|
-
*
|
|
9
|
-
* @param {string} identifier - 实体的唯一标识符。
|
|
10
|
-
* @param {Object} data - 实体的初始数据,默认为空对象。
|
|
11
|
-
*/
|
|
12
|
-
constructor(identifier: string, data?: any);
|
|
13
|
-
/**
|
|
14
|
-
* 将当前实体实例转换为 JSON 格式。
|
|
15
|
-
*
|
|
16
|
-
* @returns {Object} - 表示实体的 JSON 对象。
|
|
17
|
-
*/
|
|
18
|
-
toJson(): any;
|
|
19
|
-
}
|
|
20
|
-
import { AddonClientEntityDescription } from "../addon/entity/clientEntity.js";
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { AddonClientEntity, AddonClientEntityDefinition, AddonClientEntityDescription } from "../addon/entity/clientEntity.js";
|
|
2
|
-
/**
|
|
3
|
-
* ClientEntity 类,用于表示客户端实体。
|
|
4
|
-
* 继承自 AddonClientEntityDescription,并扩展了实体的数据加载和 JSON 序列化功能。
|
|
5
|
-
*/
|
|
6
|
-
export class ClientEntity extends AddonClientEntityDescription {
|
|
7
|
-
/**
|
|
8
|
-
* 构造函数,用于创建一个客户端实体实例。
|
|
9
|
-
*
|
|
10
|
-
* @param {string} identifier - 实体的唯一标识符。
|
|
11
|
-
* @param {Object} data - 实体的初始数据,默认为空对象。
|
|
12
|
-
*/
|
|
13
|
-
constructor(identifier, data = {}) {
|
|
14
|
-
// 调用父类构造函数,初始化实体的标识符
|
|
15
|
-
super(identifier);
|
|
16
|
-
// 遍历传入的数据对象,将属性赋值到当前实例
|
|
17
|
-
const keys = Object.keys(data);
|
|
18
|
-
keys.forEach((key) => {
|
|
19
|
-
// 跳过 "identifier" 属性,因为已经在父类中处理
|
|
20
|
-
if (key === "identifier")
|
|
21
|
-
return;
|
|
22
|
-
// 将数据对象的属性赋值到当前实例
|
|
23
|
-
this[key] = data[key];
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* 将当前实体实例转换为 JSON 格式。
|
|
28
|
-
*
|
|
29
|
-
* @returns {Object} - 表示实体的 JSON 对象。
|
|
30
|
-
*/
|
|
31
|
-
toJson() {
|
|
32
|
-
// 创建一个 AddonClientEntity 实例,包含实体定义和版本信息
|
|
33
|
-
return new AddonClientEntity("1.10.0", // 版本号
|
|
34
|
-
new AddonClientEntityDefinition(this) // 实体定义
|
|
35
|
-
).toJson(); // 调用 toJson 方法,返回 JSON 格式的数据
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
export class EntityComponent {
|
|
2
|
-
static setMovement(speed: any): Map<any, any>;
|
|
3
|
-
static setCollisionBox(width: any, height: any): Map<any, any>;
|
|
4
|
-
/**
|
|
5
|
-
* 将多个组件集合合并为一个。
|
|
6
|
-
* @param {...Map} componentMaps - 多个组件集合。
|
|
7
|
-
* @returns {Map} - 合并后的组件集合。
|
|
8
|
-
*/
|
|
9
|
-
static combineComponents(...componentMaps: Map<any, any>[]): Map<any, any>;
|
|
10
|
-
/**
|
|
11
|
-
* 创建 minecraft:health 组件。
|
|
12
|
-
* @param {Object} options 配置选项
|
|
13
|
-
* @param {number} options.max 实体的最大生命值
|
|
14
|
-
* @param {number|Object} options.value 实体的初始生命值(可以是固定值或范围值)
|
|
15
|
-
* @returns {Map} 包含 minecraft:health 组件的 Map 对象
|
|
16
|
-
* @throws {Error} 如果参数无效。
|
|
17
|
-
*/
|
|
18
|
-
static setHealth(options?: {
|
|
19
|
-
max: number;
|
|
20
|
-
value: number | any;
|
|
21
|
-
}): Map<any, any>;
|
|
22
|
-
/**
|
|
23
|
-
* 验证 minecraft:health 组件的参数。
|
|
24
|
-
* @param {number} max 最大生命值
|
|
25
|
-
* @param {number|Object} value 初始生命值
|
|
26
|
-
* @throws {Error} 如果参数无效。
|
|
27
|
-
*/
|
|
28
|
-
static validateHealthParameters(max: number, value: number | any): void;
|
|
29
|
-
/**
|
|
30
|
-
* 创建 minecraft:physics 组件。
|
|
31
|
-
* @param {boolean} has_collision 是否碰撞(默认:true)
|
|
32
|
-
* @param {boolean} has_gravity 是否受重力影响(默认:true)
|
|
33
|
-
* @param {boolean} push_towards_closest_space 是否在卡住时推向最近空间(默认:false)
|
|
34
|
-
* @returns {Map} 包含 minecraft:physics 组件的 Map 对象
|
|
35
|
-
* @throws {Error} 如果参数不是布尔类型。
|
|
36
|
-
*/
|
|
37
|
-
static setPhysics(has_collision?: boolean, has_gravity?: boolean, push_towards_closest_space?: boolean): Map<any, any>;
|
|
38
|
-
/**
|
|
39
|
-
* 创建 minecraft:scale 组件。
|
|
40
|
-
* @param {number} value 实体的缩放比例(默认:1.0)
|
|
41
|
-
* @returns {Map} 包含 minecraft:scale 组件的 Map 对象
|
|
42
|
-
* @throws {Error} 如果参数无效。
|
|
43
|
-
*/
|
|
44
|
-
static setScale(value?: number): Map<any, any>;
|
|
45
|
-
/**
|
|
46
|
-
* 创建默认的 minecraft:nameable 组件(不填写参数)。
|
|
47
|
-
* @returns {Map} 包含 minecraft:nameable 组件的 Map 对象
|
|
48
|
-
*/
|
|
49
|
-
static setDefaultNameable(): Map<any, any>;
|
|
50
|
-
/**
|
|
51
|
-
* 创建自定义的 minecraft:nameable 组件(填写参数)。
|
|
52
|
-
* @param {boolean} allowNameTagRenaming 是否允许使用命名牌重命名(默认:true)
|
|
53
|
-
* @param {boolean} alwaysShow 是否始终显示名称(默认:false)
|
|
54
|
-
* @param {Object} defaultTrigger 默认触发事件(可选)
|
|
55
|
-
* @param {Array} nameActions 特殊名称及其对应的事件(可选)
|
|
56
|
-
* @returns {Map} 包含 minecraft:nameable 组件的 Map 对象
|
|
57
|
-
* @throws {Error} 如果参数无效。
|
|
58
|
-
*/
|
|
59
|
-
static setCustomNameable(allowNameTagRenaming?: boolean, alwaysShow?: boolean, defaultTrigger?: any, nameActions?: any[]): Map<any, any>;
|
|
60
|
-
/**
|
|
61
|
-
* 创建 minecraft:pushable 组件。
|
|
62
|
-
* @param {boolean} isPushable 是否可以被其他实体推动(默认:true)
|
|
63
|
-
* @param {boolean} isPushableByPiston 是否可以被活塞推动(默认:true)
|
|
64
|
-
* @returns {Map} 包含 minecraft:pushable 组件的 Map 对象
|
|
65
|
-
* @throws {Error} 如果参数无效。
|
|
66
|
-
*/
|
|
67
|
-
static setPushable(isPushable?: boolean, isPushableByPiston?: boolean): Map<any, any>;
|
|
68
|
-
/**
|
|
69
|
-
* 创建 minecraft:jump.static 组件。
|
|
70
|
-
* @param {number} jumpPower 跳跃的初始垂直速度(默认:0.42)
|
|
71
|
-
* @returns {Map} 包含 minecraft:jump.static 组件的 Map 对象
|
|
72
|
-
* @throws {Error} 如果参数无效。
|
|
73
|
-
*/
|
|
74
|
-
static setJumpStatic(jumpPower?: number): Map<any, any>;
|
|
75
|
-
/**
|
|
76
|
-
* 创建 minecraft:navigation.walk 组件。
|
|
77
|
-
* @param {Object} options 配置选项
|
|
78
|
-
* @param {boolean} options.avoidDamageBlocks 是否避免伤害性方块(默认:false)
|
|
79
|
-
* @param {boolean} options.avoidPortals 是否避免传送门(默认:false)
|
|
80
|
-
* @param {boolean} options.avoidSun 是否避免阳光下的方块(默认:false)
|
|
81
|
-
* @param {boolean} options.avoidWater 是否避免水(默认:false)
|
|
82
|
-
* @param {Array} options.blocksToAvoid 需要避免的方块列表(默认:[])
|
|
83
|
-
* @param {boolean} options.canBreach 是否可以跳出水面(默认:false)
|
|
84
|
-
* @param {boolean} options.canBreakDoors 是否可以破坏门(默认:false)
|
|
85
|
-
* @param {boolean} options.canFloat 是否可以漂浮(默认:false)
|
|
86
|
-
* @param {boolean} options.canJump 是否可以跳跃(默认:true)
|
|
87
|
-
* @param {boolean} options.canOpenDoors 是否可以开门(默认:false)
|
|
88
|
-
* @param {boolean} options.canOpenIronDoors 是否可以开铁门(默认:false)
|
|
89
|
-
* @param {boolean} options.canPassDoors 是否可以穿过门(默认:true)
|
|
90
|
-
* @param {boolean} options.canPathFromAir 是否可以在空中开始路径规划(默认:false)
|
|
91
|
-
* @param {boolean} options.canPathOverLava 是否可以在熔岩表面行走(默认:false)
|
|
92
|
-
* @param {boolean} options.canPathOverWater 是否可以在水面上行走(默认:false)
|
|
93
|
-
* @param {boolean} options.canSink 是否会在水中下沉(默认:true)
|
|
94
|
-
* @param {boolean} options.canSwim 是否可以游泳(默认:false)
|
|
95
|
-
* @param {boolean} options.canWalk 是否可以在地面上行走(默认:true)
|
|
96
|
-
* @param {boolean} options.canWalkInLava 是否可以在熔岩中行走(默认:false)
|
|
97
|
-
* @param {boolean} options.isAmphibious 是否可以在水下行走(默认:false)
|
|
98
|
-
* @returns {Map} 包含 minecraft:navigation.walk 组件的 Map 对象
|
|
99
|
-
* @throws {Error} 如果参数无效。
|
|
100
|
-
*/
|
|
101
|
-
static setNavigationWalk(options?: {
|
|
102
|
-
avoidDamageBlocks: boolean;
|
|
103
|
-
avoidPortals: boolean;
|
|
104
|
-
avoidSun: boolean;
|
|
105
|
-
avoidWater: boolean;
|
|
106
|
-
blocksToAvoid: any[];
|
|
107
|
-
canBreach: boolean;
|
|
108
|
-
canBreakDoors: boolean;
|
|
109
|
-
canFloat: boolean;
|
|
110
|
-
canJump: boolean;
|
|
111
|
-
canOpenDoors: boolean;
|
|
112
|
-
canOpenIronDoors: boolean;
|
|
113
|
-
canPassDoors: boolean;
|
|
114
|
-
canPathFromAir: boolean;
|
|
115
|
-
canPathOverLava: boolean;
|
|
116
|
-
canPathOverWater: boolean;
|
|
117
|
-
canSink: boolean;
|
|
118
|
-
canSwim: boolean;
|
|
119
|
-
canWalk: boolean;
|
|
120
|
-
canWalkInLava: boolean;
|
|
121
|
-
isAmphibious: boolean;
|
|
122
|
-
}): Map<any, any>;
|
|
123
|
-
/**
|
|
124
|
-
* 创建 minecraft:movement.basic 组件。
|
|
125
|
-
* @param {number} maxTurn 实体每 tick 可以转向的最大角度(默认:30.0)
|
|
126
|
-
* @returns {Map} 包含 minecraft:movement.basic 组件的 Map 对象
|
|
127
|
-
* @throws {Error} 如果参数无效。
|
|
128
|
-
*/
|
|
129
|
-
static setMovementBasic(maxTurn?: number): Map<any, any>;
|
|
130
|
-
/**
|
|
131
|
-
* 创建 minecraft:projectile 组件。
|
|
132
|
-
* @param {Object} options 配置选项
|
|
133
|
-
* @param {number} options.anchor 发射锚点(默认:0)
|
|
134
|
-
* @param {number} options.angleOffset 角度偏移(默认:0.0)
|
|
135
|
-
* @param {boolean} options.catchFire 是否点燃目标(默认:false)
|
|
136
|
-
* @param {boolean} options.critParticleOnHurt 是否生成暴击粒子(默认:false)
|
|
137
|
-
* @param {boolean} options.destroyOnHurt 是否在击中时销毁(默认:false)
|
|
138
|
-
* @param {string} options.filter 过滤的实体(可选)
|
|
139
|
-
* @param {boolean} options.fireAffectedByGriefing 是否受游戏规则影响(默认:false)
|
|
140
|
-
* @param {number} options.gravity 重力值(默认:0.05)
|
|
141
|
-
* @param {string} options.hitSound 击中声音(可选)
|
|
142
|
-
* @param {string} options.hitGroundSound 击中地面声音(可选)
|
|
143
|
-
* @param {boolean} options.homing 是否追踪目标(默认:false)
|
|
144
|
-
* @param {number} options.inertia 空气惯性(默认:0.99)
|
|
145
|
-
* @param {boolean} options.isDangerous 是否对玩家危险(默认:false)
|
|
146
|
-
* @param {boolean} options.knockback 是否击退目标(默认:true)
|
|
147
|
-
* @param {boolean} options.lightning 是否召唤闪电(默认:false)
|
|
148
|
-
* @param {number} options.liquidInertia 水中惯性(默认:0.6)
|
|
149
|
-
* @param {boolean} options.multipleTargets 是否可击中多个目标(默认:true)
|
|
150
|
-
* @param {number[]} options.offset 发射偏移量(默认:[0, 0, 0])
|
|
151
|
-
* @param {number} options.onFireTime 着火时间(默认:0.0)
|
|
152
|
-
* @param {Object} options.onHit 击中时的行为(可选)
|
|
153
|
-
* @param {string} options.particle 碰撞粒子(默认:"ironcrack")
|
|
154
|
-
* @param {number} options.power 初始速度(默认:1.3)
|
|
155
|
-
* @param {number} options.reflectImmunity 反射免疫时间(默认:0.0)
|
|
156
|
-
* @param {boolean} options.reflectOnHurt 是否反射(默认:false)
|
|
157
|
-
* @param {string} options.shootSound 发射声音(可选)
|
|
158
|
-
* @param {boolean} options.shootTarget 是否朝向目标发射(默认:true)
|
|
159
|
-
* @param {boolean} options.shouldBounce 是否反弹(默认:false)
|
|
160
|
-
* @param {boolean} options.splashPotion 是否为喷溅药水(默认:false)
|
|
161
|
-
* @param {number} options.splashRange 喷溅范围(默认:4)
|
|
162
|
-
* @param {boolean} options.stopOnHurt 是否在击中时停止(默认:false)
|
|
163
|
-
* @param {number} options.uncertaintyBase 基础精度(默认:0)
|
|
164
|
-
* @param {number} options.uncertaintyMultiplier 精度倍数(默认:0)
|
|
165
|
-
* @returns {Map} 包含 minecraft:projectile 组件的 Map 对象
|
|
166
|
-
* @throws {Error} 如果参数无效。
|
|
167
|
-
*/
|
|
168
|
-
static setProjectile(options?: {
|
|
169
|
-
anchor: number;
|
|
170
|
-
angleOffset: number;
|
|
171
|
-
catchFire: boolean;
|
|
172
|
-
critParticleOnHurt: boolean;
|
|
173
|
-
destroyOnHurt: boolean;
|
|
174
|
-
filter: string;
|
|
175
|
-
fireAffectedByGriefing: boolean;
|
|
176
|
-
gravity: number;
|
|
177
|
-
hitSound: string;
|
|
178
|
-
hitGroundSound: string;
|
|
179
|
-
homing: boolean;
|
|
180
|
-
inertia: number;
|
|
181
|
-
isDangerous: boolean;
|
|
182
|
-
knockback: boolean;
|
|
183
|
-
lightning: boolean;
|
|
184
|
-
liquidInertia: number;
|
|
185
|
-
multipleTargets: boolean;
|
|
186
|
-
offset: number[];
|
|
187
|
-
onFireTime: number;
|
|
188
|
-
onHit: any;
|
|
189
|
-
particle: string;
|
|
190
|
-
power: number;
|
|
191
|
-
reflectImmunity: number;
|
|
192
|
-
reflectOnHurt: boolean;
|
|
193
|
-
shootSound: string;
|
|
194
|
-
shootTarget: boolean;
|
|
195
|
-
shouldBounce: boolean;
|
|
196
|
-
splashPotion: boolean;
|
|
197
|
-
splashRange: number;
|
|
198
|
-
stopOnHurt: boolean;
|
|
199
|
-
uncertaintyBase: number;
|
|
200
|
-
uncertaintyMultiplier: number;
|
|
201
|
-
}): Map<any, any>;
|
|
202
|
-
}
|