diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-09-13 00:57:02 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-09-13 00:57:02 +0200 |
commit | 22b8f3a2e0d46b36658fd46fc3e14af85b9dfe45 (patch) | |
tree | ce3313ef732b7e0c6e15d9ee0982432a4fd845f6 | |
parent | Fixed water speed issues (diff) | |
download | cuberite-22b8f3a2e0d46b36658fd46fc3e14af85b9dfe45.tar cuberite-22b8f3a2e0d46b36658fd46fc3e14af85b9dfe45.tar.gz cuberite-22b8f3a2e0d46b36658fd46fc3e14af85b9dfe45.tar.bz2 cuberite-22b8f3a2e0d46b36658fd46fc3e14af85b9dfe45.tar.lz cuberite-22b8f3a2e0d46b36658fd46fc3e14af85b9dfe45.tar.xz cuberite-22b8f3a2e0d46b36658fd46fc3e14af85b9dfe45.tar.zst cuberite-22b8f3a2e0d46b36658fd46fc3e14af85b9dfe45.zip |
-rw-r--r-- | source/BlockID.cpp | 2 | ||||
-rw-r--r-- | source/Entities/Entity.cpp | 49 | ||||
-rw-r--r-- | source/Entities/Minecart.cpp | 20 | ||||
-rw-r--r-- | source/Entities/Minecart.h | 14 |
4 files changed, 62 insertions, 23 deletions
diff --git a/source/BlockID.cpp b/source/BlockID.cpp index b53507f17..40664647a 100644 --- a/source/BlockID.cpp +++ b/source/BlockID.cpp @@ -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] = true; + g_BlockIsSolid[E_BLOCK_RAIL] = false; g_BlockIsSolid[E_BLOCK_REDSTONE_REPEATER_OFF] = false; g_BlockIsSolid[E_BLOCK_REDSTONE_REPEATER_ON] = false; g_BlockIsSolid[E_BLOCK_REDSTONE_TORCH_OFF] = false; diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp index 2443b1810..d884fe51c 100644 --- a/source/Entities/Entity.cpp +++ b/source/Entities/Entity.cpp @@ -12,6 +12,7 @@ #include "../Simulator/FluidSimulator.h" #include "../PluginManager.h" #include "../Tracer.h" +#include "Minecart.h" @@ -553,6 +554,11 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) { fallspeed = m_Gravity * a_Dt / 3; // Fall 3x slower in water. } + else if ((IsBlockRail(BlockBelow)) && (IsMinecart())) // Rails aren't solid, except for Minecarts + { + fallspeed = 0; + m_bOnGround = true; + } else if (BlockIn == E_BLOCK_COBWEB) { NextSpeed.y *= 0.05; // Reduce overall falling speed @@ -567,25 +573,40 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) } else { - if ( - (BlockBelow != E_BLOCK_RAIL) && - (BlockBelow != E_BLOCK_DETECTOR_RAIL) && - (BlockBelow != E_BLOCK_POWERED_RAIL) && - (BlockBelow != E_BLOCK_ACTIVATOR_RAIL) - ) + if (IsMinecart()) { - // Friction - if (NextSpeed.SqrLength() > 0.0004f) + if (!IsBlockRail(BlockBelow)) { - NextSpeed.x *= 0.7f / (1 + a_Dt); - if (fabs(NextSpeed.x) < 0.05) + // Friction if minecart is off track, otherwise, Minecart.cpp handles this + if (NextSpeed.SqrLength() > 0.0004f) { - NextSpeed.x = 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; + } } - NextSpeed.z *= 0.7f / (1 + a_Dt); - if (fabs(NextSpeed.z) < 0.05) + } + else + { + // Friction + if (NextSpeed.SqrLength() > 0.0004f) { - 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; + } } } } diff --git a/source/Entities/Minecart.cpp b/source/Entities/Minecart.cpp index f633206a2..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 diff --git a/source/Entities/Minecart.h b/source/Entities/Minecart.h index f98b02bb5..0ca6586db 100644 --- a/source/Entities/Minecart.h +++ b/source/Entities/Minecart.h @@ -16,6 +16,20 @@ +inline bool IsBlockRail(BLOCKTYPE a_BlockType) + { + return ( + (a_BlockType == E_BLOCK_RAIL) || + (a_BlockType == E_BLOCK_ACTIVATOR_RAIL) || + (a_BlockType == E_BLOCK_DETECTOR_RAIL) || + (a_BlockType == E_BLOCK_POWERED_RAIL) + ) ; + } + + + + + class cMinecart : public cEntity { |