-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_bot.js
2117 lines (1882 loc) · 103 KB
/
create_bot.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
const { Worker, isMainThread, parentPort, workerData } = require('worker_threads');
const mineflayer = require('mineflayer');
const { pathfinder, Movements, goals } = require('mineflayer-pathfinder');
const { GoalBlock } = goals;
const inventoryViewer = require('mineflayer-web-inventory')
const collectBlock = require('mineflayer-collectblock').plugin
const toolPlugin = require('mineflayer-tool').plugin
var Vec3 = require('vec3');
const crypto = require('crypto');
const dns = require('dns');
const util = require('util');
const Http = require('http')
const ProxyAgent = require('proxy-agent')
const atob = require('atob');
var Socks = require('socks').SocksClient;
const PNGImage = require('pngjs-image');
const fs = require('fs');
const path = require('path');
const url = require('url');
const Jimp = require('jimp');
const unidecode = require('unidecode');
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
process.on('unhandledRejection', (reason, promise) => {
if (reason.message !== '(mineflayer-web-inventory) INFO: mineflayer-web-inventory is not running') { // webinventory dev fix that shit verification, its just if(bot.webInventory.running) stop on bot 'end'
// dont make nothing
}
});
process.on('uncaughtException', (err) => {
parentPort.postMessage({ type: 'electron', action: 'error', data: 'Exceção não tratada capturada: ' + err.message});
parentPort.postMessage({ type: 'electron', action: 'error', data: 'Stack: ' + err.stack});
});
global.listadecommandos = ["$killaura", "$spammer", "$goto ", "$shift", "$move ", "$holditem", "$sethotbarslot ", "$listslots", "$setinventoryslot ", "$dropall", "$inventoryinterface", "$follow ", "$miner ", "$miner2 ", "$clickentity"]
global.Syntax = `
<span style="color:yellow">Lista de comandos existentes:</span><br/>
<span style="color:white">- KillAura, Ataca todas entidades ao redor:</span> <span style="color:orange">$killaura</span><br/>
<span style="color:white">- Follow, Segue algum jogador pelo nome:</span> <span style="color:orange">$follow [nome]</span><br/>
<span style="color:white">- Miner, Minera blocos pelo nome do bloco:</span> <span style="color:orange">$miner [bloco]</span><br/>
<span style="color:white">- Miner2, Minera blocos de coordenada tal ate coordenada tal:</span> <span style="color:orange">$miner2 [x] [y] [z] [x2] [y2] [z2]</span><br/>
<span style="color:white">- Goto, Anda ate as coordenadas fornecidas:</span> <span style="color:orange">$goto [x] [y] [z]</span><br/>
<span style="color:white">- Shift, Fica agachado:</span> <span style="color:orange">$shift</span><br/>
<span style="color:white">- SetHotBarSlot, Seta o slot da sua hotbar para o fornecido (0-8):</span> <span style="color:orange">$sethotbarslot [numero]</span><br/>
<span style="color:white">- SetInventorySlot, Seta o slot da janela aberta para o fornecido:</span> <span style="color:orange">$setinventoryslot [numero] [drop]</span><br/>
<span style="color:white">- ListSlots, Mostra a quantidade de slots total da janela aberta:</span> <span style="color:orange">$listslots</span><br/>
<span style="color:white">- DropAll, Dropa todos itens do inventario:</span> <span style="color:orange">$dropall</span><br/>
<span style="color:white">- InventoryInterface, Mostra seu inventario em outra janela:</span> <span style="color:orange">$inventoryinterface</span><br/>
<span style="color:white">- HoldItem, Clica o botao esquerdo e solta com o item que esta na mao:</span> <span style="color:orange">$holditem</span><br/>
<span style="color:white">- ClickEntity, Clica o botao direito e solta com na entidade mais proxima:</span> <span style="color:orange">$clickentity</span><br/>
<span style="color:white">- Spammer, Spamma mensagens:</span> <span style="color:orange">$spammer</span><br/>
<span style="color:white">- Move, Faz o bot se mover por um tempo determinado. (As direções podem ser combinadas com o caractere "|":</span> <span style="color:orange">$move [direções jump,forward,back,left,right,sneak,sprint] [duração em ticks]
</span><br/>
`
if (isMainThread) {
let bots = {};
let botsConectado = [];
let autoreconnect = false;
let autoreconnectdelay = 0;
let fallcheckbypass = false;
setInterval(() => {
for (const botUsername in bots) {
const worker = bots[botUsername];
if (worker) {
worker.postMessage({ type: 'botsConectadoUpdate', data: botsConectado });
}
}
}, 200);
process.on('message', async (process_msg_) => {
if (process_msg_.event === 'connect-bot') {
const { host, username, version, proxy, proxyType } = process_msg_.data;
if (botsConectado.includes(username)) return;
const worker = new Worker(__filename, {
workerData: { host, username, version, proxy, proxyType }
});
worker.on('message', (msg) => {
if (msg.type === 'webcontents' || msg.type === 'ipcMain' || msg.type === 'electron' || msg.type === 'closewindowcaptcha') {
process.send(msg);
if(msg.event === 'bot-connected')
{
botsConectado.push(msg.data);
} else if(msg.event === 'bot-disconnected') {
const index = botsConectado.indexOf(msg.data);
if (index > -1) {
botsConectado.splice(index, 1);
}
}
} else if (msg.type === 'thread-asked-for-both') {
worker.postMessage({ type: 'form-data-changed-reconnect', data: {autoReconnect: autoreconnect, delay: autoreconnectdelay} });
worker.postMessage({ type: 'form-data-changed-fallcheck', data: {fallCheck: fallcheckbypass} });
} else if (msg.type === 'closeeverywindowinventory') {
for (const botUsername in bots) {
const worker = bots[botUsername];
if (worker) {
worker.postMessage({ type: 'closewindowinventoryhardcoded' });
}
}
}
});
worker.on('error', (err) => {
parentPort.postMessage({ type: 'electron', action: 'error', data: `Erro no worker para ${username}: ${err.message}`});
});
worker.on('exit', (code) => {
if (code !== 0) {
parentPort.postMessage({ type: 'electron', action: 'error', data: `Worker para ${username} parou com código de saída ${code}`});
}
});
bots[username] = worker;
}
if (process_msg_.event === 'send-message') {
const { botUsername, message } = process_msg_.data;
const worker = bots[botUsername];
if (worker) {
worker.postMessage({ type: 'send-message', botUsername, message });
}
}
if (process_msg_.event === 'send-message-for-all-threads') {
const { message } = process_msg_.message;
for (const botUsername in bots) {
const worker = bots[botUsername];
if (worker) {
worker.postMessage({ type: 'send-message', botUsername, message });
}
}
}
if (process_msg_.event === 'form-data-changed-reconnect') {
autoreconnect = process_msg_.data.autoReconnect;
autoreconnectdelay = parseInt(process_msg_.data.delay);
for (const botUsername in bots) {
const worker = bots[botUsername];
if (worker) {
worker.postMessage({
type: 'form-data-changed-reconnect',
data: {
autoReconnect: autoreconnect,
delay: autoreconnectdelay
}
});
}
}
}
if (process_msg_.event === 'form-data-changed-fallcheck') {
fallcheckbypass = process_msg_.data.fallCheck;
for (const botUsername in bots) {
const worker = bots[botUsername];
if (worker) {
worker.postMessage({
type: 'form-data-changed-fallcheck',
data: { fallCheck: fallcheckbypass }
});
}
}
}
if (process_msg_.event === 'remove-bot') {
const botUsername = process_msg_.data;
const worker = bots[botUsername];
if (worker) {
worker.postMessage({ type: 'remove-bot', botUsername });
}
}
if (process_msg_.event === 'reco-bot') {
const { host, botUsername, version, proxy, proxyType } = process_msg_.data;
const worker = bots[botUsername];
if (worker) {
worker.postMessage({ type: 'reco-bot', host, botUsername, version, proxy, proxyType });
}
}
if (process_msg_.event === 'captcha-input-janela1') {
const { botrightnow, captchaInput } = process_msg_.data;
const worker = bots[botrightnow];
if (worker) {
worker.postMessage({ type: 'captcha-input-janela1', captchaInput});
}
}
});
}
else {
const { host, username, version, proxy, proxyType } = workerData;
let bot = {};
let autoreconnect = false;
let autoreconnectdelay = 0;
let fallcheckbypass = false;
let botsConectado = [];
const ipPortRegex = /^(?:\d{1,3}\.){3}\d{1,3}:\d+$/
const botSpammers = {};
var globalParkourMode = false;
var globalBlockPlacingAllowed = true;
let ClickTextDetect = false;
let textFromFile = '';
let botsSemAutoReconnect = [];
const botTimers = {};
var killAuraActive = {}
let attackInterval = {};
let killAuraDelay = 1;
let DistanceReach = 3;
let isMoving = {};
var IsSneaking = {};
var isFollowing = {};
var playerToFollow = {};
var followInterval = {};
var miningState = {};
let placedBlocks = new Set();
let record = {};
let useFakeHost = false;
let captchaImages = {};
const resolveSrv = util.promisify(dns.resolveSrv);
const lookup = util.promisify(dns.lookup);
const filePath = path.join(__dirname, '/configUBBOT/ClickText.txt');
function handleFileRead(data) {
if (data.includes('text="')) {
const textFromFileFromVar = data.split('text="')[1].split('"')[0];
if (textFromFileFromVar) {
const textWithoutAccents = unidecode(textFromFileFromVar);
ClickTextDetect = true;
textFromFile = textWithoutAccents;
}
}
}
if (fs.existsSync(filePath)) {
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) console.error(`Erro ao ler o arquivo: ${err}`);
else handleFileRead(data);
});
}
function initBotSpammer(botUsername) {
if (!botSpammers[botUsername]) {
botSpammers[botUsername] = {
active: false,
message: '',
randomTell: false,
delay: 1000,
antispam: {
active: false,
length: 0
}
};
}
}
function generateRandomString(length) {
return crypto.randomBytes(Math.ceil(length/2))
.toString('hex')
.slice(0, length);
}
function startSpammer(bot) {
const spammer = botSpammers[bot.username];
if (!spammer || !spammer.active) return;
let message = spammer.message;
if (spammer.antispam.active) {
const antispamString = generateRandomString(spammer.antispam.length);
message += ` [${antispamString}]`;
}
if (spammer.randomTell) {
const players = Object.keys(bot.players);
const filteredPlayers = players.filter(player => !botsConectado.includes(player));
if (filteredPlayers.length > 0) {
const randomPlayer = filteredPlayers[Math.floor(Math.random() * filteredPlayers.length)];
bot.chat(`/tell ${randomPlayer} ${message}`);
}
} else {
bot.chat(message);
}
setTimeout(() => startSpammer(bot), spammer.delay);
}
function handleSpammerCommand(bot, args) {
initBotSpammer(bot.username);
const spammer = botSpammers[bot.username];
switch(args[1]) {
case undefined:
spammer.active = !spammer.active;
if (spammer.active) {
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: `<br/><span style='color:green'>Spammer ativado!</span><br/>` } });
startSpammer(bot);
} else {
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: `<br/><span style='color:red'>Spammer Desativado!</span><br/>` } });
}
break;
case 'message':
spammer.message = args.slice(2).join(' ').replace(/^"(.*)"$/, '$1');
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: `<br/><span style='color:orange'>Mensagem do spammer definida: ${spammer.message}</span><br/>` } });
break;
case 'random_tell':
spammer.randomTell = !spammer.randomTell;
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: `<br/><span style='color:orange'>Modo random tell ${spammer.randomTell ? 'ativado' : 'desativado'}!</span><br/>` } });
break;
case 'delay':
if (args[2] && !isNaN(args[2])) {
spammer.delay = parseInt(args[2]);
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: `<br/><span style='color:orange'>Delay do spammer definido para ${spammer.delay}ms</span><br/>` } });
}
break;
case 'antispam':
if (args[2] && !isNaN(args[2])) {
const length = parseInt(args[2]);
spammer.antispam.active = length > 0;
spammer.antispam.length = length;
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: `<br/><span style='color:orange'>Antispam ${spammer.antispam.active ? 'ativado' : 'desativado'} com comprimento ${length}</span><br/>` } });
} else {
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: `<br/><span style='color:red'>Uso correto: $spammer antispam [tamanho]</span><br/>` } });
}
break;
default:
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: `<br/><span style='color:red'>Comando $spammer inválido!</span><br/>` } });
}
}
async function minerar2(bot, x1, y1, z1, x2, y2, z2) {
if (!miningState[bot.username]) {
return;
}
[x1, x2] = [Math.min(x1, x2), Math.max(x1, x2)];
[y1, y2] = [Math.min(y1, y2), Math.max(y1, y2)];
[z1, z2] = [Math.min(z1, z2), Math.max(z1, z2)];
for (let x = x1; x <= x2; x++) {
for (let y = y1; y <= y2; y++) {
for (let z = z1; z <= z2; z++) {
if (!miningState[bot.username]) {
return;
}
const block = bot.blockAt(new Vec3(x, y, z));
if (block && block.name !== 'air') {
await minerarBloco(bot, block);
}
}
}
}
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: `<br/><span style='color:green'>Mineraçao concluida!</span><br/>` } });
}
async function minerarBloco(bot, block) {
const mcData = require('minecraft-data')(bot.version);
const defaultMove = new Movements(bot, mcData);
defaultMove.allowParkour = globalParkourMode;
if(!globalBlockPlacingAllowed)
{
defaultMove.placeCost = Number.MAX_SAFE_INTEGER;
}
bot.pathfinder.setMovements(defaultMove);
const goal = new goals.GoalNear(block.position.x, block.position.y, block.position.z, 3);
try {
await bot.pathfinder.goto(goal);
} catch (error) {
parentPort.postMessage({ type: 'electron', action: 'error', data: 'Não foi possível alcançar o bloco em: ' + block.position + ': ' + error});
return;
}
try {
await bot.tool.equipForBlock(block, {});
await bot.dig(block);
parentPort.postMessage({ type: 'electron', action: 'log', data: 'Bloco minerado em ' + block.position});
} catch (error) {
parentPort.postMessage({ type: 'electron', action: 'error', data: 'Erro ao minerar o bloco em' + block.position + ' : ' + error});
}
}
function iniciarMineracao(bot, x1, y1, z1, x2, y2, z2) {
miningState[bot.username] = true;
minerar2(bot, x1, y1, z1, x2, y2, z2);
}
function pararMineracao(bot) {
miningState[bot.username] = false;
}
function processMinecraftCodes(message) {
if (typeof message !== 'string') {
parentPort.postMessage({ type: 'electron', action: 'error', data: 'message deve ser uma string' });
return message;
}
const colorCodes = {
'§0': 'black',
'§1': 'dark_blue',
'§2': 'dark_green',
'§3': 'dark_aqua',
'§4': 'dark_red',
'§5': 'dark_purple',
'§6': 'gold',
'§7': 'gray',
'§8': 'dark_gray',
'§9': 'blue',
'§a': 'green',
'§b': 'aqua',
'§c': 'red',
'§d': 'light_purple',
'§e': 'yellow',
'§f': 'white'
};
for (let code in colorCodes) {
let regex = new RegExp(code, 'g');
message = message.replace(regex, `<span style="color:${colorCodes[code]}">`);
message = message.replace(/§r/g, '</span>');
}
return message;
}
function escapeHtml(unsafe) {
if (typeof unsafe !== 'string') {
return '';
}
return unsafe
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
function minecraftColorToHtml(color) {
const colorMap = {
'black': 'black',
'dark_blue': 'darkblue',
'dark_green': 'darkgreen',
'dark_aqua': 'teal',
'dark_red': 'darkred',
'dark_purple': 'purple',
'gold': 'gold',
'gray': 'gray',
'dark_gray': 'darkgray',
'blue': 'blue',
'green': 'green',
'aqua': 'aqua',
'red': 'red',
'light_purple': 'violet',
'yellow': 'yellow',
'white': 'white',
'§0': 'black',
'§1': 'darkblue',
'§2': 'darkgreen',
'§3': 'teal',
'§4': 'darkred',
'§5': 'purple',
'§6': 'gold',
'§7': 'gray',
'§8': 'darkgray',
'§9': 'blue',
'§a': 'green',
'§b': 'aqua',
'§c': 'red',
'§d': 'light_purple',
'§e': 'yellow',
'§f': 'white'
};
return colorMap[color] || color;
}
function processMessage(message) {
if (typeof message === 'string') {
return escapeHtml(message);
}
if (message.translate) {
return processTranslate(message);
}
let fullMessage = message.text ? escapeHtml(message.text) : '';
if (Array.isArray(message.extra)) {
message.extra.forEach((extraMessage) => {
fullMessage += ' ' + processMessage(extraMessage);
});
}
let color = message.color ? `color: ${minecraftColorToHtml(message.color)};` : '';
let fontWeight = message.bold ? 'font-weight: bold;' : '';
return `<span style="${color}${fontWeight}">${fullMessage}</span>`;
}
function processTranslate(message) {
let template = message.translate || '';
let parts = [];
if (Array.isArray(message.with)) {
parts = message.with.map(part => {
if (typeof part === 'object' && part.text) {
let hover = part.hoverEvent ? ` data-hover="${escapeHtml(JSON.stringify(part.hoverEvent))}"` : '';
let click = part.clickEvent ? ` data-click="${escapeHtml(JSON.stringify(part.clickEvent))}"` : '';
return `<span${hover}${click}>${escapeHtml(part.text)}</span>`;
}
return escapeHtml(String(part));
});
}
let result = template.replace(/%s/g, () => parts.shift() || '');
if (!template && parts.length > 0) {
result = parts.join(' ');
}
let color = message.color ? `color: ${minecraftColorToHtml(message.color)};` : '';
return `<span class="minecraft-message" style="${color}">${result}</span>`;
}
function processTitle(title) {
let titleObject;
if (typeof title === 'string') {
titleObject = JSON.parse(title);
} else if (typeof title === 'object') {
titleObject = title;
} else {
throw new Error(`Unexpected title type: ${typeof title}`);
}
let fullTitle, htmlColor, fontWeight;
if (titleObject.value) {
// Estrutura para a versão 1.20.4
fullTitle = escapeHtml(titleObject.value.text.value.replace(/§l/g, '<strong>')).replace(/<\/strong>/g, '') + '</strong>';
htmlColor = minecraftColorToHtml(titleObject.value.color.value);
fontWeight = titleObject.value.bold || titleObject.value.text.value.includes('§l') ? 'bold' : 'normal';
} else {
// Estrutura para a versão 1.20.2
fullTitle = escapeHtml(titleObject.text.replace(/§l/g, '<strong>')).replace(/<\/strong>/g, '') + '</strong>';
htmlColor = minecraftColorToHtml(titleObject.color);
fontWeight = titleObject.bold || titleObject.text.includes('§l') ? 'bold' : 'normal';
}
return `<span style="color:${htmlColor}; font-weight:${fontWeight};">${fullTitle}</span>`;
}
function getColor(colorId) {
const colors = [
{ red: 0, green: 0, blue: 0, alpha: 255 },
{ red: 89, green: 125, blue: 39, alpha: 255 },
{ red: 109, green: 153, blue: 48, alpha: 255 },
{ red: 127, green: 178, blue: 56, alpha: 255 },
{ red: 67, green: 94, blue: 29, alpha: 255 },
{ red: 174, green: 164, blue: 115, alpha: 255 },
{ red: 213, green: 201, blue: 140, alpha: 255 },
{ red: 247, green: 233, blue: 163, alpha: 255 },
{ red: 130, green: 123, blue: 86, alpha: 255 },
{ red: 140, green: 140, blue: 140, alpha: 255 },
{ red: 171, green: 171, blue: 171, alpha: 255 },
{ red: 199, green: 199, blue: 199, alpha: 255 },
{ red: 105, green: 105, blue: 105, alpha: 255 },
{ red: 180, green: 0, blue: 0, alpha: 255 },
{ red: 220, green: 0, blue: 0, alpha: 255 },
{ red: 255, green: 0, blue: 0, alpha: 255 },
{ red: 135, green: 0, blue: 0, alpha: 255 },
{ red: 112, green: 112, blue: 180, alpha: 255 },
{ red: 138, green: 138, blue: 220, alpha: 255 },
{ red: 160, green: 160, blue: 255, alpha: 255 },
{ red: 84, green: 84, blue: 135, alpha: 255 },
{ red: 117, green: 117, blue: 117, alpha: 255 },
{ red: 144, green: 144, blue: 144, alpha: 255 },
{ red: 167, green: 167, blue: 167, alpha: 255 },
{ red: 88, green: 88, blue: 88, alpha: 255 },
{ red: 0, green: 87, blue: 0, alpha: 255 },
{ red: 0, green: 106, blue: 0, alpha: 255 },
{ red: 0, green: 124, blue: 0, alpha: 255 },
{ red: 0, green: 65, blue: 0, alpha: 255 },
{ red: 180, green: 180, blue: 180, alpha: 255 },
{ red: 220, green: 220, blue: 220, alpha: 255 },
{ red: 255, green: 255, blue: 255, alpha: 255 },
{ red: 135, green: 135, blue: 135, alpha: 255 },
{ red: 115, green: 118, blue: 129, alpha: 255 },
{ red: 141, green: 144, blue: 158, alpha: 255 },
{ red: 164, green: 168, blue: 184, alpha: 255 },
{ red: 86, green: 88, blue: 97, alpha: 255 },
{ red: 106, green: 76, blue: 54, alpha: 255 },
{ red: 130, green: 94, blue: 66, alpha: 255 },
{ red: 151, green: 109, blue: 77, alpha: 255 },
{ red: 79, green: 57, blue: 40, alpha: 255 },
{ red: 79, green: 79, blue: 79, alpha: 255 },
{ red: 96, green: 96, blue: 96, alpha: 255 },
{ red: 112, green: 112, blue: 112, alpha: 255 },
{ red: 59, green: 59, blue: 59, alpha: 255 },
{ red: 45, green: 45, blue: 180, alpha: 255 },
{ red: 55, green: 55, blue: 220, alpha: 255 },
{ red: 64, green: 64, blue: 255, alpha: 255 },
{ red: 33, green: 33, blue: 135, alpha: 255 },
{ red: 100, green: 84, blue: 50, alpha: 255 },
{ red: 123, green: 102, blue: 62, alpha: 255 },
{ red: 143, green: 119, blue: 72, alpha: 255 },
{ red: 75, green: 63, blue: 38, alpha: 255 },
{ red: 180, green: 177, blue: 172, alpha: 255 },
{ red: 220, green: 217, blue: 211, alpha: 255 },
{ red: 255, green: 252, blue: 245, alpha: 255 },
{ red: 135, green: 133, blue: 129, alpha: 255 },
{ red: 152, green: 89, blue: 36, alpha: 255 },
{ red: 186, green: 109, blue: 44, alpha: 255 },
{ red: 216, green: 127, blue: 51, alpha: 255 },
{ red: 114, green: 67, blue: 27, alpha: 255 },
{ red: 125, green: 53, blue: 152, alpha: 255 },
{ red: 153, green: 65, blue: 186, alpha: 255 },
{ red: 178, green: 76, blue: 216, alpha: 255 },
{ red: 94, green: 40, blue: 114, alpha: 255 },
{ red: 72, green: 108, blue: 152, alpha: 255 },
{ red: 88, green: 132, blue: 186, alpha: 255 },
{ red: 102, green: 153, blue: 216, alpha: 255 },
{ red: 54, green: 81, blue: 114, alpha: 255 },
{ red: 161, green: 161, blue: 36, alpha: 255 },
{ red: 197, green: 197, blue: 44, alpha: 255 },
{ red: 229, green: 229, blue: 51, alpha: 255 },
{ red: 121, green: 121, blue: 27, alpha: 255 },
{ red: 89, green: 144, blue: 17, alpha: 255 },
{ red: 109, green: 176, blue: 21, alpha: 255 },
{ red: 127, green: 204, blue: 25, alpha: 255 },
{ red: 67, green: 108, blue: 13, alpha: 255 },
{ red: 170, green: 89, blue: 116, alpha: 255 },
{ red: 208, green: 109, blue: 142, alpha: 255 },
{ red: 242, green: 127, blue: 165, alpha: 255 },
{ red: 128, green: 67, blue: 87, alpha: 255 },
{ red: 53, green: 53, blue: 53, alpha: 255 },
{ red: 65, green: 65, blue: 65, alpha: 255 },
{ red: 76, green: 76, blue: 76, alpha: 255 },
{ red: 40, green: 40, blue: 40, alpha: 255 },
{ red: 108, green: 108, blue: 108, alpha: 255 },
{ red: 132, green: 132, blue: 132, alpha: 255 },
{ red: 153, green: 153, blue: 153, alpha: 255 },
{ red: 81, green: 81, blue: 81, alpha: 255 },
{ red: 53, green: 89, blue: 108, alpha: 255 },
{ red: 65, green: 109, blue: 132, alpha: 255 },
{ red: 76, green: 127, blue: 153, alpha: 255 },
{ red: 40, green: 67, blue: 81, alpha: 255 },
{ red: 89, green: 44, blue: 125, alpha: 255 },
{ red: 109, green: 54, blue: 153, alpha: 255 },
{ red: 127, green: 63, blue: 178, alpha: 255 },
{ red: 67, green: 33, blue: 94, alpha: 255 },
{ red: 36, green: 53, blue: 125, alpha: 255 },
{ red: 44, green: 65, blue: 153, alpha: 255 },
{ red: 51, green: 76, blue: 178, alpha: 255 },
{ red: 27, green: 40, blue: 94, alpha: 255 },
{ red: 72, green: 53, blue: 36, alpha: 255 },
{ red: 88, green: 65, blue: 44, alpha: 255 },
{ red: 102, green: 76, blue: 51, alpha: 255 },
{ red: 54, green: 40, blue: 27, alpha: 255 },
{ red: 72, green: 89, blue: 36, alpha: 255 },
{ red: 88, green: 109, blue: 44, alpha: 255 },
{ red: 102, green: 127, blue: 51, alpha: 255 },
{ red: 54, green: 67, blue: 27, alpha: 255 },
{ red: 108, green: 36, blue: 36, alpha: 255 },
{ red: 132, green: 44, blue: 44, alpha: 255 },
{ red: 153, green: 51, blue: 51, alpha: 255 },
{ red: 81, green: 27, blue: 27, alpha: 255 },
{ red: 17, green: 17, blue: 17, alpha: 255 },
{ red: 21, green: 21, blue: 21, alpha: 255 },
{ red: 25, green: 25, blue: 25, alpha: 255 },
{ red: 13, green: 13, blue: 13, alpha: 255 },
{ red: 176, green: 168, blue: 54, alpha: 255 },
{ red: 215, green: 205, blue: 66, alpha: 255 },
{ red: 250, green: 238, blue: 77, alpha: 255 },
{ red: 132, green: 126, blue: 40, alpha: 255 },
{ red: 64, green: 154, blue: 150, alpha: 255 },
{ red: 79, green: 188, blue: 183, alpha: 255 },
{ red: 92, green: 219, blue: 213, alpha: 255 },
{ red: 48, green: 115, blue: 112, alpha: 255 },
{ red: 52, green: 90, blue: 180, alpha: 255 },
{ red: 63, green: 110, blue: 220, alpha: 255 },
{ red: 74, green: 128, blue: 255, alpha: 255 },
{ red: 39, green: 67, blue: 135, alpha: 255 },
{ red: 0, green: 153, blue: 40, alpha: 255 },
{ red: 0, green: 187, blue: 50, alpha: 255 },
{ red: 0, green: 217, blue: 58, alpha: 255 },
{ red: 0, green: 114, blue: 30, alpha: 255 },
{ red: 91, green: 60, blue: 34, alpha: 255 },
{ red: 111, green: 74, blue: 42, alpha: 255 },
{ red: 129, green: 86, blue: 49, alpha: 255 },
{ red: 68, green: 45, blue: 25, alpha: 255 },
{ red: 79, green: 1, blue: 0, alpha: 255 },
{ red: 96, green: 1, blue: 0, alpha: 255 },
{ red: 112, green: 2, blue: 0, alpha: 255 },
{ red: 59, green: 1, blue: 0, alpha: 255 },
{ red: 147, green: 124, blue: 113, alpha: 255 },
{ red: 180, green: 152, blue: 138, alpha: 255 },
{ red: 209, green: 177, blue: 161, alpha: 255 },
{ red: 110, green: 93, blue: 85, alpha: 255 },
{ red: 112, green: 57, blue: 25, alpha: 255 },
{ red: 137, green: 70, blue: 31, alpha: 255 },
{ red: 159, green: 82, blue: 36, alpha: 255 },
{ red: 84, green: 43, blue: 19, alpha: 255 },
{ red: 105, green: 61, blue: 76, alpha: 255 },
{ red: 128, green: 75, blue: 93, alpha: 255 },
{ red: 149, green: 87, blue: 108, alpha: 255 },
{ red: 78, green: 46, blue: 57, alpha: 255 },
{ red: 79, green: 76, blue: 97, alpha: 255 },
{ red: 96, green: 93, blue: 119, alpha: 255 },
{ red: 112, green: 108, blue: 138, alpha: 255 },
{ red: 59, green: 57, blue: 73, alpha: 255 },
{ red: 131, green: 93, blue: 25, alpha: 255 },
{ red: 160, green: 114, blue: 31, alpha: 255 },
{ red: 186, green: 133, blue: 36, alpha: 255 },
{ red: 98, green: 70, blue: 19, alpha: 255 },
{ red: 72, green: 82, blue: 37, alpha: 255 },
{ red: 88, green: 100, blue: 45, alpha: 255 },
{ red: 103, green: 117, blue: 53, alpha: 255 },
{ red: 54, green: 61, blue: 28, alpha: 255 },
{ red: 112, green: 54, blue: 55, alpha: 255 },
{ red: 138, green: 66, blue: 67, alpha: 255 },
{ red: 160, green: 77, blue: 78, alpha: 255 },
{ red: 84, green: 40, blue: 41, alpha: 255 },
{ red: 40, green: 28, blue: 24, alpha: 255 },
{ red: 49, green: 35, blue: 30, alpha: 255 },
{ red: 57, green: 41, blue: 35, alpha: 255 },
{ red: 30, green: 21, blue: 18, alpha: 255 },
{ red: 95, green: 75, blue: 69, alpha: 255 },
{ red: 116, green: 92, blue: 84, alpha: 255 },
{ red: 135, green: 107, blue: 98, alpha: 255 },
{ red: 71, green: 56, blue: 51, alpha: 255 },
{ red: 61, green: 64, blue: 64, alpha: 255 },
{ red: 75, green: 79, blue: 79, alpha: 255 },
{ red: 87, green: 92, blue: 92, alpha: 255 },
{ red: 46, green: 48, blue: 48, alpha: 255 },
{ red: 86, green: 51, blue: 62, alpha: 255 },
{ red: 105, green: 62, blue: 75, alpha: 255 },
{ red: 122, green: 73, blue: 88, alpha: 255 },
{ red: 64, green: 38, blue: 46, alpha: 255 },
{ red: 53, green: 43, blue: 64, alpha: 255 },
{ red: 65, green: 53, blue: 79, alpha: 255 },
{ red: 76, green: 62, blue: 92, alpha: 255 },
{ red: 40, green: 32, blue: 48, alpha: 255 },
{ red: 53, green: 35, blue: 24, alpha: 255 },
{ red: 65, green: 43, blue: 30, alpha: 255 },
{ red: 76, green: 50, blue: 35, alpha: 255 },
{ red: 40, green: 26, blue: 18, alpha: 255 },
{ red: 53, green: 57, blue: 29, alpha: 255 },
{ red: 65, green: 70, blue: 36, alpha: 255 },
{ red: 76, green: 82, blue: 42, alpha: 255 },
{ red: 40, green: 43, blue: 22, alpha: 255 }
]
colorId -= 3 //
if (!colors[colorId]) return { red: 255, green: 255, blue: 255, alpha: 255 }
else return colors[colorId];
}
async function getSRVRecord(domain) {
try {
const records = await resolveSrv('_minecraft._tcp.' + domain);
if (records.length > 0) {
const record = records[0];
const { address } = await lookup(record.name);
return {
ip: address,
port: record.port,
};
}
} catch (err) {
parentPort.postMessage({ type: 'electron', action: 'error', data: err});
}
return null;
}
function addBlockToChunk(chunk, blockType, position) {
if (!chunk) {
parentPort.postMessage({ type: 'electron', action: 'error', data: 'Chunk is undefined.'});
return;
}
if (typeof chunk.setBlock !== 'function') {
parentPort.postMessage({ type: 'electron', action: 'error', data: 'Chunk does not have a setBlock method.'});
return;
}
const newBlock = {
type: blockType,
metadata: 0,
light: 15,
skyLight: 15,
};
try {
chunk.setBlock(position.x, position.y, position.z, newBlock);
} catch (error) {
parentPort.postMessage({ type: 'electron', action: 'error', data: 'Error while setting block in chunk: ' + error});
}
}
async function head_captcha_solver_2(bot, window) {
let headCount = 0;
let urls = {};
let slots = {};
let images = {};
for (let i = 0; i < window.slots.length; i++) {
let slot = window.slots[i];
if (slot && slot.nbt) {
if (slot.name === 'player_head' || slot.name === 'skull') {
headCount++;
let nbt = JSON.stringify(slot.nbt);
let regex = /"Value":{"type":"string","value":"(.*?)"}/g;
let matches = [...nbt.matchAll(regex)];
if (matches.length > 0) {
let base64 = matches[0][1];
let decodedString = atob(base64);
try {
let jsonObject = JSON.parse(decodedString);
if (jsonObject.textures && jsonObject.textures.SKIN && jsonObject.textures.SKIN.url) {
let url = jsonObject.textures.SKIN.url;
urls[url] = (urls[url] || 0) + 1;
slots[url] = i;
}
} catch (e) {
parentPort.postMessage({ type: 'electron', action: 'error', data: 'Erro ao analisar a string decodificada em JSON: ' + e});
}
}
}
}
}
if (headCount < 3) {
return;
}
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: "<br/><span style='color:orange'>[HEADCAPTCHA-2]</span> <span style='color:yellow'>Captcha de cabeça detectado KKKKKKKKKKKKKKKKKKKKKK, que bosta heim, quem que usa isso hoje em dia</span><br/> " } });
for (let url in urls) {
try {
images[url] = await Jimp.read(url);
} catch (e) {
parentPort.postMessage({ type: 'electron', action: 'error', data: 'Erro ao carregar a imagem: ' + e});
}
}
let uniqueUrl = false;
for (let url1 in images) {
let isUnique = true;
for (let url2 in images) {
if (url1 !== url2) {
let diff = Jimp.diff(images[url1], images[url2]);
if (diff.percent < 0.1) {
isUnique = false;
break;
}
}
if (isUnique) {
uniqueUrl = url1;
break;
}
}
}
if (uniqueUrl) {
let slotIndex = slots[uniqueUrl];
bot.clickWindow(slotIndex, 0, 0);
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: "<br/><span style='color:orange'>[HEADCAPTCHA-2]</span> <span style='color:green'>Pronto eu resolvi esse captcha de bosta ai</span><br/> " } });
} else {
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: "<br/><span style='color:orange'>[HEADCAPTCHA-2]</span> <span style='color:red'>Vish fudeu nao encontrei nenhuma URL unica pra esse captcha fudido</span><br/> " } });
}
}
async function head_captcha_solver(bot, window) {
let headCount = 0;
let urls = {};
let slots = {};
let images = {};
for (let i = 0; i < window.slots.length; i++) {
let slot = window.slots[i];
if (slot && slot.nbt) {
if (slot.name === 'player_head' || slot.name === 'skull') {
headCount++;
let nbt = JSON.stringify(slot.nbt);
let regex = /"Value":\{"type":"string","value":"(.*?)"\}/g;
let matches = [...nbt.matchAll(regex)];
if (matches.length > 1) {
let base64 = matches[1][1];
let decodedString = atob(base64);
try {
let jsonObject = JSON.parse(decodedString);
if (jsonObject.textures && jsonObject.textures.SKIN && jsonObject.textures.SKIN.url) {
let url = jsonObject.textures.SKIN.url;
urls[url] = (urls[url] || 0) + 1;
slots[url] = i;
}
} catch (e) {
parentPort.postMessage({ type: 'electron', action: 'error', data: 'Erro ao analisar a string decodificada em JSON: ' + e});
}
}
}
}
}
if (headCount < 3) {
return;
}
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: "<br/><span style='color:orange'>[HEADCAPTCHA]</span> <span style='color:yellow'>Captcha de cabeça detectado KKKKKKKKKKKKKKKKKKKKKK, que bosta heim, quem que usa isso hoje em dia</span><br/> " } });
for (let url in urls) {
try {
images[url] = await Jimp.read(url);
} catch (e) {
parentPort.postMessage({ type: 'electron', action: 'error', data: 'Erro ao carregar a imagem: ' + e});
}
}
let uniqueUrl = false;
for (let url1 in images) {
let isUnique = true;
for (let url2 in images) {
if (url1 !== url2) {
let diff = Jimp.diff(images[url1], images[url2]);
if (diff.percent < 0.1) {
isUnique = false;
break;
}
}
if (isUnique) {
uniqueUrl = url1;
break;
}
}
}
if (uniqueUrl) {
let slotIndex = slots[uniqueUrl];
bot.clickWindow(slotIndex, 0, 0);
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: "<br/><span style='color:orange'>[HEADCAPTCHA]</span> <span style='color:green'>Pronto eu resolvi esse captcha de bosta ai</span><br/> " } });
} else {
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: "<br/><span style='color:orange'>[HEADCAPTCHA]</span> <span style='color:red'>Vish fudeu nao encontrei nenhuma URL unica pra esse captcha fudido</span><br/> " } });
parentPort.postMessage({ type: 'webcontents', event: 'bot-message', data: { bot: bot.username, message: "<br/><span style='color:orange'>[HEADCAPTCHA]</span> <span style='color:yellow'>Tentando outro metodo...</span><br/> " } });
head_captcha_solver_2(bot, window)
}
}
function calculateDistance(pos1, pos2) {
const dx = pos1.x - pos2.x;
const dy = pos1.y - pos2.y;
const dz = pos1.z - pos2.z;
return Math.sqrt(dx*dx + dy*dy + dz*dz);
}
function findNearestEntity(bot, onlyplayer) {
let nearestEntity = null;
let nearestDistance = Infinity;
for (const entityId in bot.entities) {
const entity = bot.entities[entityId];
if (entity === undefined) { // idk why some entities are undefined, thats so cringe
continue;
}
if (entity === bot.entity ||
entity.id === bot.entity.id ||
(entity.username && entity.username === bot.username)) {
continue;
}
if(onlyplayer)
{
if(entity.type !== 'player')
{
continue;
}