2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
// Minecart.cpp
|
|
|
|
|
|
|
|
// Implements the cMinecart class representing a minecart in the world
|
2013-08-27 15:38:11 -04:00
|
|
|
// Indiana Jones!
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
#include "Minecart.h"
|
2013-08-19 05:39:13 -04:00
|
|
|
#include "../World.h"
|
|
|
|
#include "../ClientHandle.h"
|
2013-09-22 15:43:00 -04:00
|
|
|
#include "../Chunk.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
#include "Player.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) :
|
|
|
|
super(etMinecart, a_X, a_Y, a_Z, 0.98, 0.7),
|
2013-10-08 14:20:49 -04:00
|
|
|
m_Payload(a_Payload),
|
|
|
|
m_LastDamage(0)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2013-08-28 17:13:27 -04:00
|
|
|
SetMass(20.f);
|
|
|
|
SetMaxHealth(6);
|
2013-09-02 07:01:49 -04:00
|
|
|
SetHealth(6);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cMinecart::SpawnOn(cClientHandle & a_ClientHandle)
|
|
|
|
{
|
2013-08-29 08:47:22 -04:00
|
|
|
char SubType = 0;
|
2013-08-28 17:13:27 -04:00
|
|
|
switch (m_Payload)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2013-08-29 08:47:22 -04:00
|
|
|
case mpNone: SubType = 0; break;
|
|
|
|
case mpChest: SubType = 1; break;
|
|
|
|
case mpFurnace: SubType = 2; break;
|
|
|
|
case mpTNT: SubType = 3; break;
|
|
|
|
case mpHopper: SubType = 5; break;
|
2013-07-29 07:13:03 -04:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
ASSERT(!"Unknown payload, cannot spawn on client");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-08-29 09:00:39 -04:00
|
|
|
a_ClientHandle.SendSpawnVehicle(*this, 10, SubType); // 10 = Minecarts, SubType = What type of Minecart
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-09-02 07:01:49 -04:00
|
|
|
void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2013-09-22 15:43:00 -04:00
|
|
|
int PosY = (int)floor(GetPosY());
|
|
|
|
if ((PosY <= 0) || (PosY >= cChunkDef::Height))
|
2013-09-02 07:01:49 -04:00
|
|
|
{
|
2013-09-22 15:43:00 -04:00
|
|
|
// Outside the world, just process normal falling physics
|
|
|
|
super::HandlePhysics(a_Dt, a_Chunk);
|
|
|
|
BroadcastMovementUpdate();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RelPosX = (int)floor(GetPosX()) - a_Chunk.GetPosX() * cChunkDef::Width;
|
|
|
|
int RelPosZ = (int)floor(GetPosZ()) - a_Chunk.GetPosZ() * cChunkDef::Width;
|
|
|
|
cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelPosX, RelPosZ);
|
|
|
|
if (Chunk == NULL)
|
|
|
|
{
|
|
|
|
// Inside an unloaded chunk, bail out all processing
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
BLOCKTYPE BelowType = Chunk->GetBlock(RelPosX, PosY - 1, RelPosZ);
|
|
|
|
BLOCKTYPE InsideType = Chunk->GetBlock(RelPosX, PosY, RelPosZ);
|
2013-09-02 07:01:49 -04:00
|
|
|
|
2013-09-22 15:43:00 -04:00
|
|
|
if (IsBlockRail(BelowType))
|
|
|
|
{
|
|
|
|
HandleRailPhysics(a_Dt, *Chunk);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (IsBlockRail(InsideType))
|
2013-09-02 07:01:49 -04:00
|
|
|
{
|
2013-09-22 15:43:00 -04:00
|
|
|
SetPosY(PosY + 1);
|
|
|
|
HandleRailPhysics(a_Dt, *Chunk);
|
2013-09-02 07:01:49 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-22 15:43:00 -04:00
|
|
|
super::HandlePhysics(a_Dt, *Chunk);
|
|
|
|
BroadcastMovementUpdate();
|
2013-09-02 07:01:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const double MAX_SPEED = 8;
|
|
|
|
static const double MAX_SPEED_NEGATIVE = (0 - MAX_SPEED);
|
2013-09-22 15:43:00 -04:00
|
|
|
|
2013-09-02 07:01:49 -04:00
|
|
|
void cMinecart::HandleRailPhysics(float a_Dt, cChunk & a_Chunk)
|
|
|
|
{
|
|
|
|
|
|
|
|
super::HandlePhysics(a_Dt, a_Chunk); // Main physics handling
|
|
|
|
|
2013-08-27 15:38:11 -04:00
|
|
|
/*
|
|
|
|
NOTE: Please bear in mind that taking away from negatives make them even more negative,
|
2013-08-29 08:47:22 -04:00
|
|
|
adding to negatives make them positive, etc.
|
2013-08-27 15:38:11 -04:00
|
|
|
*/
|
|
|
|
|
2013-09-02 07:01:49 -04:00
|
|
|
// Get block meta below the cart
|
2013-09-22 15:43:00 -04:00
|
|
|
int RelPosX = (int)floor(GetPosX()) - a_Chunk.GetPosX() * cChunkDef::Width;
|
|
|
|
int RelPosZ = (int)floor(GetPosZ()) - a_Chunk.GetPosZ() * cChunkDef::Width;
|
|
|
|
NIBBLETYPE BelowMeta = a_Chunk.GetMeta(RelPosX, (int)floor(GetPosY() - 1), RelPosZ);
|
2013-08-27 15:38:11 -04:00
|
|
|
double SpeedX = GetSpeedX(), SpeedY = GetSpeedY(), SpeedZ = GetSpeedZ(); // Get current speed
|
2013-09-02 07:01:49 -04:00
|
|
|
|
|
|
|
switch (BelowMeta)
|
2013-08-27 15:38:11 -04:00
|
|
|
{
|
2013-09-03 07:33:54 -04:00
|
|
|
case E_META_RAIL_ZM_ZP: // NORTHSOUTH
|
2013-08-27 15:38:11 -04:00
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
SetRotation(270);
|
|
|
|
SpeedY = 0; // Don't move vertically as on ground
|
|
|
|
SpeedX = 0; // Correct diagonal movement from curved rails
|
|
|
|
|
|
|
|
if (SpeedZ != 0) // Don't do anything if cart is stationary
|
2013-08-27 15:38:11 -04:00
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
if (SpeedZ > 0)
|
|
|
|
{
|
|
|
|
// Going SOUTH, slow down
|
|
|
|
SpeedZ = SpeedZ - 0.1;
|
|
|
|
}
|
|
|
|
else
|
2013-08-27 15:38:11 -04:00
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
// Going NORTH, slow down
|
|
|
|
SpeedZ = SpeedZ + 0.1;
|
2013-08-27 15:38:11 -04:00
|
|
|
}
|
|
|
|
}
|
2013-09-02 07:01:49 -04:00
|
|
|
break;
|
|
|
|
}
|
2013-08-27 15:38:11 -04:00
|
|
|
|
2013-09-03 07:33:54 -04:00
|
|
|
case E_META_RAIL_XM_XP: // EASTWEST
|
2013-09-02 07:01:49 -04:00
|
|
|
{
|
|
|
|
SetRotation(180);
|
|
|
|
SpeedY = 0;
|
|
|
|
SpeedZ = 0;
|
2013-08-27 15:38:11 -04:00
|
|
|
|
2013-09-02 07:01:49 -04:00
|
|
|
if (SpeedX != 0)
|
|
|
|
{
|
|
|
|
if (SpeedX > 0)
|
2013-08-27 15:38:11 -04:00
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
SpeedX = SpeedX - 0.1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SpeedX = SpeedX + 0.1;
|
2013-08-27 15:38:11 -04:00
|
|
|
}
|
|
|
|
}
|
2013-09-02 07:01:49 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-03 07:33:54 -04:00
|
|
|
case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH
|
2013-09-02 07:01:49 -04:00
|
|
|
{
|
|
|
|
SetRotation(270);
|
|
|
|
SetPosY(floor(GetPosY()) + 0.2); // It seems it doesn't work without levitation :/
|
|
|
|
SpeedX = 0;
|
2013-08-27 15:38:11 -04:00
|
|
|
|
2013-09-02 07:01:49 -04:00
|
|
|
if (SpeedZ >= 0)
|
2013-08-27 15:38:11 -04:00
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
// SpeedZ POSITIVE, going SOUTH
|
|
|
|
if (SpeedZ <= MAX_SPEED) // Speed limit
|
2013-08-27 15:38:11 -04:00
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
SpeedZ = SpeedZ + 0.5; // Speed up
|
|
|
|
SpeedY = (0 - SpeedZ); // Downward movement is negative (0 minus positive numbers is negative)
|
2013-08-27 15:38:11 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
SpeedZ = MAX_SPEED; // Enforce speed limit
|
|
|
|
SpeedY = (0 - SpeedZ);
|
2013-08-27 15:38:11 -04:00
|
|
|
}
|
|
|
|
}
|
2013-09-02 07:01:49 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// SpeedZ NEGATIVE, going NORTH
|
|
|
|
SpeedZ = SpeedZ + 0.4; // Slow down
|
|
|
|
SpeedY = (0 - SpeedZ); // Upward movement is positive (0 minus negative number is positive number)
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-03 07:33:54 -04:00
|
|
|
case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH
|
2013-09-02 07:01:49 -04:00
|
|
|
{
|
|
|
|
SetRotation(270);
|
|
|
|
SetPosY(floor(GetPosY()) + 0.2);
|
|
|
|
SpeedX = 0;
|
2013-08-27 15:38:11 -04:00
|
|
|
|
2013-09-02 07:01:49 -04:00
|
|
|
if (SpeedZ > 0)
|
2013-08-27 15:38:11 -04:00
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
// SpeedZ POSITIVE, going SOUTH
|
|
|
|
SpeedZ = SpeedZ - 0.4; // Slow down
|
|
|
|
SpeedY = SpeedZ; // Upward movement positive
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (SpeedZ >= MAX_SPEED_NEGATIVE) // Speed limit
|
2013-08-27 15:38:11 -04:00
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
// SpeedZ NEGATIVE, going NORTH
|
|
|
|
SpeedZ = SpeedZ - 0.5; // Speed up
|
|
|
|
SpeedY = SpeedZ; // Downward movement negative
|
2013-08-27 15:38:11 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
SpeedZ = MAX_SPEED_NEGATIVE; // Enforce speed limit
|
|
|
|
SpeedY = SpeedZ;
|
2013-08-27 15:38:11 -04:00
|
|
|
}
|
|
|
|
}
|
2013-09-02 07:01:49 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-03 07:33:54 -04:00
|
|
|
case E_META_RAIL_ASCEND_XM: // ASCEND EAST
|
2013-09-02 07:01:49 -04:00
|
|
|
{
|
|
|
|
SetRotation(180);
|
|
|
|
SetPosY(floor(GetPosY()) + 0.2);
|
|
|
|
SpeedZ = 0;
|
2013-08-27 15:38:11 -04:00
|
|
|
|
2013-09-02 07:01:49 -04:00
|
|
|
if (SpeedX >= 0)
|
2013-08-27 15:38:11 -04:00
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
if (SpeedX <= MAX_SPEED)
|
2013-08-27 15:38:11 -04:00
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
SpeedX = SpeedX + 0.5;
|
|
|
|
SpeedY = (0 - SpeedX);
|
2013-08-27 15:38:11 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
SpeedX = MAX_SPEED;
|
2013-08-27 15:38:11 -04:00
|
|
|
SpeedY = (0 - SpeedX);
|
|
|
|
}
|
|
|
|
}
|
2013-09-02 07:01:49 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
SpeedX = SpeedX + 0.4;
|
|
|
|
SpeedY = (0 - SpeedX);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-03 07:33:54 -04:00
|
|
|
case E_META_RAIL_ASCEND_XP: // ASCEND WEST
|
2013-09-02 07:01:49 -04:00
|
|
|
{
|
|
|
|
SetRotation(180);
|
|
|
|
SetPosY(floor(GetPosY()) + 0.2);
|
|
|
|
SpeedZ = 0;
|
2013-08-27 15:38:11 -04:00
|
|
|
|
2013-09-02 07:01:49 -04:00
|
|
|
if (SpeedX > 0)
|
2013-08-27 15:38:11 -04:00
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
SpeedX = SpeedX - 0.4;
|
|
|
|
SpeedY = SpeedX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (SpeedX >= MAX_SPEED_NEGATIVE)
|
2013-08-27 15:38:11 -04:00
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
SpeedX = SpeedX - 0.5;
|
2013-08-27 15:38:11 -04:00
|
|
|
SpeedY = SpeedX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
SpeedX = MAX_SPEED_NEGATIVE;
|
|
|
|
SpeedY = SpeedX;
|
2013-08-27 15:38:11 -04:00
|
|
|
}
|
|
|
|
}
|
2013-09-02 07:01:49 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-03 07:33:54 -04:00
|
|
|
case E_META_RAIL_CURVED_ZM_XM: // Ends pointing NORTH and WEST
|
2013-09-02 07:01:49 -04:00
|
|
|
{
|
|
|
|
SetRotation(315); // Set correct rotation server side
|
|
|
|
SetPosY(floor(GetPosY()) + 0.2); // Levitate dat cart
|
|
|
|
|
|
|
|
if (SpeedZ > 0) // Cart moving south
|
|
|
|
{
|
|
|
|
SpeedX = (0 - SpeedZ); // Diagonally move southwest (which will make cart hit a southwest rail)
|
|
|
|
}
|
|
|
|
else if (SpeedX > 0) // Cart moving east
|
|
|
|
{
|
|
|
|
SpeedZ = (0 - SpeedX); // Diagonally move northeast
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-03 07:33:54 -04:00
|
|
|
case E_META_RAIL_CURVED_ZM_XP: // Curved NORTH EAST
|
2013-09-02 07:01:49 -04:00
|
|
|
{
|
|
|
|
SetRotation(225);
|
|
|
|
SetPosY(floor(GetPosY()) + 0.2);
|
|
|
|
|
|
|
|
if (SpeedZ > 0)
|
|
|
|
{
|
|
|
|
SpeedX = SpeedZ;
|
|
|
|
}
|
|
|
|
else if (SpeedX < 0)
|
|
|
|
{
|
|
|
|
SpeedZ = SpeedX;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-03 07:33:54 -04:00
|
|
|
case E_META_RAIL_CURVED_ZP_XM: // Curved SOUTH WEST
|
2013-09-02 07:01:49 -04:00
|
|
|
{
|
|
|
|
SetRotation(135);
|
|
|
|
SetPosY(floor(GetPosY()) + 0.2);
|
|
|
|
|
|
|
|
if (SpeedZ < 0)
|
|
|
|
{
|
|
|
|
SpeedX = SpeedZ;
|
|
|
|
}
|
|
|
|
else if (SpeedX > 0)
|
|
|
|
{
|
|
|
|
SpeedZ = SpeedX;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-08-27 15:38:11 -04:00
|
|
|
|
2013-09-03 07:33:54 -04:00
|
|
|
case E_META_RAIL_CURVED_ZP_XP: // Curved SOUTH EAST
|
2013-09-02 07:01:49 -04:00
|
|
|
{
|
|
|
|
SetRotation(45);
|
|
|
|
SetPosY(floor(GetPosY()) + 0.2);
|
|
|
|
|
|
|
|
if (SpeedZ < 0)
|
|
|
|
{
|
|
|
|
SpeedX = (0 - SpeedZ);
|
|
|
|
}
|
|
|
|
else if (SpeedX < 0)
|
2013-08-27 15:38:11 -04:00
|
|
|
{
|
2013-09-02 07:01:49 -04:00
|
|
|
SpeedZ = (0 - SpeedX);
|
2013-08-27 15:38:11 -04:00
|
|
|
}
|
2013-09-02 07:01:49 -04:00
|
|
|
break;
|
|
|
|
}
|
2013-08-27 15:38:11 -04:00
|
|
|
|
2013-09-02 07:01:49 -04:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
ASSERT(!"Unhandled rail meta!"); // Dun dun DUN!
|
|
|
|
break;
|
2013-08-27 15:38:11 -04:00
|
|
|
}
|
|
|
|
}
|
2013-09-02 07:01:49 -04:00
|
|
|
|
2013-08-27 15:38:11 -04:00
|
|
|
// Set speed to speed variables
|
|
|
|
SetSpeedX(SpeedX);
|
|
|
|
SetSpeedY(SpeedY);
|
|
|
|
SetSpeedZ(SpeedZ);
|
|
|
|
|
2013-09-02 07:01:49 -04:00
|
|
|
|
|
|
|
// Broadcast position to client
|
2013-08-27 15:38:11 -04:00
|
|
|
BroadcastMovementUpdate();
|
2013-09-02 07:01:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-27 15:38:11 -04:00
|
|
|
|
2013-09-02 07:01:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
void cMinecart::DoTakeDamage(TakeDamageInfo & TDI)
|
|
|
|
{
|
2013-10-08 14:20:49 -04:00
|
|
|
m_LastDamage = TDI.FinalDamage;
|
2013-09-02 07:01:49 -04:00
|
|
|
super::DoTakeDamage(TDI);
|
|
|
|
|
2013-10-08 14:20:49 -04:00
|
|
|
m_World->BroadcastEntityMetadata(*this);
|
|
|
|
|
2013-09-09 13:55:42 -04:00
|
|
|
if (GetHealth() <= 0)
|
2013-09-02 07:01:49 -04:00
|
|
|
{
|
|
|
|
Destroy(true);
|
2013-10-08 14:20:49 -04:00
|
|
|
|
|
|
|
cItems Drops;
|
|
|
|
switch (m_Payload)
|
|
|
|
{
|
|
|
|
case mpNone:
|
|
|
|
{
|
|
|
|
Drops.push_back(cItem(E_ITEM_MINECART, 1, 0));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case mpChest:
|
|
|
|
{
|
|
|
|
Drops.push_back(cItem(E_ITEM_CHEST_MINECART, 1, 0));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case mpFurnace:
|
|
|
|
{
|
|
|
|
Drops.push_back(cItem(E_ITEM_FURNACE_MINECART, 1, 0));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case mpTNT:
|
|
|
|
{
|
2013-10-09 16:02:59 -04:00
|
|
|
Drops.push_back(cItem(E_ITEM_MINECART_WITH_TNT, 1, 0));
|
2013-10-08 14:20:49 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case mpHopper:
|
|
|
|
{
|
2013-10-09 16:02:59 -04:00
|
|
|
Drops.push_back(cItem(E_ITEM_MINECART_WITH_HOPPER, 1, 0));
|
2013-10-08 14:20:49 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
ASSERT(!"Unhandled minecart type when spawning pickup!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ());
|
2013-09-02 07:01:49 -04:00
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// cEmptyMinecart:
|
|
|
|
|
|
|
|
cEmptyMinecart::cEmptyMinecart(double a_X, double a_Y, double a_Z) :
|
|
|
|
super(mpNone, a_X, a_Y, a_Z)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cEmptyMinecart::OnRightClicked(cPlayer & a_Player)
|
|
|
|
{
|
|
|
|
if (m_Attachee != NULL)
|
|
|
|
{
|
|
|
|
if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
|
|
|
|
{
|
|
|
|
// This player is already sitting in, they want out.
|
|
|
|
a_Player.Detach();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_Attachee->IsPlayer())
|
|
|
|
{
|
|
|
|
// Another player is already sitting in here, cannot attach
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Detach whatever is sitting in this minecart now:
|
|
|
|
m_Attachee->Detach();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Attach the player to this minecart
|
|
|
|
a_Player.AttachTo(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// cMinecartWithChest:
|
|
|
|
|
|
|
|
cMinecartWithChest::cMinecartWithChest(double a_X, double a_Y, double a_Z) :
|
|
|
|
super(mpChest, a_X, a_Y, a_Z)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cMinecartWithChest::SetSlot(int a_Idx, const cItem & a_Item)
|
|
|
|
{
|
|
|
|
ASSERT((a_Idx >= 0) && (a_Idx < ARRAYCOUNT(m_Items)));
|
|
|
|
|
|
|
|
m_Items[a_Idx] = a_Item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cMinecartWithChest::OnRightClicked(cPlayer & a_Player)
|
|
|
|
{
|
|
|
|
// Show the chest UI window to the player
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// cMinecartWithFurnace:
|
|
|
|
|
|
|
|
cMinecartWithFurnace::cMinecartWithFurnace(double a_X, double a_Y, double a_Z) :
|
2013-10-08 14:20:49 -04:00
|
|
|
super(mpFurnace, a_X, a_Y, a_Z),
|
|
|
|
m_IsFueled(false)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cMinecartWithFurnace::OnRightClicked(cPlayer & a_Player)
|
|
|
|
{
|
2013-10-08 14:20:49 -04:00
|
|
|
if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_COAL)
|
|
|
|
{
|
|
|
|
if (!a_Player.IsGameModeCreative())
|
|
|
|
{
|
|
|
|
a_Player.GetInventory().RemoveOneEquippedItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_IsFueled = true;
|
|
|
|
m_World->BroadcastEntityMetadata(*this);
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-08-16 06:23:24 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// cMinecartWithTNT:
|
|
|
|
|
|
|
|
cMinecartWithTNT::cMinecartWithTNT(double a_X, double a_Y, double a_Z) :
|
|
|
|
super(mpTNT, a_X, a_Y, a_Z)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Make it activate when passing over activator rail
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// cMinecartWithHopper:
|
|
|
|
|
|
|
|
cMinecartWithHopper::cMinecartWithHopper(double a_X, double a_Y, double a_Z) :
|
|
|
|
super(mpHopper, a_X, a_Y, a_Z)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Make it suck up blocks and travel further than any other cart and physics and put and take blocks
|
|
|
|
// AND AVARYTHING!!
|