From 8464f689ea214d3c30105ae58539885cf1268317 Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 4 Feb 2014 10:59:05 -0800 Subject: Improved Type safety of eBlockFace May Fix #640 --- src/Piston.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/Piston.h') diff --git a/src/Piston.h b/src/Piston.h index 92ddf6938..9bbc8c6b9 100644 --- a/src/Piston.h +++ b/src/Piston.h @@ -2,7 +2,7 @@ #pragma once - +#include "Defines.h" // fwd: World.h @@ -54,6 +54,25 @@ public: } } } + + static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) + { + switch (a_MetaData) + { + //case -1: return BLOCK_FACE_NONE; //can never happen as metadata is unsigned + case 0x0: return BLOCK_FACE_YM; + case 0x1: return BLOCK_FACE_YP; + case 0x2: return BLOCK_FACE_ZM; + case 0x3: return BLOCK_FACE_ZP; + case 0x4: return BLOCK_FACE_XM; + case 0x5: return BLOCK_FACE_XP; + default: + { + ASSERT(!"Invalid Metadata"); + return BLOCK_FACE_NONE; + } + } + } void ExtendPiston( int, int, int ); void RetractPiston( int, int, int ); -- cgit v1.2.3