summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockNewLeaves.h
blob: 5a267e8c67cf5dafa7bcbcd70b99c8535473c8c6 (plain) (blame)
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
#pragma once
#include "BlockHandler.h"
#include "BlockLeaves.h"
#include "../World.h"






class cBlockNewLeavesHandler :
	public cBlockLeavesHandler
{
public:
	cBlockNewLeavesHandler(BLOCKTYPE a_BlockType)
		: cBlockLeavesHandler(a_BlockType)
	{
	}


	virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
	{
		MTRand rand;

		// Only the first 2 bits contain the display information, the others are for growing
		if (rand.randInt(5) == 0)
		{
			a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, (a_BlockMeta & 3) + 4));
		}
	}


	void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override
	{
		cBlockHandler::OnDestroyed(a_ChunkInterface, a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ);
	}
} ;