summaryrefslogtreecommitdiffstats
path: root/source/Entities/Minecart.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-09-15 20:49:08 +0200
committermadmaxoft <github@xoft.cz>2013-09-15 20:49:08 +0200
commit5cde7d8a29b38360ae36f9e8c5210bee07fce612 (patch)
tree816bbb5c99b9ac3ce64920ccc9e6abd88519c022 /source/Entities/Minecart.cpp
parentMerge branch 'bugfixes' of git://github.com/tigerw/MCServer into tigerw-bugfixes (diff)
parentAdded break (diff)
downloadcuberite-5cde7d8a29b38360ae36f9e8c5210bee07fce612.tar
cuberite-5cde7d8a29b38360ae36f9e8c5210bee07fce612.tar.gz
cuberite-5cde7d8a29b38360ae36f9e8c5210bee07fce612.tar.bz2
cuberite-5cde7d8a29b38360ae36f9e8c5210bee07fce612.tar.lz
cuberite-5cde7d8a29b38360ae36f9e8c5210bee07fce612.tar.xz
cuberite-5cde7d8a29b38360ae36f9e8c5210bee07fce612.tar.zst
cuberite-5cde7d8a29b38360ae36f9e8c5210bee07fce612.zip
Diffstat (limited to 'source/Entities/Minecart.cpp')
-rw-r--r--source/Entities/Minecart.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/source/Entities/Minecart.cpp b/source/Entities/Minecart.cpp
index 0c0b7b58a..a2f1e5593 100644
--- a/source/Entities/Minecart.cpp
+++ b/source/Entities/Minecart.cpp
@@ -54,20 +54,24 @@ void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
if ((GetPosY() > 0) && (GetPosY() < cChunkDef::Height))
{
BLOCKTYPE BelowType = GetWorld()->GetBlock(floor(GetPosX()), floor(GetPosY() -1 ), floor(GetPosZ()));
+ BLOCKTYPE InsideType = GetWorld()->GetBlock(floor(GetPosX()), floor(GetPosY()), floor(GetPosZ()));
- if (
- (BelowType == E_BLOCK_RAIL) ||
- (BelowType == E_BLOCK_POWERED_RAIL) ||
- (BelowType == E_BLOCK_DETECTOR_RAIL) ||
- (BelowType == E_BLOCK_ACTIVATOR_RAIL)
- )
+ if (IsBlockRail(BelowType))
{
HandleRailPhysics(a_Dt, a_Chunk);
}
else
{
- super::HandlePhysics(a_Dt, a_Chunk);
- BroadcastMovementUpdate();
+ if (IsBlockRail(InsideType))
+ {
+ SetPosY(ceil(GetPosY()));
+ HandleRailPhysics(a_Dt, a_Chunk);
+ }
+ else
+ {
+ super::HandlePhysics(a_Dt, a_Chunk);
+ BroadcastMovementUpdate();
+ }
}
}
else
@@ -105,9 +109,6 @@ void cMinecart::HandleRailPhysics(float a_Dt, cChunk & a_Chunk)
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)
@@ -130,8 +131,6 @@ void cMinecart::HandleRailPhysics(float a_Dt, cChunk & a_Chunk)
SpeedY = 0;
SpeedZ = 0;
- SetPosY(floor(GetPosY()));
-
if (SpeedX != 0)
{
if (SpeedX > 0)
@@ -347,7 +346,7 @@ void cMinecart::DoTakeDamage(TakeDamageInfo & TDI)
{
super::DoTakeDamage(TDI);
- if (GetHealth() == 0)
+ if (GetHealth() <= 0)
{
Destroy(true);
}