aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/ShoreLayer.cpp
blob: 7ae52557dd0ead20b054ca19c110046394d9f40a (plain)
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
#include "stdafx.h"
#include "net.minecraft.world.level.newbiome.layer.h"
#include "net.minecraft.world.level.biome.h"

ShoreLayer::ShoreLayer(int64_t seed, shared_ptr<Layer> parent) : Layer(seed)
{
	this->parent = parent;
}

intArray ShoreLayer::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 (old == Biome::mushroomIsland->id)
			{
                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 == Biome::ocean->id || _e == Biome::ocean->id || _w == Biome::ocean->id || _s == Biome::ocean->id)
				{
                    result[x + y * w] = Biome::mushroomIslandShore->id;
                }
				else
				{
                    result[x + y * w] = old;
                }
			}
			else if (old != Biome::ocean->id && old != Biome::river->id && old != Biome::swampland->id && old != Biome::extremeHills->id)
			{
				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 == Biome::ocean->id || _e == Biome::ocean->id || _w == Biome::ocean->id || _s == Biome::ocean->id)
				{
					result[x + y * w] = Biome::beaches->id;
				}
				else
				{
					result[x + y * w] = old;
				}
			}
			else if (old == Biome::extremeHills->id)
			{
				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 != Biome::extremeHills->id || _e != Biome::extremeHills->id || _w != Biome::extremeHills->id || _s != Biome::extremeHills->id)
				{
					result[x + y * w] = Biome::smallerExtremeHills->id;
				}
				else
				{
					result[x + y * w] = old;
				}
			}
			else
			{
                result[x + y * w] = old;
            }
        }
    }

    return result;
}