1
0

Re-implement repeater locking

This commit is contained in:
Tiger Wang
2020-04-17 09:40:26 +01:00
parent a55f61548e
commit c1ea5f982d
3 changed files with 111 additions and 20 deletions

View File

@@ -77,38 +77,42 @@ public:
return 11;
}
inline static Vector3i GetRearCoordinateOffset(NIBBLETYPE a_Meta)
inline static Vector3i GetLeftCoordinateOffset(NIBBLETYPE a_Meta)
{
switch (a_Meta & 0x3) // We only want the direction (bottom) bits
switch (a_Meta & E_META_REDSTONE_REPEATER_FACING_MASK) // We only want the direction (bottom) bits
{
case 0x0: return {0, 0, 1};
case 0x1: return {-1, 0, 0};
case 0x2: return {0, 0, -1};
case 0x3: return {1, 0, 0};
case E_META_REDSTONE_REPEATER_FACING_ZM: return { -1, 0, 0 };
case E_META_REDSTONE_REPEATER_FACING_XP: return { 0, 0, -1 };
case E_META_REDSTONE_REPEATER_FACING_ZP: return { 1, 0, 0 };
case E_META_REDSTONE_REPEATER_FACING_XM: return { 0, 0, 1 };
default:
{
LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
ASSERT(!"Unknown metadata while determining orientation of repeater!");
return {0, 0, 0};
return { 0, 0, 0 };
}
}
}
inline static Vector3i GetFrontCoordinateOffset(NIBBLETYPE a_Meta)
{
switch (a_Meta & 0x3) // We only want the direction (bottom) bits
return -GetRearCoordinateOffset(a_Meta);
}
inline static Vector3i GetRearCoordinateOffset(NIBBLETYPE a_Meta)
{
switch (a_Meta & E_META_REDSTONE_REPEATER_FACING_MASK) // We only want the direction (bottom) bits
{
case 0x0: return {0, 0, -1};
case 0x1: return {1, 0, 0};
case 0x2: return {0, 0, 1};
case 0x3: return {-1, 0, 0};
case E_META_REDSTONE_REPEATER_FACING_ZM: return { 0, 0, 1 };
case E_META_REDSTONE_REPEATER_FACING_XP: return { -1, 0, 0 };
case E_META_REDSTONE_REPEATER_FACING_ZP: return { 0, 0, -1 };
case E_META_REDSTONE_REPEATER_FACING_XM: return { 1, 0, 0 };
default:
{
LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
ASSERT(!"Unknown metadata while determining orientation of repeater!");
return {0, 0, 0};
return { 0, 0, 0 };
}
}
}