summaryrefslogtreecommitdiffstats
path: root/src/Blocks
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-05-08 20:17:31 +0200
committerMattes D <github@xoft.cz>2014-05-08 20:17:31 +0200
commitccf44f18d1258e7b75db36afdc39bc816f7c78fe (patch)
tree7a5a436db251e032af712374830d394753fccc83 /src/Blocks
parentcNetherFortGen uses cGridStructGen. (diff)
parentFixed MSVC 64-bit build warnings. (diff)
downloadcuberite-ccf44f18d1258e7b75db36afdc39bc816f7c78fe.tar
cuberite-ccf44f18d1258e7b75db36afdc39bc816f7c78fe.tar.gz
cuberite-ccf44f18d1258e7b75db36afdc39bc816f7c78fe.tar.bz2
cuberite-ccf44f18d1258e7b75db36afdc39bc816f7c78fe.tar.lz
cuberite-ccf44f18d1258e7b75db36afdc39bc816f7c78fe.tar.xz
cuberite-ccf44f18d1258e7b75db36afdc39bc816f7c78fe.tar.zst
cuberite-ccf44f18d1258e7b75db36afdc39bc816f7c78fe.zip
Diffstat (limited to 'src/Blocks')
-rw-r--r--src/Blocks/BlockAnvil.h7
-rw-r--r--src/Blocks/BlockBed.h7
-rw-r--r--src/Blocks/BlockDirt.h8
-rw-r--r--src/Blocks/BlockFarmland.h4
-rw-r--r--src/Blocks/BlockFluid.h6
-rw-r--r--src/Blocks/BlockHandler.cpp9
-rw-r--r--src/Blocks/BlockHandler.h3
-rw-r--r--src/Blocks/BlockLeaves.h6
-rw-r--r--src/Blocks/BlockSlab.h6
-rw-r--r--src/Blocks/BlockStairs.h5
10 files changed, 53 insertions, 8 deletions
diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h
index 93a796ef7..35a356678 100644
--- a/src/Blocks/BlockAnvil.h
+++ b/src/Blocks/BlockAnvil.h
@@ -23,6 +23,13 @@ public:
{
a_Pickups.push_back(cItem(E_BLOCK_ANVIL, 1, a_BlockMeta >> 2));
}
+
+
+ virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
+ {
+ cWindow * Window = new cAnvilWindow(a_BlockX, a_BlockY, a_BlockZ);
+ a_Player->OpenWindow(Window);
+ }
virtual bool GetPlacementBlockTypeMeta(
diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h
index 92804aaac..51e79b888 100644
--- a/src/Blocks/BlockBed.h
+++ b/src/Blocks/BlockBed.h
@@ -39,6 +39,13 @@ public:
}
+ virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override
+ {
+ return true;
+ }
+
+
+
// Bed specific helper functions
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h
index aa24b8668..2d4fccbac 100644
--- a/src/Blocks/BlockDirt.h
+++ b/src/Blocks/BlockDirt.h
@@ -35,8 +35,10 @@ public:
// Grass becomes dirt if there is something on top of it:
if (a_RelY < cChunkDef::Height - 1)
{
- BLOCKTYPE Above = a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ);
- if ((!cBlockInfo::IsTransparent(Above) && !cBlockInfo::IsOneHitDig(Above)) || IsBlockWater(Above))
+ BLOCKTYPE Above;
+ NIBBLETYPE AboveMeta;
+ a_Chunk.GetBlockTypeMeta(a_RelX, a_RelY + 1, a_RelZ, Above, AboveMeta);
+ if (!cBlockInfo::GetHandler(Above)->CanDirtGrowGrass(AboveMeta))
{
a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_DIRT, E_META_DIRT_NORMAL);
return;
@@ -77,7 +79,7 @@ public:
BLOCKTYPE AboveDest;
NIBBLETYPE AboveMeta;
Chunk->GetBlockTypeMeta(BlockX, BlockY + 1, BlockZ, AboveDest, AboveMeta);
- if ((cBlockInfo::IsOneHitDig(AboveDest) || cBlockInfo::IsTransparent(AboveDest)) && !IsBlockWater(AboveDest))
+ if (cBlockInfo::GetHandler(AboveDest)->CanDirtGrowGrass(AboveMeta))
{
if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread((cWorld*) &a_WorldInterface, BlockX * cChunkDef::Width, BlockY, BlockZ * cChunkDef::Width, ssGrassSpread))
{
diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h
index b720ccd14..3dd5bcd1d 100644
--- a/src/Blocks/BlockFarmland.h
+++ b/src/Blocks/BlockFarmland.h
@@ -52,9 +52,9 @@ public:
return;
}
- int NumBlocks = Area.GetBlockCount();
+ size_t NumBlocks = Area.GetBlockCount();
BLOCKTYPE * BlockTypes = Area.GetBlockTypes();
- for (int i = 0; i < NumBlocks; i++)
+ for (size_t i = 0; i < NumBlocks; i++)
{
if (
(BlockTypes[i] == E_BLOCK_WATER) ||
diff --git a/src/Blocks/BlockFluid.h b/src/Blocks/BlockFluid.h
index d486d642d..d0c4ea55b 100644
--- a/src/Blocks/BlockFluid.h
+++ b/src/Blocks/BlockFluid.h
@@ -49,6 +49,12 @@ public:
}
super::Check(a_ChunkInterface, a_PluginInterface, a_RelX, a_RelY, a_RelZ, a_Chunk);
}
+
+
+ virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override
+ {
+ return false;
+ }
} ;
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index a764c6f44..304e35e84 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -400,6 +400,15 @@ bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, in
+bool cBlockHandler::CanDirtGrowGrass(NIBBLETYPE a_Meta)
+{
+ return ((cBlockInfo::IsTransparent(m_BlockType)) || (cBlockInfo::IsOneHitDig(m_BlockType)));
+}
+
+
+
+
+
bool cBlockHandler::IsUseable()
{
return false;
diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h
index 3a3efb3cc..fb6cae729 100644
--- a/src/Blocks/BlockHandler.h
+++ b/src/Blocks/BlockHandler.h
@@ -85,6 +85,9 @@ public:
/// Checks if the block can stay at the specified relative coords in the chunk
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk);
+
+ /** Can the dirt under this block grow to grass? */
+ virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta);
/** Checks if the block can be placed at this point.
Default: CanBeAt(...)
diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h
index d21227b07..495e849fa 100644
--- a/src/Blocks/BlockLeaves.h
+++ b/src/Blocks/BlockLeaves.h
@@ -138,14 +138,14 @@ bool HasNearLog(cBlockArea & a_Area, int a_BlockX, int a_BlockY, int a_BlockZ)
{
// Filter the blocks into a {leaves, log, other (air)} set:
BLOCKTYPE * Types = a_Area.GetBlockTypes();
- for (int i = a_Area.GetBlockCount() - 1; i > 0; i--)
+ for (size_t i = a_Area.GetBlockCount() - 1; i > 0; i--)
{
switch (Types[i])
{
- case E_BLOCK_NEW_LEAVES:
- case E_BLOCK_NEW_LOG:
case E_BLOCK_LEAVES:
case E_BLOCK_LOG:
+ case E_BLOCK_NEW_LEAVES:
+ case E_BLOCK_NEW_LOG:
{
break;
}
diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h
index 76f5ed0e7..80841b094 100644
--- a/src/Blocks/BlockSlab.h
+++ b/src/Blocks/BlockSlab.h
@@ -97,6 +97,12 @@ public:
return "";
}
+
+ virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override
+ {
+ return ((a_Meta & 0x8) != 0);
+ }
+
/// Returns true if the specified blocktype is one of the slabs handled by this handler
static bool IsAnySlabType(BLOCKTYPE a_BlockType)
diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h
index 09ff254a6..a49fda5ae 100644
--- a/src/Blocks/BlockStairs.h
+++ b/src/Blocks/BlockStairs.h
@@ -77,6 +77,11 @@ public:
// Reset meta to 0
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
}
+
+ virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override
+ {
+ return true;
+ }
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{