diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/FuzzyZoomLayer.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.World/FuzzyZoomLayer.cpp')
| -rw-r--r-- | Minecraft.World/FuzzyZoomLayer.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Minecraft.World/FuzzyZoomLayer.cpp b/Minecraft.World/FuzzyZoomLayer.cpp new file mode 100644 index 00000000..65c6709e --- /dev/null +++ b/Minecraft.World/FuzzyZoomLayer.cpp @@ -0,0 +1,72 @@ +#include "stdafx.h" +#include "System.h" +#include "net.minecraft.world.level.newbiome.layer.h" + +FuzzyZoomLayer::FuzzyZoomLayer(__int64 seedMixup, shared_ptr<Layer>parent) : Layer(seedMixup) +{ + this->parent = parent; +} + +intArray FuzzyZoomLayer::getArea(int xo, int yo, int w, int h) +{ + int px = xo >> 1; + int py = yo >> 1; + int pw = (w >> 1) + 3; + int ph = (h >> 1) + 3; + intArray p = parent->getArea(px, py, pw, ph); + + intArray tmp = IntCache::allocate((pw * 2) * (ph * 2)); + int ww = (pw << 1); + for (int y = 0; y < ph - 1; y++) + { + int ry = y << 1; + int pp = ry * ww; + int ul = p[(0 + 0) + (y + 0) * pw]; + int dl = p[(0 + 0) + (y + 1) * pw]; + for (int x = 0; x < pw - 1; x++) + { + initRandom((x + px) << 1, (y + py) << 1); + int ur = p[(x + 1) + (y + 0) * pw]; + int dr = p[(x + 1) + (y + 1) * pw]; + + tmp[pp] = ul; + tmp[pp++ + ww] = random(ul, dl); + tmp[pp] = random(ul, ur); + tmp[pp++ + ww] = random(ul, ur, dl, dr); + + ul = ur; + dl = dr; + } + } + intArray result = IntCache::allocate(w * h); + for (int y = 0; y < h; y++) + { + System::arraycopy(tmp, (y + (yo & 1)) * (pw << 1) + (xo & 1), &result, y * w, w); + } + + return result; +} + +int FuzzyZoomLayer::random(int a, int b) +{ + return nextRandom(2) == 0 ? a : b; +} + +int FuzzyZoomLayer::random(int a, int b, int c, int d) +{ + int s = nextRandom(4); + if (s == 0) return a; + if (s == 1) return b; + if (s == 2) return c; + return d; +} + +shared_ptr<Layer>FuzzyZoomLayer::zoom(__int64 seed, shared_ptr<Layer>sup, int count) +{ + shared_ptr<Layer> result = sup; + for (int i = 0; i < count; i++) + { + result = shared_ptr<Layer>(new FuzzyZoomLayer(seed + i, result)); + } + return result; +}
\ No newline at end of file |
