summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemThrowable.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-05-06 00:45:35 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-05-06 00:45:35 +0200
commit1df7dbe7c91953c2413908b846649e884b7ac53c (patch)
treee385aaf8d1a0c3bf7380aaf6847e66ecb1ba4873 /src/Items/ItemThrowable.h
parentA bit of reformatting. (diff)
downloadcuberite-1df7dbe7c91953c2413908b846649e884b7ac53c.tar
cuberite-1df7dbe7c91953c2413908b846649e884b7ac53c.tar.gz
cuberite-1df7dbe7c91953c2413908b846649e884b7ac53c.tar.bz2
cuberite-1df7dbe7c91953c2413908b846649e884b7ac53c.tar.lz
cuberite-1df7dbe7c91953c2413908b846649e884b7ac53c.tar.xz
cuberite-1df7dbe7c91953c2413908b846649e884b7ac53c.tar.zst
cuberite-1df7dbe7c91953c2413908b846649e884b7ac53c.zip
Diffstat (limited to 'src/Items/ItemThrowable.h')
-rw-r--r--src/Items/ItemThrowable.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h
index f90caf037..35c2b8731 100644
--- a/src/Items/ItemThrowable.h
+++ b/src/Items/ItemThrowable.h
@@ -28,15 +28,19 @@ 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
{
+ Vector3d Pos = a_Player->GetThrowStartPos();
+ Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff;
+
+ if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, a_Player->GetEquippedItem(), &Speed) < 0)
+ {
+ return false;
+ }
+
if (!a_Player->IsGameModeCreative())
{
a_Player->GetInventory().RemoveOneEquippedItem();
}
- Vector3d Pos = a_Player->GetThrowStartPos();
- Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff;
- a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, a_Player->GetEquippedItem(), &Speed);
-
return true;
}
@@ -127,7 +131,7 @@ public:
return false;
}
- if (a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, a_Player->GetEquippedItem()) == -1)
+ if (a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, a_Player->GetEquippedItem()) < 0)
{
return false;
}