Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockTracer.h
Go to the documentation of this file.
1 
2 // BlockTracer.h
3 
4 // Declares the classes common for all blocktracers
5 
6 
7 
8 
9 
10 #pragma once
11 
12 
13 
14 
15 
16 #include "Defines.h"
17 #include "ChunkDef.h"
18 
19 
20 
21 
22 // fwd: World.h
23 class cWorld;
24 
25 
26 
27 
28 
29 class cBlockTracer abstract
30 {
31 public:
34  class cCallbacks abstract
35  {
36  public:
37  // Force a virtual destructor in descendants:
38  virtual ~cCallbacks() {}
39 
43  virtual bool OnNextBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, eBlockFace a_EntryFace) = 0;
44 
48  virtual bool OnNextBlockNoData(Vector3i a_BlockPos, eBlockFace a_EntryFace)
49  {
50  UNUSED(a_BlockPos);
51  UNUSED(a_EntryFace);
52  return false;
53  }
54 
61  virtual bool OnOutOfWorld(Vector3d a_BlockPos)
62  {
63  UNUSED(a_BlockPos);
64  return false;
65  }
66 
73  virtual bool OnIntoWorld(Vector3d a_BlockPos)
74  {
75  UNUSED(a_BlockPos);
76  return false;
77  }
78 
82  virtual void OnNoMoreHits(void) {}
83 
87  virtual void OnNoChunk(void) {}
88  } ;
89 
90 
92  cBlockTracer(cWorld & a_World, cCallbacks & a_Callbacks) :
93  m_World(&a_World),
94  m_Callbacks(&a_Callbacks)
95  {
96  }
97 
98 
100  cWorld & SetWorld(cWorld & a_World)
101  {
102  cWorld & Old = *m_World;
103  m_World = &a_World;
104  return Old;
105  }
106 
107 
109  cCallbacks & SetCallbacks(cCallbacks & a_NewCallbacks)
110  {
111  cCallbacks & Old = *m_Callbacks;
112  m_Callbacks = &a_NewCallbacks;
113  return Old;
114  }
115 
116 protected:
118  cWorld * m_World;
119 
121  cCallbacks * m_Callbacks;
122 } ;
123 
124 
125 
126 
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Definition: Defines.h:38
#define UNUSED
Definition: Globals.h:72
Definition: World.h:53