summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Entities/Minecart.cpp60
1 files changed, 40 insertions, 20 deletions
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index 9420eca02..13469edb3 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -889,25 +889,35 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
((Distance.z > 0) && ((Distance.x / Distance.z) >= 1)) ||
((Distance.z < 0) && ((Distance.x / Distance.z) <= 1))
)
- { // Moving -X + Z
- if ((-GetSpeedX() * 0.4 / sqrt(2)) < 0.01) // ~ speedX >= 0
- { // Immobile or not moving in the "right" direction. Give it a bump!
+ // Moving -X +Z
+ {
+ if ((-GetSpeedX() * 0.4 / sqrt(2)) < 0.01)
+ // ~ speedX >= 0
+ {
+ // Immobile or not moving in the "right" direction. Give it a bump!
AddSpeedX(-4 / sqrt(2));
AddSpeedZ(4 / sqrt(2));
}
- else // ~ SpeedX < 0
- { // Moving in the "right" direction. Only accelerate it a bit.
+ else
+ // ~ SpeedX < 0
+ {
+ // Moving in the "right" direction. Only accelerate it a bit.
SetSpeedX(GetSpeedX() * 0.4 / sqrt(2));
SetSpeedZ(GetSpeedZ() * 0.4 / sqrt(2));
}
- } // Moving +X -Z
- else if ((GetSpeedX() * 0.4 / sqrt(2)) < 0.01) // ~ SpeedX <= 0
- { // Immobile or not moving in the "right" direction
+ }
+ else if ((GetSpeedX() * 0.4 / sqrt(2)) < 0.01)
+ // Moving +X -Z
+ // ~ SpeedX <= 0
+ {
+ // Immobile or not moving in the "right" direction
AddSpeedX(4 / sqrt(2));
AddSpeedZ(-4 / sqrt(2));
}
- else // ~ SpeedX > 0
- { // Moving in the "right" direction
+ else
+ // ~ SpeedX > 0
+ {
+ // Moving in the "right" direction
SetSpeedX(GetSpeedX() * 0.4 / sqrt(2));
SetSpeedZ(GetSpeedZ() * 0.4 / sqrt(2));
}
@@ -928,29 +938,39 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
Let's consider a z-x-coordinate system where the minecart is the center (0/0).
The minecart moves along the line x = z, the perpendicular line to this is x = -z.
In order to decide to which side the minecart is to be pushed, it must be checked on what side of the perpendicular line the pushing entity is located. */
- if ( // Moving +X +Z
+ if (
((Distance.z > 0) && ((Distance.x / Distance.z) <= -1)) ||
((Distance.z < 0) && ((Distance.x / Distance.z) >= -1))
)
+ // Moving +X +Z
{
- if ((GetSpeedX() * 0.4) < 0.01) // ~ SpeedX <= 0
- { // Immobile or not moving in the "right" direction
+ if ((GetSpeedX() * 0.4) < 0.01)
+ // ~ SpeedX <= 0
+ {
+ // Immobile or not moving in the "right" direction
AddSpeedX(4 / sqrt(2));
AddSpeedZ(4 / sqrt(2));
}
- else // SpeedX > 0
- { // Moving in the "right" direction
+ else
+ // SpeedX > 0
+ {
+ // Moving in the "right" direction
SetSpeedX(GetSpeedX() * 0.4 / sqrt(2));
SetSpeedZ(GetSpeedZ() * 0.4 / sqrt(2));
}
- } // Moving -X -Z
- else if ((-GetSpeedX() * 0.4) < 0.01) // ~ SpeedX >= 0
- { // Immobile or not moving in the "right" direction
+ }
+ else if ((-GetSpeedX() * 0.4) < 0.01)
+ // Moving -X -Z
+ // ~ SpeedX >= 0
+ {
+ // Immobile or not moving in the "right" direction
AddSpeedX(-4 / sqrt(2));
AddSpeedZ(-4 / sqrt(2));
}
- else // ~ SpeedX < 0
- { // Moving in the "right" direction
+ else
+ // ~ SpeedX < 0
+ {
+ // Moving in the "right" direction
SetSpeedX(GetSpeedX() * 0.4 / sqrt(2));
SetSpeedZ(GetSpeedZ() * 0.4 / sqrt(2));
}