summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Items/ItemBoat.h39
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;
}
-
} ;