1
0
cuberite-2a/src/Blocks/BlockObserver.h
Tiger Wang 68cced73af
BlockHandler initialisation is a constant expression (#4891)
* BlockHandler initialisation is a constant expression

If we can't make it all namespaces, this is the next best I guess.

+ Tag handlers constexpr, const as needed
+ Inherit constructors
* Privatise handler functions

* More constexpr

Co-authored-by: Alexander Harkness <me@bearbin.net>
2020-09-20 13:50:52 +00:00

41 lines
865 B
C++

#pragma once
#include "BlockHandler.h"
#include "Mixins.h"
class cBlockObserverHandler:
public cClearMetaOnDrop<cPitchYawRotator<cBlockHandler>>
{
using Super = cClearMetaOnDrop<cPitchYawRotator<cBlockHandler>>;
public:
using Super::Super;
inline static Vector3i GetObservingFaceOffset(NIBBLETYPE a_Meta)
{
return -GetSignalOutputOffset(a_Meta);
}
inline static Vector3i GetSignalOutputOffset(NIBBLETYPE a_Meta)
{
switch (a_Meta & 0x7)
{
case 0x00: return { 0, 1, 0 };
case 0x01: return { 0, -1, 0 };
case 0x02: return { 0, 0, 1 };
case 0x03: return { 0, 0, -1 };
case 0x04: return { 1, 0, 0 };
case 0x05: return { -1, 0, 0 };
default:
{
LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
ASSERT(!"Unknown metadata while determining orientation of observer!");
return { 0, 0, 0 };
}
}
}
};