From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.World/RegionHillsLayer.cpp | 78 ++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Minecraft.World/RegionHillsLayer.cpp (limited to 'Minecraft.World/RegionHillsLayer.cpp') diff --git a/Minecraft.World/RegionHillsLayer.cpp b/Minecraft.World/RegionHillsLayer.cpp new file mode 100644 index 00000000..dad114b0 --- /dev/null +++ b/Minecraft.World/RegionHillsLayer.cpp @@ -0,0 +1,78 @@ +#include "stdafx.h" +#include "net.minecraft.world.level.biome.h" +#include "IntCache.h" +#include "RegionHillsLayer.h" + +RegionHillsLayer::RegionHillsLayer(__int64 seed, shared_ptr parent) : Layer(seed) +{ + this->parent = parent; +} + +intArray RegionHillsLayer::getArea(int xo, int yo, int w, int h) +{ + intArray b = parent->getArea(xo - 1, yo - 1, w + 2, h + 2); + + intArray result = IntCache::allocate(w * h); + for (int y = 0; y < h; y++) + { + for (int x = 0; x < w; x++) + { + initRandom(x + xo, y + yo); + int old = b[(x + 1) + (y + 1) * (w + 2)]; + if (nextRandom(3) == 0) + { + int next = old; + if (old == Biome::desert->id) + { + next = Biome::desertHills->id; + } + else if (old == Biome::forest->id) + { + next = Biome::forestHills->id; + } + else if (old == Biome::taiga->id) + { + next = Biome::taigaHills->id; + } + else if (old == Biome::plains->id) + { + next = Biome::forest->id; + } + else if (old == Biome::iceFlats->id) + { + next = Biome::iceMountains->id; + } + else if (old == Biome::jungle->id) + { + next = Biome::jungleHills->id; + + } + if (next == old) + { + result[x + y * w] = old; + } + else + { + int _n = b[(x + 1) + (y + 1 - 1) * (w + 2)]; + int _e = b[(x + 1 + 1) + (y + 1) * (w + 2)]; + int _w = b[(x + 1 - 1) + (y + 1) * (w + 2)]; + int _s = b[(x + 1) + (y + 1 + 1) * (w + 2)]; + if (_n == old && _e == old && _w == old && _s == old) + { + result[x + y * w] = next; + } + else + { + result[x + y * w] = old; + } + } + } + else + { + result[x + y * w] = old; + } + } + } + + return result; +} \ No newline at end of file -- cgit v1.2.3