-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathYumeSignEnum.ts
More file actions
97 lines (87 loc) · 4.11 KB
/
Copy pathYumeSignEnum.ts
File metadata and controls
97 lines (87 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// SIGN for AUTO_BEHAVIOR
import { SimulatedPlayer, LookDuration } from '@minecraft/server-gametest'
import { Player } from '@minecraft/server'
import { commandManager } from '../yumeCommand/CommandRegistry'
import { ModalFormData } from '@minecraft/server-ui';
export enum SIGN {
AUTO_BREAKBLOCK_SIGN = 'AUTO_BREAKBLOCK_SIGN',
ATTACK_SIGN = 'ATTACK_SIGN',
AUTO_ATTACK_SIGN = 'AUTO_ATTACK_SIGN',
AUTO_CHASE_SIGN = 'AUTO_CHASE_SIGN',
AUTO_JUMP_SIGN = 'AUTO_JUMP_SIGN',
AUTO_TRIDENT_SIGN = 'AUTO_TRIDENT_SIGN',
AUTO_CONSUME_SIGN = 'AUTO_CONSUME_SIGN',
AUTO_RESPAWN_SIGN = 'AUTO_RESPAWN_SIGN',
YUME_SIM_SIGN = 'YUME_SIM_SIGN', //'#yumeSimSign#',
}
export default SIGN
export const SIGN_TAG_LIST:string[] = Object.keys(SIGN)
export enum SIGN_ZH {
AUTO_BREAKBLOCK_SIGN = '自动挖掘标签',
ATTACK_SIGN = '攻击标签',
AUTO_ATTACK_SIGN = '自动攻击标签',
AUTO_CHASE_SIGN = '自动追及标签',
AUTO_JUMP_SIGN = '自动跳跃标签',
AUTO_TRIDENT_SIGN = '自动丢三叉戟标签',
AUTO_CONSUME_SIGN = '自动食用标签',
AUTO_RESPAWN_SIGN = '自动重生标签',
YUME_SIM_SIGN = '云梦假人标签',
}
// SIGN for normal BEHAVIOR
export enum BEHAVIOR {
lookAtEntity = 'lookAtEntity',
teleport = 'teleport',
useAndStopUsingItem = 'useAndStopUsingItem',
useItemInSlot = 'useItemInSlot',
stopUsingItem = 'stopUsingItem',
interact = 'interact',
swapMainhandItem = 'swapMainhandItem',
swapInventory = 'swapInventory',
swapEquipment = 'swapEquipment',
rename = 'rename',
recycle = 'recycle', // item and exp
disconnect = 'disconnect',
}
export const BEHAVIOR_LIST:string[] = Object.keys(BEHAVIOR)
export enum BEHAVIOR_ZH {
lookAtEntity = '扭头',
teleport = '移动',
useAndStopUsingItem = '使用',
useItemInSlot = '开始使用',
stopUsingItem = '停止使用',
interact = '开始交互',
swapMainhandItem = '互换主手物品',
swapInventory = '互换背包',
swapEquipment = '互换装备',
rename = '改名',
recycle = '回收', // item and exp
disconnect = '销毁',
}
export const BEHAVIOR_FUNCTION = {
// @ts-ignore
lookAtEntity : (sim:SimulatedPlayer,player:Player)=>sim.lookAtEntity(player,LookDuration.Instant),
teleport : (sim:SimulatedPlayer,player:Player)=>sim.teleport(player.location),
useAndStopUsingItem : (sim:SimulatedPlayer&Player)=>sim.useItemInSlot(sim.selectedSlotIndex) && sim.stopUsingItem(),
useItemInSlot : (sim:SimulatedPlayer&Player)=>sim.useItemInSlot(sim.selectedSlotIndex),
stopUsingItem : (sim:SimulatedPlayer)=>sim.stopUsingItem(),
interact : (sim:SimulatedPlayer)=>sim.interact(),
swapMainhandItem : (sim:SimulatedPlayer,player:Player)=>commandManager.execute('假人主手物品交换',{entity:player,sim}),
swapInventory : (sim:SimulatedPlayer,player:Player)=>commandManager.execute('假人背包交换',{entity:player,sim}),
swapEquipment : (sim:SimulatedPlayer,player:Player)=>commandManager.execute('假人装备交换',{entity:player,sim}),
rename: async (sim: SimulatedPlayer, player: Player) => {
const modalForm = new ModalFormData().title("假人改名");
try {
modalForm.textField(`由 "${sim.nameTag}" 改为:`, '输入新名称', { defaultValue: sim.nameTag });
} catch {
// @ts-expect-error 如果不支持如上传参方式,回退到 1.21.7x 的方式
modalForm.textField(`由 "${sim.nameTag}" 改为:`, '输入新名称', sim.nameTag);
}
const { canceled, formValues } = await modalForm.show(<any>player);
if (canceled) return;
sim.nameTag = <string>formValues[0];
// commandManager.executeCommand('假人改名', [name], { entity: player, sim });
},
recycle : (sim:SimulatedPlayer,player:Player)=>commandManager.execute('假人资源回收',{entity:player,sim}), // item and exp
disconnect : (sim:SimulatedPlayer,player:Player)=>commandManager.execute('假人销毁',{sim,entity:player}),
}
export const exeBehavior = (behavior: string) => BEHAVIOR[behavior] && BEHAVIOR_FUNCTION[behavior]