You can spawn boats on water.
This commit is contained in:
parent
f521cbeb31
commit
324fa55bf0
@ -10,6 +10,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Entities/Boat.h"
|
#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
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
double x = (double)a_BlockX + 0.5;
|
class cCallbacks :
|
||||||
double y = (double)a_BlockY + 0.5;
|
public cBlockTracer::cCallbacks
|
||||||
double z = (double)a_BlockZ + 0.5;
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
cBoat * Boat = NULL;
|
cLineBlockTracer Tracer(*a_World, Callbacks);
|
||||||
|
Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector());
|
||||||
|
Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5);
|
||||||
|
|
||||||
Boat = new cBoat (x, y, z);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
cBoat * Boat = new cBoat(x, y + 1, z);
|
||||||
Boat->Initialize(a_World);
|
Boat->Initialize(a_World);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user