summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-04-22 23:27:01 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-04-22 23:27:01 +0200
commit923441b6b300fabb6bca081de2171051c7e22062 (patch)
tree9fcbbbc7f09a5f8b22e93df151e35e48cc820fe3
parentMerge pull request #3156 from LogicParrot/hashFix (diff)
parentFix minecart block collision on curved rails (diff)
downloadcuberite-923441b6b300fabb6bca081de2171051c7e22062.tar
cuberite-923441b6b300fabb6bca081de2171051c7e22062.tar.gz
cuberite-923441b6b300fabb6bca081de2171051c7e22062.tar.bz2
cuberite-923441b6b300fabb6bca081de2171051c7e22062.tar.lz
cuberite-923441b6b300fabb6bca081de2171051c7e22062.tar.xz
cuberite-923441b6b300fabb6bca081de2171051c7e22062.tar.zst
cuberite-923441b6b300fabb6bca081de2171051c7e22062.zip
-rw-r--r--src/Entities/Minecart.cpp66
1 files changed, 56 insertions, 10 deletions
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index 1b037e830..2b4a26e5c 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -25,7 +25,7 @@ class cMinecartCollisionCallback :
{
public:
cMinecartCollisionCallback(Vector3d a_Pos, double a_Height, double a_Width, UInt32 a_UniqueID, UInt32 a_AttacheeUniqueID) :
- m_DoesInteserct(false),
+ m_DoesIntersect(false),
m_CollidedEntityPos(0, 0, 0),
m_Pos(a_Pos),
m_Height(a_Height),
@@ -54,7 +54,7 @@ public:
if (bbEntity.DoesIntersect(bbMinecart))
{
m_CollidedEntityPos = a_Entity->GetPosition();
- m_DoesInteserct = true;
+ m_DoesIntersect = true;
return true;
}
return false;
@@ -62,7 +62,7 @@ public:
bool FoundIntersection(void) const
{
- return m_DoesInteserct;
+ return m_DoesIntersect;
}
Vector3d GetCollidedEntityPosition(void) const
@@ -71,7 +71,7 @@ public:
}
protected:
- bool m_DoesInteserct;
+ bool m_DoesIntersect;
Vector3d m_CollidedEntityPos;
@@ -768,25 +768,71 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta)
break;
}
case E_META_RAIL_CURVED_ZM_XM:
+ {
+ BLOCKTYPE BlockXM = m_World->GetBlock(POSX_TOINT - 1, POSY_TOINT, POSZ_TOINT);
+ BLOCKTYPE BlockZM = m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT - 1);
+
+ if (
+ ((GetSpeedZ() < 0) && (!IsBlockRail(BlockZM) && cBlockInfo::IsSolid(BlockZM))) ||
+ ((GetSpeedX() < 0) && (!IsBlockRail(BlockXM) && cBlockInfo::IsSolid(BlockXM)))
+ )
+ {
+ SetSpeed(0, 0, 0);
+ SetPosition(POSX_TOINT + 0.5, GetPosY(), POSZ_TOINT + 0.5);
+ return true;
+ }
+
+ break;
+ }
case E_META_RAIL_CURVED_ZM_XP:
+ {
+ BLOCKTYPE BlockXP = m_World->GetBlock(POSX_TOINT + 1, POSY_TOINT, POSZ_TOINT);
+ BLOCKTYPE BlockZM = m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT - 1);
+
+ if (
+ ((GetSpeedZ() < 0) && (!IsBlockRail(BlockZM) && cBlockInfo::IsSolid(BlockZM))) ||
+ ((GetSpeedX() > 0) && (!IsBlockRail(BlockXP) && cBlockInfo::IsSolid(BlockXP)))
+ )
+ {
+ SetSpeed(0, 0, 0);
+ SetPosition(POSX_TOINT + 0.5, GetPosY(), POSZ_TOINT + 0.5);
+ return true;
+ }
+
+ break;
+ }
case E_META_RAIL_CURVED_ZP_XM:
- case E_META_RAIL_CURVED_ZP_XP:
{
BLOCKTYPE BlockXM = m_World->GetBlock(POSX_TOINT - 1, POSY_TOINT, POSZ_TOINT);
+ BLOCKTYPE BlockZP = m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT + 1);
+
+ if (
+ ((GetSpeedZ() > 0) && (!IsBlockRail(BlockZP) && cBlockInfo::IsSolid(BlockZP))) ||
+ ((GetSpeedX() < 0) && (!IsBlockRail(BlockXM) && cBlockInfo::IsSolid(BlockXM)))
+ )
+ {
+ SetSpeed(0, 0, 0);
+ SetPosition(POSX_TOINT + 0.5, GetPosY(), POSZ_TOINT + 0.5);
+ return true;
+ }
+
+ break;
+ }
+ case E_META_RAIL_CURVED_ZP_XP:
+ {
BLOCKTYPE BlockXP = m_World->GetBlock(POSX_TOINT + 1, POSY_TOINT, POSZ_TOINT);
- BLOCKTYPE BlockZM = m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT - 1);
BLOCKTYPE BlockZP = m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT + 1);
+
if (
- (!IsBlockRail(BlockXM) && cBlockInfo::IsSolid(BlockXM)) ||
- (!IsBlockRail(BlockXP) && cBlockInfo::IsSolid(BlockXP)) ||
- (!IsBlockRail(BlockZM) && cBlockInfo::IsSolid(BlockZM)) ||
- (!IsBlockRail(BlockZP) && cBlockInfo::IsSolid(BlockZP))
+ ((GetSpeedZ() > 0) && (!IsBlockRail(BlockZP) && cBlockInfo::IsSolid(BlockZP))) ||
+ ((GetSpeedX() > 0) && (!IsBlockRail(BlockXP) && cBlockInfo::IsSolid(BlockXP)))
)
{
SetSpeed(0, 0, 0);
SetPosition(POSX_TOINT + 0.5, GetPosY(), POSZ_TOINT + 0.5);
return true;
}
+
break;
}
default: break;