summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ClientHandle.cpp14
-rw-r--r--src/Items/ItemHoe.h10
2 files changed, 17 insertions, 7 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 2bffc3cb1..642a5246a 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1204,15 +1204,16 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
);
cWorld * World = m_Player->GetWorld();
+ bool AreRealCoords = (Vector3d(a_BlockX, a_BlockY, a_BlockZ) - m_Player->GetPosition()).Length() <= 5;
if (
(a_BlockFace != BLOCK_FACE_NONE) && // The client is interacting with a specific block
IsValidBlock(a_HeldItem.m_ItemType) &&
- ((Vector3d(a_BlockX, a_BlockY, a_BlockZ) - m_Player->GetPosition()).Length() >= 5)
+ !AreRealCoords
)
{
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- if ((a_BlockX >= 0) && (a_BlockY >= 0) && (a_BlockZ >= 0))
+ if ((a_BlockX != -1) && (a_BlockY >= 0) && (a_BlockZ != -1))
{
World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
if (a_BlockY < cChunkDef::Height - 1)
@@ -1228,11 +1229,16 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
return;
}
+ if (!AreRealCoords)
+ {
+ a_BlockFace = BLOCK_FACE_NONE;
+ }
+
cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
if (PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
{
// A plugin doesn't agree with the action, replace the block on the client and quit:
- if ((a_BlockX >= 0) && (a_BlockY >= 0) && (a_BlockZ >= 0))
+ if (AreRealCoords)
{
cChunkInterface ChunkInterface(World->GetChunkMap());
BLOCKTYPE BlockType = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
@@ -1278,7 +1284,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
return;
}
- if ((Vector3d(a_BlockX, a_BlockY, a_BlockZ) - m_Player->GetPosition()).Length() <= 5)
+ if (AreRealCoords)
{
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
diff --git a/src/Items/ItemHoe.h b/src/Items/ItemHoe.h
index 8d0b71478..987357739 100644
--- a/src/Items/ItemHoe.h
+++ b/src/Items/ItemHoe.h
@@ -18,11 +18,15 @@ public:
{
}
- virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override
+ virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override
{
- BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ if (a_Dir == BLOCK_FACE_NONE)
+ {
+ return false;
+ }
- if ((Block == E_BLOCK_DIRT) || (Block == E_BLOCK_GRASS))
+ BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ if (IsBlockTypeOfDirt(Block))
{
a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FARMLAND, 0);
a_Player->UseEquippedItem();