summaryrefslogtreecommitdiffstats
path: root/source/Torch.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-24 00:09:57 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-24 00:09:57 +0200
commitecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26 (patch)
tree898e37fe747f0fdcefeb88f833557fd45db3347c /source/Torch.h
parentSource files cleanup: ChunkDataSerializer is Protocol-related (diff)
downloadcuberite-ecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26.tar
cuberite-ecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26.tar.gz
cuberite-ecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26.tar.bz2
cuberite-ecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26.tar.lz
cuberite-ecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26.tar.xz
cuberite-ecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26.tar.zst
cuberite-ecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26.zip
Diffstat (limited to 'source/Torch.h')
-rw-r--r--source/Torch.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/source/Torch.h b/source/Torch.h
new file mode 100644
index 000000000..fa301c3d4
--- /dev/null
+++ b/source/Torch.h
@@ -0,0 +1,77 @@
+
+#pragma once
+#include "Vector3i.h"
+#include "Defines.h"
+
+
+
+
+
+class cTorch //tolua_export
+{ //tolua_export
+public:
+
+ static char DirectionToMetaData( char a_Direction ) //tolua_export
+ { //tolua_export
+ switch (a_Direction)
+ {
+ case BLOCK_FACE_BOTTOM: ASSERT(!"Shouldn't be getting this direction"); return 0;
+ case BLOCK_FACE_TOP: return E_META_TORCH_FLOOR;
+ case BLOCK_FACE_EAST: return E_META_TORCH_EAST;
+ case BLOCK_FACE_WEST: return E_META_TORCH_WEST;
+ case BLOCK_FACE_NORTH: return E_META_TORCH_NORTH;
+ case BLOCK_FACE_SOUTH: return E_META_TORCH_SOUTH;
+ default:
+ {
+ ASSERT(!"Unhandled torch direction!");
+ break;
+ }
+ };
+ return 0x0;
+ } //tolua_export
+
+
+ static char MetaDataToDirection(char a_MetaData) //tolua_export
+ { //tolua_export
+ switch (a_MetaData)
+ {
+ case 0: return BLOCK_FACE_TOP; // by default, the torches stand on the ground
+ case E_META_TORCH_FLOOR: return BLOCK_FACE_TOP;
+ case E_META_TORCH_EAST: return BLOCK_FACE_EAST;
+ case E_META_TORCH_WEST: return BLOCK_FACE_WEST;
+ case E_META_TORCH_NORTH: return BLOCK_FACE_NORTH;
+ case E_META_TORCH_SOUTH: return BLOCK_FACE_SOUTH;
+ default:
+ {
+ ASSERT(!"Unhandled torch metadata");
+ break;
+ }
+ }
+ return 0;
+ } //tolua_export
+
+
+ static bool IsAttachedTo(const Vector3i & a_TorchPos, char a_TorchMeta, const Vector3i & a_BlockPos)
+ {
+ switch (a_TorchMeta)
+ {
+ case 0x0:
+ case E_META_TORCH_FLOOR: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 1, 0)));
+ case E_META_TORCH_EAST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, -1)));
+ case E_META_TORCH_WEST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, 1)));
+ case E_META_TORCH_NORTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(-1, 0, 0)));
+ case E_META_TORCH_SOUTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(1, 0, 0)));
+ default:
+ {
+ ASSERT(!"Unhandled torch meta!");
+ break;
+ }
+ }
+ return false;
+ }
+
+} ; //tolua_export
+
+
+
+