From 0e236c03f96860ff66d8e8bd7ae22c400f55e197 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 9 Jun 2012 11:32:34 +0000 Subject: Bonemeal is consumed in survival mode when used on growable blocks git-svn-id: http://mc-server.googlecode.com/svn/trunk@582 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cClientHandle.cpp | 6 +++++- source/cClientHandle.h | 2 +- source/cWorld.cpp | 13 +++++++------ source/cWorld.h | 4 ++-- 4 files changed, 15 insertions(+), 10 deletions(-) (limited to 'source') 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 -- cgit v1.2.3