aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/IslandLayer.cpp
blob: 0a6cc3fa02e8c6230dd23179d46669fabaf4fadc (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
#include "stdafx.h"
#include "net.minecraft.world.level.newbiome.layer.h"

IslandLayer::IslandLayer(int64_t seedMixup) : Layer(seedMixup)
{
}

intArray IslandLayer::getArea(int xo, int yo, int w, int h)
{
	intArray result = IntCache::allocate(w * h);
	for (int y = 0; y < h; y++)
	{
		for (int x = 0; x < w; x++)
		{
			initRandom(xo + x, yo + y);
			result[x + y * w] = (nextRandom(10) == 0) ? 1 : 0;
		}
	}
	// if (0, 0) is located here, place an island
	if (xo > -w && xo <= 0 && yo > -h && yo <= 0)
	{
		result[-xo + -yo * w] = 1;
	}
	return result;
}