@@ -8,7 +8,7 @@ namespace MinecraftClient.Commands
88 public class Move : Command
99 {
1010 public override string CmdName { get { return "move" ; } }
11- public override string CmdUsage { get { return "move <on|off|get|up|down|east|west|north|south|x y z|gravity [on|off]> [-f]" ; } }
11+ public override string CmdUsage { get { return "move <on|off|get|up|down|east|west|north|south|center| x y z|gravity [on|off]> [-f]" ; } }
1212 public override string CmdDesc { get { return "walk or start walking. \" -f\" : force unsafe movements like falling or touching fire" ; } }
1313
1414 public override string Run ( McClient handler , string command , Dictionary < string , object > localVars )
@@ -17,7 +17,14 @@ public override string Run(McClient handler, string command, Dictionary<string,
1717 bool takeRisk = false ;
1818
1919 if ( args . Count < 1 )
20- return GetCmdDescTranslated ( ) ;
20+ {
21+ string desc = GetCmdDescTranslated ( ) ;
22+
23+ if ( handler . GetTerrainEnabled ( ) )
24+ handler . Log . Info ( getChunkLoadingStatus ( handler . GetWorld ( ) ) ) ;
25+
26+ return desc ;
27+ }
2128
2229 if ( args . Contains ( "-f" ) )
2330 {
@@ -56,6 +63,11 @@ public override string Run(McClient handler, string command, Dictionary<string,
5663 case "west" : direction = Direction . West ; break ;
5764 case "north" : direction = Direction . North ; break ;
5865 case "south" : direction = Direction . South ; break ;
66+ case "center" :
67+ Location current = handler . GetCurrentLocation ( ) ;
68+ Location currentCenter = new Location ( Math . Floor ( current . X ) + 0.5 , current . Y , Math . Floor ( current . Z ) + 0.5 ) ;
69+ handler . MoveTo ( currentCenter , allowDirectTeleport : true ) ;
70+ return Translations . Get ( "cmd.move.walk" , currentCenter , current ) ;
5971 case "get" : return handler . GetCurrentLocation ( ) . ToString ( ) ;
6072 default : return Translations . Get ( "cmd.look.unknown" , args [ 0 ] ) ;
6173 }
@@ -76,8 +88,15 @@ public override string Run(McClient handler, string command, Dictionary<string,
7688 int z = int . Parse ( args [ 2 ] ) ;
7789 Location goal = new Location ( x , y , z ) ;
7890
91+ if ( handler . GetWorld ( ) . GetChunkColumn ( goal ) == null || handler . GetWorld ( ) . GetChunkColumn ( goal ) . FullyLoaded == false )
92+ return Translations . Get ( "cmd.move.chunk_not_loaded" ) ;
93+
94+ Location current = handler . GetCurrentLocation ( ) ;
95+ Location currentCenter = new Location ( Math . Floor ( current . X ) + 0.5 , current . Y , Math . Floor ( current . Z ) + 0.5 ) ;
96+ handler . MoveTo ( currentCenter , allowDirectTeleport : true ) ;
97+
7998 if ( handler . MoveTo ( goal , allowUnsafe : takeRisk ) )
80- return Translations . Get ( "cmd.move.walk" , goal ) ;
99+ return Translations . Get ( "cmd.move.walk" , goal , current ) ;
81100 else return takeRisk ? Translations . Get ( "cmd.move.fail" , goal ) : Translations . Get ( "cmd.move.suggestforce" , goal ) ;
82101 }
83102 catch ( FormatException ) { return GetCmdDescTranslated ( ) ; }
@@ -86,5 +105,19 @@ public override string Run(McClient handler, string command, Dictionary<string,
86105 }
87106 else return Translations . Get ( "extra.terrainandmovement_required" ) ;
88107 }
108+
109+ private string getChunkLoadingStatus ( World world )
110+ {
111+ double chunkLoadedRatio ;
112+ if ( world . chunkCnt == 0 )
113+ chunkLoadedRatio = 0 ;
114+ else
115+ chunkLoadedRatio = ( world . chunkCnt - world . chunkLoadNotCompleted ) / ( double ) world . chunkCnt ;
116+
117+ string status = Translations . Get ( "cmd.move.chunk_loading_status" ,
118+ chunkLoadedRatio , world . chunkCnt - world . chunkLoadNotCompleted , world . chunkCnt ) ;
119+
120+ return status ;
121+ }
89122 }
90123}
0 commit comments