forked from ZombieStriker/omegga-brminer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
omegga.plugin.ts
669 lines (595 loc) · 25.9 KB
/
omegga.plugin.ts
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
import OmeggaPlugin, { OL, PS, PC, Vector, Brick, WriteSaveObject, OmeggaPlayer } from 'omegga';
import { PlayerStats } from './playerstats';
import Ore from './ore'
import OreType from './oretype'
import { Chunk } from './chunk';
type Config = { foo: string };
const CHUNK_SIZE = 51200;
const BRICK_SIZE = 20;
let spots: Chunk[] = []; //An array of all positions that have been generated
let ores: Ore[] = []; //An array of all current ores loaded in memory.
//let playerstats : {[index:string]: PlayerStats} = {}; //An Object containing all player data
let playerstats : PlayerStats[] = []; //An Object containing all player data
let oretypes: OreType[] = [];
let stonetypes: OreType[]=[];
let lava: OreType = new OreType(1,"Lava",0,-5000000,5000,13,5);
let lotto: OreType = new OreType(15000,"LottoBlock",0,-5000000,5000,18,5);
let globalMoneyMultiplier = 1;
let globalMoneyMultiplierTimer = 0;
let rlcbmium=null;
export default class Plugin implements OmeggaPlugin<Config, Storage> {
omegga: OL;
config: PC<Config>;
store: PS<Storage>;
constructor(omegga: OL, config: PC<Config>, store: PS<Storage>) {
this.omegga = omegga;
this.config = config;
this.store = store;
}
async init() {
this.omegga.on('autorestart',async()=>{
for(const pla of this.omegga.getPlayers()){
const pss_bank = await this.store.get("playerStatsObject_"+pla.name+"_bank");
const pss_level = await this.store.get("playerStatsObject_"+pla.name+"_level");
const pss_ls = await this.store.get("playerStatsObject_"+pla.name+"_ls");
if(pss_bank === undefined || pss_bank===null){
playerstats[pla.name] = new PlayerStats(pla.name, 1, 0, 0,0,0);
if(pla!=undefined && pla.name!=undefined)
console.info(`New player '${pla.name}' detected, giving them a playerstats template.`);
} else {
const pss_lm = await this.store.get("playerStatsObject_"+pla.name+"_lm");
const pss_bm = await this.store.get("playerStatsObject_"+pla.name+"_bm");
if(pss_lm===undefined||pss_lm===null){
playerstats[pla.name] = new PlayerStats(pla.name, pss_level, pss_bank, pss_ls,0,0);
}else{
playerstats[pla.name] = new PlayerStats(pla.name, pss_level, pss_bank, pss_ls,pss_lm,pss_bm);
}
}
}
this.omegga.clearAllBricks();
this.omegga.loadBricks("brminer")
spots=[];
ores=[];
});
for(const pla of this.omegga.getPlayers()){
const pss_bank = await this.store.get("playerStatsObject_"+pla.name+"_bank");
const pss_level = await this.store.get("playerStatsObject_"+pla.name+"_level");
const pss_ls = await this.store.get("playerStatsObject_"+pla.name+"_ls");
if(pss_bank === undefined || pss_bank===null){
playerstats[pla.name] = new PlayerStats(pla.name, 1, 0, 0,0,0);
if(pla!=undefined && pla.name!=undefined)
console.info(`New player '${pla.name}' detected, giving them a playerstats template.`);
} else {
const pss_lm = await this.store.get("playerStatsObject_"+pla.name+"_lm");
const pss_bm = await this.store.get("playerStatsObject_"+pla.name+"_bm");
if(pss_lm===undefined||pss_lm===null){
playerstats[pla.name] = new PlayerStats(pla.name, pss_level, pss_bank, pss_ls,0,0);
}else{
playerstats[pla.name] = new PlayerStats(pla.name, pss_level, pss_bank, pss_ls,pss_lm,pss_bm);
}
}
}
this.omegga.clearAllBricks();
this.omegga.loadBricks("brminer")
oretypes.push(new OreType(10,"Tin",5,-4000000000,4000000000,0,6));
oretypes.push(new OreType(200000,"FrogInCharium", 4000,4000,20000,12,6));
oretypes.push(new OreType(10,"Coal",5,-4000000000,4000000000,0,11));
oretypes.push(new OreType(20,"Copper",5,-40000,4000,15,6));
oretypes.push(new OreType(30,"Cobalt",10,-40000,4000,20,6));
oretypes.push(new OreType(60,"Iron",15,-40000,4000,7,6));
oretypes.push(new OreType(70,"Tungsten",25,-40000,4000,10,6));
oretypes.push(new OreType(100,"Gold",45,-40000,4000,16,6));
oretypes.push(new OreType(200,"Diamond",50,-40000,4000,20,4));
oretypes.push(new OreType(400,"Emerald",100,-40000,4000,18,3));
oretypes.push(new OreType(1100,"Dura-Steel",100,-160000,-4000,19,6));
oretypes.push(new OreType(1200,"Netherite",125,-160000,-4000,8,6));
oretypes.push(new OreType(2200,"Plasteel",225,-160000,-4000,20,3));
oretypes.push(new OreType(4100,"Platinum",425,-160000,-4000,20,3));
oretypes.push(new OreType(5100,"Beskar",525,-160000,-4000,11,6));
oretypes.push(new OreType(10100,"Uranium",1025,-160000,-4000,17,5));
oretypes.push(new OreType(50500,"Graphite",5000,-32000,-4000,37,3));
oretypes.push(new OreType(200000,"Flavium", 20000,-320000,-16000,12,6));
oretypes.push(rlcbmium=new OreType(101000,"rlcbmium",10100,-320000,-16000,23,4));
oretypes.push(new OreType(501000,"Aware",50100,-320000,-16000,32,6));
oretypes.push(new OreType(1001000,"Cakium",100100,-640000,-32000,37,6));
oretypes.push(new OreType(5005000,"Simulatium",500100,-640000,-32000,37,7));
oretypes.push(new OreType(101000000,"Bobcatiumm",10100100,-640000,-32000,24,7));
stonetypes.push(new OreType(99995,"Space",32,28000,52000,11,5));
stonetypes.push(new OreType(59999,"Thin Air",20,24000,28000,72,3));
stonetypes.push(new OreType(9995,"Air",15,20000,24000,79,3));
stonetypes.push(new OreType(995,"Water",10,16000,20000,82,3));
stonetypes.push(new OreType(15,"Gravel",5,8000,16000,7,3));
stonetypes.push(new OreType(5,"Dirt",2,4000,8000,12,3));
//Players Spawn here
stonetypes.push(new OreType(5,"Stone",1,-4000,4000,4,3));
stonetypes.push(new OreType(15,"Hard Stone",2,-8000,-4000,5,3));
stonetypes.push(new OreType(115,"Harder Stone",4,-12000,-8000,5,3));
stonetypes.push(new OreType(1115,"Hardest Stone",8,-16000,-12000,6,3));
stonetypes.push(new OreType(11115,"Deepslate",16,-20000,-16000,7,3));
stonetypes.push(new OreType(22225,"Bedrock",32,-24000,-20000,8,3));
stonetypes.push(new OreType(33335,"Granite",64,-30000,-24000,12,3));
stonetypes.push(new OreType(55555,"Condensed Stone",128,-40000,-30000,7,3));
stonetypes.push(new OreType(66666,"Hardened Stone Squared",256,-50000,-40000,8,3));
stonetypes.push(new OreType(100000,"Deep Stone",512,-70000,-50000,9,3));
//Autosaver
const autosaver = setInterval(()=>{
console.info("Saving PlayerStats for ALL...")
for(const pss of playerstats){
if(pss!=null && pss != undefined){
this.store.set("playerStatsObject_"+pss.name+"_bank", pss.bank);
this.store.set("playerStatsObject_"+pss.name+"_level", pss.level);
this.store.set("playerStatsObject_"+pss.name+"_ls", pss.lavasuit);
this.store.set("playerStatsObject_"+pss.name+"_lm", pss.lowestY);
this.store.set("playerStatsObject_"+pss.name+"_bm", pss.blocksmined);
}
}
},(this.config['autosave_interval']*60000));
const globalMoneyMultiplierTimerInterval = setInterval(()=>{
globalMoneyMultiplierTimer--;
if(globalMoneyMultiplierTimer==0){
globalMoneyMultiplier=1;
this.omegga.broadcast("Ore prices have returned to normal.");
}
},1000*60);
this.omegga.on('join', async (player: OmeggaPlayer) => {
const name = player.name
const pss_bank = await this.store.get("playerStatsObject_"+name+"_bank");
const pss_level = await this.store.get("playerStatsObject_"+name+"_level");
const pss_ls = await this.store.get("playerStatsObject_"+name+"_ls");
if(pss_bank === undefined || pss_bank===null){
playerstats[name] = new PlayerStats(name, 1, 0, 0,0,0)
console.info(`New player '${name}' has joined, giving them a playerstats template.`)
return;
}else{
if(playerstats[name]!=undefined&&playerstats[name]!=null){
const pss_lm = await this.store.get("playerStatsObject_"+name+"_lm");
const pss_bm = await this.store.get("playerStatsObject_"+name+"_bm");
if(pss_lm===undefined||pss_lm===null){
playerstats[name]=new PlayerStats(name, pss_level,pss_bank,pss_ls,0,0);
}else{
playerstats[name]=new PlayerStats(name, pss_level,pss_bank,pss_ls,pss_lm,pss_bm);
}
}
}
})
this.omegga.on('leave', async (player: OmeggaPlayer) =>{
const name = player.name
console.info("Saving PlayerStats for "+name+"...")
const pla = playerstats[name];
if(pla!=null){
this.store.set("playerStatsObject_"+name+"_bank",pla.bank);
this.store.set("playerStatsObject_"+name+"_level",pla.level);
this.store.set("playerStatsObject_"+name+"_ls",pla.lavasuit);
this.store.set("playerStatsObject_"+name+"_lm", pla.lowestY);
this.store.set("playerStatsObject_"+name+"_bm", pla.blocksmined);
}
})
this.omegga.on('cmd:bank', async (speaker: string) => {
let playerstat = playerstats[speaker]
this.omegga.whisper(speaker, "You have $"+playerstat.bank);
});
this.omegga.on('cmd:top', async (speaker: string) => {
let playerArray: string[] = [];
for(const pla of this.omegga.getPlayers()){
playerArray.push(pla.name);
}
playerArray.sort(function(a, b) {
const playerstat1 = playerstats[a]
const playerstat2 = playerstats[b]
return playerstat1.level - playerstat2.level;
});
for(const pla of playerArray){
const playerstat = playerstats[pla]
if(playerstat!=undefined){
this.omegga.whisper(speaker, "-"+pla+" : $"+playerstat.bank+" || Level: "+playerstat.level+" || Blocks mined:"+playerstat.blocksmined);
}else{
this.omegga.whisper(speaker, "-"+pla+" : $ERROR");
}
}
});
this.omegga.on('cmd:upgrade', async (speaker: string) => {
let playerstat = playerstats[speaker]
let cost: number = (playerstat.level*5)+75;
if(playerstat.bank<cost){
this.omegga.whisper(speaker, "You need atleast $"+cost+" to upgrade your pick. You have $"+playerstat.bank);
return;
}else{
playerstat.level++;
playerstat.bank-=cost;
this.omegga.whisper(speaker, "You are now at level "+playerstat.level+".");
}
});
this.omegga.on('cmd:mined', async (speaker: string) => {
let playerstat = playerstats[speaker]
this.omegga.whisper(speaker, "You have mined "+playerstat.blocksmined+".");
});
this.omegga.on('cmd:?', async (speaker: string) => {
this.omegga.whisper(speaker, "--==Commands==--");
this.omegga.whisper(speaker, "/? - sends you to this help page");
this.omegga.whisper(speaker, "/upgrade - Upgrades your pick by one level.");
this.omegga.whisper(speaker, "/upgrademax - Upgrades your pick by the max amount of levels you can buy");
this.omegga.whisper(speaker, "/buyhs - Buys a heat suit so you can mine lava");
this.omegga.whisper(speaker, "/bank - See how much money you currently have.");
this.omegga.whisper(speaker, "/top - See how much money/levels everyone online has.");
});
this.omegga.on('cmd:buyhs', async (speaker: string) => {
const playerstat = playerstats[speaker]
if(playerstat.bank<100){
this.omegga.whisper(speaker, "You need atleast $100 to buy a heat suit. You have $"+playerstat.bank);
return;
}else{
playerstat.lavasuit++;
playerstat.bank-=100;
this.omegga.whisper(speaker, "You now have "+playerstat.lavasuit+" heat suits.");
}
});
this.omegga.on('cmd:upgrademax', async (speaker: string) => {
let playerstat = playerstats[speaker]
let cost: number = (playerstat.level*5)+75;
if(playerstat.bank<cost){
this.omegga.whisper(speaker, "You need atleast $"+cost+" to upgrade your pick. You have $"+playerstat.bank);
return;
}else{
while(playerstat.bank>=cost){
playerstat.level++;
playerstat.bank-=cost;
}
this.omegga.whisper(speaker, "You are now at level "+playerstat.level+".");
}
});
this.omegga.on('interact',
async ({ player, position }) => {
let playerstat = playerstats[player.name]
const name = player.name
if(playerstat === undefined){
playerstats[name] = new PlayerStats(name, 1, 0, 0,0,0)
console.info(`New player '${name}' has joined, giving them a playerstats template.`)
return;
}
if(Date.now()-playerstat.cooldown<100){
return;
}
playerstat.cooldown=Date.now();
let ore = await this.getOre(position);
if(ore==null){
await this.genOre([position]);
ore = await this.getOre(position);
}
//This code is always expected to work, however if a user attempts to access a brick that doesn't exist, instead of an unhandled exception crash, we log it and mine the brick.
try {
if(ore!=null){
if(ore.getDurability()>0&&ore.getDurability()-playerstat.level<=0){
playerstat.blocksmined++;
if(ore.type.price>0){
this.omegga.middlePrint(player.name,ore.type.name+" || Earned: $"+(ore.type.price*globalMoneyMultiplier));
playerstat.bank+=(ore.type.price*globalMoneyMultiplier);
}
switch (ore.type) {
case lava:
if(playerstat.lavasuit>0){
playerstat.lavasuit--;
}else{
this.omegga.getPlayer(player.id).kill();
this.omegga.broadcast(""+playerstat.name+" was killed by lava!");
}
break;
case lotto:
const slot = getRandomInt(100);
if(slot<10){
let recieved = playerstat.bank;
recieved*=Math.random();
playerstat.bank-=recieved;
this.omegga.whisper(playerstat.name,"You has lost $"+recieved+".");
}else if(slot<30){
let recieved = playerstat.bank;
recieved*=Math.random();
playerstat.bank+=recieved;
this.omegga.whisper(playerstat.name,"You have recieved $"+recieved+".");
}else if (slot<45){
globalMoneyMultiplier-=Math.random();
this.omegga.broadcast(playerstat.name+" mined a lotto-block and lowered the multiplier to "+globalMoneyMultiplier);
}else if (slot < 68){
globalMoneyMultiplier+=Math.random();
this.omegga.broadcast(playerstat.name+" mined a lotto-block and raised the multiplier to "+globalMoneyMultiplier);
}else{
this.omegga.broadcast(playerstat.name+" mined a lotto-block that did nothing!");
}
break;
case rlcbmium:
let date = new Date();
this.omegga.broadcast(playerstat.name+": it is now "+date.getHours()+":"+date.getMinutes());
break;
default:
break;
}
}
ore.setDurability(ore.getDurability()-playerstat.level);
}
} catch (error) {
console.error(`Brick at position (${position[0]},${position[1]},${position[2]}) doesn't exist!`);
}
if(ore == null || ore.getDurability() <= 0){
// checks for spots that have already been mined
if(ore == null) {
let chunk = getChunk(position[0],position[1],position[2]);
if(chunk.spots.indexOf("x"+position[0]+"y"+position[1]+"z"+position[2])==-1){
chunk.spots.push("x"+position[0]+"y"+position[1]+"z"+position[2]);
}
}
let x1: string = "x"+(position[0]+40)+"y"+position[1]+"z"+position[2];
let chunk = getChunk(position[0]+40,position[1],position[2]);
let positionArray:Array<Vector> = [];
if(chunk.spots.indexOf(x1)==-1){
positionArray.push([position[0]+40,position[1],position[2]])
chunk.spots.push(x1);
}
chunk = getChunk(position[0]-40,position[1],position[2]);
let x2: string = "x"+(position[0]-40)+"y"+position[1]+"z"+position[2];
if(chunk.spots.indexOf(x2)==-1){
positionArray.push([position[0]-40,position[1],position[2]])
chunk.spots.push(x2);
}
chunk = getChunk(position[0],position[1]+40,position[2]);
let y1: string = "x"+(position[0])+"y"+(position[1]+40)+"z"+position[2];
if(chunk.spots.indexOf(y1)==-1){
positionArray.push([position[0],position[1]+40,position[2]])
chunk.spots.push(y1);
}
chunk = getChunk(position[0],position[1]-40,position[2]);
let y2: string = "x"+(position[0])+"y"+(position[1]-40)+"z"+position[2];
if(chunk.spots.indexOf(y2)==-1){
positionArray.push([position[0],position[1]-40,position[2]])
chunk.spots.push(y2);
}
chunk = getChunk(position[0],position[1],position[2]+40);
let z1: string = "x"+(position[0])+"y"+(position[1])+"z"+(position[2]+40);
if(chunk.spots.indexOf(z1)==-1){
positionArray.push([position[0],position[1],position[2]+40])
chunk.spots.push(z1);
}
chunk = getChunk(position[0],position[1],position[2]-40);
let z2: string = "x"+(position[0])+"y"+(position[1])+"z"+(position[2]-40);
if(chunk.spots.indexOf(z2)==-1){
positionArray.push([position[0],position[1],position[2]-40])
chunk.spots.push(z2);
}
this.genOre(positionArray);
Omegga.writeln(
`Bricks.ClearRegion ${position.join(' ')} ${BRICK_SIZE} ${BRICK_SIZE} ${BRICK_SIZE}`
);
}else{
this.omegga.middlePrint(player.name,ore.type.name+" || Durability: "+ore.getDurability());
}
});
return { registeredCommands: ['upgrade','upgrademax','bank','top','?','buyhs'] };
}
async stop() {
console.info("Saving PlayerStats for ALL...")
for(const pss of playerstats){
if(pss!=null && pss != undefined){
this.store.set("playerStatsObject_"+pss.name+"_bank", pss.bank)
this.store.set("playerStatsObject_"+pss.name+"_level", pss.level)
this.store.set("playerStatsObject_"+pss.name+"_ls", pss.lavasuit)
this.store.set("playerStatsObject_"+pss.name+"_lm", pss.lowestY)
this.store.set("playerStatsObject_"+pss.name+"_bm", pss.blocksmined)
}
}
}
//Fat Function should be split for organization.
/**
* Generates ore to the memory arrays / Loads brickData.
* @param posArray
*/
genOre(posArray: Array<Vector>):void{
let positionalData = [];
for(let i = 0; i < posArray.length; i++){
let pos = posArray[i]
let blockPos: Vector = [pos[0],pos[1],pos[2]];
let ore = null;
// ore generator
if(getRandomInt(1000)<1){
ore = new Ore(blockPos,lotto);
ores.push(ore);
}else if(getRandomInt(100)<Math.min(50,-blockPos[2]/7000)){
ore = new Ore(blockPos,lava);
ores.push(ore);
}else if(getRandomInt(100)<4){
let oret = oretypes[getRandomInt(oretypes.length)];
let tries = 0;
while((oret.minY > blockPos[2] || oret.maxY<blockPos[2])&&tries<1000){
oret = oretypes[getRandomInt(oretypes.length)];
tries++;
}
ore = new Ore(blockPos,oret);
ores.push(ore);
}else{
let j = 0;
let stone = stonetypes[j];
while((stone.minY > blockPos[2] || stone.maxY<blockPos[2])&&j < stonetypes.length){
j++;
stone = stonetypes[j];
}
ore = new Ore(blockPos,stone);
ores.push(ore);
}
positionalData.push({
position:pos,
size:[BRICK_SIZE,BRICK_SIZE,BRICK_SIZE],
color:ore.type.color,
material_index:ore.type.material
})
};
const publicUser = {
id: 'ffffffff-ffff-ffff-ffff-ffffffffffff',
name: 'Generator',
};
let save:WriteSaveObject;
save = {
author: {
id: publicUser.id,
name: 'TypeScript',
},
description: 'Load Segment',
map: 'Load Segment',
brick_assets: [ 'PB_DefaultBrick' ],
colors: [
[ 255, 255, 255, 255 ], [ 184, 184, 184, 255 ], [ 136, 136, 136, 255 ],
[ 114, 114, 114, 255 ], [ 90, 90, 90, 255 ], [ 57, 57, 57, 255 ],
[ 35, 35, 35, 255 ], [ 24, 24, 24, 255 ], [ 17, 17, 17, 255 ],
[ 6, 6, 6, 255 ], [ 2, 2, 2, 255 ], [ 0, 0, 0, 255 ],
[ 87, 5, 9, 255 ], [ 235, 6, 6, 255 ], [ 255, 29, 3, 255 ],
[ 246, 73, 6, 255 ], [ 235, 157, 6, 255 ], [ 61, 164, 4, 255 ],
[ 9, 139, 5, 255 ], [ 3, 16, 255, 255 ], [ 12, 244, 255, 255 ],
[ 163, 35, 85, 255 ], [ 48, 8, 72, 255 ], [ 14, 6, 49, 255 ],
[ 41, 25, 25, 255 ], [ 96, 71, 73, 255 ], [ 181, 131, 134, 255 ],
[ 45, 44, 27, 255 ], [ 114, 109, 65, 255 ], [ 144, 139, 100, 255 ],
[ 27, 45, 28, 255 ], [ 65, 114, 68, 255 ], [ 100, 144, 103, 255 ],
[ 30, 39, 41, 255 ], [ 71, 92, 96, 255 ], [ 131, 171, 181, 255 ],
[ 23, 5, 2, 255 ], [ 90, 16, 5, 255 ], [ 77, 20, 1, 255 ],
[ 77, 30, 7, 255 ], [ 144, 60, 18, 255 ], [ 166, 104, 62, 255 ],
[ 255, 159, 78, 255 ], [ 255, 121, 78, 255 ], [ 50, 20, 13, 255 ],
[ 21, 12, 3, 255 ], [ 51, 33, 13, 255 ], [ 194, 163, 58, 255 ],
[ 19, 2, 1, 255 ], [ 73, 4, 1, 255 ], [ 190, 23, 18, 255 ],
[ 190, 59, 53, 255 ], [ 255, 149, 156, 255 ], [ 255, 79, 38, 255 ],
[ 255, 41, 2, 255 ], [ 171, 54, 27, 255 ], [ 109, 64, 5, 255 ],
[ 171, 99, 8, 255 ], [ 255, 146, 11, 255 ], [ 255, 175, 47, 255 ],
[ 22, 37, 1, 255 ], [ 67, 80, 12, 255 ], [ 122, 144, 30, 255 ],
[ 101, 255, 81, 255 ], [ 13, 204, 47, 255 ], [ 0, 77, 0, 255 ],
[ 11, 54, 11, 255 ], [ 5, 30, 3, 255 ], [ 5, 18, 5, 255 ],
[ 8, 43, 27, 255 ], [ 9, 96, 53, 255 ], [ 8, 146, 66, 255 ],
[ 5, 13, 17, 255 ], [ 11, 30, 44, 255 ], [ 1, 34, 64, 255 ],
[ 0, 65, 122, 255 ], [ 8, 118, 200, 255 ], [ 5, 152, 171, 255 ],
[ 80, 147, 163, 255 ], [ 134, 250, 255, 255 ], [ 86, 119, 242, 255 ],
[ 37, 55, 235, 255 ], [ 12, 25, 156, 255 ], [ 1, 4, 44, 255 ],
[ 8, 0, 30, 255 ], [ 18, 0, 57, 255 ], [ 56, 19, 100, 255 ],
[ 141, 45, 255, 255 ], [ 255, 93, 255, 255 ], [ 253, 149, 255, 255 ],
[ 255, 58, 116, 255 ], [ 91, 18, 55, 255 ], [ 255, 24, 255, 255 ],
[ 255, 0, 55, 255 ], [ 127, 0, 29, 255 ], [ 55, 0, 55, 255 ]
],
materials: [
'BMC_Hidden',
'BMC_Ghost',
'BMC_Ghost_Fail',
'BMC_Plastic',
'BMC_Glass',
'BMC_Glow',
'BMC_Metallic',
'BMC_Hologram'
],
brick_owners: [publicUser],
bricks: positionalData
.map(({position, size, color, material_index}) => ({
size: size,
position: position,
color:color,
material_index:material_index,
components:{
BCD_Interact:{
bPlayInteractSound:true,
ConsoleTag:``,
Message:''
},
}
})
)
};
if(save.bricks.length != 0){
Omegga.loadSaveData(save, {quiet: true});
}
}
async getOre(position: Vector) {
for (let index = 0; index < ores.length; index++) {
let element = ores[index];
if(element.location[0] === position[0]){
if(element.location[1] === position[1]){
if(element.location[2] === position[2]){
return element;
}
}
}
}
}
async clearBricks(center: Vector, extent: Vector){
// clear the old door bricks
}
/*
async getPlayer(player: string){
for (const ps of playerstats) {
if(ps.name===player){
return ps;
}
}
let bank = 0;
let level = 1;
let xxl = await this.store.get(player+"_bank" )
let xxk = await this.store.get(player+"_level" )
if(xxl !== null){
bank = +xxl;
}
if(xxk !== null){
level = +xxk;
}
const ps = new PlayerStats(player,level,bank);
playerstats.push(ps);
return ps;
}
*/
}
function getRandomInt(max: number) {
return Math.floor(Math.random() * max);
}
function getChunk(x: number, y: number, z: number){
for(const chunk of spots){
if(x/CHUNK_SIZE==chunk.x){
if(y/CHUNK_SIZE==chunk.y){
if(z/CHUNK_SIZE==chunk.z){
return chunk;
}
}
}
}
let c = new Chunk(x/CHUNK_SIZE,y/CHUNK_SIZE,z/CHUNK_SIZE);
spots.push(c);
return c;
}
/** lookup a brick by position and filter fn
* @param unique when enabled, require this door to be unique
*/
/* export async function getDoorBrickQuery(
region: { center: Vector; extent: Vector },
query: (brick: Brick) => boolean,
unique?: boolean
): Promise<{ brick: Brick; ownerId: string }> {
// get the save data around the clicked brick
const saveData = await Omegga.getSaveData(region);
// no bricks detected
if (!saveData || saveData.bricks.length === 0) return null;
// ensure the brick version has components
if (saveData.version !== 10) return null;
// find brick based on query
const index = saveData.bricks.findIndex(query);
const brick = index > -1 ? saveData.bricks[index] : null;
// prevent multiple bricks in the same position from being clicked
if (
unique &&
index > -1 &&
saveData.bricks.some((b, i) => query(b) && i !== index)
)
return null;
if (!brick) return null;
return { brick, ownerId: saveData.brick_owners[brick.owner_index - 1].id };
}*/
/** get a brick's data from interact metadata (for relative positioning) */
/*export async function getDoorBrickFromInteract(
position: Vector,
): Promise<{ brick: Brick; ownerId: string }> {
// find the brick that has a matching position to this one
return getDoorBrickQuery(
{
center: position as Vector,
extent: [30, 30, 30] as Vector,
},
b => b.position.every((p, i) => position[i] === p),
true
);
}*/