summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSTRWarrior <niels.breuker@hotmail.nl>2013-12-17 19:42:06 +0100
committerSTRWarrior <niels.breuker@hotmail.nl>2013-12-17 19:42:06 +0100
commitf1a1d6fa5c64a88d9b72d70e70c085ce75830933 (patch)
treecd0f6d20e0522e7a13b606a00fcb2408dfeab387 /src
parentMade buckets work when the player does not 'look' at a block. This fixes #265 (diff)
downloadcuberite-f1a1d6fa5c64a88d9b72d70e70c085ce75830933.tar
cuberite-f1a1d6fa5c64a88d9b72d70e70c085ce75830933.tar.gz
cuberite-f1a1d6fa5c64a88d9b72d70e70c085ce75830933.tar.bz2
cuberite-f1a1d6fa5c64a88d9b72d70e70c085ce75830933.tar.lz
cuberite-f1a1d6fa5c64a88d9b72d70e70c085ce75830933.tar.xz
cuberite-f1a1d6fa5c64a88d9b72d70e70c085ce75830933.tar.zst
cuberite-f1a1d6fa5c64a88d9b72d70e70c085ce75830933.zip
Diffstat (limited to 'src')
-rw-r--r--src/Items/ItemBucket.h33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index 87f23b554..4cddd64d8 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -46,7 +46,10 @@ public:
}
Vector3i BlockPos;
- GetBlockFromTrace(a_World, a_Player, BlockPos);
+ if (!GetBlockFromTrace(a_World, a_Player, BlockPos))
+ {
+ return false; // Nothing in range.
+ }
if (a_World->GetBlockMeta(BlockPos.x, BlockPos.y, BlockPos.z) != 0)
{
@@ -70,16 +73,18 @@ public:
return false;
}
- // Remove the bucket from the inventory
- if (!a_Player->GetInventory().RemoveOneEquippedItem())
+ // Give new bucket, filled with fluid when the gamemode is not creative:
+ if (!a_Player->IsGameModeCreative())
{
- LOG("Clicked with an empty bucket, but cannot remove one from the inventory? WTF?");
- ASSERT(!"Inventory bucket mismatch");
- return true;
+ // Remove the bucket from the inventory
+ if (!a_Player->GetInventory().RemoveOneEquippedItem())
+ {
+ LOG("Clicked with an empty bucket, but cannot remove one from the inventory? WTF?");
+ ASSERT(!"Inventory bucket mismatch");
+ return true;
+ }
+ a_Player->GetInventory().AddItem(cItem(NewItem), true, true);
}
-
- // Give new bucket, filled with fluid:
- a_Player->GetInventory().AddItem(cItem(NewItem), true, true);
// Remove water / lava block
a_Player->GetWorld()->SetBlock(BlockPos.x, BlockPos.y, BlockPos.z, E_BLOCK_AIR, 0);
@@ -153,14 +158,16 @@ public:
{
public:
Vector3d Pos;
+ bool HitFluid;
virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override
{
if (a_BlockMeta != 0) // Even if it was a water block it would not be a source.
{
return false;
}
- if ((IsBlockWater(a_BlockType)) || (IsBlockLava(a_BlockType)))
+ if (IsBlockWater(a_BlockType) || IsBlockLava(a_BlockType))
{
+ HitFluid = true;
Pos = Vector3d(a_BlockX, a_BlockY, a_BlockZ);
return true;
}
@@ -174,6 +181,12 @@ public:
Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z);
+ if (!Callbacks.HitFluid)
+ {
+ return false;
+ }
+
+
BlockPos.Set((int) Callbacks.Pos.x, (int) Callbacks.Pos.y, (int) Callbacks.Pos.z);
return true;
}