1
0
Fork 0

Merge pull request #834 from narroo/issue503

Issue503 pull Request
This commit is contained in:
Mattes D 2014-03-30 16:58:42 +02:00
commit e474f40ac9
23 changed files with 372 additions and 121 deletions

View File

@ -4,7 +4,7 @@
#include "BlockHandler.h" #include "BlockHandler.h"
#include "ChunkInterface.h" #include "ChunkInterface.h"
#include "WorldInterface.h" #include "WorldInterface.h"
#include "MetaRotater.h" #include "MetaRotator.h"
#include "../Entities/Player.h" #include "../Entities/Player.h"
@ -12,11 +12,11 @@
class cBlockBedHandler : class cBlockBedHandler :
public cMetaRotater<cBlockHandler, 0x3, 0x02, 0x03, 0x00, 0x01, true> public cMetaRotator<cBlockHandler, 0x3, 0x02, 0x03, 0x00, 0x01, true>
{ {
public: public:
cBlockBedHandler(BLOCKTYPE a_BlockType) cBlockBedHandler(BLOCKTYPE a_BlockType)
: cMetaRotater<cBlockHandler, 0x3, 0x02, 0x03, 0x00, 0x01,true>(a_BlockType) : cMetaRotator<cBlockHandler, 0x3, 0x02, 0x03, 0x00, 0x01,true>(a_BlockType)
{ {
} }

View File

@ -2,17 +2,17 @@
#include "BlockHandler.h" #include "BlockHandler.h"
#include "Chunk.h" #include "Chunk.h"
#include "MetaRotater.h" #include "MetaRotator.h"
class cBlockButtonHandler : class cBlockButtonHandler :
public cMetaRotater<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, true> public cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, true>
{ {
public: public:
cBlockButtonHandler(BLOCKTYPE a_BlockType) cBlockButtonHandler(BLOCKTYPE a_BlockType)
: cMetaRotater<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, true>(a_BlockType) : cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, true>(a_BlockType)
{ {
} }

View File

@ -4,18 +4,18 @@
#include "BlockEntity.h" #include "BlockEntity.h"
#include "../BlockArea.h" #include "../BlockArea.h"
#include "../Entities/Player.h" #include "../Entities/Player.h"
#include "MetaRotater.h" #include "MetaRotator.h"
class cBlockChestHandler : class cBlockChestHandler :
public cMetaRotater<cBlockEntityHandler, 0x07, 0x04, 0x01, 0x03, 0x02, true> public cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>
{ {
public: public:
cBlockChestHandler(BLOCKTYPE a_BlockType) cBlockChestHandler(BLOCKTYPE a_BlockType)
: cMetaRotater<cBlockEntityHandler, 0x07, 0x04, 0x01, 0x03, 0x02, true>(a_BlockType) : cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
{ {
} }

View File

@ -3,18 +3,18 @@
#include "BlockHandler.h" #include "BlockHandler.h"
#include "BlockRedstoneRepeater.h" #include "BlockRedstoneRepeater.h"
#include "MetaRotater.h" #include "MetaRotator.h"
class cBlockComparatorHandler : class cBlockComparatorHandler :
public cMetaRotater<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03, true> public cMetaRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03, true>
{ {
public: public:
cBlockComparatorHandler(BLOCKTYPE a_BlockType) cBlockComparatorHandler(BLOCKTYPE a_BlockType)
: cMetaRotater<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03, true>(a_BlockType) : cMetaRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03, true>(a_BlockType)
{ {
} }

View File

@ -110,3 +110,87 @@ const char * cBlockDoorHandler::GetStepSound(void)
NIBBLETYPE cBlockDoorHandler::MetaRotateCCW(NIBBLETYPE a_Meta)
{
if (a_Meta & 0x08)
{
return a_Meta;
}
else
{
return super::MetaRotateCCW(a_Meta);
}
}
NIBBLETYPE cBlockDoorHandler::MetaRotateCW(NIBBLETYPE a_Meta)
{
if (a_Meta & 0x08)
{
return a_Meta;
}
else
{
return super::MetaRotateCW(a_Meta);
}
}
NIBBLETYPE cBlockDoorHandler::MetaMirrorXY(NIBBLETYPE a_Meta)
{
// Top bit (0x08) contains door panel type (Top/Bottom panel) Only Bottom panels contain position data
// Return a_Meta if panel is a top panel (0x08 bit is set to 1)
// Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored
// in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
// so the function can only see either the hinge position or orientation, but not both, at any given time. The class itself
// needs extra datamembers.
if (a_Meta & 0x08) return a_Meta;
// Holds open/closed meta data. 0x0C == 1100.
NIBBLETYPE OtherMeta = a_Meta & 0x0C;
// Mirrors according to a table. 0x03 == 0011.
switch (a_Meta & 0x03)
{
case 0x03: return 0x01 + OtherMeta; // South -> North
case 0x01: return 0x03 + OtherMeta; // North -> South
}
// Not Facing North or South; No change.
return a_Meta;
}
NIBBLETYPE cBlockDoorHandler::MetaMirrorYZ(NIBBLETYPE a_Meta)
{
// Top bit (0x08) contains door panel type (Top/Bottom panel) Only Bottom panels contain position data
// Return a_Meta if panel is a top panel (0x08 bit is set to 1)
// Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored
// in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
// so the function can only see either the hinge position or orientation, but not both, at any given time.The class itself
// needs extra datamembers.
if (a_Meta & 0x08) return a_Meta;
// Holds open/closed meta data. 0x0C == 1100.
NIBBLETYPE OtherMeta = a_Meta & 0x0C;
// Mirrors according to a table. 0x03 == 0011.
switch (a_Meta & 0x03)
{
case 0x00: return 0x02 + OtherMeta; // West -> East
case 0x02: return 0x00 + OtherMeta; // East -> West
}
// Not Facing North or South; No change.
return a_Meta;
}

View File

@ -4,15 +4,15 @@
#include "BlockHandler.h" #include "BlockHandler.h"
#include "../Entities/Player.h" #include "../Entities/Player.h"
#include "Chunk.h" #include "Chunk.h"
#include "MetaRotater.h" #include "MetaRotator.h"
class cBlockDoorHandler : class cBlockDoorHandler :
public cMetaRotater<cBlockHandler, 0x03, 0x01, 0x02, 0x03, 0x00, true> public cMetaRotator<cBlockHandler, 0x03, 0x01, 0x02, 0x03, 0x00, true>
{ {
typedef cMetaRotater<cBlockHandler, 0x03, 0x01, 0x02, 0x03, 0x00, true> super; typedef cMetaRotator<cBlockHandler, 0x03, 0x01, 0x02, 0x03, 0x00, true> super;
public: public:
cBlockDoorHandler(BLOCKTYPE a_BlockType); cBlockDoorHandler(BLOCKTYPE a_BlockType);
@ -21,6 +21,10 @@ public:
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override; virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override;
virtual const char * GetStepSound(void) override; virtual const char * GetStepSound(void) override;
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override;
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override;
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override;
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override;
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player, cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
@ -142,14 +146,14 @@ public:
static void ChangeDoor(cChunkInterface & a_ChunkInterface, int a_X, int a_Y, int a_Z) static void ChangeDoor(cChunkInterface & a_ChunkInterface, int a_X, int a_Y, int a_Z)
{ {
NIBBLETYPE OldMetaData = a_ChunkInterface.GetBlockMeta(a_X, a_Y, a_Z); NIBBLETYPE OldMetaData = a_ChunkInterface.GetBlockMeta(a_X, a_Y, a_Z);
a_ChunkInterface.SetBlockMeta(a_X, a_Y, a_Z, ChangeStateMetaData(OldMetaData)); a_ChunkInterface.SetBlockMeta(a_X, a_Y, a_Z, ChangeStateMetaData(OldMetaData));
if (OldMetaData & 8) if (OldMetaData & 8)
{ {
// Current block is top of the door // Current block is top of the door
BLOCKTYPE BottomBlock = a_ChunkInterface.GetBlock(a_X, a_Y - 1, a_Z); BLOCKTYPE BottomBlock = a_ChunkInterface.GetBlock(a_X, a_Y - 1, a_Z);
NIBBLETYPE BottomMeta = a_ChunkInterface.GetBlockMeta(a_X, a_Y - 1, a_Z); NIBBLETYPE BottomMeta = a_ChunkInterface.GetBlockMeta(a_X, a_Y - 1, a_Z);
if (IsDoor(BottomBlock) && !(BottomMeta & 8)) if (IsDoor(BottomBlock) && !(BottomMeta & 8))
{ {
@ -168,62 +172,6 @@ public:
} }
} }
} }
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
{
if (a_Meta & 0x08)
{
return a_Meta;
}
else
{
return super::MetaRotateCCW(a_Meta);
}
}
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
{
if (a_Meta & 0x08)
{
return a_Meta;
}
else
{
return super::MetaRotateCW(a_Meta);
}
}
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
{
if (a_Meta & 0x08)
{
return a_Meta;
}
else
{
return super::MetaMirrorXY(a_Meta);
}
}
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
{
if (a_Meta & 0x08)
{
return a_Meta;
}
else
{
return super::MetaMirrorYZ(a_Meta);
}
}
} ; } ;

View File

@ -6,18 +6,18 @@
#pragma once #pragma once
#include "../Piston.h" #include "../Piston.h"
#include "MetaRotater.h" #include "MetaRotator.h"
class cBlockDropSpenserHandler : class cBlockDropSpenserHandler :
public cMetaRotater<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04> public cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>
{ {
public: public:
cBlockDropSpenserHandler(BLOCKTYPE a_BlockType) : cBlockDropSpenserHandler(BLOCKTYPE a_BlockType) :
cMetaRotater<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType) cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
{ {
} }

View File

@ -2,17 +2,17 @@
#pragma once #pragma once
#include "BlockEntity.h" #include "BlockEntity.h"
#include "MetaRotater.h" #include "MetaRotator.h"
class cBlockEnderchestHandler : class cBlockEnderchestHandler :
public cMetaRotater<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04> public cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>
{ {
public: public:
cBlockEnderchestHandler(BLOCKTYPE a_BlockType) cBlockEnderchestHandler(BLOCKTYPE a_BlockType)
: cMetaRotater<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType) : cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
{ {
} }

View File

@ -2,17 +2,17 @@
#pragma once #pragma once
#include "BlockHandler.h" #include "BlockHandler.h"
#include "MetaRotater.h" #include "MetaRotator.h"
class cBlockFenceGateHandler : class cBlockFenceGateHandler :
public cMetaRotater<cBlockHandler, 0x03, 0x02, 0x03, 0x00, 0x01, true> public cMetaRotator<cBlockHandler, 0x03, 0x02, 0x03, 0x00, 0x01, true>
{ {
public: public:
cBlockFenceGateHandler(BLOCKTYPE a_BlockType) : cBlockFenceGateHandler(BLOCKTYPE a_BlockType) :
cMetaRotater<cBlockHandler, 0x03, 0x02, 0x03, 0x00, 0x01, true>(a_BlockType) cMetaRotator<cBlockHandler, 0x03, 0x02, 0x03, 0x00, 0x01, true>(a_BlockType)
{ {
} }

View File

@ -4,17 +4,17 @@
#include "BlockEntity.h" #include "BlockEntity.h"
#include "../World.h" #include "../World.h"
#include "../Piston.h" #include "../Piston.h"
#include "MetaRotator.h"
class cBlockFurnaceHandler : class cBlockFurnaceHandler :
public cBlockEntityHandler public cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>
{ {
public: public:
cBlockFurnaceHandler(BLOCKTYPE a_BlockType) : cBlockFurnaceHandler(BLOCKTYPE a_BlockType)
cBlockEntityHandler(a_BlockType) : cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
{ {
} }

View File

@ -3,16 +3,16 @@
// Declares the cBlockHopperHandler class representing the handler for the Hopper block // Declares the cBlockHopperHandler class representing the handler for the Hopper block
#include "MetaRotator.h"
class cBlockHopperHandler : class cBlockHopperHandler :
public cBlockEntityHandler public cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>
{ {
public: public:
cBlockHopperHandler(BLOCKTYPE a_BlockType) cBlockHopperHandler(BLOCKTYPE a_BlockType)
: cBlockEntityHandler(a_BlockType) : cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
{ {
} }
@ -39,6 +39,21 @@ public:
} }
return true; return true;
} }
virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
{
// Bit 0x08 is a flag. Lowest three bits are position. 0x08 == 1000
NIBBLETYPE OtherMeta = a_Meta & 0x08;
// Mirrors defined by by a table. (Source, mincraft.gamepedia.com) 0x07 == 0111
switch (a_Meta & 0x07)
{
case 0x00: return 0x01 + OtherMeta; // Down -> Up
case 0x01: return 0x00 + OtherMeta; // Up -> Down
}
// Not Facing Up or Down; No change.
return a_Meta;
}
} ; } ;

View File

@ -9,11 +9,11 @@
class cBlockLadderHandler : class cBlockLadderHandler :
public cBlockHandler public cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04>
{ {
public: public:
cBlockLadderHandler(BLOCKTYPE a_BlockType) cBlockLadderHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType) : cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
{ {
} }

View File

@ -1,17 +1,18 @@
#pragma once #pragma once
#include "BlockHandler.h" #include "BlockHandler.h"
#include "MetaRotator.h"
class cBlockLeverHandler : class cBlockLeverHandler :
public cBlockHandler public cMetaRotator<cBlockHandler, 0x07, 0x04, 0x02, 0x03, 0x01, false>
{ {
typedef cMetaRotator<cBlockHandler, 0x07, 0x04, 0x02, 0x03, 0x01, false> super;
public: public:
cBlockLeverHandler(BLOCKTYPE a_BlockType) cBlockLeverHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType) : cMetaRotator<cBlockHandler, 0x07, 0x04, 0x02, 0x03, 0x01, false>(a_BlockType)
{ {
} }
@ -104,6 +105,36 @@ public:
return (a_RelY > 0) && cBlockInfo::IsSolid(BlockIsOn); return (a_RelY > 0) && cBlockInfo::IsSolid(BlockIsOn);
} }
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
{
switch (a_Meta)
{
case 0x00: return 0x07; // Ceiling rotation
case 0x07: return 0x00;
case 0x05: return 0x06; // Ground rotation
case 0x06: return 0x05;
default: return super::MetaRotateCCW(a_Meta); // Wall Rotation
}
}
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
{
switch (a_Meta)
{
case 0x00: return 0x07; // Ceiling rotation
case 0x07: return 0x00;
case 0x05: return 0x06; // Ground rotation
case 0x06: return 0x05;
default: return super::MetaRotateCCW(a_Meta); // Wall Rotation
}
}
} ; } ;

View File

@ -1,16 +1,16 @@
#pragma once #pragma once
#include "BlockHandler.h" #include "BlockHandler.h"
#include "MetaRotator.h"
class cBlockPumpkinHandler : class cBlockPumpkinHandler :
public cBlockHandler public cMetaRotator<cBlockHandler, 0x07, 0x02, 0x03, 0x00, 0x01, false>
{ {
public: public:
cBlockPumpkinHandler(BLOCKTYPE a_BlockType) cBlockPumpkinHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType) : cMetaRotator<cBlockHandler, 0x07, 0x02, 0x03, 0x00, 0x01, false>(a_BlockType)
{ {
} }

View File

@ -434,6 +434,141 @@ public:
} }
return true; return true;
} }
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
{
// Bit 0x08 is a flag when a_Meta is in the range 0x00--0x05 and 0x0A--0x0F.
// Bit 0x08 specifies direction when a_Meta is in the range 0x06-0x09.
if ((a_Meta < 0x06) || (a_Meta > 0x09))
{
// Save powered rail flag.
NIBBLETYPE OtherMeta = a_Meta & 0x08;
// Rotates according to table; 0x07 == 0111.
// Rails can either be flat (North/South) or Ascending (Asc. East)
switch (a_Meta & 0x07)
{
case 0x00: return 0x01 + OtherMeta; // North/South -> East/West
case 0x01: return 0x00 + OtherMeta; // East/West -> North/South
case 0x02: return 0x04 + OtherMeta; // Asc. East -> Asc. North
case 0x04: return 0x03 + OtherMeta; // Asc. North -> Asc. West
case 0x03: return 0x05 + OtherMeta; // Asc. West -> Asc. South
case 0x05: return 0x02 + OtherMeta; // Asc. South -> Asc. East
}
}
else
{
switch (a_Meta)
{
// Corner Directions
case 0x06: return 0x09; // Northwest Cnr. -> Southwest Cnr.
case 0x07: return 0x06; // Northeast Cnr. -> Northwest Cnr.
case 0x08: return 0x07; // Southeast Cnr. -> Northeast Cnr.
case 0x09: return 0x08; // Southwest Cnr. -> Southeast Cnr.
}
}
// To avoid a compiler warning;
return a_Meta;
}
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
{
// Bit 0x08 is a flag for value in the range 0x00--0x05 and specifies direction for values withint 0x006--0x09.
if ((a_Meta < 0x06) || (a_Meta > 0x09))
{
// Save powered rail flag.
NIBBLETYPE OtherMeta = a_Meta & 0x08;
// Rotates according to table; 0x07 == 0111.
// Rails can either be flat (North/South) or Ascending (Asc. East)
switch (a_Meta & 0x07)
{
case 0x00: return 0x01 + OtherMeta; // North/South -> East/West
case 0x01: return 0x00 + OtherMeta; // East/West -> North/South
case 0x02: return 0x05 + OtherMeta; // Asc. East -> Asc. South
case 0x05: return 0x03 + OtherMeta; // Asc. South -> Asc. West
case 0x03: return 0x04 + OtherMeta; // Asc. West -> Asc. North
case 0x04: return 0x02 + OtherMeta; // Asc. North -> Asc. East
}
}
else
{
switch (a_Meta)
{
// Corner Directions
case 0x06: return 0x07; // Northwest Cnr. -> Northeast Cnr.
case 0x07: return 0x08; // Northeast Cnr. -> Southeast Cnr.
case 0x08: return 0x09; // Southeast Cnr. -> Southwest Cnr.
case 0x09: return 0x06; // Southwest Cnr. -> Northwest Cnr.
}
}
// To avoid a compiler warning;
return a_Meta;
}
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
{
// Bit 0x08 is a flag for value in the range 0x00--0x05 and specifies direction for values withint 0x006--0x09.
if ((a_Meta < 0x06) || (a_Meta > 0x09))
{
// Save powered rail flag.
NIBBLETYPE OtherMeta = a_Meta & 0x08;
// Mirrors according to table; 0x07 == 0111.
// Rails can either be flat (North/South) or Ascending (Asc. East)
switch (a_Meta & 0x07)
{
case 0x05: return 0x04 + OtherMeta; // Asc. South -> Asc. North
case 0x04: return 0x05 + OtherMeta; // Asc. North -> Asc. South
}
}
else
{
switch (a_Meta)
{
// Corner Directions
case 0x06: return 0x09; // Northwest Cnr. -> Southwest Cnr.
case 0x07: return 0x08; // Northeast Cnr. -> Southeast Cnr.
case 0x08: return 0x07; // Southeast Cnr. -> Northeast Cnr.
case 0x09: return 0x06; // Southwest Cnr. -> Northwest Cnr.
}
}
// To avoid a compiler warning;
return a_Meta;
}
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
{
// Bit 0x08 is a flag for value in the range 0x00--0x05 and specifies direction for values withint 0x006--0x09.
if ((a_Meta < 0x06) || (a_Meta > 0x09))
{
// Save powered rail flag.
NIBBLETYPE OtherMeta = a_Meta & 0x08;
// Mirrors according to table; 0x07 == 0111.
// Rails can either be flat (North/South) or Ascending (Asc. East)
switch (a_Meta & 0x07)
{
case 0x02: return 0x03 + OtherMeta; // Asc. East -> Asc. West
case 0x03: return 0x02 + OtherMeta; // Asc. West -> Asc. East
}
}
else
{
switch (a_Meta)
{
// Corner Directions
case 0x06: return 0x07; // Northwest Cnr. -> Northeast Cnr.
case 0x07: return 0x06; // Northeast Cnr. -> Northwest Cnr.
case 0x08: return 0x09; // Southeast Cnr. -> Southwest Cnr.
case 0x09: return 0x08; // Southwest Cnr. -> Southeast Cnr.
}
}
// To avoid a compiler warning;
return a_Meta;
}
} ; } ;

View File

@ -3,17 +3,17 @@
#include "BlockHandler.h" #include "BlockHandler.h"
#include "Chunk.h" #include "Chunk.h"
#include "MetaRotator.h"
class cBlockRedstoneRepeaterHandler : class cBlockRedstoneRepeaterHandler :
public cBlockHandler public cMetaRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03, true>
{ {
public: public:
cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType) cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType) : cMetaRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03, true>(a_BlockType)
{ {
} }

View File

@ -71,6 +71,37 @@ public:
{ {
a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ); a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ);
} }
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
{
return (++a_Meta) & 0x0F;
}
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
{
return (--a_Meta) & 0x0F;
}
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
{
// Mirrors signs over the XY plane (North-South Mirroring)
// There are 16 meta values which correspond to different directions.
// These values are equated to angles on a circle; 0x08 = 180 degrees.
return (a_Meta < 0x08) ? 0x08 + a_Meta : 0x08 - a_Meta;
}
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
{
// Mirrors signs over the YZ plane (East-West Mirroring)
// There are 16 meta values which correspond to different directions.
// These values are equated to angles on a circle; 0x10 = 360 degrees.
return 0x10 - a_Meta;
}
} ; } ;

View File

@ -14,8 +14,6 @@
class cBlockSlabHandler : class cBlockSlabHandler :
public cBlockHandler public cBlockHandler
{ {
@ -184,6 +182,15 @@ public:
ASSERT(!"Unhandled double slab type!"); ASSERT(!"Unhandled double slab type!");
return ""; return "";
} }
virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
{
NIBBLETYPE OtherMeta = a_Meta & 0x07; // Contains unrelated meta data.
// 8th bit is up/down. 1 right-side-up, 0 is up-side-down.
return (a_Meta & 0x08) ? 0x00 + OtherMeta : 0x01 + OtherMeta;
}
} ; } ;

View File

@ -2,17 +2,17 @@
#pragma once #pragma once
#include "BlockHandler.h" #include "BlockHandler.h"
#include "MetaRotater.h" #include "MetaRotator.h"
class cBlockStairsHandler : class cBlockStairsHandler :
public cMetaRotater<cBlockHandler, 0x03, 0x03, 0x00, 0x02, 0x01, true> public cMetaRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x02, 0x01, true>
{ {
public: public:
cBlockStairsHandler(BLOCKTYPE a_BlockType) : cBlockStairsHandler(BLOCKTYPE a_BlockType) :
cMetaRotater<cBlockHandler, 0x03, 0x03, 0x00, 0x02, 0x01, true>(a_BlockType) cMetaRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x02, 0x01, true>(a_BlockType)
{ {
} }

View File

@ -2,17 +2,17 @@
#include "BlockHandler.h" #include "BlockHandler.h"
#include "../Chunk.h" #include "../Chunk.h"
#include "MetaRotater.h" #include "MetaRotator.h"
class cBlockTorchHandler : class cBlockTorchHandler :
public cMetaRotater<cBlockHandler, 0x7, 0x4, 0x1, 0x3, 0x2> public cMetaRotator<cBlockHandler, 0x7, 0x4, 0x1, 0x3, 0x2>
{ {
public: public:
cBlockTorchHandler(BLOCKTYPE a_BlockType) cBlockTorchHandler(BLOCKTYPE a_BlockType)
: cMetaRotater<cBlockHandler, 0x7, 0x4, 0x1, 0x3, 0x2>(a_BlockType) : cMetaRotator<cBlockHandler, 0x7, 0x4, 0x1, 0x3, 0x2>(a_BlockType)
{ {
} }

View File

@ -2,17 +2,17 @@
#pragma once #pragma once
#include "BlockHandler.h" #include "BlockHandler.h"
#include "MetaRotator.h"
class cBlockTrapdoorHandler : class cBlockTrapdoorHandler :
public cBlockHandler public cMetaRotator<cBlockHandler, 0x03, 0x01, 0x02, 0x00, 0x03, false>
{ {
public: public:
cBlockTrapdoorHandler(BLOCKTYPE a_BlockType) cBlockTrapdoorHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType) : cMetaRotator<cBlockHandler, 0x03, 0x01, 0x02, 0x00, 0x03, false>(a_BlockType)
{ {
} }

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "BlockHandler.h" #include "BlockHandler.h"
#include "MetaRotater.h" #include "MetaRotator.h"

View File

@ -1,4 +1,4 @@
// MetaRotater.h // MetaRotator.h
// Provides a mixin for rotations and reflections // Provides a mixin for rotations and reflections
@ -21,15 +21,15 @@ Inherit from this class providing your base class as Base, the BitMask for the d
*/ */
template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched = false> template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched = false>
class cMetaRotater : public Base class cMetaRotator : public Base
{ {
public: public:
cMetaRotater(BLOCKTYPE a_BlockType) : cMetaRotator(BLOCKTYPE a_BlockType) :
Base(a_BlockType) Base(a_BlockType)
{} {}
virtual ~cMetaRotater() {} virtual ~cMetaRotator() {}
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override; virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override;
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override; virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override;
@ -42,7 +42,7 @@ public:
template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched> template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched>
NIBBLETYPE cMetaRotater<Base, BitMask, North, East, South, West, AssertIfNotMatched>::MetaRotateCW(NIBBLETYPE a_Meta) NIBBLETYPE cMetaRotator<Base, BitMask, North, East, South, West, AssertIfNotMatched>::MetaRotateCW(NIBBLETYPE a_Meta)
{ {
NIBBLETYPE OtherMeta = a_Meta & (~BitMask); NIBBLETYPE OtherMeta = a_Meta & (~BitMask);
switch (a_Meta & BitMask) switch (a_Meta & BitMask)
@ -64,7 +64,7 @@ NIBBLETYPE cMetaRotater<Base, BitMask, North, East, South, West, AssertIfNotMatc
template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched> template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched>
NIBBLETYPE cMetaRotater<Base, BitMask, North, East, South, West, AssertIfNotMatched>::MetaRotateCCW(NIBBLETYPE a_Meta) NIBBLETYPE cMetaRotator<Base, BitMask, North, East, South, West, AssertIfNotMatched>::MetaRotateCCW(NIBBLETYPE a_Meta)
{ {
NIBBLETYPE OtherMeta = a_Meta & (~BitMask); NIBBLETYPE OtherMeta = a_Meta & (~BitMask);
switch (a_Meta & BitMask) switch (a_Meta & BitMask)
@ -86,7 +86,7 @@ NIBBLETYPE cMetaRotater<Base, BitMask, North, East, South, West, AssertIfNotMatc
template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched> template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched>
NIBBLETYPE cMetaRotater<Base, BitMask, North, East, South, West, AssertIfNotMatched>::MetaMirrorXY(NIBBLETYPE a_Meta) NIBBLETYPE cMetaRotator<Base, BitMask, North, East, South, West, AssertIfNotMatched>::MetaMirrorXY(NIBBLETYPE a_Meta)
{ {
NIBBLETYPE OtherMeta = a_Meta & (~BitMask); NIBBLETYPE OtherMeta = a_Meta & (~BitMask);
switch (a_Meta & BitMask) switch (a_Meta & BitMask)
@ -103,7 +103,7 @@ NIBBLETYPE cMetaRotater<Base, BitMask, North, East, South, West, AssertIfNotMatc
template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched> template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched>
NIBBLETYPE cMetaRotater<Base, BitMask, North, East, South, West, AssertIfNotMatched>::MetaMirrorYZ(NIBBLETYPE a_Meta) NIBBLETYPE cMetaRotator<Base, BitMask, North, East, South, West, AssertIfNotMatched>::MetaMirrorYZ(NIBBLETYPE a_Meta)
{ {
NIBBLETYPE OtherMeta = a_Meta & (~BitMask); NIBBLETYPE OtherMeta = a_Meta & (~BitMask);
switch (a_Meta & BitMask) switch (a_Meta & BitMask)