summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockRedstoneOre.h
blob: 4b570ab7309e67520c2ff44b873653d35854f92d (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
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
75
76
77
78
79
80

#pragma once

#include "BlockHandler.h"
#include "BlockOre.h"





class cBlockRedstoneOreHandler :
	public cBlockOreHandler
{
	using Super = cBlockOreHandler;

public:

	using Super::Super;  // Inherit constructor from base

	virtual bool OnUse(
		cChunkInterface & a_ChunkInterface,
		cWorldInterface & a_WorldInterface,
		cPlayer & a_Player,
		int a_BlockX, int a_BlockY, int a_BlockZ,
		eBlockFace a_BlockFace,
		int a_CursorX, int a_CursorY, int a_CursorZ
	) override
	{
		Vector3i BlockPos{a_BlockX, a_BlockY, a_BlockZ};
		a_ChunkInterface.SetBlock(BlockPos, E_BLOCK_REDSTONE_ORE_GLOWING, 0);
		return false;
	}

	virtual void OnDigging(
		cChunkInterface & a_ChunkInterface,
		cWorldInterface & a_WorldInterface,
		cPlayer & a_Player,
		int a_BlockX, int a_BlockY, int a_BlockZ
	) override
	{
		Vector3i BlockPos{a_BlockX, a_BlockY, a_BlockZ};
		a_ChunkInterface.SetBlock(BlockPos, E_BLOCK_REDSTONE_ORE_GLOWING, 0);
	}

	virtual bool IsUseable() override
	{
		return true;
	}
};





class cBlockGlowingRedstoneOreHandler:
	public cBlockOreHandler
{
	using Super = cBlockOreHandler;

public:

	using Super::Super;  // Inherit constructor from base

	virtual void OnUpdate(
		cChunkInterface & a_ChunkInterface,
		cWorldInterface & a_WorldInterface,
		cBlockPluginInterface & a_BlockPluginInterface,
		cChunk & a_Chunk,
		const Vector3i a_RelPos
	) override
	{
		auto BlockPos = a_Chunk.RelativeToAbsolute(a_RelPos);
		a_ChunkInterface.SetBlock(BlockPos, E_BLOCK_REDSTONE_ORE, 0);
	}
};