Merge branch 'master' of git://github.com/tigerw/MCServer into tigerw-master
This commit is contained in:
commit
cdaa483778
@ -1 +1 @@
|
||||
Subproject commit c8ef7e9f8ed2bc1ffdbb3756c2024536bf004698
|
||||
Subproject commit e3a45f34303331be77aceacf2ba53e503ad7284f
|
@ -1 +1 @@
|
||||
Subproject commit bef8ff2a883e98db94f842f9db3d256a039b1fcd
|
||||
Subproject commit 3019c7b396221b987cd3f89d422276f764834ffe
|
59370
source/Bindings.cpp
59370
source/Bindings.cpp
File diff suppressed because it is too large
Load Diff
@ -782,7 +782,7 @@ public:
|
||||
g_BlockIsSolid[E_BLOCK_NETHER_PORTAL] = false;
|
||||
g_BlockIsSolid[E_BLOCK_PISTON] = false;
|
||||
g_BlockIsSolid[E_BLOCK_PISTON_EXTENSION] = false;
|
||||
g_BlockIsSolid[E_BLOCK_RAIL] = false;
|
||||
g_BlockIsSolid[E_BLOCK_RAIL] = true;
|
||||
g_BlockIsSolid[E_BLOCK_REDSTONE_REPEATER_OFF] = false;
|
||||
g_BlockIsSolid[E_BLOCK_REDSTONE_REPEATER_ON] = false;
|
||||
g_BlockIsSolid[E_BLOCK_REDSTONE_TORCH_OFF] = false;
|
||||
|
@ -560,6 +560,18 @@ enum
|
||||
E_META_SNOW_LAYER_SEVEN = 6,
|
||||
E_META_SNOW_LAYER_EIGHT = 7,
|
||||
|
||||
// E_BLOCK_RAIL metas
|
||||
E_META_RAIL_ZM_ZP = 0,
|
||||
E_META_RAIL_XM_XP = 1,
|
||||
E_META_RAIL_ASCEND_XP = 2,
|
||||
E_META_RAIL_ASCEND_XM = 3,
|
||||
E_META_RAIL_ASCEND_ZM = 4,
|
||||
E_META_RAIL_ASCEND_ZP = 5,
|
||||
E_META_RAIL_CURVED_ZP_XP = 6,
|
||||
E_META_RAIL_CURVED_ZP_XM = 7,
|
||||
E_META_RAIL_CURVED_ZM_XM = 8,
|
||||
E_META_RAIL_CURVED_ZM_XP = 9,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Item metas:
|
||||
|
||||
|
@ -8,37 +8,6 @@
|
||||
|
||||
|
||||
|
||||
/// Meta values for the rail
|
||||
enum ENUM_RAIL_DIRECTIONS
|
||||
{
|
||||
E_RAIL_NORTH_SOUTH = 0,
|
||||
E_RAIL_EAST_WEST = 1,
|
||||
E_RAIL_ASCEND_EAST = 2,
|
||||
E_RAIL_ASCEND_WEST = 3,
|
||||
E_RAIL_ASCEND_NORTH = 4,
|
||||
E_RAIL_ASCEND_SOUTH = 5,
|
||||
E_RAIL_CURVED_SOUTH_EAST = 6,
|
||||
E_RAIL_CURVED_SOUTH_WEST = 7,
|
||||
E_RAIL_CURVED_NORTH_WEST = 8,
|
||||
E_RAIL_CURVED_NORTH_EAST = 9,
|
||||
|
||||
// Some useful synonyms:
|
||||
E_RAIL_DIR_X = E_RAIL_EAST_WEST,
|
||||
E_RAIL_DIR_Z = E_RAIL_NORTH_SOUTH,
|
||||
E_RAIL_ASCEND_XP = E_RAIL_ASCEND_EAST,
|
||||
E_RAIL_ASCEND_XM = E_RAIL_ASCEND_WEST,
|
||||
E_RAIL_ASCEND_ZM = E_RAIL_ASCEND_NORTH,
|
||||
E_RAIL_ASCEND_ZP = E_RAIL_ASCEND_SOUTH,
|
||||
E_RAIL_CURVED_XPZP = E_RAIL_CURVED_SOUTH_EAST,
|
||||
E_RAIL_CURVED_XMZP = E_RAIL_CURVED_SOUTH_WEST,
|
||||
E_RAIL_CURVED_XMZM = E_RAIL_CURVED_NORTH_WEST,
|
||||
E_RAIL_CURVED_XPZM = E_RAIL_CURVED_NORTH_EAST,
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enum ENUM_PURE
|
||||
{
|
||||
E_PURE_UPDOWN = 0,
|
||||
@ -96,13 +65,13 @@ public:
|
||||
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
|
||||
switch (Meta)
|
||||
{
|
||||
case E_RAIL_ASCEND_EAST:
|
||||
case E_RAIL_ASCEND_WEST:
|
||||
case E_RAIL_ASCEND_NORTH:
|
||||
case E_RAIL_ASCEND_SOUTH:
|
||||
case E_META_RAIL_ASCEND_XP:
|
||||
case E_META_RAIL_ASCEND_XM:
|
||||
case E_META_RAIL_ASCEND_ZM:
|
||||
case E_META_RAIL_ASCEND_ZP:
|
||||
{
|
||||
// Mapping between the meta and the neighbors that need checking
|
||||
Meta -= E_RAIL_ASCEND_EAST; // Base index at zero
|
||||
Meta -= E_META_RAIL_ASCEND_XP; // Base index at zero
|
||||
static const struct
|
||||
{
|
||||
int x, z;
|
||||
@ -157,12 +126,12 @@ public:
|
||||
}
|
||||
if (RailsCnt == 1)
|
||||
{
|
||||
if (Neighbors[7]) return E_RAIL_ASCEND_SOUTH;
|
||||
else if (Neighbors[6]) return E_RAIL_ASCEND_NORTH;
|
||||
else if (Neighbors[5]) return E_RAIL_ASCEND_WEST;
|
||||
else if (Neighbors[4]) return E_RAIL_ASCEND_EAST;
|
||||
else if (Neighbors[0] || Neighbors[1]) return E_RAIL_EAST_WEST;
|
||||
else if (Neighbors[2] || Neighbors[3]) return E_RAIL_NORTH_SOUTH;
|
||||
if (Neighbors[7]) return E_META_RAIL_ASCEND_ZP;
|
||||
else if (Neighbors[6]) return E_META_RAIL_ASCEND_ZM;
|
||||
else if (Neighbors[5]) return E_META_RAIL_ASCEND_XM;
|
||||
else if (Neighbors[4]) return E_META_RAIL_ASCEND_XP;
|
||||
else if (Neighbors[0] || Neighbors[1]) return E_META_RAIL_XM_XP;
|
||||
else if (Neighbors[2] || Neighbors[3]) return E_META_RAIL_ZM_ZP;
|
||||
ASSERT(!"Weird neighbor count");
|
||||
return Meta;
|
||||
}
|
||||
@ -175,16 +144,16 @@ public:
|
||||
}
|
||||
if (RailsCnt > 1)
|
||||
{
|
||||
if (Neighbors[3] && Neighbors[0]) return E_RAIL_CURVED_SOUTH_EAST;
|
||||
else if (Neighbors[3] && Neighbors[1]) return E_RAIL_CURVED_SOUTH_WEST;
|
||||
else if (Neighbors[2] && Neighbors[0]) return E_RAIL_CURVED_NORTH_EAST;
|
||||
else if (Neighbors[2] && Neighbors[1]) return E_RAIL_CURVED_NORTH_WEST;
|
||||
else if (Neighbors[7] && Neighbors[2]) return E_RAIL_ASCEND_SOUTH;
|
||||
else if (Neighbors[3] && Neighbors[6]) return E_RAIL_ASCEND_NORTH;
|
||||
else if (Neighbors[5] && Neighbors[0]) return E_RAIL_ASCEND_WEST;
|
||||
else if (Neighbors[4] && Neighbors[1]) return E_RAIL_ASCEND_EAST;
|
||||
else if (Neighbors[0] && Neighbors[1]) return E_RAIL_EAST_WEST;
|
||||
else if (Neighbors[2] && Neighbors[3]) return E_RAIL_NORTH_SOUTH;
|
||||
if (Neighbors[3] && Neighbors[0]) return E_META_RAIL_CURVED_ZP_XP;
|
||||
else if (Neighbors[3] && Neighbors[1]) return E_META_RAIL_CURVED_ZP_XM;
|
||||
else if (Neighbors[2] && Neighbors[0]) return E_META_RAIL_CURVED_ZM_XP;
|
||||
else if (Neighbors[2] && Neighbors[1]) return E_META_RAIL_CURVED_ZM_XM;
|
||||
else if (Neighbors[7] && Neighbors[2]) return E_META_RAIL_ASCEND_ZP;
|
||||
else if (Neighbors[3] && Neighbors[6]) return E_META_RAIL_ASCEND_ZM;
|
||||
else if (Neighbors[5] && Neighbors[0]) return E_META_RAIL_ASCEND_XM;
|
||||
else if (Neighbors[4] && Neighbors[1]) return E_META_RAIL_ASCEND_XP;
|
||||
else if (Neighbors[0] && Neighbors[1]) return E_META_RAIL_XM_XP;
|
||||
else if (Neighbors[2] && Neighbors[3]) return E_META_RAIL_ZM_ZP;
|
||||
ASSERT(!"Weird neighbor count");
|
||||
}
|
||||
return Meta;
|
||||
@ -200,7 +169,7 @@ public:
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
switch (Meta)
|
||||
{
|
||||
case E_RAIL_NORTH_SOUTH:
|
||||
case E_META_RAIL_ZM_ZP:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN) ||
|
||||
@ -212,7 +181,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case E_RAIL_EAST_WEST:
|
||||
case E_META_RAIL_XM_XP:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN) ||
|
||||
@ -224,7 +193,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case E_RAIL_ASCEND_EAST:
|
||||
case E_META_RAIL_ASCEND_XP:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_EAST) ||
|
||||
@ -236,7 +205,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case E_RAIL_ASCEND_WEST:
|
||||
case E_META_RAIL_ASCEND_XM:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) ||
|
||||
@ -248,7 +217,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case E_RAIL_ASCEND_NORTH:
|
||||
case E_META_RAIL_ASCEND_ZM:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH) ||
|
||||
@ -260,7 +229,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case E_RAIL_ASCEND_SOUTH:
|
||||
case E_META_RAIL_ASCEND_ZP:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
|
||||
@ -272,7 +241,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case E_RAIL_CURVED_SOUTH_EAST:
|
||||
case E_META_RAIL_CURVED_ZP_XP:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ||
|
||||
@ -284,7 +253,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case E_RAIL_CURVED_SOUTH_WEST:
|
||||
case E_META_RAIL_CURVED_ZP_XM:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ||
|
||||
@ -296,7 +265,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case E_RAIL_CURVED_NORTH_WEST:
|
||||
case E_META_RAIL_CURVED_ZM_XM:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
|
||||
@ -308,7 +277,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case E_RAIL_CURVED_NORTH_EAST:
|
||||
case E_META_RAIL_CURVED_ZM_XP:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
|
||||
@ -356,11 +325,11 @@ public:
|
||||
case BLOCK_FACE_NORTH:
|
||||
{
|
||||
if (
|
||||
(Meta == E_RAIL_NORTH_SOUTH) ||
|
||||
(Meta == E_RAIL_ASCEND_NORTH) ||
|
||||
(Meta == E_RAIL_ASCEND_SOUTH) ||
|
||||
(Meta == E_RAIL_CURVED_SOUTH_EAST) ||
|
||||
(Meta == E_RAIL_CURVED_SOUTH_WEST)
|
||||
(Meta == E_META_RAIL_ZM_ZP) ||
|
||||
(Meta == E_META_RAIL_ASCEND_ZM) ||
|
||||
(Meta == E_META_RAIL_ASCEND_ZP) ||
|
||||
(Meta == E_META_RAIL_CURVED_ZP_XP) ||
|
||||
(Meta == E_META_RAIL_CURVED_ZP_XM)
|
||||
)
|
||||
{
|
||||
return false;
|
||||
@ -371,11 +340,11 @@ public:
|
||||
case BLOCK_FACE_SOUTH:
|
||||
{
|
||||
if (
|
||||
(Meta == E_RAIL_NORTH_SOUTH) ||
|
||||
(Meta == E_RAIL_ASCEND_NORTH) ||
|
||||
(Meta == E_RAIL_ASCEND_SOUTH) ||
|
||||
(Meta == E_RAIL_CURVED_NORTH_EAST) ||
|
||||
(Meta == E_RAIL_CURVED_NORTH_WEST)
|
||||
(Meta == E_META_RAIL_ZM_ZP) ||
|
||||
(Meta == E_META_RAIL_ASCEND_ZM) ||
|
||||
(Meta == E_META_RAIL_ASCEND_ZP) ||
|
||||
(Meta == E_META_RAIL_CURVED_ZM_XP) ||
|
||||
(Meta == E_META_RAIL_CURVED_ZM_XM)
|
||||
)
|
||||
{
|
||||
return false;
|
||||
@ -386,11 +355,11 @@ public:
|
||||
case BLOCK_FACE_EAST:
|
||||
{
|
||||
if (
|
||||
(Meta == E_RAIL_EAST_WEST) ||
|
||||
(Meta == E_RAIL_ASCEND_EAST) ||
|
||||
(Meta == E_RAIL_ASCEND_WEST) ||
|
||||
(Meta == E_RAIL_CURVED_SOUTH_WEST) ||
|
||||
(Meta == E_RAIL_CURVED_NORTH_WEST)
|
||||
(Meta == E_META_RAIL_XM_XP) ||
|
||||
(Meta == E_META_RAIL_ASCEND_XP) ||
|
||||
(Meta == E_META_RAIL_ASCEND_XM) ||
|
||||
(Meta == E_META_RAIL_CURVED_ZP_XM) ||
|
||||
(Meta == E_META_RAIL_CURVED_ZM_XM)
|
||||
)
|
||||
{
|
||||
return false;
|
||||
@ -400,11 +369,11 @@ public:
|
||||
case BLOCK_FACE_WEST:
|
||||
{
|
||||
if (
|
||||
(Meta == E_RAIL_EAST_WEST) ||
|
||||
(Meta == E_RAIL_ASCEND_EAST) ||
|
||||
(Meta == E_RAIL_ASCEND_WEST) ||
|
||||
(Meta == E_RAIL_CURVED_SOUTH_EAST) ||
|
||||
(Meta == E_RAIL_CURVED_NORTH_EAST)
|
||||
(Meta == E_META_RAIL_XM_XP) ||
|
||||
(Meta == E_META_RAIL_ASCEND_XP) ||
|
||||
(Meta == E_META_RAIL_ASCEND_XM) ||
|
||||
(Meta == E_META_RAIL_CURVED_ZP_XP) ||
|
||||
(Meta == E_META_RAIL_CURVED_ZM_XP)
|
||||
)
|
||||
{
|
||||
return false;
|
||||
|
@ -1938,9 +1938,9 @@ void cClientHandle::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
|
||||
|
||||
|
||||
|
||||
void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType)
|
||||
void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) // VehicleTypeType is specific to Minecarts
|
||||
{
|
||||
m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType);
|
||||
m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType, a_VehicleSubType);
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,7 +125,7 @@ public:
|
||||
void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock);
|
||||
void SendSpawnMob (const cMonster & a_Mob);
|
||||
void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch);
|
||||
void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType);
|
||||
void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType);
|
||||
void SendTabCompletionResults(const AStringVector & a_Results);
|
||||
void SendTeleportEntity (const cEntity & a_Entity);
|
||||
void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
@ -503,6 +503,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
||||
int RelBlockX = BlockX - (NextChunk->GetPosX() * cChunkDef::Width);
|
||||
int RelBlockZ = BlockZ - (NextChunk->GetPosZ() * cChunkDef::Width);
|
||||
BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ );
|
||||
BLOCKTYPE BlockBelow = NextChunk->GetBlock( RelBlockX, BlockY - 1, RelBlockZ );
|
||||
if (!g_BlockIsSolid[BlockIn]) // Making sure we are not inside a solid block
|
||||
{
|
||||
if (m_bOnGround) // check if it's still on the ground
|
||||
@ -545,18 +546,26 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Friction
|
||||
if (NextSpeed.SqrLength() > 0.0004f)
|
||||
if (
|
||||
(BlockBelow != E_BLOCK_RAIL) &&
|
||||
(BlockBelow != E_BLOCK_DETECTOR_RAIL) &&
|
||||
(BlockBelow != E_BLOCK_POWERED_RAIL) &&
|
||||
(BlockBelow != E_BLOCK_ACTIVATOR_RAIL)
|
||||
)
|
||||
{
|
||||
NextSpeed.x *= 0.7f / (1 + a_Dt);
|
||||
if (fabs(NextSpeed.x) < 0.05)
|
||||
// Friction
|
||||
if (NextSpeed.SqrLength() > 0.0004f)
|
||||
{
|
||||
NextSpeed.x = 0;
|
||||
}
|
||||
NextSpeed.z *= 0.7f / (1 + a_Dt);
|
||||
if (fabs(NextSpeed.z) < 0.05)
|
||||
{
|
||||
NextSpeed.z = 0;
|
||||
NextSpeed.x *= 0.7f / (1 + a_Dt);
|
||||
if (fabs(NextSpeed.x) < 0.05)
|
||||
{
|
||||
NextSpeed.x = 0;
|
||||
}
|
||||
NextSpeed.z *= 0.7f / (1 + a_Dt);
|
||||
if (fabs(NextSpeed.z) < 0.05)
|
||||
{
|
||||
NextSpeed.z = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ protected:
|
||||
|
||||
bool m_bOnGround;
|
||||
float m_Gravity;
|
||||
|
||||
|
||||
// Last Position.
|
||||
double m_LastPosX, m_LastPosY, m_LastPosZ;
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Minecart.cpp
|
||||
|
||||
// Implements the cMinecart class representing a minecart in the world
|
||||
// Indiana Jones!
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Minecart.h"
|
||||
@ -17,6 +18,9 @@ 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),
|
||||
m_Payload(a_Payload)
|
||||
{
|
||||
SetMass(20.f);
|
||||
SetMaxHealth(6);
|
||||
SetHealth(6);
|
||||
}
|
||||
|
||||
|
||||
@ -24,30 +28,329 @@ cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) :
|
||||
|
||||
void cMinecart::SpawnOn(cClientHandle & a_ClientHandle)
|
||||
{
|
||||
char Type = 0;
|
||||
switch (m_Payload) //Wiki.vg is outdated on this!!
|
||||
char SubType = 0;
|
||||
switch (m_Payload)
|
||||
{
|
||||
case mpNone: Type = 9; break; //?
|
||||
case mpChest: Type = 10; break;
|
||||
case mpFurnace: Type = 11; break; //?
|
||||
case mpTNT: Type = 12; break; //?
|
||||
case mpHopper: Type = 13; break; //?
|
||||
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;
|
||||
default:
|
||||
{
|
||||
ASSERT(!"Unknown payload, cannot spawn on client");
|
||||
return;
|
||||
}
|
||||
}
|
||||
a_ClientHandle.SendSpawnVehicle(*this, Type);
|
||||
a_ClientHandle.SendSpawnVehicle(*this, 10, SubType); // 10 = Minecarts, SubType = What type of Minecart
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cMinecart::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
||||
{
|
||||
// TODO: the physics
|
||||
if ((GetPosY() > 0) && (GetPosY() < cChunkDef::Height))
|
||||
{
|
||||
BLOCKTYPE BelowType = GetWorld()->GetBlock(floor(GetPosX()), floor(GetPosY() -1 ), floor(GetPosZ()));
|
||||
|
||||
if (
|
||||
(BelowType == E_BLOCK_RAIL) ||
|
||||
(BelowType == E_BLOCK_POWERED_RAIL) ||
|
||||
(BelowType == E_BLOCK_DETECTOR_RAIL) ||
|
||||
(BelowType == E_BLOCK_ACTIVATOR_RAIL)
|
||||
)
|
||||
{
|
||||
HandleRailPhysics(a_Dt, a_Chunk);
|
||||
}
|
||||
else
|
||||
{
|
||||
super::HandlePhysics(a_Dt, a_Chunk);
|
||||
BroadcastMovementUpdate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super::HandlePhysics(a_Dt, a_Chunk);
|
||||
BroadcastMovementUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static const double MAX_SPEED = 8;
|
||||
static const double MAX_SPEED_NEGATIVE = (0 - MAX_SPEED);
|
||||
void cMinecart::HandleRailPhysics(float a_Dt, cChunk & a_Chunk)
|
||||
{
|
||||
|
||||
super::HandlePhysics(a_Dt, a_Chunk); // Main physics handling
|
||||
|
||||
/*
|
||||
NOTE: Please bear in mind that taking away from negatives make them even more negative,
|
||||
adding to negatives make them positive, etc.
|
||||
*/
|
||||
|
||||
// Get block meta below the cart
|
||||
NIBBLETYPE BelowMeta = GetWorld()->GetBlockMeta(floor(GetPosX()), floor(GetPosY() -1 ), floor(GetPosZ()));
|
||||
double SpeedX = GetSpeedX(), SpeedY = GetSpeedY(), SpeedZ = GetSpeedZ(); // Get current speed
|
||||
|
||||
switch (BelowMeta)
|
||||
{
|
||||
case E_META_RAIL_ZM_ZP: // NORTHSOUTH
|
||||
{
|
||||
SetRotation(270);
|
||||
SpeedY = 0; // Don't move vertically as on ground
|
||||
SpeedX = 0; // Correct diagonal movement from curved rails
|
||||
|
||||
// Set Y as current Y rounded up to bypass friction
|
||||
SetPosY(floor(GetPosY()));
|
||||
|
||||
if (SpeedZ != 0) // Don't do anything if cart is stationary
|
||||
{
|
||||
if (SpeedZ > 0)
|
||||
{
|
||||
// Going SOUTH, slow down
|
||||
SpeedZ = SpeedZ - 0.1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Going NORTH, slow down
|
||||
SpeedZ = SpeedZ + 0.1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_META_RAIL_XM_XP: // EASTWEST
|
||||
{
|
||||
SetRotation(180);
|
||||
SpeedY = 0;
|
||||
SpeedZ = 0;
|
||||
|
||||
SetPosY(floor(GetPosY()));
|
||||
|
||||
if (SpeedX != 0)
|
||||
{
|
||||
if (SpeedX > 0)
|
||||
{
|
||||
SpeedX = SpeedX - 0.1;
|
||||
}
|
||||
else
|
||||
{
|
||||
SpeedX = SpeedX + 0.1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH
|
||||
{
|
||||
SetRotation(270);
|
||||
SetPosY(floor(GetPosY()) + 0.2); // It seems it doesn't work without levitation :/
|
||||
SpeedX = 0;
|
||||
|
||||
if (SpeedZ >= 0)
|
||||
{
|
||||
// SpeedZ POSITIVE, going SOUTH
|
||||
if (SpeedZ <= MAX_SPEED) // Speed limit
|
||||
{
|
||||
SpeedZ = SpeedZ + 0.5; // Speed up
|
||||
SpeedY = (0 - SpeedZ); // Downward movement is negative (0 minus positive numbers is negative)
|
||||
}
|
||||
else
|
||||
{
|
||||
SpeedZ = MAX_SPEED; // Enforce speed limit
|
||||
SpeedY = (0 - SpeedZ);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH
|
||||
{
|
||||
SetRotation(270);
|
||||
SetPosY(floor(GetPosY()) + 0.2);
|
||||
SpeedX = 0;
|
||||
|
||||
if (SpeedZ > 0)
|
||||
{
|
||||
// SpeedZ POSITIVE, going SOUTH
|
||||
SpeedZ = SpeedZ - 0.4; // Slow down
|
||||
SpeedY = SpeedZ; // Upward movement positive
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SpeedZ >= MAX_SPEED_NEGATIVE) // Speed limit
|
||||
{
|
||||
// SpeedZ NEGATIVE, going NORTH
|
||||
SpeedZ = SpeedZ - 0.5; // Speed up
|
||||
SpeedY = SpeedZ; // Downward movement negative
|
||||
}
|
||||
else
|
||||
{
|
||||
SpeedZ = MAX_SPEED_NEGATIVE; // Enforce speed limit
|
||||
SpeedY = SpeedZ;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_META_RAIL_ASCEND_XM: // ASCEND EAST
|
||||
{
|
||||
SetRotation(180);
|
||||
SetPosY(floor(GetPosY()) + 0.2);
|
||||
SpeedZ = 0;
|
||||
|
||||
if (SpeedX >= 0)
|
||||
{
|
||||
if (SpeedX <= MAX_SPEED)
|
||||
{
|
||||
SpeedX = SpeedX + 0.5;
|
||||
SpeedY = (0 - SpeedX);
|
||||
}
|
||||
else
|
||||
{
|
||||
SpeedX = MAX_SPEED;
|
||||
SpeedY = (0 - SpeedX);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SpeedX = SpeedX + 0.4;
|
||||
SpeedY = (0 - SpeedX);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_META_RAIL_ASCEND_XP: // ASCEND WEST
|
||||
{
|
||||
SetRotation(180);
|
||||
SetPosY(floor(GetPosY()) + 0.2);
|
||||
SpeedZ = 0;
|
||||
|
||||
if (SpeedX > 0)
|
||||
{
|
||||
SpeedX = SpeedX - 0.4;
|
||||
SpeedY = SpeedX;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SpeedX >= MAX_SPEED_NEGATIVE)
|
||||
{
|
||||
SpeedX = SpeedX - 0.5;
|
||||
SpeedY = SpeedX;
|
||||
}
|
||||
else
|
||||
{
|
||||
SpeedX = MAX_SPEED_NEGATIVE;
|
||||
SpeedY = SpeedX;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_META_RAIL_CURVED_ZM_XM: // Ends pointing NORTH and WEST
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
case E_META_RAIL_CURVED_ZM_XP: // Curved NORTH EAST
|
||||
{
|
||||
SetRotation(225);
|
||||
SetPosY(floor(GetPosY()) + 0.2);
|
||||
|
||||
if (SpeedZ > 0)
|
||||
{
|
||||
SpeedX = SpeedZ;
|
||||
}
|
||||
else if (SpeedX < 0)
|
||||
{
|
||||
SpeedZ = SpeedX;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_META_RAIL_CURVED_ZP_XM: // Curved SOUTH WEST
|
||||
{
|
||||
SetRotation(135);
|
||||
SetPosY(floor(GetPosY()) + 0.2);
|
||||
|
||||
if (SpeedZ < 0)
|
||||
{
|
||||
SpeedX = SpeedZ;
|
||||
}
|
||||
else if (SpeedX > 0)
|
||||
{
|
||||
SpeedZ = SpeedX;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_META_RAIL_CURVED_ZP_XP: // Curved SOUTH EAST
|
||||
{
|
||||
SetRotation(45);
|
||||
SetPosY(floor(GetPosY()) + 0.2);
|
||||
|
||||
if (SpeedZ < 0)
|
||||
{
|
||||
SpeedX = (0 - SpeedZ);
|
||||
}
|
||||
else if (SpeedX < 0)
|
||||
{
|
||||
SpeedZ = (0 - SpeedX);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
ASSERT(!"Unhandled rail meta!"); // Dun dun DUN!
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Set speed to speed variables
|
||||
SetSpeedX(SpeedX);
|
||||
SetSpeedY(SpeedY);
|
||||
SetSpeedZ(SpeedZ);
|
||||
|
||||
|
||||
// Broadcast position to client
|
||||
BroadcastMovementUpdate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cMinecart::DoTakeDamage(TakeDamageInfo & TDI)
|
||||
{
|
||||
super::DoTakeDamage(TDI);
|
||||
|
||||
if (GetHealth() == 0)
|
||||
{
|
||||
Destroy(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,7 +36,10 @@ public:
|
||||
|
||||
// cEntity overrides:
|
||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override;
|
||||
void HandleRailPhysics(float a_Dt, cChunk & a_Chunk);
|
||||
virtual void DoTakeDamage(TakeDamageInfo & TDI) override;
|
||||
|
||||
|
||||
ePayload GetPayload(void) const { return m_Payload; }
|
||||
|
||||
|
@ -21,12 +21,13 @@ void cSkeleton::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
{
|
||||
cMonster::Tick(a_Dt, a_Chunk);
|
||||
|
||||
// TODO Outsource
|
||||
// TODO should do SkyLight check, mobs in the dark don´t burn
|
||||
if ((GetWorld()->GetTimeOfDay() < (12000 + 1000)) && !IsOnFire())
|
||||
if ((GetWorld()->GetBlockSkyLight(GetPosX(), GetPosY(), GetPosZ()) == 15) && (GetWorld()->GetBlock(GetPosX(), GetPosY(), GetPosZ()) != E_BLOCK_SOULSAND))
|
||||
{
|
||||
// Burn for 10 ticks, then decide again
|
||||
StartBurning(10);
|
||||
if ((GetWorld()->GetTimeOfDay() < (12000 + 1000)) && !IsOnFire())
|
||||
{
|
||||
// Burn for 100 ticks, then decide again
|
||||
StartBurning(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,12 @@
|
||||
|
||||
#include "Zombie.h"
|
||||
#include "../World.h"
|
||||
#include "../LineBlockTracer.h"
|
||||
|
||||
|
||||
|
||||
|
||||
// They're eating your brains!
|
||||
|
||||
cZombie::cZombie(void) :
|
||||
super("Zombie", 54, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8)
|
||||
@ -20,12 +22,13 @@ cZombie::cZombie(void) :
|
||||
void cZombie::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
{
|
||||
super::Tick(a_Dt, a_Chunk);
|
||||
|
||||
// TODO Same as in cSkeleton :D
|
||||
if ((GetWorld()->GetTimeOfDay() < (12000 + 1000)) && !IsOnFire())
|
||||
if ((GetWorld()->GetBlockSkyLight(GetPosX(), GetPosY(), GetPosZ()) == 15) && (GetWorld()->GetBlock(GetPosX(), GetPosY(), GetPosZ()) != E_BLOCK_SOULSAND))
|
||||
{
|
||||
// Burn for 10 ticks, then decide again
|
||||
StartBurning(10);
|
||||
if ((GetWorld()->GetTimeOfDay() < (12000 + 1000)) && !IsOnFire())
|
||||
{
|
||||
// Burn for 100 ticks, then decide again
|
||||
StartBurning(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) = 0;
|
||||
virtual void SendSpawnMob (const cMonster & a_Mob) = 0;
|
||||
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) = 0;
|
||||
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType) = 0;
|
||||
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) = 0;
|
||||
virtual void SendTabCompletionResults(const AStringVector & a_Results) = 0;
|
||||
virtual void SendTeleportEntity (const cEntity & a_Entity) = 0;
|
||||
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
|
||||
|
@ -747,7 +747,7 @@ void cProtocol125::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
|
||||
|
||||
|
||||
|
||||
void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType)
|
||||
void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType)
|
||||
{
|
||||
cCSLock Lock(m_CSPacket);
|
||||
WriteByte (PACKET_SPAWN_OBJECT);
|
||||
@ -758,10 +758,13 @@ void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp
|
||||
WriteInt ((int)(a_Vehicle.GetPosZ() * 32));
|
||||
WriteByte ((Byte)((a_Vehicle.GetPitch() / 360.f) * 256));
|
||||
WriteByte ((Byte)((a_Vehicle.GetRotation() / 360.f) * 256));
|
||||
WriteInt (1);
|
||||
WriteShort((short)(a_Vehicle.GetSpeedX() * 400));
|
||||
WriteShort((short)(a_Vehicle.GetSpeedY() * 400));
|
||||
WriteShort((short)(a_Vehicle.GetSpeedZ() * 400));
|
||||
WriteInt (a_VehicleSubType);
|
||||
if (a_VehicleSubType != 0)
|
||||
{
|
||||
WriteShort((short)(a_Vehicle.GetSpeedX() * 400));
|
||||
WriteShort((short)(a_Vehicle.GetSpeedY() * 400));
|
||||
WriteShort((short)(a_Vehicle.GetSpeedZ() * 400));
|
||||
}
|
||||
Flush();
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
|
||||
virtual void SendSpawnMob (const cMonster & a_Mob) override;
|
||||
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override;
|
||||
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType) override;
|
||||
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) override;
|
||||
virtual void SendTabCompletionResults(const AStringVector & a_Results) override;
|
||||
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
|
||||
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
|
@ -229,21 +229,24 @@ void cProtocol146::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
|
||||
|
||||
|
||||
|
||||
void cProtocol146::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType)
|
||||
void cProtocol146::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType)
|
||||
{
|
||||
cCSLock Lock(m_CSPacket);
|
||||
WriteByte(PACKET_SPAWN_OBJECT);
|
||||
WriteInt (a_Vehicle.GetUniqueID());
|
||||
WriteByte(a_VehicleType);
|
||||
WriteInt ((int)(a_Vehicle.GetPosX() * 32));
|
||||
WriteInt ((int)(a_Vehicle.GetPosY() * 32));
|
||||
WriteInt ((int)(a_Vehicle.GetPosZ() * 32));
|
||||
WriteByte (PACKET_SPAWN_OBJECT);
|
||||
WriteInt (a_Vehicle.GetUniqueID());
|
||||
WriteByte (a_VehicleType);
|
||||
WriteInt ((int)(a_Vehicle.GetPosX() * 32));
|
||||
WriteInt ((int)(a_Vehicle.GetPosY() * 32));
|
||||
WriteInt ((int)(a_Vehicle.GetPosZ() * 32));
|
||||
WriteByte ((Byte)((a_Vehicle.GetPitch() / 360.f) * 256));
|
||||
WriteByte ((Byte)((a_Vehicle.GetRotation() / 360.f) * 256));
|
||||
WriteInt (1);
|
||||
WriteShort((short)(a_Vehicle.GetSpeedX() * 400));
|
||||
WriteShort((short)(a_Vehicle.GetSpeedY() * 400));
|
||||
WriteShort((short)(a_Vehicle.GetSpeedZ() * 400));
|
||||
WriteInt (a_VehicleSubType);
|
||||
if (a_VehicleSubType != 0)
|
||||
{
|
||||
WriteShort((short)(a_Vehicle.GetSpeedX() * 400));
|
||||
WriteShort((short)(a_Vehicle.GetSpeedY() * 400));
|
||||
WriteShort((short)(a_Vehicle.GetSpeedZ() * 400));
|
||||
}
|
||||
Flush();
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
|
||||
virtual void SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) override;
|
||||
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override;
|
||||
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType) override;
|
||||
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) override;
|
||||
} ;
|
||||
|
||||
|
||||
|
@ -502,10 +502,10 @@ void cProtocolRecognizer::SendSpawnObject(const cEntity & a_Entity, char a_Objec
|
||||
|
||||
|
||||
|
||||
void cProtocolRecognizer::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType)
|
||||
void cProtocolRecognizer::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType)
|
||||
{
|
||||
ASSERT(m_Protocol != NULL);
|
||||
m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType);
|
||||
m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType, a_VehicleSubType);
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,7 +96,7 @@ public:
|
||||
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
|
||||
virtual void SendSpawnMob (const cMonster & a_Mob) override;
|
||||
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override;
|
||||
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType) override;
|
||||
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) override;
|
||||
virtual void SendTabCompletionResults(const AStringVector & a_Results) override;
|
||||
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
|
||||
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
|
Loading…
Reference in New Issue
Block a user