the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 122 lines 3.2 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.level.newbiome.layer.h" 3#include "System.h" 4 5VoronoiZoom::VoronoiZoom(__int64 seedMixup, shared_ptr<Layer>parent) : Layer(seedMixup) 6{ 7 this->parent = parent; 8} 9 10intArray VoronoiZoom::getArea(int xo, int yo, int w, int h) 11{ 12 xo -= 2; 13 yo -= 2; 14 int bits = 2; 15 int ss = 1 << bits; 16 int px = xo >> bits; 17 int py = yo >> bits; 18 int pw = (w >> bits) + 3; 19 int ph = (h >> bits) + 3; 20 intArray p = parent->getArea(px, py, pw, ph); 21 22 int ww = pw << bits; 23 int hh = ph << bits; 24 intArray tmp = IntCache::allocate(ww * hh); 25 for (int y = 0; y < ph - 1; y++) 26 { 27 int ul = p[(0 + 0) + (y + 0) * pw]; 28 int dl = p[(0 + 0) + (y + 1) * pw]; 29 for (int x = 0; x < pw - 1; x++) 30 { 31 double s = ss * 0.9; 32 initRandom((x + px) << bits, (y + py) << bits); 33 double x0 = (nextRandom(1024) / 1024.0 - 0.5) * s; 34 double y0 = (nextRandom(1024) / 1024.0 - 0.5) * s; 35 initRandom((x + px + 1) << bits, (y + py) << bits); 36 double x1 = (nextRandom(1024) / 1024.0 - 0.5) * s + ss; 37 double y1 = (nextRandom(1024) / 1024.0 - 0.5) * s; 38 initRandom((x + px) << bits, (y + py + 1) << bits); 39 double x2 = (nextRandom(1024) / 1024.0 - 0.5) * s; 40 double y2 = (nextRandom(1024) / 1024.0 - 0.5) * s + ss; 41 initRandom((x + px + 1) << bits, (y + py + 1) << bits); 42 double x3 = (nextRandom(1024) / 1024.0 - 0.5) * s + ss; 43 double y3 = (nextRandom(1024) / 1024.0 - 0.5) * s + ss; 44 45 int ur = p[(x + 1) + (y + 0) * pw]; 46 int dr = p[(x + 1) + (y + 1) * pw]; 47 48 for (int yy = 0; yy < ss; yy++) 49 { 50 int pp = ((y << bits) + yy) * ww + ((x << bits)); 51 for (int xx = 0; xx < ss; xx++) 52 { 53 double d0 = ((yy - y0) * (yy - y0) + (xx - x0) * (xx - x0)); 54 double d1 = ((yy - y1) * (yy - y1) + (xx - x1) * (xx - x1)); 55 double d2 = ((yy - y2) * (yy - y2) + (xx - x2) * (xx - x2)); 56 double d3 = ((yy - y3) * (yy - y3) + (xx - x3) * (xx - x3)); 57 58 if (d0 < d1 && d0 < d2 && d0 < d3) 59 { 60 tmp[pp++] = ul; 61 } 62 else if (d1 < d0 && d1 < d2 && d1 < d3) 63 { 64 tmp[pp++] = ur; 65 } 66 else if (d2 < d0 && d2 < d1 && d2 < d3) 67 { 68 tmp[pp++] = dl; 69 } 70 else 71 { 72 tmp[pp++] = dr; 73 } 74 } 75 } 76 77 ul = ur; 78 dl = dr; 79 } 80 } 81 intArray result = IntCache::allocate(w * h); 82 for (int y = 0; y < h; y++) 83 { 84 System::arraycopy(tmp, (y + (yo & (ss - 1))) * (pw << bits) + (xo & (ss - 1)), &result, y * w, w); 85 } 86 return result; 87} 88 89int VoronoiZoom::random(int a, int b) 90{ 91 return nextRandom(2) == 0 ? a : b; 92} 93 94int VoronoiZoom::random(int a, int b, int c, int d) 95{ 96 if (b == c && c == d) return b; 97 if (a == b && a == c) return a; 98 if (a == b && a == d) return a; 99 if (a == c && a == d) return a; 100 101 if (a == b && c != d) return a; 102 if (a == c && b != d) return a; 103 if (a == d && b != c) return a; 104 105 if (b == a && c != d) return b; 106 if (b == c && a != d) return b; 107 if (b == d && a != c) return b; 108 109 if (c == a && b != d) return c; 110 if (c == b && a != d) return c; 111 if (c == d && a != b) return c; 112 113 if (d == a && b != c) return c; 114 if (d == b && a != c) return c; 115 if (d == c && a != b) return c; 116 117 int s = nextRandom(4); 118 if (s == 0) return a; 119 if (s == 1) return b; 120 if (s == 2) return c; 121 return d; 122}