Fix AutoDig

This commit is contained in:
BruceChen 2022-11-01 16:37:50 +08:00
parent d7471e3741
commit e954801a0d
5 changed files with 55 additions and 24 deletions

View file

@ -33,7 +33,7 @@ namespace MinecraftClient.ChatBots
[TomlInlineComment("$config.ChatBot.AutoDig.Mode$")]
public ModeType Mode = ModeType.lookat;
[TomlInlineComment("$config.ChatBot.AutoDig.Locations$")]
[TomlPrecedingComment("$config.ChatBot.AutoDig.Locations$")]
public Coordination[] Locations = new Coordination[] { new(123.5, 64, 234.5), new(124.5, 63, 235.5) };
[TomlInlineComment("$config.ChatBot.AutoDig.Location_Order$")]

View file

@ -749,10 +749,13 @@ namespace MinecraftClient.Protocol.Handlers
// Teleport confirm packet
SendPacket(PacketTypesOut.TeleportConfirm, dataTypes.GetVarInt(teleportID));
if (Config.Main.Advanced.TemporaryFixBadpacket)
{
SendLocationUpdate(location, true, yaw, pitch, true);
if (teleportID == 1)
SendLocationUpdate(location, true, yaw, pitch, true);
}
}
else
{
handler.UpdateLocation(location, yaw, pitch);
@ -2550,7 +2553,7 @@ namespace MinecraftClient.Protocol.Handlers
/// <returns>True if the location update was successfully sent</returns>
public bool SendLocationUpdate(Location location, bool onGround, float? yaw, float? pitch)
{
return SendLocationUpdate(location, onGround, yaw, pitch, false);
return SendLocationUpdate(location, onGround, yaw, pitch, true);
}
public bool SendLocationUpdate(Location location, bool onGround, float? yaw = null, float? pitch = null, bool forceUpdate = false)
@ -2560,6 +2563,8 @@ namespace MinecraftClient.Protocol.Handlers
byte[] yawpitch = Array.Empty<byte>();
PacketTypesOut packetType = PacketTypesOut.PlayerPosition;
if (Config.Main.Advanced.TemporaryFixBadpacket)
{
if (yaw.HasValue && pitch.HasValue && (forceUpdate || yaw.Value != LastYaw || pitch.Value != LastPitch))
{
yawpitch = dataTypes.ConcatBytes(dataTypes.GetFloat(yaw.Value), dataTypes.GetFloat(pitch.Value));
@ -2567,6 +2572,17 @@ namespace MinecraftClient.Protocol.Handlers
LastYaw = yaw.Value; LastPitch = pitch.Value;
}
}
else
{
if (yaw.HasValue && pitch.HasValue)
{
yawpitch = dataTypes.ConcatBytes(dataTypes.GetFloat(yaw.Value), dataTypes.GetFloat(pitch.Value));
packetType = PacketTypesOut.PlayerPositionAndRotation;
LastYaw = yaw.Value; LastPitch = pitch.Value;
}
}
try
{

View file

@ -5649,6 +5649,15 @@ namespace MinecraftClient {
}
}
/// <summary>
/// Looks up a localized string similar to Temporary fix for Badpacket issue on some servers..
/// </summary>
internal static string config_Main_Advanced_temporary_fix_badpacket {
get {
return ResourceManager.GetString("config.Main.Advanced.temporary_fix_badpacket", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use &quot;none&quot;, &quot;bit_4&quot;, &quot;bit_8&quot; or &quot;bit_24&quot;. This can be checked by opening the debug log..
/// </summary>

View file

@ -2669,4 +2669,7 @@ Logging in...</value>
<data name="mcc.backup_old_config" xml:space="preserve">
<value>The old MinecraftClient.ini has been backed up as {0}</value>
</data>
<data name="config.Main.Advanced.temporary_fix_badpacket" xml:space="preserve">
<value>Temporary fix for Badpacket issue on some servers.</value>
</data>
</root>

View file

@ -508,6 +508,9 @@ namespace MinecraftClient
[TomlInlineComment("$config.Main.Advanced.movement_speed$")]
public int MovementSpeed = 2;
[TomlInlineComment("$config.Main.Advanced.temporary_fix_badpacket$")]
public bool TemporaryFixBadpacket = false;
[TomlInlineComment("$config.Main.Advanced.inventory_handling$")]
public bool InventoryHandling = false;