aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/RegionHillsLayer.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/RegionHillsLayer.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/RegionHillsLayer.cpp')
-rw-r--r--Minecraft.World/RegionHillsLayer.cpp78
1 files changed, 78 insertions, 0 deletions
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<Layer> 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