diff options
author | Mattes D <github@xoft.cz> | 2014-05-06 21:44:55 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-05-06 21:44:55 +0200 |
commit | e400b1acd8b0c1457f33bc1730996a3530fa0a4f (patch) | |
tree | cd26c0d2b87b62882bcc7b64503de408dd391e6f /src/Items | |
parent | Changed cPieceGenerator to support pairings. (diff) | |
parent | Merge branch 'master' into fixes (diff) | |
download | cuberite-e400b1acd8b0c1457f33bc1730996a3530fa0a4f.tar cuberite-e400b1acd8b0c1457f33bc1730996a3530fa0a4f.tar.gz cuberite-e400b1acd8b0c1457f33bc1730996a3530fa0a4f.tar.bz2 cuberite-e400b1acd8b0c1457f33bc1730996a3530fa0a4f.tar.lz cuberite-e400b1acd8b0c1457f33bc1730996a3530fa0a4f.tar.xz cuberite-e400b1acd8b0c1457f33bc1730996a3530fa0a4f.tar.zst cuberite-e400b1acd8b0c1457f33bc1730996a3530fa0a4f.zip |
Diffstat (limited to 'src/Items')
-rw-r--r-- | src/Items/ItemLilypad.h | 14 | ||||
-rw-r--r-- | src/Items/ItemThrowable.h | 17 |
2 files changed, 18 insertions, 13 deletions
diff --git a/src/Items/ItemLilypad.h b/src/Items/ItemLilypad.h index 8fc1d8543..bc650cdbd 100644 --- a/src/Items/ItemLilypad.h +++ b/src/Items/ItemLilypad.h @@ -47,9 +47,9 @@ public: public cBlockTracer::cCallbacks { public: - cCallbacks(cWorld * a_CBWorld) : - m_HasHitFluid(false), - m_World(a_CBWorld) + + cCallbacks(void) : + m_HasHitFluid(false) { } @@ -62,10 +62,9 @@ public: return false; } AddFaceDirection(a_CBBlockX, a_CBBlockY, a_CBBlockZ, BLOCK_FACE_YP); // Always place pad at top of water block - BLOCKTYPE Block = m_World->GetBlock(a_CBBlockX, a_CBBlockY, a_CBBlockZ); if ( - !IsBlockWater(Block) && - cBlockInfo::FullyOccupiesVoxel(Block) + !IsBlockWater(a_CBBlockType) && + cBlockInfo::FullyOccupiesVoxel(a_CBBlockType) ) { // Can't place lilypad on air/in another block! @@ -80,11 +79,10 @@ public: Vector3i m_Pos; bool m_HasHitFluid; - cWorld * m_World; }; - cCallbacks Callbacks(a_World); + cCallbacks Callbacks; cLineBlockTracer Tracer(*a_Player->GetWorld(), Callbacks); Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector()); Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h index c6a4e714e..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,10 @@ public: return false; } - a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, a_Player->GetEquippedItem()); + 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; + } if (!a_Player->IsGameModeCreative()) { |