summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Piveteau <chripiveteau@gmail.com>2014-08-13 18:53:23 +0200
committerChristophe Piveteau <chripiveteau@gmail.com>2014-08-13 18:53:23 +0200
commita544c0238ba4c94d78692a7592107f8e510893ee (patch)
tree34c869ae7208dec38e936ec16094d4a4de4ba07e /src
parentMerge pull request #1319 from mc-server/webadminfixes (diff)
downloadcuberite-a544c0238ba4c94d78692a7592107f8e510893ee.tar
cuberite-a544c0238ba4c94d78692a7592107f8e510893ee.tar.gz
cuberite-a544c0238ba4c94d78692a7592107f8e510893ee.tar.bz2
cuberite-a544c0238ba4c94d78692a7592107f8e510893ee.tar.lz
cuberite-a544c0238ba4c94d78692a7592107f8e510893ee.tar.xz
cuberite-a544c0238ba4c94d78692a7592107f8e510893ee.tar.zst
cuberite-a544c0238ba4c94d78692a7592107f8e510893ee.zip
Diffstat (limited to 'src')
-rw-r--r--src/Entities/Minecart.cpp72
1 files changed, 70 insertions, 2 deletions
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index d4eadc5d5..19eaa207f 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -871,11 +871,79 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
return true;
}
case E_META_RAIL_CURVED_ZM_XM:
+ case E_META_RAIL_CURVED_ZP_XP:
+ {
+ Vector3d Distance(
+ MinecartCollisionCallback.GetCollidedEntityPosition().x - GetPosX(),
+ 0,
+ MinecartCollisionCallback.GetCollidedEntityPosition().z - GetPosZ()
+ );
+
+ if ( Distance.z == 0. ) Distance.z = 0.0001;
+ if ( ((Distance.z>=0)&&((Distance.x/Distance.z)>=1)) || ((Distance.z<0)&&((Distance.x/Distance.z)<=1)) )
+ {
+ if ( (-GetSpeedX() * 0.4) < 0.01 )
+ {
+ AddSpeedX( -4/sqrt(2) );
+ AddSpeedZ( 4/sqrt(2) );
+ }
+ else
+ {
+ SetSpeedX( -GetSpeedX() * 0.4 );
+ SetSpeedZ( GetSpeedZ() * 0.4 );
+ }
+ }
+ else
+ {
+ if ((GetSpeedX() * 0.4) < 0.01)
+ {
+ AddSpeedX( 4/sqrt(2) );
+ AddSpeedZ( -4/sqrt(2) );
+ }
+ else
+ {
+ SetSpeedX( GetSpeedX() * 0.4 );
+ SetSpeedZ( -GetSpeedZ() * 0.4 );
+ }
+ }
+ break;
+ }
case E_META_RAIL_CURVED_ZM_XP:
case E_META_RAIL_CURVED_ZP_XM:
- case E_META_RAIL_CURVED_ZP_XP:
{
- // TODO - simply can't be bothered right now
+ Vector3d Distance(
+ MinecartCollisionCallback.GetCollidedEntityPosition().x - GetPosX(),
+ 0,
+ MinecartCollisionCallback.GetCollidedEntityPosition().z - GetPosZ()
+ );
+
+ if ( Distance.z == 0. ) Distance.z = 0.0001;
+ if ( ((Distance.z>=0)&&((Distance.x/Distance.z)<=-1)) || ((Distance.z<0)&&((Distance.x/Distance.z)>=-1)) )
+ {
+ if ( (GetSpeedX() * 0.4) < 0.01 )
+ {
+ AddSpeedX( 4/sqrt(2) );
+ AddSpeedZ( 4/sqrt(2) );
+ }
+ else
+ {
+ SetSpeedX( GetSpeedX() * 0.4 );
+ SetSpeedZ( GetSpeedZ() * 0.4 );
+ }
+ }
+ else
+ {
+ if ((-GetSpeedX() * 0.4) < 0.01)
+ {
+ AddSpeedX( -4/sqrt(2) );
+ AddSpeedZ( -4/sqrt(2) );
+ }
+ else
+ {
+ SetSpeedX( -GetSpeedX() * 0.4 );
+ SetSpeedZ( -GetSpeedZ() * 0.4 );
+ }
+ }
break;
}
default: break;