diff options
author | STRWarrior <niels.breuker@hotmail.nl> | 2013-12-16 18:01:33 +0100 |
---|---|---|
committer | STRWarrior <niels.breuker@hotmail.nl> | 2013-12-16 18:01:33 +0100 |
commit | 324fa55bf0c72f61ce8b5dfc3df7770d61a8e25f (patch) | |
tree | f28f412f2c36f72ad930a919f3ac9be7dab549de /src | |
parent | Fixed cClientHandle::Tick() being called from two threads. (diff) | |
download | cuberite-324fa55bf0c72f61ce8b5dfc3df7770d61a8e25f.tar cuberite-324fa55bf0c72f61ce8b5dfc3df7770d61a8e25f.tar.gz cuberite-324fa55bf0c72f61ce8b5dfc3df7770d61a8e25f.tar.bz2 cuberite-324fa55bf0c72f61ce8b5dfc3df7770d61a8e25f.tar.lz cuberite-324fa55bf0c72f61ce8b5dfc3df7770d61a8e25f.tar.xz cuberite-324fa55bf0c72f61ce8b5dfc3df7770d61a8e25f.tar.zst cuberite-324fa55bf0c72f61ce8b5dfc3df7770d61a8e25f.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Items/ItemBoat.h | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/src/Items/ItemBoat.h b/src/Items/ItemBoat.h index 6e3395f1d..c50171c0c 100644 --- a/src/Items/ItemBoat.h +++ b/src/Items/ItemBoat.h @@ -10,6 +10,7 @@ #pragma once #include "../Entities/Boat.h" +#include "../LineBlockTracer.h" @@ -30,23 +31,47 @@ public: virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override { - if (a_Dir < 0) + if (a_Dir > 0) { return false; } + + class cCallbacks : + public cBlockTracer::cCallbacks + { + public: + Vector3d Pos; + virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override + { + if (a_BlockType != E_BLOCK_AIR) + { + Pos = Vector3d(a_BlockX, a_BlockY, a_BlockZ); + return true; + } + return false; + } + } Callbacks; - double x = (double)a_BlockX + 0.5; - double y = (double)a_BlockY + 0.5; - double z = (double)a_BlockZ + 0.5; + cLineBlockTracer Tracer(*a_World, Callbacks); + Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector()); + Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); - cBoat * Boat = NULL; + Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z); + + double x = Callbacks.Pos.x; + double y = Callbacks.Pos.y; + double z = Callbacks.Pos.z; + + if (x == 0 && y == 0 && z == 0) + { + return false; + } - Boat = new cBoat (x, y, z); + cBoat * Boat = new cBoat(x, y + 1, z); Boat->Initialize(a_World); return true; } - } ; |