summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-09 13:32:34 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-09 13:32:34 +0200
commit0e236c03f96860ff66d8e8bd7ae22c400f55e197 (patch)
tree3df8522a64c34a5c307d6fc1828926f9eb493643 /source
parentTall grass finally drops seeds (diff)
downloadcuberite-0e236c03f96860ff66d8e8bd7ae22c400f55e197.tar
cuberite-0e236c03f96860ff66d8e8bd7ae22c400f55e197.tar.gz
cuberite-0e236c03f96860ff66d8e8bd7ae22c400f55e197.tar.bz2
cuberite-0e236c03f96860ff66d8e8bd7ae22c400f55e197.tar.lz
cuberite-0e236c03f96860ff66d8e8bd7ae22c400f55e197.tar.xz
cuberite-0e236c03f96860ff66d8e8bd7ae22c400f55e197.tar.zst
cuberite-0e236c03f96860ff66d8e8bd7ae22c400f55e197.zip
Diffstat (limited to 'source')
-rw-r--r--source/cClientHandle.cpp6
-rw-r--r--source/cClientHandle.h2
-rw-r--r--source/cWorld.cpp13
-rw-r--r--source/cWorld.h4
4 files changed, 15 insertions, 10 deletions
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index 11a534442..5f918f121 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -1267,6 +1267,10 @@ void cClientHandle::HandleBlockPlace(cPacket_BlockPlace * a_Packet)
// Handle bonemeal and dyes on sheep
if (HandleDyes(a_Packet))
{
+ if (m_Player->GetGameMode() == eGameMode_Survival)
+ {
+ m_Player->GetInventory().RemoveItem(Item);
+ }
return;
}
break;
@@ -1582,7 +1586,7 @@ bool cClientHandle::HandleDyes(cPacket_BlockPlace * a_Packet)
if (Equipped.m_ItemHealth == E_META_DYE_WHITE)
{
cWorld * World = m_Player->GetWorld();
- World->GrowPlant(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ);
+ return World->GrowPlant(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ);
}
return false;
diff --git a/source/cClientHandle.h b/source/cClientHandle.h
index a8939f299..a2a12573a 100644
--- a/source/cClientHandle.h
+++ b/source/cClientHandle.h
@@ -205,7 +205,7 @@ private:
void HandleDisconnect (cPacket_Disconnect * a_Packet);
void HandleKeepAlive (cPacket_KeepAlive * a_Packet);
- /// Handles rclk with a dye; returns true if normal rclk processing should continue
+ /// Handles rclk with a dye; returns true if the dye is to be be consumed
bool HandleDyes(cPacket_BlockPlace * a_Packet);
/// Returns true if the rate block interactions is within a reasonable limit (bot protection)
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index 048dc1e30..7f6390dca 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -844,7 +844,7 @@ void cWorld::GrowTreeImage(const sSetBlockVector & a_Blocks)
-void cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ)
+bool cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ)
{
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
@@ -857,7 +857,7 @@ void cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ)
{
FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, 7);
}
- break;
+ return true;
}
case E_BLOCK_MELON_STEM:
@@ -871,13 +871,13 @@ void cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ)
{
GrowMelonPumpkin(a_BlockX, a_BlockY, a_BlockZ, BlockType);
}
- break;
+ return true;
}
case E_BLOCK_SAPLING:
{
GrowTreeFromSapling(a_BlockX, a_BlockY, a_BlockZ, BlockMeta);
- break;
+ return true;
}
case E_BLOCK_GRASS:
@@ -913,15 +913,16 @@ void cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ)
} // switch (random spawn block)
FastSetBlock(a_BlockX + OfsX, a_BlockY + OfsY + 1, a_BlockZ + OfsZ, SpawnType, SpawnMeta);
} // for i - 50 times
- break;
+ return true;
}
case E_BLOCK_SUGARCANE:
{
m_ChunkMap->GrowSugarcane(a_BlockX, a_BlockY, a_BlockZ, 3);
- break;
+ return true;
}
} // switch (BlockType)
+ return false;
}
diff --git a/source/cWorld.h b/source/cWorld.h
index 85823f27e..8f5cf63b0 100644
--- a/source/cWorld.h
+++ b/source/cWorld.h
@@ -244,8 +244,8 @@ public:
void GrowTreeImage(const sSetBlockVector & a_Blocks);
- /// Grows the plant at the specified block to its ripe stage (bonemeal used)
- void GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
+ /// Grows the plant at the specified block to its ripe stage (bonemeal used); returns false if the block is not growable.
+ bool GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
/// Grows a melon or a pumpkin next to the block specified (assumed to be the stem)
void GrowMelonPumpkin(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockType); // tolua_export