diff options
author | archshift <admin@archshift.com> | 2014-04-26 02:15:12 +0200 |
---|---|---|
committer | archshift <admin@archshift.com> | 2014-04-26 02:15:12 +0200 |
commit | 73edd2b96102bff9fbd74d34740fea3daa40b15f (patch) | |
tree | e80b64cb3d17d854e34ba7d026945149ae46f799 | |
parent | Moved the weather picker out of TickWeather(), squashing a warning and improving readability. (diff) | |
download | cuberite-73edd2b96102bff9fbd74d34740fea3daa40b15f.tar cuberite-73edd2b96102bff9fbd74d34740fea3daa40b15f.tar.gz cuberite-73edd2b96102bff9fbd74d34740fea3daa40b15f.tar.bz2 cuberite-73edd2b96102bff9fbd74d34740fea3daa40b15f.tar.lz cuberite-73edd2b96102bff9fbd74d34740fea3daa40b15f.tar.xz cuberite-73edd2b96102bff9fbd74d34740fea3daa40b15f.tar.zst cuberite-73edd2b96102bff9fbd74d34740fea3daa40b15f.zip |
-rw-r--r-- | src/Entities/FallingBlock.cpp | 4 | ||||
-rw-r--r-- | src/Entities/Minecart.cpp | 34 |
2 files changed, 17 insertions, 21 deletions
diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp index a66c7e4ae..f48fb156b 100644 --- a/src/Entities/FallingBlock.cpp +++ b/src/Entities/FallingBlock.cpp @@ -87,7 +87,9 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk) AddSpeedY(MilliDt * -9.8f); AddPosition(GetSpeed() * MilliDt); - if ((GetSpeedX() != 0) || (GetSpeedZ() != 0)) + //If not static (One billionth precision) broadcast movement. + float epsilon = 0.000000001; + if ((fabs(GetSpeedX()) > epsilon) || (fabs(GetSpeedZ()) > epsilon)) { BroadcastMovementUpdate(); } diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index db55eb058..ceaa713bb 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -234,18 +234,15 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta); if (EntCol || BlckCol) return; - if (GetSpeedZ() != 0) // Don't do anything if cart is stationary + if (GetSpeedZ() > 0) { - if (GetSpeedZ() > 0) - { - // Going SOUTH, slow down - AddSpeedZ(-0.1); - } - else - { - // Going NORTH, slow down - AddSpeedZ(0.1); - } + // Going SOUTH, slow down + AddSpeedZ(-0.1); + } + else if (GetSpeedZ() < 0) + { + // Going NORTH, slow down + AddSpeedZ(0.1); } break; } @@ -259,16 +256,13 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta); if (EntCol || BlckCol) return; - if (GetSpeedX() != 0) + if (GetSpeedX() > 0) { - if (GetSpeedX() > 0) - { - AddSpeedX(-0.1); - } - else - { - AddSpeedX(0.1); - } + AddSpeedX(-0.1); + } + else if (GetSpeedX() < 0) + { + AddSpeedX(0.1); } break; } |