summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-12-16 23:14:44 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-12-16 23:14:44 +0100
commited80ff9fc8c7bd29b696652b3741c16249c26c3b (patch)
treef48222cf7c4d15bd7afb74950d222372f5065e99 /src/Items
parentAPIDump: Ignoring the multi-inheritance members. (diff)
parentBoats spawn on top of a block. not between 4 blocks. (diff)
downloadcuberite-ed80ff9fc8c7bd29b696652b3741c16249c26c3b.tar
cuberite-ed80ff9fc8c7bd29b696652b3741c16249c26c3b.tar.gz
cuberite-ed80ff9fc8c7bd29b696652b3741c16249c26c3b.tar.bz2
cuberite-ed80ff9fc8c7bd29b696652b3741c16249c26c3b.tar.lz
cuberite-ed80ff9fc8c7bd29b696652b3741c16249c26c3b.tar.xz
cuberite-ed80ff9fc8c7bd29b696652b3741c16249c26c3b.tar.zst
cuberite-ed80ff9fc8c7bd29b696652b3741c16249c26c3b.zip
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..79c8e9589 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 + 0.5, y + 1, z + 0.5);
Boat->Initialize(a_World);
return true;
}
-
} ;