Implemented Rotations
This commit is contained in:
parent
0d26e81ab5
commit
65edffd5b0
@ -12,11 +12,11 @@
|
||||
|
||||
|
||||
class cBlockBedHandler :
|
||||
public cMetaRotater<cBlockHandler,0x3,0x02,0x03,0x00,0x01>
|
||||
public cMetaRotater<cBlockHandler,0x3,0x02,0x03,0x00,0x01,true>
|
||||
{
|
||||
public:
|
||||
cBlockBedHandler(BLOCKTYPE a_BlockType)
|
||||
: cMetaRotater<cBlockHandler,0x3,0x02,0x03,0x00,0x01>(a_BlockType)
|
||||
: cMetaRotater<cBlockHandler,0x3,0x02,0x03,0x00,0x01,true>(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -2,16 +2,17 @@
|
||||
|
||||
#include "BlockHandler.h"
|
||||
#include "Chunk.h"
|
||||
#include "MetaRotater.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class cBlockButtonHandler :
|
||||
public cMetaRotater<cBlockHandler,0x07,0x04,0x01,0x03,0x02>
|
||||
public cMetaRotater<cBlockHandler,0x07,0x04,0x01,0x03,0x02,true>
|
||||
{
|
||||
public:
|
||||
cBlockButtonHandler(BLOCKTYPE a_BlockType)
|
||||
: cMetaRotater<cBlockHandler,0x07,0x04,0x01,0x03,0x02>(a_BlockType)
|
||||
: cMetaRotater<cBlockHandler,0x07,0x04,0x01,0x03,0x02,true>(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -4,17 +4,18 @@
|
||||
#include "BlockEntity.h"
|
||||
#include "../BlockArea.h"
|
||||
#include "../Entities/Player.h"
|
||||
#include "MetaRotater.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class cBlockChestHandler :
|
||||
public cMetaRotater<cBlockEntityHandler,0x07,0x04,0x01,0x03,0x02>
|
||||
public cMetaRotater<cBlockEntityHandler,0x07,0x04,0x01,0x03,0x02, true>
|
||||
{
|
||||
public:
|
||||
cBlockChestHandler(BLOCKTYPE a_BlockType)
|
||||
: cMetaRotater<cBlockEntityHandler,0x07,0x02,0x05,0x03,0x04>(a_BlockType)
|
||||
: cMetaRotater<cBlockEntityHandler,0x07,0x02,0x05,0x03,0x04, true>(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -3,17 +3,18 @@
|
||||
|
||||
#include "BlockHandler.h"
|
||||
#include "BlockRedstoneRepeater.h"
|
||||
#include "MetaRotater.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class cBlockComparatorHandler :
|
||||
public cMetaRotater<cBlockHandler,0x03,0x00,0x01,0x02,0x03>
|
||||
public cMetaRotater<cBlockHandler,0x03,0x00,0x01,0x02,0x03, true>
|
||||
{
|
||||
public:
|
||||
cBlockComparatorHandler(BLOCKTYPE a_BlockType)
|
||||
: cMetaRotater<cBlockHandler,0x03,0x00,0x01,0x02,0x03>(a_BlockType)
|
||||
: cMetaRotater<cBlockHandler,0x03,0x00,0x01,0x02,0x03, true>(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -4,14 +4,15 @@
|
||||
#include "BlockHandler.h"
|
||||
#include "../Entities/Player.h"
|
||||
#include "Chunk.h"
|
||||
#include "MetaRotater.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class cBlockDoorHandler :
|
||||
public cMetaRotater<cBlockHandler,0x03,0x01,0x02,0x03,0x00>
|
||||
public cMetaRotater<cBlockHandler,0x03,0x01,0x02,0x03,0x00, true>
|
||||
{
|
||||
typedef super cMetaRotater<cBlockHandler,0x03,0x01,0x02,0x03,0x00>;
|
||||
typedef super cMetaRotater<cBlockHandler,0x03,0x01,0x02,0x03,0x00, true>;
|
||||
public:
|
||||
cBlockDoorHandler(BLOCKTYPE a_BlockType);
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../Piston.h"
|
||||
#include "MetaRotater.h"
|
||||
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "BlockEntity.h"
|
||||
|
||||
#include "MetaRotater.h"
|
||||
|
||||
|
||||
|
||||
|
@ -2,17 +2,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "BlockHandler.h"
|
||||
|
||||
#include "MetaRotater.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class cBlockFenceGateHandler :
|
||||
public cMetaRotater<cBlockHandler,0x03,0x02,0x03,0x00,0x01>
|
||||
public cMetaRotater<cBlockHandler,0x03,0x02,0x03,0x00,0x01, true>
|
||||
{
|
||||
public:
|
||||
cBlockFenceGateHandler(BLOCKTYPE a_BlockType) :
|
||||
cMetaRotater<cBlockHandler,0x03,0x02,0x03,0x00,0x01>(a_BlockType)
|
||||
cMetaRotater<cBlockHandler,0x03,0x02,0x03,0x00,0x01, true>(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -2,17 +2,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "BlockHandler.h"
|
||||
|
||||
#include "MetaRotater.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class cBlockStairsHandler :
|
||||
public cBlockHandler
|
||||
public cMetaRotater<cBlockHandler,0x03,0x03,0x00,0x02,0x01,true>
|
||||
{
|
||||
public:
|
||||
cBlockStairsHandler(BLOCKTYPE a_BlockType) :
|
||||
cBlockHandler(a_BlockType)
|
||||
cMetaRotater<cBlockHandler,0x03,0x03,0x00,0x02,0x01,true>(a_BlockType)
|
||||
{
|
||||
|
||||
}
|
||||
@ -96,54 +96,6 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Bits 3 and 4 stay, the rest is swapped around according to a table:
|
||||
NIBBLETYPE TopBits = (a_Meta & 0x0c);
|
||||
switch (a_Meta & 0x03)
|
||||
{
|
||||
case 0x00: return TopBits | 0x03; // East -> North
|
||||
case 0x01: return TopBits | 0x02; // West -> South
|
||||
case 0x02: return TopBits | 0x00; // South -> East
|
||||
case 0x03: return TopBits | 0x01; // North -> West
|
||||
}
|
||||
// Not reachable, but to avoid a compiler warning:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Bits 3 and 4 stay, the rest is swapped around according to a table:
|
||||
NIBBLETYPE TopBits = (a_Meta & 0x0c);
|
||||
switch (a_Meta & 0x03)
|
||||
{
|
||||
case 0x00: return TopBits | 0x02; // East -> South
|
||||
case 0x01: return TopBits | 0x03; // West -> North
|
||||
case 0x02: return TopBits | 0x01; // South -> West
|
||||
case 0x03: return TopBits | 0x00; // North -> East
|
||||
}
|
||||
// Not reachable, but to avoid a compiler warning:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Bits 3 and 4 stay, the rest is swapped around according to a table:
|
||||
NIBBLETYPE TopBits = (a_Meta & 0x0c);
|
||||
switch (a_Meta & 0x03)
|
||||
{
|
||||
case 0x00: return TopBits | 0x00; // East -> East
|
||||
case 0x01: return TopBits | 0x01; // West -> West
|
||||
case 0x02: return TopBits | 0x03; // South -> North
|
||||
case 0x03: return TopBits | 0x02; // North -> South
|
||||
}
|
||||
// Not reachable, but to avoid a compiler warning:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Toggle bit 3:
|
||||
@ -151,20 +103,6 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Bits 3 and 4 stay, the rest is swapped around according to a table:
|
||||
NIBBLETYPE TopBits = (a_Meta & 0x0c);
|
||||
switch (a_Meta & 0x03)
|
||||
{
|
||||
case 0x00: return TopBits | 0x01; // East -> West
|
||||
case 0x01: return TopBits | 0x00; // West -> East
|
||||
case 0x02: return TopBits | 0x02; // South -> South
|
||||
case 0x03: return TopBits | 0x03; // North -> North
|
||||
}
|
||||
// Not reachable, but to avoid a compiler warning:
|
||||
return 0;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
|
@ -2,17 +2,17 @@
|
||||
|
||||
#include "BlockHandler.h"
|
||||
#include "../Chunk.h"
|
||||
|
||||
#include "MetaRotater.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class cBlockTorchHandler :
|
||||
public cBlockHandler
|
||||
public cMetaRotater<cBlockHandler,0x7,0x4,0x1,0x3,0x2>
|
||||
{
|
||||
public:
|
||||
cBlockTorchHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
: cMetaRotater<cBlockHandler,0x7,0x4,0x1,0x3,0x2>(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@ -185,67 +185,6 @@ public:
|
||||
{
|
||||
return "step.wood";
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Bit 4 stays, the rest is swapped around according to a table:
|
||||
NIBBLETYPE TopBits = (a_Meta & 0x08);
|
||||
switch (a_Meta & 0x07)
|
||||
{
|
||||
case 0x01: return TopBits | 0x04; // East -> North
|
||||
case 0x02: return TopBits | 0x03; // West -> South
|
||||
case 0x03: return TopBits | 0x01; // South -> East
|
||||
case 0x04: return TopBits | 0x02; // North -> West
|
||||
default: return a_Meta; // Floor -> Floor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Bit 4 stays, the rest is swapped around according to a table:
|
||||
NIBBLETYPE TopBits = (a_Meta & 0x08);
|
||||
switch (a_Meta & 0x07)
|
||||
{
|
||||
case 0x01: return TopBits | 0x03; // East -> South
|
||||
case 0x02: return TopBits | 0x04; // West -> North
|
||||
case 0x03: return TopBits | 0x02; // South -> West
|
||||
case 0x04: return TopBits | 0x01; // North -> East
|
||||
default: return a_Meta; // Floor -> Floor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Bit 4 stays, the rest is swapped around according to a table:
|
||||
NIBBLETYPE TopBits = (a_Meta & 0x08);
|
||||
switch (a_Meta & 0x07)
|
||||
{
|
||||
case 0x03: return TopBits | 0x04; // South -> North
|
||||
case 0x04: return TopBits | 0x03; // North -> South
|
||||
default: return a_Meta; // Keep the rest
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Mirroring around the XZ plane doesn't make sense for floor torches,
|
||||
// the others stay the same, so let's keep all the metas the same.
|
||||
// The base class does tht for us, no need to override MetaMirrorXZ()
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Bit 4 stays, the rest is swapped around according to a table:
|
||||
NIBBLETYPE TopBits = (a_Meta & 0x08);
|
||||
switch (a_Meta & 0x07)
|
||||
{
|
||||
case 0x01: return TopBits | 0x02; // East -> West
|
||||
case 0x02: return TopBits | 0x01; // West -> East
|
||||
default: return a_Meta; // Keep the rest
|
||||
}
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
|
@ -2,17 +2,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "BlockHandler.h"
|
||||
|
||||
#include "MetaRotater.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class cBlockVineHandler :
|
||||
public cBlockHandler
|
||||
public cMetaRotater<cBlockHandler,0xF,0x4,0x8,0x1,0x2,true>
|
||||
{
|
||||
public:
|
||||
cBlockVineHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
: cMetaRotater<cBlockHandler,0xF,0x4,0x8,0x1,0x2,true>(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@ -169,31 +169,7 @@ public:
|
||||
a_World->SetBlock(X, Y - 1, Z, E_BLOCK_VINES, a_World->GetBlockMeta(X, Y, Z));
|
||||
}
|
||||
}
|
||||
|
||||
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
return ((a_Meta >> 1) | (a_Meta << 3)) & 0x0f; // Rotate bits to the right
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
return ((a_Meta << 1) | (a_Meta >> 3)) & 0x0f; // Rotate bits to the left
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Bits 2 and 4 stay, bits 1 and 3 swap
|
||||
return ((a_Meta & 0x0a) | ((a_Meta & 0x01) << 2) | ((a_Meta & 0x04) >> 2));
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Bits 1 and 3 stay, bits 2 and 4 swap
|
||||
return ((a_Meta & 0x05) | ((a_Meta & 0x02) << 2) | ((a_Meta & 0x08) >> 2));
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user