-
Notifications
You must be signed in to change notification settings - Fork 0
/
获取粘液配方_v3.1.1.txt
287 lines (246 loc) · 8.02 KB
/
获取粘液配方_v3.1.1.txt
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
function wait_next_container() {
while(Player.openInventory().getCurrentSyncId() == LastSyncId || Player.openInventory().getCurrentSyncId() == 0){
// 等待打开容器
Client.waitTick(1)
}
LastSyncId = Player.openInventory().getCurrentSyncId()
Client.waitTick(1)
}
function getItemInfo() {
var item_id = getItemIdBySlot(16)
var data = {
"item_name":getItemNameBySlot(16),
"isMaterials":false,
"output_times":Player.openInventory().getSlot(16).getCount(),
"craft_id":getItemIdBySlot(10),
"craft_name":getItemNameBySlot(10),
"materials":[]
}
var tabel = [3,4,5,12,13,14,21,22,23]
for (let i = 0; i < 9; i++) {
let material_id = getItemIdBySlot(tabel[i])
let material_name = getItemNameBySlot(tabel[i])
let material_count = Player.openInventory().getSlot(tabel[i]).getCount()
if (material_id!="minecraft:air"){
data["materials"].push({
"material_id":material_id,
"material_name":material_name,
"material_count":material_count,
"position":i
})
}
}
return [item_id, data]
}
function close_inventory() {
Player.openInventory().close()
while (Player.openInventory().getCurrentSyncId()!=0) {
Client.waitTick(1)
}
}
function back_to_last_menu() {
var state = findItemById("slimefun:_UI_BACK","container")
enter_into_slot_menu(state['slot'][0][0])
}
function back_to_main_menu() {
var state
while((state = findItemById("slimefun:_UI_BACK","container"))) {
if (state['count'] == 0)
break
enter_into_slot_menu(state['slot'][0][0])
Client.waitTick(1)
}
}
function enter_into_slot_menu(slot) {
Player.openInventory().click(slot)
wait_next_container()
}
function loads(s) {
return eval('('+s+')');
}
function dumps(o) {
return JSON.stringify(o)
}
function getItemNameBySlot(Index) {
return Player.openInventory().getSlot(Index).getName().getString()
}
function getItemNbtBySlot(Index) {
Item = Player.openInventory().getSlot(Index), Nbt = Item.getNBT()
return Nbt
}
function getItemIdBySlot(Index) {
var Item = Player.openInventory().getSlot(Index)
var Nbt = Item.getNBT()
if (Nbt==null) {
return Item.getItemId()
}
else {
if (Nbt.has("PublicBukkitValues")) {
let PublicBukkitValues = Nbt.get("PublicBukkitValues")
if(PublicBukkitValues.has("slimefun:slimefun_item")) {
return "slimefun:"+PublicBukkitValues.get("slimefun:slimefun_item").asString()
}
else{
return PublicBukkitValues.asString()
}
}
else{
return Item.getItemId()
}
}
}
function findItemById(id,map_identifiers) {
let correct_slot = []
let item_count = 0
if (typeof(map_identifiers)=="string"){
for (let slot = 0; slot < Player.openInventory().getTotalSlots() ; slot++) {
let map_loc = Player.openInventory().getLocation(slot)
if (map_loc != map_identifiers)
continue
let item = Player.openInventory().getSlot(slot)
// Chat.log(slot);
let item_id = getItemIdBySlot(slot)
if (item_id == id) {
correct_slot.push([slot, item.getCount()])
item_count += item.getCount()
}
}
}
else if(typeof(map_identifiers)=="object"){
for (let slot = 0; slot < Player.openInventory().getTotalSlots() ; slot++) {
let map_loc = Player.openInventory().getLocation(slot)
if (!map_identifiers.includes(map_loc))
continue
let item = Player.openInventory().getSlot(slot)
let item_id = getItemIdBySlot(slot)
if (item_id == id) {
correct_slot.push([slot, item.getCount()])
item_count += item.getCount()
}
}
}
return {"slot":correct_slot.sort(function(a,b){return a[1]-b[1]}), "count":item_count}
}
function nextPage() {
var state = findItemById('slimefun:_UI_NEXT_ACTIVE','container')
if (state['count'] == 0 ) {
return false
}
else{
enter_into_slot_menu(state['slot'][0][0])
return true
}
}
function method(o) {
for (const m in o) {
Chat.log(m)
}
}
function merge(a,b) {
for (const k in a) {
if (!(k in b)) {
b[k] = a[k]
}
}
return b
}
function move_sf_guide_to_main_hand(){
s = findItemById('{"slimefun:slimefun_guide_mode":"SURVIVAL_MODE"}',['main','hotbar'])
main_hand_slot = Player.openInventory().getSelectedHotbarSlotIndex()
// KeyBind.pressKeyBind("key.inventory")
Player.openInventory().swapHotbar(s['slot'][0][0], main_hand_slot)
Player.openInventory().close()
}
function open_guide(){
move_sf_guide_to_main_hand()
me.interact()
wait_next_container()
}
var LastSyncId = 0
var SF_TITLE = ""
if (FS.makeDir('./config/')) {
FS.createFile('./config/', 'type_list.txt')
Chat.log("初始化成功,请进入config文件夹,编辑type_list.txt文件")
}
else{
var me = Player.getPlayer()
me.interact()
wait_next_container()
back_to_main_menu()
var file = FS.open('./config/type_list.txt').readLines()
var class_list = []
while(file.hasNext()) {
line = file.next().split(',').map(str => parseInt(str));
class_list.push(line)
}
current_data = {}
current_mkm = {}
for (let index = 0; index < class_list.length; index++) {
let UNLOCK = true
for (let deep = 0; deep < class_list[index].length; deep++) {
item_id= getItemIdBySlot(class_list[index][deep])
if (item_id == 'minecraft:barrier') {
Chat.log(getItemNameBySlot(class_list[index][deep]))
UNLOCK = false
break
}
enter_into_slot_menu(class_list[index][deep])
}
if (UNLOCK==false) {
continue
}
do {
for (let slot = 9; slot < 45; slot++) {
item_id= getItemIdBySlot(slot)
// Chat.log(item_id)
item_name = getItemNameBySlot(slot)
if (item_id == "minecraft:air") {
break
}
if (item_id == 'slimefun:_UI_NO_PERMISSION') {
Chat.log("未解锁:"+item_name)
continue
}
if (item_id == 'slimefun:_UI_NOT_RESEARCHED') {
Chat.log("未解锁:"+item_name)
continue
}
Chat.log("读取:"+item_name)
enter_into_slot_menu(slot)
info = getItemInfo()
current_data[info[0]] = info[1]
current_mkm[item_name] = info[0]
back_to_last_menu()
}
} while (nextPage());
back_to_main_menu()
}
if (FS.exists('./config/craft_formula.json') ) {
f = FS.open('./config/craft_formula.json')
previous_data = loads(f.read())
data = merge(previous_data,current_data)
s = dumps(data)
f.write(s)
Chat.log("已将新配方合并至craft_formula.json")
}
else{
FS.createFile('./config/', 'craft_formula.json')
f = FS.open('./config/craft_formula.json')
s = dumps(current_data)
f.write(s)
Chat.log("已创建craft_formula.json并写入配方")
}
if (FS.exists('./config/mainKeyMap.json') ) {
f = FS.open('./config/mainKeyMap.json')
previous_mkm = loads(f.read())
mkm = merge(previous_mkm,current_mkm)
s = dumps(mkm)
f.write(s)
}
else{
FS.createFile('./config/', 'mainKeyMap.json')
f = FS.open('./config/mainKeyMap.json')
s = dumps(current_mkm)
f.write(s)
}
}