This repository was archived by the owner on Sep 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
751 lines (681 loc) · 32.8 KB
/
Program.cs
File metadata and controls
751 lines (681 loc) · 32.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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
using EEUniverse.Library;
using EEUniverse.LoginExtensions;
using System;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.IO;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using static System.Net.Mime.MediaTypeNames;
namespace eeuthingy
{
public class Program
{
private static async Task Main(string[] args)
{
Client client = new Client("");
var token = "";
ConsoleKey key;
bool mask = true;
bool valid = true;
bool edit = false;
do
{
token = "";
valid = true;
Console.Clear();
Console.WriteLine("Paste token here (press F2 to toggle masking):");
do
{
var keyInfo = Console.ReadKey(intercept: true);
key = keyInfo.Key;
if (key == ConsoleKey.Backspace && token.Length > 0)
{
Console.Write("\b \b");
token = token[0..^1];
}
else if (!char.IsControl(keyInfo.KeyChar))
{
if (mask)
Console.Write("*");
else
Console.Write(key);
token += keyInfo.KeyChar;
}
if (key == ConsoleKey.F2)
{
mask = !mask;
Console.SetCursorPosition(0, 1); //set the cursor position to the start
for (var i = 0; i < token.Length; i++)
{
if (mask)
Console.Write("*");
else
Console.Write(token[i]);
}
}
} while (key != ConsoleKey.Enter);
Console.WriteLine("\nPlease wait...");
try
{
if (token.StartsWith("__Host"))
client = await GoogleLogin.GetClientFromCookieAsync(token);
else
client = new Client(token);
await client.ConnectAsync();
}
catch (Exception e)
{
valid = false;
Console.Clear();
Console.WriteLine($"Couldn't connect to the EEU server, check if the token was entered correctly.\nException: {e}\nPress the ENTER key to try again.");
Console.ReadLine();
}
} while (!valid);
Console.Clear();
Console.WriteLine("Enter world ID:");
var worldId = Console.ReadLine();
var connection = client.CreateWorldConnection(worldId);
bool connected = false;
var botId = -1; var worldWidth = 0; var worldHeight = 0; //max characters in a sign in 120, bytes can be represented by up to 2 characters so we have a max of 60 bytes per sign
const int maxChars = 120; //max characters in a sign is 120
const int maxBytes = maxChars * 6 / 8; //in base64 a character represents 6 bits, so we can hold up to maxChars * 6 [bits] * 8 [bits in a byte] bytes in a sign.
const int maxNameLength = 85;
const string outPath = "out/";
Block[,] World = {};
Console.WriteLine("Waiting for init...");
Task.Delay(5000).ContinueWith(t =>
{
if (!connected)
Console.WriteLine("5 seconds have passed without connecting, very likely something has gone wrong. Maybe the world ID is incorrect, the world is private or the servers are down. Restart this program and try again.");
});
connection.OnMessage += async (s, m) =>
{
if (m.Type == MessageType.Init)
{
connected = true;
Console.Clear();
Console.WriteLine($"Connected to world {worldId}!");
botId = m.GetInt(0);
worldWidth = m.GetInt(9);
worldHeight = m.GetInt(10);
if (m.GetString(1) == m.GetString(7)) //if bot name is the same as owner name that means we have edit rights
edit = true;
World = new Block[worldWidth, worldHeight];
var index = 0;
for (var y = 0; y < worldHeight; y++)
for (var x = 0; x < worldWidth; x++)
{
var bId = m.GetInt(11 + index);
bId &= 0xFFFF; //gets the foreground id, we don't care about backgrounds
if (bId >= 55 && bId <= 58)
{
World[x, y] = new Block(bId, m.GetString(11 + index + 1));
index += 3;
}
else
{
World[x, y] = new Block(bId);
if (bId == 59) //portal
index += 5;
else if (bId == 100 || bId == 103 || bId == 104 || bId == 105) //switch doors, coin doors
index += 3;
else if (bId == 93 || bId == 94 || bId == 98 || bId == 99 || bId == 101 || bId == 102) //switches, effects
index += 2;
else
index++;
}
}
Chat("Connected!");
}
else if (m.Type == MessageType.PlaceBlock)
{
if (m.GetInt(1) == 1) //only recieve foreground blocks
{
var bId = m.GetInt(4);
World[m.GetInt(2), m.GetInt(3)].id = bId;
if (bId >= 55 && bId <= 58)
World[m.GetInt(2), m.GetInt(3)].text = m.GetString(5);
}
}
else if (m.Type == MessageType.Clear)
{
for (var y = 0; y < worldHeight; y++) //clears the world
for (var x = 0; x < worldWidth; x++)
{
World[x, y].id = 0;
World[x, y].text = "";
}
}
else if(m.Type == MessageType.CanEdit)
{
if (m.GetInt(0) == botId)
edit = m.GetBool(1);
}
else if (m.Type == MessageType.Chat)
{
if (m.GetInt(0) != botId)
{
var chatMsg = m.GetString(1);
if (chatMsg.StartsWith("!help ") || chatMsg == ("!help"))
{
printHelp(chatMsg);
}
else if (chatMsg.StartsWith("!write ") || chatMsg == ("!write"))
{
try
{
await writeFile(chatMsg);
}
catch (Exception e)
{
Chat($"write: An error has occured. Check console for details.");
Console.WriteLine($"An error has occured.\nException: {e}");
}
}
else if (chatMsg.StartsWith("!read ") || chatMsg == ("!read"))
{
try
{
readFile(chatMsg);
}
catch (Exception e)
{
Chat($"read: An error has occured. Check console for details.");
Console.WriteLine($"An error has occured.\nException: {e}");
}
}
else if (chatMsg.StartsWith("!verify ") || chatMsg == ("!verify"))
{
try
{
verifyFile();
}
catch (Exception e)
{
Chat($"verify: An error has occured. Check console for details.");
Console.WriteLine($"An error has occured.\nException: {e}");
}
}
else if (chatMsg.StartsWith("!maxsize ") || chatMsg == ("!maxsize"))
{
printMaxSize();
}
}
}
};
await connection.SendAsync(MessageType.Init, 0);
Thread.Sleep(-1);
async void Chat(string msg)
{
await connection.SendAsync(MessageType.Chat, msg);
}
//command methods
void printHelp(string chatMsg)
{
string[] param = chatMsg.Split();
if (param.Length <= 1)
{
Chat("Command list, type \"!help [command]\" for more details: !help !write !read !verify !maxsize");
return;
}
if (param[1][0] == '!')
param[1] = param[1].Substring(1);
switch (param[1])
{
case "help":
Chat("!help - Sends a list of the commands available.");
Chat("!help [command] - Sends the detailed explanation and usage of a command.");
break;
case "write":
Chat("!write [path to file] - Clears the world and writes the file provided to the world.");
break;
case "read":
Chat("!read - Reads the contents of the world into a file and creates it in the folder /out. Any files with the same name will be overwritten.");
Chat("!read -i [new file name] - Ignores the blue info sign at (0, 0) when reading. This requires choosing a new file name and skipping hash checking.");
break;
case "verify":
Chat("!verify - Checks the file stored in the world for any errors. If no errors are detected, sends some stats about the file.");
break;
case "maxsize":
Chat("!maxsize - Get the max file size in bytes that this world can store.");
break;
default:
Chat($"Command \"{param[1]}\" doesn't exist.");
break;
}
}
async Task writeFile(string chatMsg)
{
if(!edit)
{
Chat($"write: I don't have edit rights.");
return;
}
string[] param = chatMsg.Split();
if (param.Length <= 1)
{
Chat($"write: You must provide the path to the file.");
return;
}
var filePath = chatMsg.Substring(chatMsg.IndexOf(' ') + 1);
if (!File.Exists(filePath))
{
Chat($"write: File \"{filePath}\" does not exist.");
return;
}
var fileName = Path.GetFileName(filePath);
if (fileName.Length > maxNameLength)
{
Chat($"write: File name is longer than the max of {maxNameLength} characters. Shorten it and try again.");
return;
}
using (var fs = new FileStream(filePath, FileMode.Open))
{
var fileLen = (int)fs.Length;
if (fileLen > worldWidth * worldHeight * maxBytes - maxBytes)
{
if (fileName.Length > 50)
{
fileName = fileName.Substring(0, 50);
fileName += "...";
}
Chat($"write: File \"{filePath}\" is too big. Max bytes: {worldWidth * worldHeight * maxBytes}, file size: {fileLen} bytes");
return;
}
if (fileLen == 0)
{
Chat($"write: File \"{filePath}\" is empty.");
return;
}
for (var y = 0; y < worldHeight; y++) //clears the world
for (var x = 0; x < worldWidth; x++)
{
World[x, y] = new Block(0);
await connection.SendAsync(MessageType.PlaceBlock, 1, x, y, 0);
}
var bytes = new byte[fileLen];
fs.Read(bytes, 0, fileLen);
for (int i = 0; i < fileLen; i += 16)
{
var cnt = Math.Min(16, fileLen - i);
var line = new byte[cnt];
Array.Copy(bytes, i, line, 0, cnt);
}
var base64Encode = System.Convert.ToBase64String(bytes);
var writeIndex = 0;
var signX = 1; var signY = 0;
var encodeLength = base64Encode.Length;
while (writeIndex < encodeLength)
{
var writeString = "";
if (encodeLength - writeIndex < maxChars)
writeString = base64Encode.Substring(writeIndex, encodeLength - writeIndex);
else
writeString = base64Encode.Substring(writeIndex, maxChars);
writeIndex += maxChars;
await connection.SendAsync(MessageType.PlaceBlock, 1, signX, signY, 55, writeString);
World[signX, signY] = new Block(55, writeString);
signX++;
if (signX >= worldWidth)
{
signX = 0;
signY++;
}
}
string MD5Hash;
using (MD5 md5 = MD5.Create())
MD5Hash = Convert.ToHexString(md5.ComputeHash(bytes)); //calculate md5 hash and put it in a hex string
await connection.SendAsync(MessageType.PlaceBlock, 1, 0, 0, 58, fileName + "|" + MD5Hash); //store the filename and md5 hash in a blue sign located at 0, 0
World[0, 0] = new Block(58, fileName + "|" + MD5Hash);
Chat($"write: All done, bytes written: {bytes.Length}");
}
}
void readFile(string chatMsg)
{
string[] param = chatMsg.Split();
Regex rg = new Regex("[^0-9A-F]+"); //checks if a string contains characters not used to represent hex numbers
Regex base64Rg = new Regex("[^0-9a-zA-Z+\\/=]+"); //checks if a string contains characters not used to represent base64 numbers
Regex nameRg = new Regex("[\\\\\\/:\\*\\?\\\"<>\\|]+"); //checks for characters that can't be in a file name
bool skipInfo = false;
if (param.Length >= 2)
{
if (param[1] == "-i")
{
if (param.Length == 2)
{
Chat("read: You must provide a new name for the file.");
return;
}
int index = chatMsg.IndexOf(' ');
while (!chatMsg.Substring(index).StartsWith(param[2])) //accounting for multiple spaces between "-i" and file name (there's probably a better way to do this)
index = chatMsg.IndexOf(' ', index + 1) + 1;
param[2] = chatMsg.Substring(index); //everything after "-i" is considered the file name
if (param[2].Contains(@"\") || param[2].Contains("/"))
{
Chat(@"read: Reading in directories other than the default not allowed, don't use '/' or '\'.");
return;
}
if (param[2].Length > maxNameLength)
{
Chat($"read: File name is longer than the max of {maxNameLength} characters. Shorten it and try again.");
return;
}
if (nameRg.IsMatch(param[2]))
{
Chat("read: File name contains invalid characters.");
return;
}
skipInfo = true;
}
}
if (!skipInfo)
{
if (World[1, 0].id != 55 || World[1, 0].text == "")
{
Chat($"read: No file detected in this world.");
return;
}
if (World[0, 0].id != 58 || World[0, 0].text == "")
{
Chat($"read: Blue info sign not found or is empty. Use !read -i [new file name] to ignore this warning.");
return;
}
}
string[] infoParam = World[0, 0].text.Split("|");
if (!skipInfo)
{
if (infoParam.Length > 2)
{
Chat($"read: Blue info sign is invalid. Use !read -i [new file name] to ignore this warning.");
return;
}
if (infoParam.Length == 1)
{
Chat($"read: MD5 hash not found. Use !read -i [new file name] to ignore this warning.");
return;
}
if (nameRg.IsMatch(infoParam[0]))
{
Chat($"read: File name contains invalid characters. Use !read -i [new file name] to ignore this warning.");
return;
}
if (infoParam[1].Length != 32)
{
Chat($"read: MD5 hash is invalid. Use !read -i [new file name] to ignore this warning.");
return;
}
if (rg.IsMatch(infoParam[1]))
{
Chat($"read: MD5 hash contains invalid characters. Use !read -i [new file name] to ignore this warning.");
return;
}
}
var filePath = "";
var MD5Hash = "";
if (!skipInfo)
{
filePath = outPath + infoParam[0];
MD5Hash = infoParam[1];
}
else
filePath = outPath + param[2];
if (Path.GetDirectoryName(filePath) != "") //if GetDirectoryName is null CreateDirectory will fail and throw an exception
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
using (var fs = new FileStream(filePath, FileMode.Create))
using (var bw = new BinaryWriter(fs))
{
var fileLen = (int)fs.Length;
var signX = 1; var signY = 0;
bool errors = false;
var base64String = ""; var prevBase64String = "";
List<byte> bytes = new List<byte>(); //used for checking md5 hash
while (World[signX, signY].id == 55 && signY < worldHeight && !base64String.Contains('='))
{
prevBase64String = base64String;
base64String = World[signX, signY].text;
if (base64Rg.IsMatch(base64String) || base64String.Length % 4 != 0)
{
Chat($"read: Invalid sign content, stopping. The file created may be corrupted. x = {signX}, y = {signY}");
return;
}
if (prevBase64String.Length < maxChars && (signX > 1 || signY > 0))
{
var errX = signX - 1; var errY = signY;
if (errX < 0)
{
errX = worldWidth - 1;
errY--;
}
Chat($"read: Warning: Sign containing less than {maxChars} characters detected before end of file. The file created may be corrupted. x = {errX}, y = {errY}, length: {prevBase64String.Length}");
errors = true;
}
try {
byte[] curBytes = Convert.FromBase64String(base64String);
if (!skipInfo)
bytes.AddRange(curBytes);
bw.Write(curBytes);
}
catch (Exception) //too lazy to check for bad base64 strings myself, this will do
{
Chat($"read: Invalid sign content, stopping. The file created may be corrupted. x = {signX}, y = {signY}");
return;
}
signX++;
if (signX >= worldWidth)
{
signX = 0;
signY++;
}
}
var readMD5Hash = "";
if(!skipInfo)
using (MD5 md5 = MD5.Create())
readMD5Hash = Convert.ToHexString(md5.ComputeHash(bytes.ToArray()));
if(!skipInfo && readMD5Hash != MD5Hash)
{
Chat($"read: MD5 hash mismatch! File has been modified or corrupted. (Stored hash: {MD5Hash}, actual hash: {readMD5Hash})");
errors = true;
}
if (!errors)
Chat($"read: The file \"{filePath}\" has been successfully created.");
else
Chat($"read: The file \"{filePath}\" has been created, but it might be corrupted. Check previous messages for details.");
}
return;
}
void verifyFile()
{
var success = 1;
var infoSuccess = true;
var signX = 1; var signY = 0;
var fileSize = 0;
var fileName = "";
Regex rg = new Regex("[^0-9A-F]+");
Regex base64Rg = new Regex("[^0-9a-zA-Z+\\/=]+");
Regex nameRg = new Regex("[\\\\\\/:\\*\\?\\\"<>\\|]+");
var base64String = ""; var prevBase64String = "";
var MD5Hash = "";
List<byte> bytes = new List<byte>(); //used for checking md5 hash
if (World[1, 0].id != 55 || World[1, 0].text == "")
{
Chat("verify: No file detected in this world.");
return;
}
if (World[0, 0].id != 58 || World[0, 0].text == "")
{
Chat("verify: Blue info sign not found or is empty. Use !read -i [new file name] to ignore this warning.");
infoSuccess = false;
}
else
{
string[] infoParam = World[0, 0].text.Split("|");
if (infoParam.Length > 2)
{
Chat($"verify: Blue info sign is invalid. Use !read -i [new file name] to ignore this warning.");
infoSuccess = false;
}
else if (infoParam.Length == 1)
{
Chat($"verify: MD5 hash not found. Use !read -i [new file name] to ignore this warning.");
infoSuccess = false;
}
else if (nameRg.IsMatch(infoParam[0]))
{
Chat($"verify: File name contains invalid characters. Use !read -i [new file name] to ignore this warning.");
infoSuccess = false;
}
if (infoParam[1].Length != 32)
{
Chat($"verify: MD5 hash is invalid. Use !read -i [new file name] to ignore this warning.");
infoSuccess = false;
}
else if (rg.IsMatch(infoParam[1]))
{
Chat($"verify: MD5 hash contains invalid characters. Use !read -i [new file name] to ignore this warning.");
infoSuccess = false;
}
if (infoSuccess)
{
MD5Hash = infoParam[1];
fileName = infoParam[0];
}
}
while (World[signX, signY].id == 55 && signY < worldHeight && !base64String.Contains('='))
{
prevBase64String = base64String;
base64String = World[signX, signY].text;
if (base64Rg.IsMatch(base64String))
{
Chat($"verify: Detected sign that contains invalid characters, reading will fail. x = {signX}, y = {signY}");
success = 0;
}
if (base64String.Length % 4 != 0)
{
Chat($"verify: Detected sign that contains an invalid number of characters, reading will fail. x = {signX}, y = {signY}");
success = 0;
}
if (base64String.Length == 0)
{
Chat($"verify: Detected empty sign. Reading may result in a corrupted file. x = {signX}, y = {signY}");
if (success > 0)
success = 2;
}
if (prevBase64String.Length < maxChars && (signX > 1 || signY > 0))
{
var errX = signX - 1; var errY = signY;
if (errX < 0)
{
errX = worldWidth - 1;
errY--;
}
Chat($"verify: Sign containing less than {maxChars} characters detected before end of file. Reading may result in a corrupted file. x = {errX}, y = {errY}, length: {prevBase64String.Length}");
if (success > 0)
success = 2;
}
if (success > 0)
{
try {
bytes.AddRange(Convert.FromBase64String(base64String));
fileSize += base64String.Length * 6 / 8;
if (base64String.Contains("=="))
fileSize -= 2;
else if (base64String.Contains('='))
fileSize -= 1;
}
catch(Exception)
{
Chat($"verify: Detected sign that has an invalid format, reading will fail. x = {signX}, y = {signY}");
success = 0;
}
}
signX++;
if (signX >= worldWidth)
{
signX = 0;
signY++;
}
}
if (success > 0)
{
var readMD5Hash = "";
using (MD5 md5 = MD5.Create())
readMD5Hash = Convert.ToHexString(md5.ComputeHash(bytes.ToArray()));
if (infoSuccess)
if (MD5Hash != readMD5Hash)
{
Chat($"verify: MD5 hash mismatch! File has been modified or corrupted. (Stored hash: {MD5Hash}, actual hash: {readMD5Hash})");
MD5Hash = readMD5Hash;
success = 2;
}
else
MD5Hash = readMD5Hash;
}
if (fileName.Length > 50)
{
fileName = fileName.Substring(0, 50);
fileName += "...";
}
if (success == 1)
{
var msg = $"verify: File contains no errors.";
if (infoSuccess)
{
msg += $" File name: \"{fileName}\", file size: {fileSize} bytes";
if (fileSize >= 1_000_000)
msg += $" (~{fileSize / 1_000_000.0:0.00} MB)";
else if (fileSize >= 1_000)
msg += $" (~{fileSize / 1_000.0:0.00} KB)";
msg += ".";
}
Chat(msg);
Chat($"verify: MD5 hash: {MD5Hash}");
}
else if (success == 2)
{
var msg = "verify: File contains errors, but can be read. The file may be corrupted upon creation.";
if (infoSuccess)
{
msg += $" File name: \"{fileName}\", file size: {fileSize} bytes";
if (fileSize >= 1_000_000)
msg += $" (~{fileSize / 1_000_000.0:0.00} MB)";
else if (fileSize >= 1_000)
msg += $" (~{fileSize / 1_000.0:0.00} KB)";
msg += ".";
}
Chat(msg);
Chat($"verify: MD5 hash: {MD5Hash}");
}
else
Chat($"verify: File contains errors and cannot be read.");
if(!infoSuccess && success > 0)
Chat($"verify: Blue info sign is invalid and cannot be read. You can skip reading it by using !read -i [new file name]. Note that this also skips hash checking.");
}
void printMaxSize()
{
var maxSize = worldWidth * worldHeight * maxBytes - maxBytes;
var msg = $"maxsize: This world can fit {maxSize} bytes";
if (maxSize >= 1_000_000)
msg += $" (~{maxSize / 1_000_000.0:0.00} MB)";
else if (maxSize >= 1_000)
msg += $" (~{maxSize / 1_000.0:0.00} KB)";
msg += ".";
Chat(msg);
}
}
}
public class Block
{
public int id;
public string text;
public Block(int id, string text = "")
{
this.id = id;
this.text = text;
}
}
}