-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusefulCommands.js
5641 lines (5536 loc) · 256 KB
/
usefulCommands.js
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*百度 ID: L18929567654
(C): MISTER_CHAN
版本:*/ const VERSION = "217.6.21"; /*
Since (DD/MM/YY): 06/03/16
*/ const RIGHT = "如欲转载, 必须注明出处."; /*
You must not copy the code or change the author's name.
※ usefulCommands 严禁使用方块启动器与 Toolbox 以外的启动器运行.
※ You must not use com.duowan.groundhog.mctools or other pupilar apps.*/
const BlockFriction = {ICE: Block.getFriction(79), STANDARD: Block.getFriction(0)},
CTX = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(),
FOR = "1.0",
DYE_COLOR = [-15132391, -6737101, -10059981, -10073037, -13415246, -8339378, -11763815, -6710887, -11776948, -884827, -8401895, -1710797, -10053160, -5092136, -2588877, -1],
Int = {MAX_VALUE: 2147483647, MIN_VALUE: -2147483648},
Long = {MAX_VALUE: 9223372036854775807, MIN_VALUE: -9223372036854775808},
MC_VER = ModPE.getMinecraftVersion(),
Short = {MAX_VALUE: 32767, MIN_VALUE: -32768},
TEXT_PARAMS = new android.widget.LinearLayout.LayoutParams(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT, android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT), TMI = CTX.getPackageName() == "io.mrarm.mctoolbox",
UPDATES = "" +
"\n版本: " + VERSION + "\n" +
"\n如有建议或疑问 请在百度贴吧私讯作者\n" +
RIGHT + "\n" +
"如欲引用 usefulCommands 所含算法 必须注明出处 否则视为侵权\n" +
"\n" + "=== 主要功能 ===" + "\n" +
"1\t死亡防喷 (keep inventory)\n" +
"2\t自动瞄准\n" +
"3\t防跳虛空\n" +
"4\t疾跑 跳跃提升\n" +
"5\t穿墙\n" +
"...\n" +
"\n" + "=== 玩法 ===" + "\n" +
"如有疑问 请尝试长按控件将可能显示帮助\n" +
"如使用 Toolbox 运行 usefulCommands 将支持在服务器使用",
Wnd = {WIDTH: CTX.getWindowManager().getDefaultDisplay().getWidth() / 4, HEIGHT: CTX.getWindowManager().getDefaultDisplay().getHeight() / 4};
var atapil = false, axpld = false,
bi = {items: []}, bl = false,
calc = {prev: "1 + 1"}, noFalling = {noFalling: false, height: 23, x: NaN, z: NaN}, carriedColor = 0, chat = {prev: "", window: undefined}, ctrller = {ctrller: false, velY: 0, window: undefined},
died = false, doLangEdit = false,
Ench = {}, enderEye = false, entroller = {ent: -1, pos: new Point()}, esc = false, Explode = {burnt: false, explode: false, radius: 4},
featherFalling = false,
hbr = {fb: EntityType.FIREBALL, hbr: false, vel: 5, window: undefined},
inv = {dontGetItame: false}, invulnerable = false, isInGame = false,
ki = {count: [], damage: [], enches: [], ki: false, id: [], lvl: 0, xp: 0},
ladder = false, lan = null, ld = {rec: true, pos: new Point()}, list = [], locked = false, lockTime = -1, lockWeather = {lightning: -1, rain: -1},
miner = false, ModTick = {speed: {millis: 50, nanos: 0}, type: false},
ndt = [], noclip = new Point(), nvtm = [],
paint = {clay: false, grass: false, wool: false}, pe = false, pickTile = false, ports = {ports: {name: [], pos: []}}, ppe = -1, pui = false,
qsc = false, quickBuilding = {cube: {canSetPort: false, clipbrd: new Point(), lower: new Point(), name: false, upper: new Point()}, fillRoad: false, linear: {canDestroy: false, canPlace: false, direction: "x-", length: 0, ratt: false, fid: 0, fata: 0, step: 1}},
rd = false, respawn = {dying: false, respawn: true, window: undefined}, rotatroller = {controller: false, invertYaxis: false, sensitivity: 1, window: undefined},
Scenter = {distance: NaN, hotOres: ["14:", "15:", "16:", "21:", "56:", "73:", "74:", "89:", "129:", "153:"], inradius: 16, isSearching: false, nearestOre: new Point(), ore: "56:", scenter: false, showTime: 0}, shl = 0, signTextNa = false, sp = false, sprint = {time: false, vel: 0, velY: 0, x: NaN, z: NaN}, st = {editable: false},
Target = {attackable: false, automatic: false, doGetPitch: true, ent: -1, i: false, regExp: "", text: undefined, window: undefined}, theme = 0, tipHp = true, tipPos = [], tipTile = false, treeCapitator = false, txtMnu, txtTipMsg,
useItemToTp = 0, usePlyrLst = false,
veinMiner = {maxMined: "2048", mined: 0, ores: ["14:", "15:", "16:", "21:", "56:", "73:", "74:", "89:", "129:", "153:"], veinMiner: false},
web = {web: false, th: false, prev: new Point()}, wndMnuTxt;
xpBottles = {isThrowing: false, pos: new Point()};
Block.OPAQUE_TILES = /^(1|2|3|4|5|7|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|29|33|34|35|41|42|43|44|45|46|47|48|49|52|53|54|56|57|58|60|61|62|64|65|67|71|73|74|79|80|81|82|84|85|86|87|88|89|91|92|93|94|95|96|97|98|99|100|101|102|103|106|107|108|109|110|111|112|113|114|116|117|118|120|121|122|123|124|125|126|127|128|129|130|133|134|135|136|137|138|139|140|144|145|146|149|150|151|152|153|154|155|156|158|159|160|161|162|163|164|165|166|167|168|170|171|172|173|174|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|200|201|202|203|204|205|206|207|208|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|243|245|246|247|248|249|250|251|252|253|254|255)$/,
Entity.be = {ents: [], types: []}, Entity.canRide = false, Entity.canSel = false, Entity.efv = {e: -1, effects: []}, Entity.lockEffects = {effects: [], showParticle: true}, Entity.rider = -1, Entity.riding = -1, Entity.sel = {ents: []},
Item.insoluble = false,
Level.destrocksByMock = {cd: 0, threads: []},
ModPE.camera = -1, ModPE.lockMextToTrot = false, ModPE.showTime = 0, ModPE.stim = !TMI, ModPE.wndLeaveGame, ModPE.wndTipMsg,
Player.ACCELERATION = 0.07840000092983246, Player.insoluble = "|";
function addItem(player, left) {
var layout = new android.widget.LinearLayout(CTX);
layout.setOrientation(layout.VERTICAL);
var text = new android.widget.TextView(CTX);
text.setText(ModPE.getI18n("entity.Item.name") + " ID");
text.setTextSize(text.getTextSize());
layout.addView(text);
var lytId = new android.widget.LinearLayout(CTX);
layout.addView(lytId);
var edtId = new android.widget.EditText(CTX);
edtId.setText("57");
edtId.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
lytId.addView(edtId);
var text = new android.widget.TextView(CTX);
text.setText(":");
lytId.addView(text);
var edtDamage = new android.widget.EditText(CTX);
edtDamage.setText("0");
edtDamage.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
lytId.addView(edtDamage);
var text = new android.widget.TextView(CTX);
text.setText(ModPE.getI18n("entity.Item.name") + " ID 査询");
layout.addView(text);
var edtKeyword = new android.widget.EditText(CTX);
edtKeyword.setHint("关键词");
edtKeyword.setLayoutParams(TEXT_PARAMS);
layout.addView(edtKeyword);
var btnSearch = new android.widget.Button(CTX);
btnSearch.setText("搜寻");
btnSearch.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
const RESULTS = Item.searchItem(edtKeyword.getText());
txtResult.setText("共 " + RESULTS.length + " 个结果");
lytSearch.removeView(lytResults[lytResults.length - 1]);
lytResults.push();
lytResults[lytResults.length - 1] = new android.widget.LinearLayout(CTX);
lytResults[lytResults.length - 1].setOrientation(lytResults[lytResults.length - 1].VERTICAL);
lytSearch.addView(lytResults[lytResults.length - 1]);
for (var r in RESULTS) {
var button = new android.widget.Button(CTX);
button.setText(RESULTS[r] + "\n" +
Item.getName(RESULTS[r].split(":")[0], RESULTS[r].split(":")[1]));
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
edtId.setText(view.getText().split("\n")[0].split(":")[0]);
edtDamage.setText(view.getText().split("\n")[0].split(":")[1]);
}}));
lytResults[lytResults.length - 1].addView(button);
}
}}));
layout.addView(btnSearch);
var lytSearch = new android.widget.LinearLayout(CTX);
lytSearch.setOrientation(lytSearch.VERTICAL);
layout.addView(lytSearch);
var lytResults = [];
lytResults[0] = new android.widget.LinearLayout(CTX);
lytSearch.addView(lytResults[0]);
var txtResult = new android.widget.TextView(CTX);
lytSearch.addView(txtResult);
var text = new android.widget.TextView(CTX);
text.setText("数量");
text.setTextSize(text.getTextSize());
layout.addView(text);
var lytAmount = new android.widget.LinearLayout(CTX);
layout.addView(lytAmount);
var edtAmount = new android.widget.EditText(CTX);
edtAmount.setText("1");
edtAmount.setInputType(android.text.InputType.TYPE_CLASS_NUMBER | android.text.InputType.TYPE_NUMBER_FLAG_SIGNED);
lytAmount.addView(edtAmount);
var text = new android.widget.TextView(CTX);
text.setText("个");
lytAmount.addView(text);
var sekAmount = new android.widget.SeekBar(CTX);
sekAmount.setMax(256);
sekAmount.setProgress(1 + 1);
sekAmount.setOnSeekBarChangeListener(new android.widget.SeekBar.OnSeekBarChangeListener({onProgressChanged: function (view) {
edtAmount.setText(String(sekAmount.getProgress() - 1));
}}));
layout.addView(sekAmount);
var button = new android.widget.Button(CTX);
button.setText("OK");
button.setTextSize(button.getTextSize());
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
if (player == getPlayerEnt())
addItemInventory(edtId.getText(), edtAmount.getText(), edtDamage.getText()); else Level.dropItem(Entity.getX(player), Entity.getY(player), Entity.getZ(player), 0, edtId.getText(), edtAmount.getText(), edtDamage.getText());
wndAddItems.dismiss();
if (left == 1) {
wndInv.dismiss();
inv.inv();
}
}}));
layout.addView(button);
var scroll = new android.widget.ScrollView(CTX);
scroll.addView(layout);
var wndAddItems = new android.widget.PopupWindow(scroll, Wnd.WIDTH, Wnd.HEIGHT * 4, true);
wndAddItems.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.argb(127, 255, 255, 255)));
wndAddItems.showAtLocation(CTX.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.TOP, Wnd.WIDTH * left, 0);
}
function addPlayer(player) {
for (var p in list) if (list[p] == player) return;
list.push(player);
preventDefault();
}
function antiduowan() {
var layout = new android.widget.LinearLayout(CTX);
layout.setOrientation(layout.VERTICAL);
var text = new android.widget.TextView(CTX);
text.setText("Useful\ncommands");
text.setTextSize(text.getTextSize());
layout.addView(text);
var text = new android.widget.TextView(CTX);
text.setText("V" + VERSION);
layout.addView(text);
if (isInGame) {
var button = new android.widget.Button(CTX);
button.setText("玩家");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
Player.player();
}}));
layout.addView(button);
var button = new android.widget.Button(CTX);
button.setText("游戏");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
game();
}}));
layout.addView(button);
var button = new android.widget.Button(CTX);
button.setText((inv.dontGetItame ? "[防止出错] " : "") + ModPE.getI18n("container.inventory"));
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
inv.inv();
}}));
button.setOnLongClickListener(new android.view.View.OnLongClickListener({onLongClick: function (view) {
inv.dontGetItame = !inv.dontGetItame;
wndMnu.dismiss();
antiduowan();
return true;
}}));
layout.addView(button);
var button = new android.widget.Button(CTX);
button.setText("管理玩家");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
Player.players();
}}));
layout.addView(button);
if (lan) {
var button = new android.widget.Button(CTX);
button.setText(ModPE.getI18n("container.enchant"));
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
Ench.ench(Player.getSelectedSlotId(), 0);
}}));
layout.addView(button);
}
var button = new android.widget.Button(CTX);
button.setText("效果");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
Entity.effect(getPlayerEnt());
}}));
layout.addView(button);
if (pe) {
var button = new android.widget.Button(CTX);
button.setText("快速建造");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
quickBuilding.build();
}}));
layout.addView(button);
}
var button = new android.widget.Button(CTX);
button.setText("实体");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
Entity.ent();
}}));
layout.addView(button);
var button = new android.widget.Button(CTX);
button.setText("记彔点");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
ports.pm();
}}));
layout.addView(button);
}
if (TMI) {
var button = new android.widget.Button(CTX);
button.setText("屛幕截图");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
ModPE.screenshot();
}}));
layout.addView(button);
}
var button = new android.widget.Button(CTX);
button.setText("快速计算器");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
calc.calc();
}}));
layout.addView(button);
var button = new android.widget.Button(CTX);
button.setText("快速浏览器");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
webView("http://www.baidu.com/");
}}));
layout.addView(button);
var button = new android.widget.Button(CTX);
button.setText("JS 设定");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
popupWindow();
}}));
layout.addView(button);
var button = new android.widget.Button(CTX);
button.setText("\u5173\u4e8e");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
credits();
}}));
layout.addView(button);
var scroll = new android.widget.ScrollView(CTX);
scroll.addView(layout);
wndMnu = new android.widget.PopupWindow(scroll, Wnd.WIDTH, Wnd.HEIGHT * 4, true);
wndMnu.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.argb(127, 255, 255, 255)));
wndMnu.showAtLocation(CTX.getWindow().getDecorView(), android.view.Gravity.LEFT | android.view.Gravity.TOP, 0, 0);
}
function argbToRgb(color) {
return (color - Int.MIN_VALUE) % 0x1000000;
}
function attackHook(attacker, victim) {
if (Target.automatic && Target.attackable) if (/^(-1|0)$/.test(Target.ent) && new RegExp(Target.regExp, "i".string(Target.i)).test(Entity.getNameTag(victim))) {
Target.setTarget(victim);
preventDefault();
}
if (Entity.canSel) if (("," + Entity.sel.ents.join() + ",").indexOf("," + victim + ",") == -1) {
Entity.sel.ents.push(victim);
preventDefault();
}
if (sp) {
ModPE.scor(victim, true);
preventDefault();
}
if (pe) {
if (atapil) if (Player.isPlayer(victim)) addPlayer(victim);
for (var p in nvtm) if (nvtm[p] == attacker) preventDefault();
if (attacker == Entity.efv.e) for (var e in Entity.efv.effects) Entity.addEffect(victim, Entity.efv.effects[e].type, Entity.efv.effects[e].t, Entity.efv.effects[e].lvl, TMI, !TMI);
if (hbr.hbr && getCarriedItem() == 369) Level.spawnMob(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 93);
}
if (Entity.canRide) {
if (pe) {
if (/^(-1|0)$/.test(Entity.rider)) {
Entity.rider = victim;
print("\n已设置实体 rider = " + victim);
} else {
rideAnimal(Entity.rider, victim);
Entity.rider = -1;
print("\n已设置实体 riding = " + victim);
}
} else rideAnimal(attacker, victim);
preventDefault();
}
}
bi.add = function () {
var layout = new android.widget.LinearLayout(CTX);
layout.setOrientation(layout.VERTICAL);
var text = new android.widget.TextView(CTX);
text.setText(ModPE.getI18n("entity.Item.name") + " ID");
text.setTextSize(text.getTextSize());
layout.addView(text);
var lytId = new android.widget.LinearLayout(CTX);
layout.addView(lytId);
var edtId = new android.widget.EditText(CTX);
edtId.setText("46");
edtId.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
lytId.addView(edtId);
var text = new android.widget.TextView(CTX);
text.setText(":");
lytId.addView(text);
var edtDamage = new android.widget.EditText(CTX);
edtDamage.setHint("选填");
edtDamage.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
lytId.addView(edtDamage);
var text = new android.widget.TextView(CTX);
text.setText(ModPE.getI18n("entity.Item.name") + " ID 査询");
layout.addView(text);
var edtKeyword = new android.widget.EditText(CTX);
edtKeyword.setHint("关键词");
edtKeyword.setLayoutParams(TEXT_PARAMS);
layout.addView(edtKeyword);
var btnSearch = new android.widget.Button(CTX);
btnSearch.setText("搜寻");
btnSearch.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
const RESULTS = Item.searchItem(edtKeyword.getText());
txtResult.setText("共 " + RESULTS.length + " 个结果");
lytSearch.removeView(lytResults[lytResults.length - 1]);
lytResults.push();
lytResults[lytResults.length - 1] = new android.widget.LinearLayout(CTX);
lytResults[lytResults.length - 1].setOrientation(lytResults[lytResults.length - 1].VERTICAL);
lytSearch.addView(lytResults[lytResults.length - 1]);
for (var r in RESULTS) {
var button = new android.widget.Button(CTX);
button.setText(RESULTS[r] + "\n" +
Item.getName(RESULTS[r].split(":")[0], RESULTS[r].split(":")[1]));
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
edtId.setText(view.getText().split("\n")[0].split(":")[0]);
if (view.getText().split("\n")[0].split(":")[1] != 0) edtDamage.setText(view.getText().split("\n")[0].split(":")[1]);
}}));
lytResults[lytResults.length - 1].addView(button);
}
}}));
layout.addView(btnSearch);
var lytSearch = new android.widget.LinearLayout(CTX);
lytSearch.setOrientation(lytSearch.VERTICAL);
layout.addView(lytSearch);
var lytResults = [];
lytResults[0] = new android.widget.LinearLayout(CTX);
lytSearch.addView(lytResults[lytResults.length - 1]);
var txtResult = new android.widget.TextView(CTX);
lytSearch.addView(txtResult);
var button = new android.widget.Button(CTX);
button.setText("OK");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
const ID = edtId.getText() + ":" + edtDamage.getText();
if (("," + bi.items.join() + ",").indexOf("," + ID + ",") == -1) bi.items.push(ID);
wndAddBi.dismiss();
wndBi.dismiss();
bi.bi();
}}));
layout.addView(button);
var scroll = new android.widget.ScrollView(CTX);
scroll.addView(layout);
var wndAddBi = new android.widget.PopupWindow(scroll, Wnd.WIDTH, Wnd.HEIGHT * 4, true);
wndAddBi.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.argb(127, 255, 255, 255)));
wndAddBi.showAtLocation(CTX.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.TOP, Wnd.WIDTH * 2, 0);
}
bi.bi = function () {
var layout = new android.widget.LinearLayout(CTX);
layout.setOrientation(layout.VERTICAL);
var text = new android.widget.TextView(CTX);
text.setText("长按以刪除");
layout.addView(text);
var scroll = new android.widget.ScrollView(CTX);
layout.addView(scroll);
var lytItems = new android.widget.LinearLayout(CTX);
lytItems.setOrientation(lytItems.VERTICAL);
scroll.addView(lytItems);
var button = new android.widget.Button(CTX);
button.setText("+\n");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
bi.add();
}}));
lytItems.addView(button);
for (var i in bi.items) {
var button = new android.widget.Button(CTX);
button.setText(bi.items[i] + "\n" + Item.getName(bi.items[i].split(":")[0], bi.items[i].split(":")[1]));
button.setOnLongClickListener(new android.view.View.OnLongClickListener({onLongClick: function (view) {
for (var i in bi.items) if (bi.items[i] == (view.getText()).split("\n")[0]) bi.items.splice(i, 1);
wndBi.dismiss();
bi.bi();
return true;
}}));
lytItems.addView(button);
}
wndBi = new android.widget.PopupWindow(layout, Wnd.WIDTH, Wnd.HEIGHT * 4, true);
wndBi.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.argb(127, 255, 255, 255)));
wndBi.showAtLocation(CTX.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.TOP, Wnd.WIDTH, 0);
}
calc.calc = function () {
var layout = new android.widget.LinearLayout(CTX);
layout.setOrientation(layout.VERTICAL);
var edtExp = new android.widget.EditText(CTX);
edtExp.setText(calc.prev);
layout.addView(edtExp);
button = new android.widget.Button(CTX);
button.setText("Return");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
try {
txtReturn.setText(String(eval(String(edtExp.getText()))));
}
catch (err) {
txtReturn.setText("Error: " + err);
}
calc.prev = edtExp.getText();
}}));
layout.addView(button);
var txtReturn = new android.widget.TextView(CTX);
txtReturn.setOnLongClickListener(new android.view.View.OnLongClickListener({onLongClick: function (view) {
CTX.getSystemService(CTX.CLIPBOARD_SERVICE).setText(txtReturn.getText());
print("\n已复制");
return true;
}}));
layout.addView(txtReturn);
var scroll = new android.widget.ScrollView(CTX);
scroll.addView(layout);
var window = new android.widget.PopupWindow(scroll, Wnd.WIDTH * 3, Wnd.HEIGHT * 4, true);
window.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.argb(127, 255, 255, 255)));
window.showAtLocation(CTX.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.TOP, 0, 0);
}
chat.load = function () {
var layout = new android.widget.LinearLayout(CTX);
var button = new android.widget.Button(CTX);
button.setText("使用 android 介面发送聊天");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
var layout = new android.widget.LinearLayout(CTX);
layout.setOrientation(layout.VERTICAL);
var edtChat = new android.widget.EditText(CTX);
edtChat.setText(chat.prev);
layout.addView(edtChat);
var button = new android.widget.Button(CTX);
button.setText("→");
button.setLayoutParams(TEXT_PARAMS);
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
Server.sendChat(edtChat.getText());
chat.prev = edtChat.getText();
}}));
layout.addView(button);
var scroll = new android.widget.ScrollView(CTX);
scroll.addView(layout);
var window = new android.widget.PopupWindow(scroll, Wnd.WIDTH * 3, Wnd.HEIGHT * 3, true);
window.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.argb(127, 255, 255, 255)));
window.showAtLocation(CTX.getWindow().getDecorView(), android.view.Gravity.CENTER | android.view.Gravity.CENTER, 0, 0);
}}));
layout.addView(button);
chat.window = new android.widget.PopupWindow(layout, Wnd.WIDTH * 3, Wnd.HEIGHT / 2);
chat.window.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.argb(127, 255, 255, 255)));
}
function continueDestroyBlock(x, y, z, side, progress) {
Scenter.showNearestOre();
}
function credits() {
var layout = new android.widget.LinearLayout(CTX);
layout.setOrientation(layout.VERTICAL);
var text = new android.widget.TextView(CTX);
text.setText("\x42\x79\x20\x4d\x49\x53\x54\x45\x52\x5f\x43\x48\x41\x4e\n" +
"\u767e\u5ea6\x20\x49\x44\x3a\x20\x4c\x31\x38\x39\x32\x39\x35\x36\x37\x36\x35\x34\n" +
eval("\x55\x50\x44\x41\x54\x45\x53"));
layout.addView(text);
var button = new android.widget.Button(CTX);
button.setText("\u5e38\u7528\u529f\u80fd");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
eval("\x73\x68\x6f\x77\x55\x73\x65\x66\x75\x6c\x43\x6f\x6d\x6d\x61\x6e\x64\x73\x28\x29\x3b");
}}));
layout.addView(button);
var button = new android.widget.Button(CTX);
button.setText("\u68c0\u67e5\u66f4\u65b0");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
webView("ht和tp:/谐/p和an.b谐aid和u.c谐om/s/1nvhJ9Uh".replace(/[和谐]/g, ""));
}}));
layout.addView(button);
var button = new android.widget.Button(CTX);
button.setText("\u53cd\u9988\u4e0e\u5efa\u8bae");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
webView("ht和tp:/谐/ti和eba.b谐aid和u.c谐om/p/4755088955?share=9105&fr=share&see_lz=0".replace(/[和谐]/g, ""));
}}));
layout.addView(button);
var scroll = new android.widget.ScrollView(CTX);
scroll.addView(layout);
var window = new android.widget.PopupWindow(scroll, Wnd.WIDTH * 3, Wnd.HEIGHT * 4, true);
window.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.argb(127, 255, 255, 255)));
window.showAtLocation(CTX.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.TOP, 0, 0);
}
ctrller.load = function () {
var layout = new android.widget.LinearLayout(CTX);
layout.setOrientation(layout.VERTICAL);
var button = new android.widget.Button(CTX);
button.setOnTouchListener(new android.view.View.OnTouchListener({onTouch: function (view, event) {
switch (event.getAction()) {
case event.ACTION_DOWN:
ctrller.velY = 16;
break;
case event.ACTION_UP:
ctrller.velY = 0;
break;
}
return false;
}}));
button.setText("↑");
layout.addView(button);
var button = new android.widget.Button(CTX);
button.setOnTouchListener(new android.view.View.OnTouchListener({onTouch: function (view, event) {
switch (event.getAction()) {
case event.ACTION_DOWN:
ctrller.velY = -16;
break;
case event.ACTION_UP:
ctrller.velY = 0;
break;
}
return false;
}}));
button.setText("↓");
layout.addView(button);
ctrller.window = new android.widget.PopupWindow(layout, Wnd.WIDTH / 2, Wnd.HEIGHT);
ctrller.window.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.argb(127, 255, 255, 255)));
}
function deathHook(murderer, victim) {
died = true;
if (victim == getPlayerEnt()) {
if (ld.rec) ld.pos = new Point(getPlayerX(), getPlayerY() + 1, getPlayerZ());
if (ki.ki) ki.keep("w");
}
}
function destroyBlock(x, y, z, side) {
const ID = getTile(x, y, z), DATA = Level.getData(x, y, z);
if (treeCapitator) tree: {
if (!/^(17|162)$/.test(ID)) break tree;
var yf = 0;
root: for (var t = y; t >= 0; t--) switch (getTile(x, t, z)) {
case 17: case 162: break;
case 2: case 3: break root;
default: break tree;
}
roof: for (var f = y; f < 128; f++) switch (getTile(x, f, z)) {
case 17: case 162: break;
case 18: case 161:
yf = f;
break roof;
default: break tree;
}
const ROOF_ID = getTile(x, yf, z);
var index = Level.destrocksByMock.threads.length;
Level.destrocksByMock.threads.push({plokad: {pos: new Point(x, t + 1, z), id: 6, data: DATA + (ID == 162 ? 4 : 0)}, tiles: []});
new java.lang.Thread(new java.lang.Runnable({run: function () {
veinMiner.mine(x, y, z, ID, undefined, index, true);
veinMiner.mined = 0;
veinMiner.mine(x, yf, z, ROOF_ID, undefined, index, true);
veinMiner.mined = 0;
}})).start();
}
if (veinMiner.veinMiner) if (("," + veinMiner.ores.join() + ",").search("," + ID + ":(" + DATA + "|),") > -1) {
var index = Level.destrocksByMock.threads.length;
Level.destrocksByMock.threads.push({tiles: []});
new java.lang.Thread(new java.lang.Runnable({run: function () {
veinMiner.mine(x, y, z, ID, DATA, index, true);
veinMiner.mined = 0;
}})).start();
}
if (quickBuilding.linear.canDestroy) {
var t = eval(quickBuilding.linear.direction.charAt(0));
const END = eval("t " + quickBuilding.linear.direction.slice(-1) + " " + quickBuilding.linear.length);
for (t; quickBuilding.linear.direction.slice(-1) == "-" ? t > END : t < END; eval("t " + quickBuilding.linear.direction.slice(-1) + "= " + quickBuilding.linear.step)) {
var xt = quickBuilding.linear.direction.charAt(0) == "x" ? t : x, yt = quickBuilding.linear.direction.charAt(0) == "y" ? t : y, zt = quickBuilding.linear.direction.charAt(0) == "z" ? t : z;
if (!quickBuilding.linear.ratt || getTile(xt, yt, zt) == quickBuilding.linear.fid && Level.getData(xt, yt, zt) == quickBuilding.linear.fata) Level.destrockBySwitching(xt, yt, zt, true);
}
}
}
function dipToPx(dips) {
return Math.ceil(dips * CTX.getResources().getDisplayMetrics().density);
}
Ench.bestEnches = function (itemId) {
var eid = "";
switch (itemId) {
case 298: case 302: case 306: case 310: case 314: eid = "0 5 6 17"; break; // 头盔
case 299: case 303: case 307: case 311: case 315: eid = "0 5 17"; break; // 胸甲
case 300: case 304: case 308: case 312: case 316: eid = "0 5 17"; break; // 护腿
case 301: case 305: case 309: case 313: case 317: eid = "2 5 7 17"; break; // 靴
case 267: case 268: case 272: case 276: case 283: eid = "9 13 17"; break; // 剑
case 256: case 269: case 273: case 277: case 284: eid = "15 17"; break; // 铲
case 257: case 270: case 274: case 278: case 285: eid = "15 17"; break; // 镐
case 258: case 271: case 275: case 279: case 286: eid = "9 15 17"; break; // 斧
case 259: case 290: case 291: case 292: case 293: case 294: case 398: case 444: eid = "17"; break; // 打火石 锄 萝卜钓竿 滑翔翅
case 359: eid = "15 17"; break; // 剪刀
case 261: eid = "17 19 20 21 22"; break; // 弓
case 346: eid = "17 23 24"; break; // 钓竿
case 340: case 403: eid = "0 5 6 7 9 13 15 17 19 20 21 22 23 24"; break; // 书
}
if (eid != undefined) return eid.split(" ");
}
Ench.canEnch = function (itemId, enchId) {
var eid = "";
switch (itemId) {
case 298: case 302: case 306: case 310: case 314: eid = "0|1|3|4|5|6|8|17"; break; // 头盔
case 299: case 303: case 307: case 311: case 315: eid = "0|1|3|4|5|17"; break; // 胸甲
case 300: case 304: case 308: case 312: case 316: eid = "0|1|3|4|5|17"; break; // 护腿
case 301: case 305: case 309: case 313: case 317: eid = "0|1|2|3|4|5|7|17"; break; // 靴
case 267: case 268: case 272: case 276: case 283: eid = "9|10|11|12|13|14|17"; break; // 剑
case 256: case 269: case 273: case 277: case 284: eid = "15|16|17|18"; break; // 铲
case 257: case 270: case 274: case 278: case 285: eid = "15|16|17|18"; break; // 镐
case 258: case 271: case 275: case 279: case 286: eid = "9|10|11|15|16|17|18"; break; // 斧
case 259: case 290: case 291: case 292: case 293: case 294: case 398: case 444: eid = "17"; break; // 打火石 锄 萝卜钓竿 滑翔翅
case 359: eid = "15|16|17"; break; // 剪刀
case 261: eid = "17|19|20|21|22"; break; // 弓
case 346: eid = "17|23|24"; break; // 钓竿
case 340: case 403: eid = "0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24"; break; // 书 附魔书
}
return new RegExp("^(" + eid + ")$").test(enchId);
}
Ench.ench = function (slotId) {
var layout = new android.widget.LinearLayout(CTX);
layout.setOrientation(layout.VERTICAL);
if (Ench.bestEnches(Player.getInventorySlot(slotId)) != "") {
var horizontalScroll = new android.widget.HorizontalScrollView(CTX);
layout.addView(horizontalScroll);
var lytCtrl = new android.widget.LinearLayout(CTX);
horizontalScroll.addView(lytCtrl);
var button = new android.widget.Button(CTX);
button.setText("OK");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
for (var e in chkEnches) try {
if (chkEnches[e].isChecked()) Player.enchant(slotId, e, edtEnches[e].getText());
}
catch (err) {
}
}}));
lytCtrl.addView(button);
var button = new android.widget.Button(CTX);
button.setText("最佳附魔");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
if (chkEnches.length > 0) try {
for (var e in chkEnches) chkEnches[e].setChecked(false);
var eids = Ench.bestEnches(Player.getInventorySlot(slotId));
if (eids != "") for (e in eids) chkEnches[eids[e]].setChecked(true);
}
catch (err) {
}
}}));
lytCtrl.addView(button);
if (!TMI) {
var button = new android.widget.Button(CTX);
button.setText("移除");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
const CN = Player.getItemCustomName(slotId), ENCHES = Player.getEnchantments(slotId);
Player.setInventorySlot(slotId, Player.getInventorySlot(slotId), Player.getInventorySlotCount(slotId), Player.getInventorySlotData(slotId));
if (CN != null && CN != "") Player.setItemCustomName(slotId, CN);
for (var e in ENCHES) try {
if (!chkEnches[ENCHES[e].type].isChecked()) Player.enchant(slotId, ENCHES[e].type, ENCHES[e].level);
}
catch (err) {
}
}}));
lytCtrl.addView(button);
}
var button = new android.widget.Button(CTX);
button.setText("移除所有");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
const CN = Player.getItemCustomName(slotId);
Player.setInventorySlot(slotId, Player.getInventorySlot(slotId), Player.getInventorySlotCount(slotId), Player.getInventorySlotData(slotId));
if (CN != null && CN != "") Player.setItemCustomName(slotId, CN);
}}));
lytCtrl.addView(button);
var text = new android.widget.TextView(CTX);
text.setText("等级取値 " + Short.MIN_VALUE + "级 ~ " + Short.MAX_VALUE + "级");
layout.addView(text);
var lytEnches = new android.widget.LinearLayout(CTX);
lytEnches.setOrientation(lytEnches.VERTICAL);
var chkEnches = [], edtEnches = [];
for (e = 0; e <= 24; e++) if (Ench.canEnch(Player.getInventorySlot(slotId), e)) {
var lytEnch = new android.widget.LinearLayout(CTX);
lytEnches.addView(lytEnch);
chkEnches[e] = new android.widget.CheckBox(CTX);
chkEnches[e].setText(e + " " + Ench.getName(e));
chkEnches[e].setOnCheckedChangeListener(new android.widget.CompoundButton.OnCheckedChangeListener({onCheckedChanged: function (view, checked) {
if (checked) {
const OPT_ENCHES = Ench.optEnches(Player.getInventorySlot(slotId), view.getText().split(" ")[0]);
for (var i in OPT_ENCHES) if (chkEnches[OPT_ENCHES[i]] != undefined) chkEnches[OPT_ENCHES[i]].setChecked(false);
if (/^(14|18)$/.test(view.getText().split(" ")[0])) print("\n等级不宜过高");
}
}}));
lytEnch.addView(chkEnches[e]);
edtEnches[e] = new android.widget.EditText(CTX);
edtEnches[e].setText(String(Short.MAX_VALUE));
edtEnches[e].setInputType(android.text.InputType.TYPE_CLASS_NUMBER | android.text.InputType.TYPE_NUMBER_FLAG_SIGNED);
lytEnch.addView(edtEnches[e]);
}
var sclEnches = new android.widget.ScrollView(CTX);
sclEnches.addView(lytEnches);
layout.addView(sclEnches);
} else {
var text = new android.widget.TextView(CTX);
text.setText("请先选定装备或工具");
text.setTextSize(text.getTextSize());
layout.addView(text);
}
var window = new android.widget.PopupWindow(layout, Wnd.WIDTH * 2, Wnd.HEIGHT * 4, true);
window.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.argb(127, 255, 255, 255)));
window.showAtLocation(CTX.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.TOP, 0, 0);
}
Ench.getName = function (id) {
const NAME = ["protect.all", "protect.fire", "protect.fall", "protect.explosion", "protect.projectile", "thorns", "oxygen", "waterWalker", "waterWorker", "damage.all", "damage.undead", "damage.arthropods", "knockback", "fire", "lootBonus", "digging", "untouching", "durability", "lootBonusDigger", "arrowDamage", "arrowKnockback", "arrowFire", "arrowInfinite", "lootBonusFishing", "fishingSpeed"];
if (NAME[id] == undefined) return "";
return ModPE.getI18n("enchantment." + NAME[id]);
}
Ench.optEnches = function (itemId, enchId) {
var eid = "";
switch (itemId) {
case 298: case 302: case 306: case 310: case 314:
if (/^(0|1|3|4)$/.test(enchId)) eid = "0|1|3|4"; else if (/^(6|8)$/.test(enchId)) eid = "6|8";
break; // 头盔
case 299: case 303: case 307: case 311: case 315: eid = "0|1|3|4"; break; // 胸甲
case 300: case 304: case 308: case 312: case 316: eid = "0|1|3|4"; break; // 护腿
case 301: case 305: case 309: case 313: case 317: eid = "0|1|2|3|4"; break; // 靴
case 267: case 268: case 272: case 276: case 283: eid = "9|10|11"; break; // 剑
case 256: case 269: case 273: case 277: case 284: eid = "16|18"; break; // 铲
case 257: case 270: case 274: case 278: case 285: eid = "16|18"; break; // 镐
case 258: case 271: case 275: case 279: case 286:
if (/^(9|10|11)$/.test(enchId)) eid = "9|10|11"; else if (/^(16|18)$/.test(enchId)) eid = "16|18";
break; // 斧
case 340: case 403:
if (/^(0|1|2|3|4)$/.test(enchId)) eid = "0|1|2|3|4";
else if (/^(6|8)$/.test(enchId)) eid = "6|8";
else if (/^(9|10|11)$/.test(enchId)) eid = "9|10|11";
else if (/^(16|18)$/.test(enchId)) eid = "16|18";
break; // 书 附魔书
}
if (!new RegExp("^(" + eid + ")$").test(enchId)) return "";
eid = eid.replace(enchId, "").replace(/(^\|)|(\|$)/, "").replace(/\|\|/, "|");
return eid.split("|");
}
Entity.be.ban = function () {
var layout = new android.widget.LinearLayout(CTX);
layout.setOrientation(layout.VERTICAL);
var button = new android.widget.Button(CTX);
button.setText("反选");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
for (var e in chkEnts) try {
chkEnts[e].setChecked(!chkEnts[e].isChecked());
}
catch (err) {
}
}}));
layout.addView(button);
var lytEnts = new android.widget.LinearLayout(CTX);
lytEnts.setOrientation(lytEnts.VERTICAL);
var scroll = new android.widget.ScrollView(CTX);
scroll.addView(lytEnts);
layout.addView(scroll);
var chkEnts = [];
for (e = 10; e <= 101; e++) if (Entity.getName(e) != "") {
chkEnts[e] = new android.widget.CheckBox(CTX);
chkEnts[e].setText(e + " " + Entity.getName(e));
chkEnts[e].setChecked(("," + Entity.be.types.join() + ",").indexOf("," + e + ",") > -1);
chkEnts[e].setOnCheckedChangeListener(new android.widget.CompoundButton.OnCheckedChangeListener({onCheckedChanged: function (view, checked) {
if (checked) Entity.be.types.push(view.getText().split(" ")[0]); else for (var ent in Entity.be.types) if (Entity.be.types[ent] == view.getText().split(" ")[0]) Entity.be.types.splice(ent, 1);
}}));
lytEnts.addView(chkEnts[e]);
}
var window = new android.widget.PopupWindow(layout, Wnd.WIDTH, Wnd.HEIGHT * 4, true);
window.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.argb(127, 255, 255, 255)));
window.showAtLocation(CTX.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.TOP, Wnd.WIDTH, 0);
}
Entity.effect = function (entity) {
var layout = new android.widget.LinearLayout(CTX);
layout.setOrientation(layout.VERTICAL);
var hslCtrl = new android.widget.HorizontalScrollView(CTX);
layout.addView(hslCtrl);
var lytCtrl = new android.widget.LinearLayout(CTX);
hslCtrl.addView(lytCtrl);
var chkLocked = {isChecked: function () {
return false;
}};
var button = new android.widget.Button(CTX);
button.setText("OK");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
if (pe) if (chkEfv.isChecked()) Entity.efv = {e: entity, effects: []};
var showParticle = true;
if (lan) showParticle = chkParticle.isChecked();
if (chkLocked.isChecked()) Entity.lockEffects = {effects: [], showParticle: showParticle};
for (var e in chkEffects) try {
if (chkEffects[e].isChecked()) {
if (lan) if (chkEfv.isChecked()) Entity.efv.effects.push({lvl: edtLvl[e].getText() - 1, t: edtSeconds[e].getText() * 20, type: e});
if (chkLocked.isChecked()) Entity.lockEffects.effects.push({lvl: edtLvl[e].getText() - 1, type: e}); else Entity.addEffect(entity, e, (edtMin[e].getText() * 60 + edtSec[e].getText() * 1) * 20, edtLvl[e].getText() - 1, TMI * showParticle, (1 - TMI) * showParticle);
}
}
catch (err) {
}
}}));
lytCtrl.addView(button);
var button = new android.widget.Button(CTX);
button.setText("移除");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
try {
for (var e in chkEffects) if (chkEffects[e].isChecked()) Entity.removeEffect(entity, e);
for (e in Entity.lockEffects.effects) if (chkEffects[Entity.lockEffects.effects[e].type].isChecked()) Entity.lockEffects.effects.splice(e, 1);
}
catch (err) {
}
}}));
lytCtrl.addView(button);
var button = new android.widget.Button(CTX);
button.setText("移除所有");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
if (pe) Entity.removeAllEffects(entity); else for (var e in chkEffects) Entity.removeEffect(entity, e);
Entity.lockEffects.effects = [];
}}));
lytCtrl.addView(button);
var hslChks = new android.widget.HorizontalScrollView(CTX);
layout.addView(hslChks);
var lytChks = new android.widget.LinearLayout(CTX);
hslChks.addView(lytChks);
if (pe) {
var chkEfv = new android.widget.CheckBox(CTX);
chkEfv.setText("效果用于攻击");
lytChks.addView(chkEfv);
}
if (lan) {
var chkParticle = new android.widget.CheckBox(CTX);
chkParticle.setText("粒子可见");
chkParticle.setChecked(true);
lytChks.addView(chkParticle);
}
if (entity == getPlayerEnt()) {
chkLocked = new android.widget.CheckBox(CTX);
chkLocked.setText("锁定");
lytChks.addView(chkLocked);
}
var text = new android.widget.TextView(CTX);
text.setText("持续时间取値 0:0 ~ " + Math.floor(Int.MAX_VALUE / 20 / 60) + ":" + Math.ceil(Int.MAX_VALUE / 20 % 60 * 100) / 100 + "\n" +
"等级取値 " + (Int.MIN_VALUE + 1) + "级 ~ " + (Int.MAX_VALUE + 1) + "级 不宜过高");
layout.addView(text);
var lytEffects = new android.widget.LinearLayout(CTX);
lytEffects.setOrientation(lytEffects.VERTICAL);
const IS_BUFF = [, -11184641, -43691, -11184641, -43691, -11184641, -11184641, -43691, -11184641, -43691, -11184641, -11184641, -11184641, -11184641, -11184641, -43691, -11184641, -43691, -43691, -43691, -43691, -11184641, -11184641, -11184641, -43691];
var chkEffects = [], edtLvl = [], edtMin = [], edtSec = [];
for (e = 1; e <= 24; e++) {
var canHave = /^(3|4|8|9|15|16|24)$/.test(e), lytEffect = new android.widget.LinearLayout(CTX);
if (pe || canHave) {
chkEffects[e] = new android.widget.CheckBox(CTX);
chkEffects[e].setText(e + " " + Entity.getEffectName(e));
chkEffects[e].setTextColor(IS_BUFF[e]);
lytEffect.addView(chkEffects[e]);
edtLvl[e] = new android.widget.EditText(CTX);
edtLvl[e].setText("128");
edtLvl[e].setInputType(android.text.InputType.TYPE_CLASS_NUMBER | android.text.InputType.TYPE_NUMBER_FLAG_SIGNED);
lytEffect.addView(edtLvl[e]);
var text = new android.widget.TextView(CTX);
text.setText("时间");
lytEffect.addView(text);
edtMin[e] = new android.widget.EditText(CTX);
edtMin[e].setText("1789569");
edtMin[e].setInputType(android.text.InputType.TYPE_CLASS_NUMBER | android.text.InputType.TYPE_NUMBER_FLAG_DECIMAL);
lytEffect.addView(edtMin[e]);
var text = new android.widget.TextView(CTX);
text.setText(":");
lytEffect.addView(text);
edtSec[e] = new android.widget.EditText(CTX);
edtSec[e].setText("42.35");
edtSec[e].setInputType(android.text.InputType.TYPE_CLASS_NUMBER | android.text.InputType.TYPE_NUMBER_FLAG_DECIMAL);
lytEffect.addView(edtSec[e]);
lytEffects.addView(lytEffect);
}
}
var sclEffects = new android.widget.ScrollView(CTX);
sclEffects.addView(lytEffects);
layout.addView(sclEffects);
var window = new android.widget.PopupWindow(layout, Wnd.WIDTH * 2, Wnd.HEIGHT * 4, true);
window.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.argb(127, 255, 255, 255)));
window.showAtLocation(CTX.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.TOP, 0, 0);
}
Entity.ent = function () {
var layout = new android.widget.LinearLayout(CTX);
layout.setOrientation(layout.VERTICAL);
if (lan) {
var button = new android.widget.Button(CTX);
button.setText("生成");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
Entity.spawn(getPlayerX(), getPlayerY(), getPlayerZ(), 1);
}}));
layout.addView(button);
}
if (pe) {
var button = new android.widget.Button(CTX);
button.setText("移除");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
Entity.rmvMnu();
}}));
layout.addView(button);
var button = new android.widget.Button(CTX);
button.setText("禁止生成");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
Entity.be.ban();
}}));
layout.addView(button);
var button = new android.widget.Button(CTX);
button.setText("扫地");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
Entity.sweeepTheFloor();
}}));
layout.addView(button);
}
var button = new android.widget.Button(CTX);
button.setText("选定");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
Entity.sel.showEnts();
}}));
layout.addView(button);
var scroll = new android.widget.ScrollView(CTX);
scroll.addView(layout);
wndEnt = new android.widget.PopupWindow(scroll, Wnd.WIDTH, Wnd.HEIGHT * 4, true);
wndEnt.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.argb(127, 255, 255, 255)));
wndEnt.showAtLocation(CTX.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.TOP, 0, 0);
}
Entity.getEffectName = function (id) {
const NAME = [, "moveSpeed", "moveSlowdown", "digSpeed", "digSlowDown", "damageBoost", "heal", "harm", "jump", "confusion", "regeneration", "resistance", "fireResistance", "waterBreathing", "invisibility", "blindness", "nightVision", "hunger", "weakness", "poison", "wither", "healthBoost", "absorption", "saturation", "levitation"];
if (NAME[id] == undefined) return "";
return ModPE.getI18n("potion." + NAME[id]);
}
Entity.getName = function (id) {
const NAME = [, , , , , , , , , , "entity.Chicken.name", "entity.Cow.name", "entity.Pig.name", "entity.Sheep.name", "entity.Wolf.name", "entity.Villager.name", "entity.MushroomCow.name", "entity.Squid.name", "entity.Rabbit.name", "entity.Bat.name", "entity.IronGolem.name", "entity.SnowMan.name", "entity.Ocelot.name", "entity.horse.name", "entity.donkey.name", "entity.mule.name", "entity.skeletonhorse.name", "entity.zombiehorse.name", "entity.PolarBear.name", , , , "entity.Zombie.name", "entity.Creeper.name", "entity.Skeleton.name", "entity.Spider.name", "entity.PigZombie.name", "entity.Slime.name", "entity.Enderman.name", "entity.Silverfish.name", "entity.CaveSpider.name", "entity.Ghast.name", "entity.LavaSlime.name", "entity.Blaze.name", "entity.ZombieVillager.name", "entity.Witch.name", "entity.Stray.name", "entity.Husk.name", "entity.WitherSkeleton.name", "entity.Guardian.name", "entity.ElderGuardian.name", , "entity.WitherBoss.name", "entity.EnderDragon.name", "潜影贝", "entity.Endermite.name", , , , , , , , "玩家", "entity.Item.name", "entity.PrimedTnt.name", "entity.FallingSand.name", , "item.experience_bottle.name", "entity.XPOrb.name", "item.ender_eye.name", "item.end_crystal.name", , , , , "潜影贝子弹", "鱼钩", , "entity.EnderDragon.name entity.Fireball.name", "entity.Arrow.name", "entity.Snowball.name", "item.egg.name", "entity.Painting.name", "entity.Minecart.name", "entity.Fireball.name", "potion.prefix.grenade entity.ThrownPotion.name", "item.ender_pearl.name", "item.lead.name 结", "entity.WitherBoss.name item.skull.char.name", "entity.Boat.name", , , "闪电", "entity.SmallFireball.name", "效果区域云", "item.hopper_minecart.name", "item.tnt_minecart.name", "item.chest_minecart.name", , "item.minecartCommandBlock.name", "potion.prefix.linger entity.ThrownPotion.name"];
if (NAME[id] == undefined) return "";
var i18n = "", name = "", words = NAME[id].split(" ");
for (var s in words) {
i18n = ModPE.getI18nEx(words[s], s > 0, s < words.length - 1);
name += /^ *$/.test(i18n) ? words[s] : i18n;
}
return name;
}
Entity.rmvMnu = function () {
var layout = new android.widget.LinearLayout(CTX);
layout.setOrientation(layout.VERTICAL);
var button = new android.widget.Button(CTX);
button.setText("OK");
button.setOnClickListener(new android.view.View.OnClickListener({onClick: function (view) {
const E = Entity.getAll();
for (var e in E) try {
if (chkEnts[Entity.getEntityTypeId(E[e])].isChecked() && E[e] != getPlayerEnt()) Entity.remove(E[e]);
}
catch (err) {
}
}}));
layout.addView(button);