summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-03-01 19:04:50 +0100
committerTycho <work.tycho+git@gmail.com>2014-03-01 19:04:50 +0100
commit65edffd5b04623dcd4cebbd1afb2575e98eee5db (patch)
tree50957f2fd3d6d81a3471a88539e6c1aad755fe90
parentMerge branch 'master' into MetaRotate (diff)
downloadcuberite-65edffd5b04623dcd4cebbd1afb2575e98eee5db.tar
cuberite-65edffd5b04623dcd4cebbd1afb2575e98eee5db.tar.gz
cuberite-65edffd5b04623dcd4cebbd1afb2575e98eee5db.tar.bz2
cuberite-65edffd5b04623dcd4cebbd1afb2575e98eee5db.tar.lz
cuberite-65edffd5b04623dcd4cebbd1afb2575e98eee5db.tar.xz
cuberite-65edffd5b04623dcd4cebbd1afb2575e98eee5db.tar.zst
cuberite-65edffd5b04623dcd4cebbd1afb2575e98eee5db.zip
-rw-r--r--src/Blocks/BlockBed.h4
-rw-r--r--src/Blocks/BlockButton.h5
-rw-r--r--src/Blocks/BlockChest.h5
-rw-r--r--src/Blocks/BlockComparator.h5
-rw-r--r--src/Blocks/BlockDoor.h5
-rw-r--r--src/Blocks/BlockDropSpenser.h1
-rw-r--r--src/Blocks/BlockEnderchest.h2
-rw-r--r--src/Blocks/BlockFenceGate.h6
-rw-r--r--src/Blocks/BlockStairs.h68
-rw-r--r--src/Blocks/BlockTorch.h67
-rw-r--r--src/Blocks/BlockVine.h30
11 files changed, 28 insertions, 170 deletions
diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h
index 6e8884114..d8a796735 100644
--- a/src/Blocks/BlockBed.h
+++ b/src/Blocks/BlockBed.h
@@ -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)
{
}
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index 5a4bf7c96..4daa03005 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -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)
{
}
diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h
index 4ab23bced..6a13e826e 100644
--- a/src/Blocks/BlockChest.h
+++ b/src/Blocks/BlockChest.h
@@ -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)
{
}
diff --git a/src/Blocks/BlockComparator.h b/src/Blocks/BlockComparator.h
index 7e672eece..238e687ab 100644
--- a/src/Blocks/BlockComparator.h
+++ b/src/Blocks/BlockComparator.h
@@ -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)
{
}
diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h
index c3647b203..8e3f2d83f 100644
--- a/src/Blocks/BlockDoor.h
+++ b/src/Blocks/BlockDoor.h
@@ -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);
diff --git a/src/Blocks/BlockDropSpenser.h b/src/Blocks/BlockDropSpenser.h
index 2253fcd1b..73937577a 100644
--- a/src/Blocks/BlockDropSpenser.h
+++ b/src/Blocks/BlockDropSpenser.h
@@ -6,6 +6,7 @@
#pragma once
#include "../Piston.h"
+#include "MetaRotater.h"
diff --git a/src/Blocks/BlockEnderchest.h b/src/Blocks/BlockEnderchest.h
index ed3f37013..6ca83399a 100644
--- a/src/Blocks/BlockEnderchest.h
+++ b/src/Blocks/BlockEnderchest.h
@@ -2,7 +2,7 @@
#pragma once
#include "BlockEntity.h"
-
+#include "MetaRotater.h"
diff --git a/src/Blocks/BlockFenceGate.h b/src/Blocks/BlockFenceGate.h
index 035579e8e..c33393590 100644
--- a/src/Blocks/BlockFenceGate.h
+++ b/src/Blocks/BlockFenceGate.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)
{
}
diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h
index c1887bc46..f07afc9f0 100644
--- a/src/Blocks/BlockStairs.h
+++ b/src/Blocks/BlockStairs.h
@@ -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;
- }
} ;
diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h
index f2a4c8665..59c896857 100644
--- a/src/Blocks/BlockTorch.h
+++ b/src/Blocks/BlockTorch.h
@@ -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
- }
- }
} ;
diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h
index ee7dcee8a..9e2105f67 100644
--- a/src/Blocks/BlockVine.h
+++ b/src/Blocks/BlockVine.h
@@ -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));
- }
} ;