1212public class MinecraftRail implements ITrackTile {
1313
1414 private EnumRailDirection direction ;
15+ private BlockPos pos ;
1516
1617 public MinecraftRail (World world , BlockPos pos ) {
18+ this .pos = pos ;
1719 IBlockState state = world .getBlockState (pos );
1820 BlockRailBase blockrailbase = (BlockRailBase )state .getBlock ();
1921 this .direction = blockrailbase .getRailDirection (world , pos , state , null );
@@ -33,13 +35,7 @@ public double getTrackSlope() {
3335 }
3436
3537 @ Override
36- public Vec3d getNextPosition (Vec3d currentPosition , float rotationYaw , float bogeyYaw , double distance ) {
37- if (distance < 0 ) {
38- distance = -distance ;
39- rotationYaw = (rotationYaw + 180 ) % 360 ;
40- bogeyYaw = (bogeyYaw + 180 ) % 360 ;
41- }
42-
38+ public Vec3d getNextPosition (Vec3d currentPosition , Vec3d motion ) {
4339 //TODO fill in the rest of the states
4440
4541 switch (direction ) {
@@ -52,14 +48,11 @@ public Vec3d getNextPosition(Vec3d currentPosition, float rotationYaw, float bog
5248 case ASCENDING_WEST :
5349 break ;
5450 case EAST_WEST :
55- break ;
51+ return currentPosition . addVector ( motion . x > 0 ? motion . lengthVector () : - motion . lengthVector (), 0 , pos . getZ () - currentPosition . z + 0.5 ) ;
5652 case NORTH_EAST :
5753 break ;
5854 case NORTH_SOUTH :
59- if (rotationYaw / 180 == 0 ) {
60- return currentPosition .addVector (0 , 0 , distance );
61- }
62- return currentPosition .addVector (0 , 0 , -distance );
55+ return currentPosition .addVector (pos .getX () - currentPosition .x + 0.5 , 0 , motion .z > 0 ? motion .lengthVector () : -motion .lengthVector ());
6356 case NORTH_WEST :
6457 break ;
6558 case SOUTH_EAST :
0 commit comments