summaryrefslogtreecommitdiffstats
path: root/src/Blocks
diff options
context:
space:
mode:
authorMasy98 <masy@antheruscraft.de>2014-12-18 19:32:48 +0100
committerMasy98 <masy@antheruscraft.de>2014-12-18 19:32:48 +0100
commit706b9181e612410ea99c9d725d3cd448dafb152c (patch)
tree0d1281525b92566409a3c4a6d0bf8a0e9d5f7dc8 /src/Blocks
parentAdded Entity Guardian (diff)
parentMerge pull request #1679 from SphinxC0re/master (diff)
downloadcuberite-706b9181e612410ea99c9d725d3cd448dafb152c.tar
cuberite-706b9181e612410ea99c9d725d3cd448dafb152c.tar.gz
cuberite-706b9181e612410ea99c9d725d3cd448dafb152c.tar.bz2
cuberite-706b9181e612410ea99c9d725d3cd448dafb152c.tar.lz
cuberite-706b9181e612410ea99c9d725d3cd448dafb152c.tar.xz
cuberite-706b9181e612410ea99c9d725d3cd448dafb152c.tar.zst
cuberite-706b9181e612410ea99c9d725d3cd448dafb152c.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockCocoaPod.h96
-rw-r--r--src/Blocks/BlockHandler.cpp2
-rw-r--r--src/Blocks/BlockPressurePlate.h3
-rw-r--r--src/Blocks/BlockRail.h4
-rw-r--r--src/Blocks/BlockTallGrass.h2
-rw-r--r--src/Blocks/BlockTorch.h1
-rw-r--r--src/Blocks/CMakeLists.txt1
7 files changed, 104 insertions, 5 deletions
diff --git a/src/Blocks/BlockCocoaPod.h b/src/Blocks/BlockCocoaPod.h
new file mode 100644
index 000000000..1b659d48f
--- /dev/null
+++ b/src/Blocks/BlockCocoaPod.h
@@ -0,0 +1,96 @@
+#pragma once
+
+#include "BlockHandler.h"
+#include "../FastRandom.h"
+
+
+
+
+
+class cBlockCocoaPodHandler :
+ public cBlockHandler
+{
+public:
+ cBlockCocoaPodHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ eBlockFace BlockFace = MetaToBlockFace(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
+ AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockFace, true);
+
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ a_Chunk.UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ, BlockType, BlockMeta);
+
+ return ((BlockType == E_BLOCK_LOG) && ((BlockMeta & 0x3) == E_META_LOG_JUNGLE));
+ }
+
+
+ virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
+ {
+ cFastRandom Random;
+
+ if (Random.NextInt(5) == 0)
+ {
+ NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
+ NIBBLETYPE TypeMeta = Meta & 0x03;
+ int GrowState = Meta >> 2;
+
+ if (GrowState < 2)
+ {
+ ++GrowState;
+ a_Chunk.SetMeta(a_RelX, a_RelY, a_RelZ, (NIBBLETYPE) (GrowState << 2 | TypeMeta));
+ }
+ }
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ int GrowState = a_BlockMeta >> 2;
+ a_Pickups.Add(E_ITEM_DYE, ((GrowState >= 2) ? 3 : 1), E_META_DYE_BROWN);
+ }
+
+
+ static eBlockFace MetaToBlockFace(NIBBLETYPE a_Meta)
+ {
+ switch (a_Meta & 0x3)
+ {
+ case 0: return BLOCK_FACE_ZM;
+ case 1: return BLOCK_FACE_XP;
+ case 2: return BLOCK_FACE_ZP;
+ case 3: return BLOCK_FACE_XM;
+ default:
+ {
+ ASSERT(!"Bad meta");
+ return BLOCK_FACE_NONE;
+ }
+ }
+ }
+
+
+ static NIBBLETYPE BlockFaceToMeta(eBlockFace a_BlockFace)
+ {
+ switch (a_BlockFace)
+ {
+ case BLOCK_FACE_ZM: return 0;
+ case BLOCK_FACE_XM: return 3;
+ case BLOCK_FACE_XP: return 1;
+ case BLOCK_FACE_ZP: return 2;
+ default:
+ {
+ ASSERT(!"Unknown face");
+ return 0;
+ }
+ }
+ }
+
+} ;
+
+
+
+
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index 60f13a747..d532aa1dc 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -17,6 +17,7 @@
#include "BlockChest.h"
#include "BlockCloth.h"
#include "BlockCobWeb.h"
+#include "BlockCocoaPod.h"
#include "BlockCommandBlock.h"
#include "BlockComparator.h"
#include "BlockCrops.h"
@@ -198,6 +199,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType);
case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType);
case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType);
+ case E_BLOCK_COCOA_POD: return new cBlockCocoaPodHandler (a_BlockType);
case E_BLOCK_COMMAND_BLOCK: return new cBlockCommandBlockHandler (a_BlockType);
case E_BLOCK_ACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType);
case E_BLOCK_COBBLESTONE: return new cBlockStoneHandler (a_BlockType);
diff --git a/src/Blocks/BlockPressurePlate.h b/src/Blocks/BlockPressurePlate.h
index a5c34a776..bd2f283a2 100644
--- a/src/Blocks/BlockPressurePlate.h
+++ b/src/Blocks/BlockPressurePlate.h
@@ -28,8 +28,7 @@ public:
return false;
}
- BLOCKTYPE BlockBelow = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
- return (cBlockInfo::IsSolid(BlockBelow));
+ return (cBlockInfo::FullyOccupiesVoxel(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
}
} ;
diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h
index 21a34d8ce..02fe3aa95 100644
--- a/src/Blocks/BlockRail.h
+++ b/src/Blocks/BlockRail.h
@@ -98,7 +98,7 @@ public:
{
return false;
}
- if (!cBlockInfo::IsSolid(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)))
+ if (!cBlockInfo::FullyOccupiesVoxel(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)))
{
return false;
}
@@ -130,7 +130,7 @@ public:
// Too close to the edge, cannot simulate
return true;
}
- return cBlockInfo::IsSolid(BlockType);
+ return cBlockInfo::FullyOccupiesVoxel(BlockType);
}
}
return true;
diff --git a/src/Blocks/BlockTallGrass.h b/src/Blocks/BlockTallGrass.h
index 8e821b899..4134a01f8 100644
--- a/src/Blocks/BlockTallGrass.h
+++ b/src/Blocks/BlockTallGrass.h
@@ -38,7 +38,7 @@ public:
virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop) override
{
- if (a_CanDrop && (a_Digger != NULL) && (a_Digger->GetEquippedWeapon().m_ItemType == E_ITEM_SHEARS))
+ if (a_CanDrop && (a_Digger != nullptr) && (a_Digger->GetEquippedWeapon().m_ItemType == E_ITEM_SHEARS))
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
cItems Drops;
diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h
index e77bbd1b8..d63df94cf 100644
--- a/src/Blocks/BlockTorch.h
+++ b/src/Blocks/BlockTorch.h
@@ -2,6 +2,7 @@
#include "BlockHandler.h"
#include "../Chunk.h"
+#include "ChunkInterface.h"
#include "MetaRotator.h"
diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt
index eed949aab..ed3e321d4 100644
--- a/src/Blocks/CMakeLists.txt
+++ b/src/Blocks/CMakeLists.txt
@@ -24,6 +24,7 @@ SET (HDRS
BlockChest.h
BlockCloth.h
BlockCobWeb.h
+ BlockCocoaPod.h
BlockCommandBlock.h
BlockComparator.h
BlockCrops.h