1
0

You can spawn boats on water.

This commit is contained in:
STRWarrior 2013-12-16 18:01:33 +01:00
parent f521cbeb31
commit 324fa55bf0

View File

@ -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);
Boat = new cBoat (x, y, 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);
return true;
}
} ;