aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/VinesFeature.cpp
blob: 1f2dacf4d9d4d494297310bdad933d3b0efbd1c8 (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
#include "stdafx.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.level.tile.h"
#include "net.minecraft.h"
#include "VinesFeature.h"


VinesFeature::VinesFeature()
{
}

bool VinesFeature::place(Level *level, Random *random, int x, int y, int z)
{
	int ox = x;
	int oz = z;

	while (y < 128)
	{
		if (level->isEmptyTile(x, y, z))
		{
			for (int face = Facing::NORTH; face <= Facing::EAST; face++)
			{
				if (Tile::vine->mayPlace(level, x, y, z, face))
				{
					level->setTileAndData(x, y, z, Tile::vine_Id, 1 << Direction::FACING_DIRECTION[Facing::OPPOSITE_FACING[face]], Tile::UPDATE_CLIENTS);
					break;
				}
			}
		}
		else
		{
			x = ox + random->nextInt(4) - random->nextInt(4);
			z = oz + random->nextInt(4) - random->nextInt(4);
		}
		y++;
	}

	return true;
}