Bugfix: Send too many movement packets

This commit is contained in:
BruceChen 2022-10-04 12:34:37 +08:00 committed by GitHub
commit 1611f3c12c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 82 additions and 50 deletions

View file

@ -1,4 +1,5 @@
using System; using System;
using System.Globalization;
using MinecraftClient.Mapping; using MinecraftClient.Mapping;
namespace MinecraftClient.ChatBots namespace MinecraftClient.ChatBots
@ -63,11 +64,11 @@ namespace MinecraftClient.ChatBots
if (parts.Length == 2) if (parts.Length == 2)
{ {
if (int.TryParse(parts[0].Trim(), out int firstTime)) if (int.TryParse(parts[0].Trim(), NumberStyles.Any, CultureInfo.CurrentCulture, out int firstTime))
{ {
timeping = firstTime; timeping = firstTime;
if (int.TryParse(parts[1].Trim(), out int secondTime)) if (int.TryParse(parts[1].Trim(), NumberStyles.Any, CultureInfo.CurrentCulture, out int secondTime))
timepingMax = secondTime; timepingMax = secondTime;
else LogToConsole(Translations.TryGet("bot.antiafk.invalid_range_partial", timeping)); else LogToConsole(Translations.TryGet("bot.antiafk.invalid_range_partial", timeping));
} }
@ -77,7 +78,7 @@ namespace MinecraftClient.ChatBots
} }
else else
{ {
if (int.TryParse(pingparam.Trim(), out int value)) if (int.TryParse(pingparam.Trim(), NumberStyles.Any, CultureInfo.CurrentCulture, out int value))
timeping = value; timeping = value;
else LogToConsole(Translations.TryGet("bot.antiafk.invalid_value")); else LogToConsole(Translations.TryGet("bot.antiafk.invalid_value"));
} }

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Globalization;
using System.IO; using System.IO;
using MinecraftClient.Mapping; using MinecraftClient.Mapping;
using MinecraftClient.Protocol.Handlers; using MinecraftClient.Protocol.Handlers;
@ -70,7 +71,7 @@ namespace MinecraftClient.ChatBots
if (args.Length < 2) if (args.Length < 2)
return "maps <list/render <id>> | maps <l/r <id>>"; return "maps <list/render <id>> | maps <l/r <id>>";
if (int.TryParse(args[1], out int mapId)) if (int.TryParse(args[1], NumberStyles.Any, CultureInfo.CurrentCulture, out int mapId))
{ {
if (!cachedMaps.ContainsKey(mapId)) if (!cachedMaps.ContainsKey(mapId))
return Translations.TryGet("bot.map.cmd.not_found", mapId); return Translations.TryGet("bot.map.cmd.not_found", mapId);
@ -101,6 +102,9 @@ namespace MinecraftClient.ChatBots
if (columnsUpdated == 0 && cachedMaps.ContainsKey(mapid)) if (columnsUpdated == 0 && cachedMaps.ContainsKey(mapid))
return; return;
if (rowsUpdated <= 0 && columnsUpdated <= 0)
return;
McMap map = new() McMap map = new()
{ {
MapId = mapid, MapId = mapid,

View file

@ -84,8 +84,8 @@ namespace MinecraftClient.ChatBots
string[] parts = argValue.Split("-"); string[] parts = argValue.Split("-");
if (parts.Length == 2) if (parts.Length == 2)
{ {
interval = int.Parse(parts[0].Trim()); interval = int.Parse(parts[0].Trim(), NumberStyles.Any, CultureInfo.CurrentCulture);
intervalMax = int.Parse(parts[1].Trim()); intervalMax = int.Parse(parts[1].Trim(), NumberStyles.Any, CultureInfo.CurrentCulture);
} }
else else
{ {
@ -94,7 +94,7 @@ namespace MinecraftClient.ChatBots
} }
else else
{ {
interval = int.Parse(argValue); interval = int.Parse(argValue, NumberStyles.Any, CultureInfo.CurrentCulture);
} }
current_task.triggerOnInterval_Interval = interval; current_task.triggerOnInterval_Interval = interval;

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using MinecraftClient.Mapping; using MinecraftClient.Mapping;
@ -30,7 +31,7 @@ namespace MinecraftClient.Commands
{ {
if (args.Length == 2) if (args.Length == 2)
{ {
if (!int.TryParse(args[1], out int radius)) if (!int.TryParse(args[1], NumberStyles.Any, CultureInfo.CurrentCulture, out int radius))
return CmdUsage; return CmdUsage;
handler.GetLogger().Info(Translations.TryGet("cmd.bed.searching", radius)); handler.GetLogger().Info(Translations.TryGet("cmd.bed.searching", radius));

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Text; using System.Text;
using MinecraftClient.Mapping; using MinecraftClient.Mapping;
@ -36,7 +37,10 @@ namespace MinecraftClient.Commands
{ {
sb.Append("Marked location: "); sb.Append("Marked location: ");
if (args.Length == 1 + 3) if (args.Length == 1 + 3)
sb.Append(String.Format("X:{0:0.00} Y:{1:0.00} Z:{2:0.00}, ", double.Parse(args[1]), double.Parse(args[2]), double.Parse(args[3]))); sb.Append(String.Format("X:{0:0.00} Y:{1:0.00} Z:{2:0.00}, ",
double.Parse(args[1], NumberStyles.Any, CultureInfo.CurrentCulture),
double.Parse(args[2], NumberStyles.Any, CultureInfo.CurrentCulture),
double.Parse(args[3], NumberStyles.Any, CultureInfo.CurrentCulture)));
sb.Append(String.Format("chunk: ({0}, {1}).\n", markChunkX, markChunkZ)); sb.Append(String.Format("chunk: ({0}, {1}).\n", markChunkX, markChunkZ));
} }
@ -230,14 +234,18 @@ namespace MinecraftClient.Commands
int chunkX, chunkZ; int chunkX, chunkZ;
if (args.Length == 1 + 3) if (args.Length == 1 + 3)
{ {
Location pos = new(double.Parse(args[1]), double.Parse(args[2]), double.Parse(args[3])); Location pos = new(
double.Parse(args[1], NumberStyles.Any, CultureInfo.CurrentCulture),
double.Parse(args[2], NumberStyles.Any, CultureInfo.CurrentCulture),
double.Parse(args[3], NumberStyles.Any, CultureInfo.CurrentCulture)
);
chunkX = pos.ChunkX; chunkX = pos.ChunkX;
chunkZ = pos.ChunkZ; chunkZ = pos.ChunkZ;
} }
else if (args.Length == 1 + 2) else if (args.Length == 1 + 2)
{ {
chunkX = int.Parse(args[1]); chunkX = int.Parse(args[1], NumberStyles.Any, CultureInfo.CurrentCulture);
chunkZ = int.Parse(args[2]); chunkZ = int.Parse(args[2], NumberStyles.Any, CultureInfo.CurrentCulture);
} }
else else
return null; return null;

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using MinecraftClient.Inventory; using MinecraftClient.Inventory;
using MinecraftClient.Mapping; using MinecraftClient.Mapping;
@ -20,7 +21,7 @@ namespace MinecraftClient.Commands
{ {
try try
{ {
int entityID = int.Parse(args[0]); int entityID = int.Parse(args[0], NumberStyles.Any, CultureInfo.CurrentCulture);
if (entityID != 0) if (entityID != 0)
{ {
if (handler.GetEntities().ContainsKey(entityID)) if (handler.GetEntities().ContainsKey(entityID))

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using MinecraftClient.Inventory; using MinecraftClient.Inventory;
@ -24,14 +25,14 @@ namespace MinecraftClient.Commands
{ {
if (args.Length >= 4) if (args.Length >= 4)
{ {
if (!int.TryParse(args[1], out int slot)) if (!int.TryParse(args[1], NumberStyles.Any, CultureInfo.CurrentCulture, out int slot))
return GetCmdDescTranslated(); return GetCmdDescTranslated();
if (Enum.TryParse(args[2], true, out ItemType itemType)) if (Enum.TryParse(args[2], true, out ItemType itemType))
{ {
if (handler.GetGamemode() == 1) if (handler.GetGamemode() == 1)
{ {
if (!int.TryParse(args[3], out int count)) if (!int.TryParse(args[3], NumberStyles.Any, CultureInfo.CurrentCulture, out int count))
return GetCmdDescTranslated(); return GetCmdDescTranslated();
if (handler.DoCreativeGive(slot, itemType, count, null)) if (handler.DoCreativeGive(slot, itemType, count, null))
@ -52,7 +53,7 @@ namespace MinecraftClient.Commands
{ {
if (args.Length >= 2) if (args.Length >= 2)
{ {
if (!int.TryParse(args[1], out int slot)) if (!int.TryParse(args[1], NumberStyles.Any, CultureInfo.CurrentCulture, out int slot))
return GetCmdDescTranslated(); return GetCmdDescTranslated();
if (handler.GetGamemode() == 1) if (handler.GetGamemode() == 1)
@ -105,7 +106,7 @@ namespace MinecraftClient.Commands
bool shouldUseItemCount = args.Length >= 3; bool shouldUseItemCount = args.Length >= 3;
int itemCount = 0; int itemCount = 0;
if (shouldUseItemCount && !int.TryParse(args[2], out itemCount)) if (shouldUseItemCount && !int.TryParse(args[2], NumberStyles.Any, CultureInfo.CurrentCulture, out itemCount))
return GetCmdDescTranslated(); return GetCmdDescTranslated();
Dictionary<int, Container> inventories = handler.GetInventories(); Dictionary<int, Container> inventories = handler.GetInventories();
@ -162,7 +163,7 @@ namespace MinecraftClient.Commands
else else
return GetHelp(); return GetHelp();
} }
else if (!int.TryParse(args[0], out inventoryId)) else if (!int.TryParse(args[0], NumberStyles.Any, CultureInfo.CurrentCulture, out inventoryId))
return GetCmdDescTranslated(); return GetCmdDescTranslated();
Container? inventory = handler.GetInventory(inventoryId); Container? inventory = handler.GetInventory(inventoryId);
@ -205,7 +206,7 @@ namespace MinecraftClient.Commands
} }
else if (action == "click" && args.Length >= 3) else if (action == "click" && args.Length >= 3)
{ {
if (!int.TryParse(args[2], out int slot)) if (!int.TryParse(args[2], NumberStyles.Any, CultureInfo.CurrentCulture, out int slot))
return GetCmdDescTranslated(); return GetCmdDescTranslated();
WindowActionType actionType = WindowActionType.LeftClick; WindowActionType actionType = WindowActionType.LeftClick;
@ -224,7 +225,7 @@ namespace MinecraftClient.Commands
} }
else if (action == "shiftclick" && args.Length >= 3) else if (action == "shiftclick" && args.Length >= 3)
{ {
if (!int.TryParse(args[2], out int slot)) if (!int.TryParse(args[2], NumberStyles.Any, CultureInfo.CurrentCulture, out int slot))
return GetCmdDescTranslated(); return GetCmdDescTranslated();
if (!handler.DoWindowAction(inventoryId, slot, WindowActionType.ShiftClick)) if (!handler.DoWindowAction(inventoryId, slot, WindowActionType.ShiftClick))
@ -234,7 +235,7 @@ namespace MinecraftClient.Commands
} }
else if (action == "drop" && args.Length >= 3) else if (action == "drop" && args.Length >= 3)
{ {
if (!int.TryParse(args[2], out int slot)) if (!int.TryParse(args[2], NumberStyles.Any, CultureInfo.CurrentCulture, out int slot))
return GetCmdDescTranslated(); return GetCmdDescTranslated();
// check item exist // check item exist

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using MinecraftClient.Mapping; using MinecraftClient.Mapping;
namespace MinecraftClient.Commands namespace MinecraftClient.Commands
@ -50,8 +51,8 @@ namespace MinecraftClient.Commands
{ {
try try
{ {
float yaw = float.Parse(args[0]); float yaw = float.Parse(args[0], NumberStyles.Any, CultureInfo.CurrentCulture);
float pitch = float.Parse(args[1]); float pitch = float.Parse(args[1], NumberStyles.Any, CultureInfo.CurrentCulture);
handler.UpdateLocation(handler.GetCurrentLocation(), yaw, pitch); handler.UpdateLocation(handler.GetCurrentLocation(), yaw, pitch);
return Translations.Get("cmd.look.at", yaw.ToString("0.00"), pitch.ToString("0.00")); return Translations.Get("cmd.look.at", yaw.ToString("0.00"), pitch.ToString("0.00"));

View file

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Linq; using System.Linq;
using System.Globalization;
namespace MinecraftClient.Inventory namespace MinecraftClient.Inventory
{ {
@ -105,7 +106,7 @@ namespace MinecraftClient.Inventory
object damage = NBT["Damage"]; object damage = NBT["Damage"];
if (damage != null) if (damage != null)
{ {
return int.Parse(damage.ToString() ?? string.Empty); return int.Parse(damage.ToString() ?? string.Empty, NumberStyles.Any, CultureInfo.CurrentCulture);
} }
} }
return 0; return 0;

View file

@ -103,7 +103,8 @@ namespace MinecraftClient
&& IsHex(toparse[cursorpos + 5])) && IsHex(toparse[cursorpos + 5]))
{ {
//"abc\u0123abc" => "0123" => 0123 => Unicode char n°0123 => Add char to string //"abc\u0123abc" => "0123" => 0123 => Unicode char n°0123 => Add char to string
data.StringValue += char.ConvertFromUtf32(int.Parse(toparse.Substring(cursorpos + 2, 4), System.Globalization.NumberStyles.HexNumber)); data.StringValue += char.ConvertFromUtf32(int.Parse(toparse.Substring(cursorpos + 2, 4),
System.Globalization.NumberStyles.HexNumber));
cursorpos += 6; continue; cursorpos += 6; continue;
} }
else if (toparse[cursorpos + 1] == 'n') else if (toparse[cursorpos + 1] == 'n')

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -66,7 +67,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
foreach (Json.JSONData state in item.Value.Properties["states"].DataArray) foreach (Json.JSONData state in item.Value.Properties["states"].DataArray)
{ {
int id = int.Parse(state.Properties["id"].StringValue); int id = int.Parse(state.Properties["id"].StringValue, NumberStyles.Any, CultureInfo.CurrentCulture);
if (knownStates.Contains(id)) if (knownStates.Contains(id))
throw new InvalidDataException("Duplicate state id " + id + "!?"); throw new InvalidDataException("Duplicate state id " + id + "!?");

View file

@ -1,4 +1,5 @@
using System; using System;
using System.Globalization;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
namespace MinecraftClient.Mapping namespace MinecraftClient.Mapping
@ -85,7 +86,7 @@ namespace MinecraftClient.Mapping
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
{ {
if (!double.TryParse(coord_str[i], out coord_res[i])) if (!double.TryParse(coord_str[i], NumberStyles.Any, CultureInfo.CurrentCulture, out coord_res[i]))
{ {
location = null; location = null;
return false; return false;
@ -126,7 +127,7 @@ namespace MinecraftClient.Mapping
{ {
if (coord_str[i].Length > 1) if (coord_str[i].Length > 1)
{ {
if (!double.TryParse(coord_str[i][1..], out coord_res[i])) if (!double.TryParse(coord_str[i][1..], NumberStyles.Any, CultureInfo.CurrentCulture, out coord_res[i]))
{ {
location = null; location = null;
return false; return false;
@ -138,7 +139,7 @@ namespace MinecraftClient.Mapping
} }
else else
{ {
if (!double.TryParse(coord_str[i], out coord_res[i])) if (!double.TryParse(coord_str[i], NumberStyles.Any, CultureInfo.CurrentCulture, out coord_res[i]))
{ {
location = null; location = null;
return false; return false;

View file

@ -61,7 +61,6 @@ namespace MinecraftClient
private float playerPitch; private float playerPitch;
private double motionY; private double motionY;
public enum MovementType { Sneak, Walk, Sprint } public enum MovementType { Sneak, Walk, Sprint }
public int currentMovementSpeed = 4;
private int sequenceId; // User for player block synchronization (Aka. digging, placing blocks, etc..) private int sequenceId; // User for player block synchronization (Aka. digging, placing blocks, etc..)
private readonly string host; private readonly string host;
@ -337,7 +336,7 @@ namespace MinecraftClient
{ {
lock (locationLock) lock (locationLock)
{ {
for (int i = 0; i < currentMovementSpeed; i++) //Needs to run at 20 tps; MCC runs at 10 tps for (int i = 0; i < Settings.MovementSpeed; i++) //Needs to run at 20 tps; MCC runs at 10 tps
{ {
if (_yaw == null || _pitch == null) if (_yaw == null || _pitch == null)
{ {
@ -2485,15 +2484,15 @@ namespace MinecraftClient
{ {
case MovementType.Sneak: case MovementType.Sneak:
// https://minecraft.fandom.com/wiki/Sneaking#Effects - Sneaking 1.31m/s // https://minecraft.fandom.com/wiki/Sneaking#Effects - Sneaking 1.31m/s
currentMovementSpeed = 2; Settings.MovementSpeed = 2;
break; break;
case MovementType.Walk: case MovementType.Walk:
// https://minecraft.fandom.com/wiki/Walking#Usage - Walking 4.317 m/s // https://minecraft.fandom.com/wiki/Walking#Usage - Walking 4.317 m/s
currentMovementSpeed = 4; Settings.MovementSpeed = 4;
break; break;
case MovementType.Sprint: case MovementType.Sprint:
// https://minecraft.fandom.com/wiki/Sprinting#Usage - Sprinting 5.612 m/s // https://minecraft.fandom.com/wiki/Sprinting#Usage - Sprinting 5.612 m/s
currentMovementSpeed = 5; Settings.MovementSpeed = 5;
break; break;
} }
} }

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -411,7 +412,7 @@ namespace MinecraftClient
return; return;
} }
string worldId = addressInput.Split(':')[1]; string worldId = addressInput.Split(':')[1];
if (!availableWorlds.Contains(worldId) && int.TryParse(worldId, out int worldIndex) && worldIndex < availableWorlds.Count) if (!availableWorlds.Contains(worldId) && int.TryParse(worldId, NumberStyles.Any, CultureInfo.CurrentCulture, out int worldIndex) && worldIndex < availableWorlds.Count)
worldId = availableWorlds[worldIndex]; worldId = availableWorlds[worldIndex];
if (availableWorlds.Contains(worldId)) if (availableWorlds.Contains(worldId))
{ {

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -26,7 +27,7 @@ namespace MinecraftClient.Protocol
foreach (KeyValuePair<string, Json.JSONData> entry in rawRegistry.Properties) foreach (KeyValuePair<string, Json.JSONData> entry in rawRegistry.Properties)
{ {
int entryId = int.Parse(entry.Value.Properties["protocol_id"].StringValue); int entryId = int.Parse(entry.Value.Properties["protocol_id"].StringValue, NumberStyles.Any, CultureInfo.CurrentCulture);
//minecraft:item_name => ItemName //minecraft:item_name => ItemName
string entryName = String.Concat( string entryName = String.Concat(

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Net.Sockets; using System.Net.Sockets;
using System.Security.Cryptography; using System.Security.Cryptography;
@ -872,7 +873,7 @@ namespace MinecraftClient.Protocol.Handlers
if (result.Length > 2 && result[0] == '§' && result[1] == '1') if (result.Length > 2 && result[0] == '§' && result[1] == '1')
{ {
string[] tmp = result.Split((char)0x00); string[] tmp = result.Split((char)0x00);
protocolversion = (byte)Int16.Parse(tmp[1]); protocolversion = (byte)Int16.Parse(tmp[1], NumberStyles.Any, CultureInfo.CurrentCulture);
version = tmp[2]; version = tmp[2];
if (protocolversion == 127) //MC 1.7.2+ if (protocolversion == 127) //MC 1.7.2+

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Net.Sockets; using System.Net.Sockets;
using System.Security.Cryptography; using System.Security.Cryptography;
@ -815,7 +816,7 @@ namespace MinecraftClient.Protocol.Handlers
List<MapIcon> icons = new(); List<MapIcon> icons = new();
// 1,9 + = needs tracking position to be true to get the icons // 1,9 + = needs tracking position to be true to get the icons
if (protocolVersion <= MC_1_9_Version || trackingPosition) if (protocolVersion <= MC_1_16_5_Version || trackingPosition)
{ {
iconcount = dataTypes.ReadNextVarInt(packetData); iconcount = dataTypes.ReadNextVarInt(packetData);
@ -2139,7 +2140,7 @@ namespace MinecraftClient.Protocol.Handlers
//Retrieve protocol version number for handling this server //Retrieve protocol version number for handling this server
if (versionData.Properties.ContainsKey("protocol")) if (versionData.Properties.ContainsKey("protocol"))
protocolVersion = int.Parse(versionData.Properties["protocol"].StringValue); protocolVersion = int.Parse(versionData.Properties["protocol"].StringValue, NumberStyles.Any, CultureInfo.CurrentCulture);
// Check for forge on the server. // Check for forge on the server.
Protocol18Forge.ServerInfoCheckForge(jsonData, ref forgeInfo); Protocol18Forge.ServerInfoCheckForge(jsonData, ref forgeInfo);

View file

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@ -73,7 +74,7 @@ namespace MinecraftClient.Protocol
{ {
string accessToken = jsonData.Properties["access_token"].StringValue; string accessToken = jsonData.Properties["access_token"].StringValue;
string refreshToken = jsonData.Properties["refresh_token"].StringValue; string refreshToken = jsonData.Properties["refresh_token"].StringValue;
int expiresIn = int.Parse(jsonData.Properties["expires_in"].StringValue); int expiresIn = int.Parse(jsonData.Properties["expires_in"].StringValue, NumberStyles.Any, CultureInfo.CurrentCulture);
// Extract email from JWT // Extract email from JWT
string payload = JwtPayloadDecode.GetPayload(jsonData.Properties["id_token"].StringValue); string payload = JwtPayloadDecode.GetPayload(jsonData.Properties["id_token"].StringValue);
@ -237,7 +238,7 @@ namespace MinecraftClient.Protocol
Email = email, Email = email,
AccessToken = dict["access_token"], AccessToken = dict["access_token"],
RefreshToken = dict["refresh_token"], RefreshToken = dict["refresh_token"],
ExpiresIn = int.Parse(dict["expires_in"]) ExpiresIn = int.Parse(dict["expires_in"], NumberStyles.Any, CultureInfo.CurrentCulture)
}; };
} }
else else

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Net.Security; using System.Net.Security;
using System.Net.Sockets; using System.Net.Sockets;
@ -317,7 +318,7 @@ namespace MinecraftClient.Protocol
{ {
try try
{ {
return Int32.Parse(MCVersion); return Int32.Parse(MCVersion, NumberStyles.Any, CultureInfo.CurrentCulture);
} }
catch catch
{ {
@ -628,7 +629,7 @@ namespace MinecraftClient.Protocol
{ {
var payload = JwtPayloadDecode.GetPayload(session.ID); var payload = JwtPayloadDecode.GetPayload(session.ID);
var json = Json.ParseJson(payload); var json = Json.ParseJson(payload);
var expTimestamp = long.Parse(json.Properties["exp"].StringValue); var expTimestamp = long.Parse(json.Properties["exp"].StringValue, NumberStyles.Any, CultureInfo.CurrentCulture);
var now = DateTime.Now; var now = DateTime.Now;
var tokenExp = UnixTimeStampToDateTime(expTimestamp); var tokenExp = UnixTimeStampToDateTime(expTimestamp);
if (Settings.DebugMessages) if (Settings.DebugMessages)

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Globalization;
using System.IO; using System.IO;
using System.Net.Security; using System.Net.Security;
using System.Net.Sockets; using System.Net.Sockets;
@ -162,7 +163,7 @@ namespace MinecraftClient.Protocol
if (raw.StartsWith("HTTP/1.1") || raw.StartsWith("HTTP/1.0")) if (raw.StartsWith("HTTP/1.1") || raw.StartsWith("HTTP/1.0"))
{ {
Queue<string> msg = new(raw.Split(new string[] { "\r\n" }, StringSplitOptions.None)); Queue<string> msg = new(raw.Split(new string[] { "\r\n" }, StringSplitOptions.None));
statusCode = int.Parse(msg.Dequeue().Split(' ')[1]); statusCode = int.Parse(msg.Dequeue().Split(' ')[1], NumberStyles.Any, CultureInfo.CurrentCulture);
while (msg.Peek() != "") while (msg.Peek() != "")
{ {

View file

@ -49,6 +49,7 @@ minecraftrealms=false # Enable support for joining Minecraft Realms
moveheadwhilewalking=true # Enable head movement while walking to avoid anti-cheat triggers moveheadwhilewalking=true # Enable head movement while walking to avoid anti-cheat triggers
timeout=30 # Set a custom timeout in seconds (Default: 30). Use only if you know what you're doing. timeout=30 # Set a custom timeout in seconds (Default: 30). Use only if you know what you're doing.
enableemoji=true # If turned off, the emoji will be replaced with a simpler character (for /chunk status) enableemoji=true # If turned off, the emoji will be replaced with a simpler character (for /chunk status)
movementspeed=2 # A movement speed higher than 2 may be considered cheating.
[Signature] [Signature]
# Chat settings (affects minecraft 1.19+) # Chat settings (affects minecraft 1.19+)

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -109,6 +110,7 @@ namespace MinecraftClient
public static bool MoveHeadWhileWalking = true; public static bool MoveHeadWhileWalking = true;
public static int Timeout = 30; public static int Timeout = 30;
public static bool EnableEmoji = true; public static bool EnableEmoji = true;
public static int MovementSpeed = 2;
// Signature // Signature
public static bool LoginWithSecureProfile = true; public static bool LoginWithSecureProfile = true;
@ -425,6 +427,7 @@ namespace MinecraftClient
case "moveheadwhilewalking": MoveHeadWhileWalking = str2bool(argValue); return true; case "moveheadwhilewalking": MoveHeadWhileWalking = str2bool(argValue); return true;
case "timeout": Timeout = str2int(argValue); return true; case "timeout": Timeout = str2int(argValue); return true;
case "enableemoji": EnableEmoji = str2bool(argValue); return true; case "enableemoji": EnableEmoji = str2bool(argValue); return true;
case "movementspwwd": MovementSpeed = str2int(argValue); return true;
case "botowners": case "botowners":
Bots_Owners.Clear(); Bots_Owners.Clear();
@ -954,7 +957,7 @@ namespace MinecraftClient
/// <returns>Float number</returns> /// <returns>Float number</returns>
public static float str2float(string str) public static float str2float(string str)
{ {
if (float.TryParse(str.Trim(), out float num)) if (float.TryParse(str.Trim(), NumberStyles.Any, CultureInfo.CurrentCulture, out float num))
return num; return num;
else else
{ {
@ -970,7 +973,7 @@ namespace MinecraftClient
/// <returns>Double number</returns> /// <returns>Double number</returns>
public static double str2double(string str) public static double str2double(string str)
{ {
if (double.TryParse(str.Trim(), out double num)) if (double.TryParse(str.Trim(), NumberStyles.Any, CultureInfo.CurrentCulture, out double num))
return num; return num;
else else
{ {
@ -1016,7 +1019,7 @@ namespace MinecraftClient
for (int j = 0; j < curCodLen; ++j) for (int j = 0; j < curCodLen; ++j)
{ {
if (!double.TryParse(coordinates_str_list[j], out res![i, j])) if (!double.TryParse(coordinates_str_list[j], NumberStyles.Any, CultureInfo.CurrentCulture, out res![i, j]))
{ {
ConsoleIO.WriteLogLine(Translations.Get("error.setting.str2locationList.convert_fail", coordinates_str_list[j])); ConsoleIO.WriteLogLine(Translations.Get("error.setting.str2locationList.convert_fail", coordinates_str_list[j]));
return null; return null;

View file

@ -1,4 +1,5 @@
using System.Runtime.InteropServices; using System.Globalization;
using System.Runtime.InteropServices;
using Microsoft.Win32; using Microsoft.Win32;
namespace MinecraftClient.WinAPI namespace MinecraftClient.WinAPI
@ -35,7 +36,7 @@ namespace MinecraftClient.WinAPI
var versionParts = ((string)version!).Split('.'); var versionParts = ((string)version!).Split('.');
if (versionParts.Length != 2) return 0; if (versionParts.Length != 2) return 0;
return uint.TryParse(versionParts[0], out uint majorAsUInt) ? majorAsUInt : 0; return uint.TryParse(versionParts[0], NumberStyles.Any, CultureInfo.CurrentCulture, out uint majorAsUInt) ? majorAsUInt : 0;
} }
return 0; return 0;
@ -62,7 +63,7 @@ namespace MinecraftClient.WinAPI
var versionParts = ((string)version!).Split('.'); var versionParts = ((string)version!).Split('.');
if (versionParts.Length != 2) return 0; if (versionParts.Length != 2) return 0;
return uint.TryParse(versionParts[1], out uint minorAsUInt) ? minorAsUInt : 0; return uint.TryParse(versionParts[1], NumberStyles.Any, CultureInfo.CurrentCulture, out uint minorAsUInt) ? minorAsUInt : 0;
} }
return 0; return 0;