Merge branch 'master' of https://github.com/MCCTeam/Minecraft-Console-Client into fix/inventory-version-regressions

# Conflicts:
#	MinecraftClient/Mapping/World.cs
This commit is contained in:
Anon 2026-06-05 21:13:59 +02:00
commit 29b0087a3a
119 changed files with 678 additions and 642 deletions

View file

@ -127,7 +127,7 @@ namespace MinecraftClient.ChatBots
private void DoAntiAfkStuff()
{
var isMovementLocked = BotMovementLock.Instance;
if (Config.Use_Terrain_Handling && GetTerrainEnabled() && isMovementLocked is {IsLocked: false})
if (Config.Use_Terrain_Handling && GetTerrainEnabled() && isMovementLocked is { IsLocked: false })
{
var currentLocation = GetCurrentLocation();

View file

@ -28,7 +28,7 @@ namespace MinecraftClient.ChatBots
public PriorityType Priority = PriorityType.distance;
[TomlInlineComment("$ChatBot.AutoAttack.Cooldown_Time$")]
public CooldownConfig Cooldown_Time = new(false, 1.0);
public CooldownConfig Cooldown_Time = new();
[TomlInlineComment("$ChatBot.AutoAttack.Interaction$")]
public InteractType Interaction = InteractType.Attack;
@ -50,10 +50,19 @@ namespace MinecraftClient.ChatBots
public void OnSettingUpdate()
{
if (Cooldown_Time.Custom && Cooldown_Time.value <= 0)
if (Cooldown_Time.Custom)
{
LogToConsole(BotName, Translations.bot_autoAttack_invalidcooldown);
Cooldown_Time.value = 1.0;
if (Cooldown_Time.Min <= 0)
Cooldown_Time.Min = 0.1;
if (Cooldown_Time.Max <= 0)
Cooldown_Time.Max = 0.1;
if (Cooldown_Time.Min > Cooldown_Time.Max)
{
double temp = Cooldown_Time.Min;
Cooldown_Time.Min = Cooldown_Time.Max;
Cooldown_Time.Max = temp;
}
}
if (Attack_Range < 1.0)
@ -72,24 +81,16 @@ namespace MinecraftClient.ChatBots
public struct CooldownConfig
{
public bool Custom;
public double value;
public bool RandomMode = false;
public double Min = 1.5;
public double Max = 2.5;
public CooldownConfig()
{
Custom = false;
value = 0;
}
public CooldownConfig(double value)
{
Custom = true;
this.value = value;
}
public CooldownConfig(bool Override, double value)
{
this.Custom = Override;
this.value = value;
RandomMode = false;
Min = 1.5;
Max = 2.5;
}
}
}
@ -105,13 +106,14 @@ namespace MinecraftClient.ChatBots
private float health = 100;
private readonly bool attackHostile = true;
private readonly bool attackPassive = false;
private readonly Random _random = new();
public AutoAttack()
{
overrideAttackSpeed = Config.Cooldown_Time.Custom;
if (Config.Cooldown_Time.Custom)
{
attackCooldownSeconds = Config.Cooldown_Time.value;
attackCooldownSeconds = Config.Cooldown_Time.Min;
attackCooldown = SecondsToAttackCooldownTicks(attackCooldownSeconds);
}
@ -137,6 +139,12 @@ namespace MinecraftClient.ChatBots
if (attackCooldownCounter == 0)
{
if (Config.Cooldown_Time.Custom && Config.Cooldown_Time.RandomMode)
{
double randomSeconds = _random.NextDouble() * (Config.Cooldown_Time.Max - Config.Cooldown_Time.Min) + Config.Cooldown_Time.Min;
attackCooldown = SecondsToAttackCooldownTicks(randomSeconds);
}
attackCooldownCounter = attackCooldown;
if (entitiesToAttack.Count > 0)
{
@ -177,6 +185,8 @@ namespace MinecraftClient.ChatBots
InteractEntity(priorityEntity, Config.Interaction); // hit the entity!
SendAnimation(Inventory.Hand.MainHand); // Arm animation
}
}
}
else
@ -188,6 +198,7 @@ namespace MinecraftClient.ChatBots
{
InteractEntity(entity.Key, Config.Interaction); // hit the entity!
}
}
SendAnimation(Inventory.Hand.MainHand); // Arm animation
}

View file

@ -86,7 +86,7 @@ namespace MinecraftClient.ChatBots
public static bool LookForScript(ref string filename)
{
//Automatically look in subfolders and try to add ".txt" file extension
char dir_slash = Path.DirectorySeparatorChar;
char dir_slash = Path.DirectorySeparatorChar;
string[] files = new string[]
{
filename,
@ -149,6 +149,12 @@ namespace MinecraftClient.ChatBots
}
}
public override bool OnDisconnect(DisconnectReason reason, string message)
{
UnloadBot();
return false;
}
public override void Update()
{
if (csharp) //C# compiled script
@ -226,8 +232,10 @@ namespace MinecraftClient.ChatBots
}
ticks = new Random().Next(min, max);
} else ticks = Convert.ToInt32(instruction_line[5..]);
} else ticks = Convert.ToInt32(instruction_line[5..]);
}
else ticks = Convert.ToInt32(instruction_line[5..]);
}
else ticks = Convert.ToInt32(instruction_line[5..]);
}
catch { }
sleepticks = ticks;

View file

@ -352,7 +352,7 @@ namespace MinecraftClient.ChatBots
replyParameters: message.MessageId,
cancellationToken: _cancellationToken,
parseMode: ParseMode.Markdown);
return;;
return; ;
}
CmdResult result = new();

View file

@ -134,8 +134,8 @@ namespace MinecraftClient.Inventory
{
object[] displayName = (object[])displayProperties["Lore"];
lores.AddRange(from string st in displayName
let str = ChatParser.ParseText(st.ToString())
select str);
let str = ChatParser.ParseText(st.ToString())
select str);
return lores.ToArray();
}
}

View file

@ -117,7 +117,8 @@ namespace MinecraftClient.Mapping
return true;
default:
return false;
};
}
;
}
}
}

View file

@ -19,7 +19,7 @@ namespace MinecraftClient.Mapping
/// <summary>
/// The dimension info of the world
/// </summary>
private static Dimension curDimension= new();
private static Dimension curDimension = new();
private static readonly Dictionary<string, Dimension> dimensionList = new();
@ -323,58 +323,58 @@ namespace MinecraftClient.Mapping
/// </summary>
/// <param name="name"> The name of the dimension type</param>
/// <param name="nbt">The dimension type (NBT Tag Compound)</param>
public static void SetDimension(string name)
{
// Try to get the dimension using the name as is
if (dimensionList.TryGetValue(name, out Dimension? dimension))
{
curDimension = dimension;
return; // Dimension found
}
public static void SetDimension(string name)
{
// Try to get the dimension using the name as is
if (dimensionList.TryGetValue(name, out Dimension? dimension))
{
curDimension = dimension;
return; // Dimension found
}
// If not found, check if name lacks 'minecraft:' prefix and try again
if (!name.StartsWith("minecraft:"))
{
string prefixedName = "minecraft:" + name;
if (dimensionList.TryGetValue(prefixedName, out dimension))
{
curDimension = dimension;
return; // Dimension found with prefixed name
}
}
else
{
string unprefixedName = name["minecraft:".Length..];
if (dimensionList.TryGetValue(unprefixedName, out dimension))
{
curDimension = dimension;
return;
}
}
// If not found, check if name lacks 'minecraft:' prefix and try again
if (!name.StartsWith("minecraft:"))
{
string prefixedName = "minecraft:" + name;
if (dimensionList.TryGetValue(prefixedName, out dimension))
{
curDimension = dimension;
return; // Dimension found with prefixed name
}
}
else
{
string unprefixedName = name["minecraft:".Length..];
if (dimensionList.TryGetValue(unprefixedName, out dimension))
{
curDimension = dimension;
return;
}
}
if (TryStoreDefaultVanillaDimension(name)
&& dimensionList.TryGetValue(name, out dimension))
{
curDimension = dimension;
return;
}
if (TryStoreDefaultVanillaDimension(name)
&& dimensionList.TryGetValue(name, out dimension))
{
curDimension = dimension;
return;
}
// If still not found, dimension does not exist
throw new KeyNotFoundException($"Dimension '{name}' not found in dimensions dictionary.");
}
// If still not found, dimension does not exist
throw new KeyNotFoundException($"Dimension '{name}' not found in dimensions dictionary.");
}
private static bool TryStoreDefaultVanillaDimension(string name)
{
var normalizedName = name.StartsWith("minecraft:")
? name
: "minecraft:" + name;
private static bool TryStoreDefaultVanillaDimension(string name)
{
var normalizedName = name.StartsWith("minecraft:")
? name
: "minecraft:" + name;
if (normalizedName is not ("minecraft:overworld" or "minecraft:the_nether" or "minecraft:the_end"))
return false;
if (normalizedName is not ("minecraft:overworld" or "minecraft:the_nether" or "minecraft:the_end"))
return false;
StoreOneDimension(name, new Dictionary<string, object>());
return true;
}
StoreOneDimension(name, new Dictionary<string, object>());
return true;
}

View file

@ -356,7 +356,7 @@ namespace MinecraftClient
return;
Retry:
Retry:
if (timeoutdetector is not null)
{
timeoutdetector.Item2.Cancel();

View file

@ -1392,18 +1392,18 @@ public sealed class MccMcpCapabilities : IMccMcpCapabilities
bool success = client.SendLocationUpdate();
return success
? MccMcpResult.Ok(new
{
success,
direction = parsedDirection.ToString(),
yaw = client.GetYaw(),
pitch = client.GetPitch(),
location = ToCoordinate(current)
})
{
success,
direction = parsedDirection.ToString(),
yaw = client.GetYaw(),
pitch = client.GetPitch(),
location = ToCoordinate(current)
})
: MccMcpResult.Fail("action_failed", data: new
{
success,
direction = parsedDirection.ToString()
});
{
success,
direction = parsedDirection.ToString()
});
});
}
@ -1426,19 +1426,19 @@ public sealed class MccMcpCapabilities : IMccMcpCapabilities
bool success = client.SendLocationUpdate();
return success
? MccMcpResult.Ok(new
{
success,
yaw = client.GetYaw(),
pitch = client.GetPitch(),
location = ToCoordinate(current)
})
{
success,
yaw = client.GetYaw(),
pitch = client.GetPitch(),
location = ToCoordinate(current)
})
: MccMcpResult.Fail("action_failed", data: new
{
success,
yaw,
pitch,
location = ToCoordinate(current)
});
{
success,
yaw,
pitch,
location = ToCoordinate(current)
});
});
}

View file

@ -506,48 +506,48 @@ namespace MinecraftClient.Protocol.Handlers
return item;
case >= Protocol18Handler.MC_1_13_2_Version:
{
var itemPresent = ReadNextBool(cache);
{
var itemPresent = ReadNextBool(cache);
if (!itemPresent)
return null;
if (!itemPresent)
return null;
itemId = ReadNextVarInt(cache);
itemId = ReadNextVarInt(cache);
if (itemId == -1)
return null;
if (itemId == -1)
return null;
var type = itemPalette.FromId(itemId);
itemCount = ReadNextByte(cache);
nbt = ReadNextNbt(cache);
return new Item(type, itemCount, itemId, nbt);
}
var type = itemPalette.FromId(itemId);
itemCount = ReadNextByte(cache);
nbt = ReadNextNbt(cache);
return new Item(type, itemCount, itemId, nbt);
}
case >= Protocol18Handler.MC_1_13_Version:
{
itemId = ReadNextShort(cache);
{
itemId = ReadNextShort(cache);
if (itemId == -1)
return null;
if (itemId == -1)
return null;
var type = itemPalette.FromId(itemId);
itemCount = ReadNextByte(cache);
nbt = ReadNextNbt(cache);
return new Item(type, itemCount, itemId, nbt);
}
var type = itemPalette.FromId(itemId);
itemCount = ReadNextByte(cache);
nbt = ReadNextNbt(cache);
return new Item(type, itemCount, itemId, nbt);
}
default:
{
itemId = ReadNextShort(cache);
{
itemId = ReadNextShort(cache);
if (itemId == -1)
return null;
if (itemId == -1)
return null;
itemCount = ReadNextByte(cache);
var data = ReadNextShort(cache);
nbt = ReadNextNbt(cache);
itemCount = ReadNextByte(cache);
var data = ReadNextShort(cache);
nbt = ReadNextNbt(cache);
// For 1.8 - 1.12.2 we combine Item Id and Item Data/Damage to a single value using: (id << 16) | data
return new Item(itemPalette.FromId((itemId << 16) | (ushort)data), itemCount, data, nbt);
}
// For 1.8 - 1.12.2 we combine Item Id and Item Data/Damage to a single value using: (id << 16) | data
return new Item(itemPalette.FromId((itemId << 16) | (ushort)data), itemCount, data, nbt);
}
}
}
@ -1346,7 +1346,7 @@ namespace MinecraftClient.Protocol.Handlers
break;
case 45:
// 1.21+
if(protocolversion >= Protocol18Handler.MC_1_21_Version)
if (protocolversion >= Protocol18Handler.MC_1_21_Version)
ReadVibration(cache);
break;
case 99:

View file

@ -169,7 +169,8 @@ namespace MinecraftClient.Protocol.Handlers.Forge
// [ Channel Version ][ String ]
// [ Required On Client ][ Bool ]
for (var i = 0; i < modsSize; i++) {
for (var i = 0; i < modsSize; i++)
{
var channelSizeAndVersionFlag = dataTypes.ReadNextVarInt(dataPackage);
var channelSize = channelSizeAndVersionFlag >> 1;
@ -181,7 +182,8 @@ namespace MinecraftClient.Protocol.Handlers.Forge
string IGNORESERVERONLY = "IGNORED";
var modVersion = isIgnoreServerOnly ? IGNORESERVERONLY : dataTypes.ReadNextString(dataPackage);
for (var i1 = 0; i1 < channelSize; i1++) {
for (var i1 = 0; i1 < channelSize; i1++)
{
dataTypes.ReadNextString(dataPackage); // channelName
dataTypes.ReadNextString(dataPackage); // channelVersion
dataTypes.ReadNextBool(dataPackage); // requiredOnClient
@ -213,7 +215,8 @@ namespace MinecraftClient.Protocol.Handlers.Forge
/// The code below is converted from forge source code, see:
/// https://github.com/MinecraftForge/MinecraftForge/blob/cb12df41e13da576b781be695f80728b9594c25f/src/main/java/net/minecraftforge/network/ServerStatusPing.java#L361
/// </para>
private static Queue<byte> decodeOptimized(string encodedData) {
private static Queue<byte> decodeOptimized(string encodedData)
{
int size0 = encodedData[0];
int size1 = encodedData[1];
int size = size0 | (size1 << 15);

View file

@ -3,8 +3,8 @@ using System.Collections.Generic;
namespace MinecraftClient.Protocol.Handlers.PacketPalettes;
public class PacketPalette1204 : PacketTypePalette
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
{ 0x00, PacketTypesIn.Bundle }, // Added in 1.19.4
{ 0x01, PacketTypesIn.SpawnEntity }, // Changed in 1.19 (Wiki name: Spawn Entity)
@ -125,7 +125,7 @@ public class PacketPalette1204 : PacketTypePalette
{ 0x74, PacketTypesIn.Tags }, // (Wiki name: Update Tags)
};
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
{
{ 0x00, PacketTypesOut.TeleportConfirm }, // (Wiki name: Confirm Teleportation)
{ 0x01, PacketTypesOut.QueryBlockNBT }, // (Wiki name: Query Block Entity Tag)
@ -184,7 +184,7 @@ public class PacketPalette1204 : PacketTypePalette
{ 0x36, PacketTypesOut.UseItem }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Use Item)
};
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
{
{ 0x00, ConfigurationPacketTypesIn.PluginMessage },
{ 0x01, ConfigurationPacketTypesIn.Disconnect },
@ -198,7 +198,7 @@ public class PacketPalette1204 : PacketTypePalette
{ 0x09, ConfigurationPacketTypesIn.UpdateTags },
};
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
{
{ 0x00, ConfigurationPacketTypesOut.ClientInformation },
{ 0x01, ConfigurationPacketTypesOut.PluginMessage },
@ -208,8 +208,8 @@ public class PacketPalette1204 : PacketTypePalette
{ 0x05, ConfigurationPacketTypesOut.ResourcePackResponse }
};
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}

View file

@ -3,8 +3,8 @@ using System.Collections.Generic;
namespace MinecraftClient.Protocol.Handlers.PacketPalettes;
public class PacketPalette1206 : PacketTypePalette
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
{ 0x00, PacketTypesIn.Bundle }, // Added in 1.19.4
{ 0x01, PacketTypesIn.SpawnEntity }, // Changed in 1.19 (Wiki name: Spawn Entity)
@ -130,7 +130,7 @@ public class PacketPalette1206 : PacketTypePalette
{ 0x79, PacketTypesIn.ProjectilePower }, // Added in 1.20.6
};
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
{
{ 0x00, PacketTypesOut.TeleportConfirm }, // (Wiki name: Confirm Teleportation)
{ 0x01, PacketTypesOut.QueryBlockNBT }, // (Wiki name: Query Block Entity Tag)
@ -192,7 +192,7 @@ public class PacketPalette1206 : PacketTypePalette
{ 0x39, PacketTypesOut.UseItem }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Use Item)
};
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
{
{ 0x00, ConfigurationPacketTypesIn.CookieRequest },
{ 0x01, ConfigurationPacketTypesIn.PluginMessage },
@ -211,7 +211,7 @@ public class PacketPalette1206 : PacketTypePalette
{ 0x0E, ConfigurationPacketTypesIn.KnownDataPacks }
};
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
{
{ 0x00, ConfigurationPacketTypesOut.ClientInformation },
{ 0x01, ConfigurationPacketTypesOut.CookieResponse },
@ -223,8 +223,8 @@ public class PacketPalette1206 : PacketTypePalette
{ 0x07, ConfigurationPacketTypesOut.KnownDataPacks }
};
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}

View file

@ -3,8 +3,8 @@ using System.Collections.Generic;
namespace MinecraftClient.Protocol.Handlers.PacketPalettes;
public class PacketPalette121 : PacketTypePalette
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
{ 0x00, PacketTypesIn.Bundle }, // Added in 1.19.4
{ 0x01, PacketTypesIn.SpawnEntity }, // Changed in 1.19 (Wiki name: Spawn Entity)
@ -132,7 +132,7 @@ public class PacketPalette121 : PacketTypePalette
{ 0x7B, PacketTypesIn.ServerLinks } // Added in 1.21
};
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
{
{ 0x00, PacketTypesOut.TeleportConfirm }, // (Wiki name: Confirm Teleportation)
{ 0x01, PacketTypesOut.QueryBlockNBT }, // (Wiki name: Query Block Entity Tag)
@ -194,7 +194,7 @@ public class PacketPalette121 : PacketTypePalette
{ 0x39, PacketTypesOut.UseItem }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Use Item)
};
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
{
{ 0x00, ConfigurationPacketTypesIn.CookieRequest },
{ 0x01, ConfigurationPacketTypesIn.PluginMessage },
@ -215,7 +215,7 @@ public class PacketPalette121 : PacketTypePalette
{ 0x10, ConfigurationPacketTypesIn.ServerLinks } // Added in 1.21 (Not used)
};
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
{
{ 0x00, ConfigurationPacketTypesOut.ClientInformation },
{ 0x01, ConfigurationPacketTypesOut.CookieResponse },
@ -227,8 +227,8 @@ public class PacketPalette121 : PacketTypePalette
{ 0x07, ConfigurationPacketTypesOut.KnownDataPacks }
};
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}

View file

@ -3,8 +3,8 @@ using System.Collections.Generic;
namespace MinecraftClient.Protocol.Handlers.PacketPalettes;
public class PacketPalette1212 : PacketTypePalette
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
{ 0x00, PacketTypesIn.Bundle }, // Bundle delimiter
{ 0x01, PacketTypesIn.SpawnEntity }, // Add Entity
@ -139,7 +139,7 @@ public class PacketPalette1212 : PacketTypePalette
{ 0x82, PacketTypesIn.ServerLinks } // Server Links
};
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
{
{ 0x00, PacketTypesOut.TeleportConfirm }, // Accept Teleportation
{ 0x01, PacketTypesOut.QueryBlockNBT }, // Block Entity Tag Query
@ -203,7 +203,7 @@ public class PacketPalette1212 : PacketTypePalette
{ 0x3B, PacketTypesOut.UseItem }, // Use Item
};
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
{
{ 0x00, ConfigurationPacketTypesIn.CookieRequest },
{ 0x01, ConfigurationPacketTypesIn.PluginMessage },
@ -224,7 +224,7 @@ public class PacketPalette1212 : PacketTypePalette
{ 0x10, ConfigurationPacketTypesIn.ServerLinks }
};
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
{
{ 0x00, ConfigurationPacketTypesOut.ClientInformation },
{ 0x01, ConfigurationPacketTypesOut.CookieResponse },
@ -236,8 +236,8 @@ public class PacketPalette1212 : PacketTypePalette
{ 0x07, ConfigurationPacketTypesOut.KnownDataPacks }
};
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}

View file

@ -3,8 +3,8 @@ using System.Collections.Generic;
namespace MinecraftClient.Protocol.Handlers.PacketPalettes;
public class PacketPalette1214 : PacketTypePalette
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
{ 0x00, PacketTypesIn.Bundle }, // Bundle delimiter
{ 0x01, PacketTypesIn.SpawnEntity }, // Add Entity
@ -139,7 +139,7 @@ public class PacketPalette1214 : PacketTypePalette
{ 0x82, PacketTypesIn.ServerLinks } // Server Links
};
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
{
{ 0x00, PacketTypesOut.TeleportConfirm }, // Accept Teleportation
{ 0x01, PacketTypesOut.QueryBlockNBT }, // Block Entity Tag Query
@ -205,7 +205,7 @@ public class PacketPalette1214 : PacketTypePalette
{ 0x3D, PacketTypesOut.UseItem }, // Use Item
};
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
{
{ 0x00, ConfigurationPacketTypesIn.CookieRequest },
{ 0x01, ConfigurationPacketTypesIn.PluginMessage },
@ -226,7 +226,7 @@ public class PacketPalette1214 : PacketTypePalette
{ 0x10, ConfigurationPacketTypesIn.ServerLinks }
};
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
{
{ 0x00, ConfigurationPacketTypesOut.ClientInformation },
{ 0x01, ConfigurationPacketTypesOut.CookieResponse },
@ -238,8 +238,8 @@ public class PacketPalette1214 : PacketTypePalette
{ 0x07, ConfigurationPacketTypesOut.KnownDataPacks }
};
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}

View file

@ -3,8 +3,8 @@ using System.Collections.Generic;
namespace MinecraftClient.Protocol.Handlers.PacketPalettes;
public class PacketPalette1215 : PacketTypePalette
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
{ 0x00, PacketTypesIn.Bundle }, // Bundle delimiter
{ 0x01, PacketTypesIn.SpawnEntity }, // Add Entity
@ -139,7 +139,7 @@ public class PacketPalette1215 : PacketTypePalette
{ 0x82, PacketTypesIn.ServerLinks } // Server Links
};
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
{
{ 0x00, PacketTypesOut.TeleportConfirm }, // Accept Teleportation
{ 0x01, PacketTypesOut.QueryBlockNBT }, // Block Entity Tag Query
@ -207,7 +207,7 @@ public class PacketPalette1215 : PacketTypePalette
{ 0x3F, PacketTypesOut.UseItem }, // Use Item
};
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
{
{ 0x00, ConfigurationPacketTypesIn.CookieRequest },
{ 0x01, ConfigurationPacketTypesIn.PluginMessage },
@ -228,7 +228,7 @@ public class PacketPalette1215 : PacketTypePalette
{ 0x10, ConfigurationPacketTypesIn.ServerLinks }
};
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
{
{ 0x00, ConfigurationPacketTypesOut.ClientInformation },
{ 0x01, ConfigurationPacketTypesOut.CookieResponse },
@ -240,8 +240,8 @@ public class PacketPalette1215 : PacketTypePalette
{ 0x07, ConfigurationPacketTypesOut.KnownDataPacks }
};
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}

View file

@ -3,8 +3,8 @@ using System.Collections.Generic;
namespace MinecraftClient.Protocol.Handlers.PacketPalettes;
public class PacketPalette1216 : PacketTypePalette
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
{ 0x00, PacketTypesIn.Bundle }, // Bundle delimiter
{ 0x01, PacketTypesIn.SpawnEntity }, // Add Entity
@ -142,7 +142,7 @@ public class PacketPalette1216 : PacketTypePalette
{ 0x85, PacketTypesIn.ShowDialog } // Show Dialog (new in 1.21.6)
};
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
{
{ 0x00, PacketTypesOut.TeleportConfirm }, // Accept Teleportation
{ 0x01, PacketTypesOut.QueryBlockNBT }, // Block Entity Tag Query
@ -212,7 +212,7 @@ public class PacketPalette1216 : PacketTypePalette
{ 0x41, PacketTypesOut.CustomClickAction } // Custom Click Action (new in 1.21.6)
};
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
{
{ 0x00, ConfigurationPacketTypesIn.CookieRequest },
{ 0x01, ConfigurationPacketTypesIn.PluginMessage },
@ -235,7 +235,7 @@ public class PacketPalette1216 : PacketTypePalette
{ 0x12, ConfigurationPacketTypesIn.ShowDialog } // New in 1.21.6
};
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
{
{ 0x00, ConfigurationPacketTypesOut.ClientInformation },
{ 0x01, ConfigurationPacketTypesOut.CookieResponse },
@ -248,8 +248,8 @@ public class PacketPalette1216 : PacketTypePalette
{ 0x08, ConfigurationPacketTypesOut.CustomClickAction } // New in 1.21.6
};
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}

View file

@ -3,8 +3,8 @@ using System.Collections.Generic;
namespace MinecraftClient.Protocol.Handlers.PacketPalettes;
public class PacketPalette1219 : PacketTypePalette
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
{ 0x00, PacketTypesIn.Bundle }, // Bundle delimiter
{ 0x01, PacketTypesIn.SpawnEntity }, // Add Entity
@ -147,7 +147,7 @@ public class PacketPalette1219 : PacketTypePalette
{ 0x8A, PacketTypesIn.ShowDialog } // Show Dialog
};
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
{
{ 0x00, PacketTypesOut.TeleportConfirm }, // Accept Teleportation
{ 0x01, PacketTypesOut.QueryBlockNBT }, // Block Entity Tag Query
@ -217,7 +217,7 @@ public class PacketPalette1219 : PacketTypePalette
{ 0x41, PacketTypesOut.CustomClickAction } // Custom Click Action
};
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
{
{ 0x00, ConfigurationPacketTypesIn.CookieRequest },
{ 0x01, ConfigurationPacketTypesIn.PluginMessage },
@ -241,7 +241,7 @@ public class PacketPalette1219 : PacketTypePalette
{ 0x13, ConfigurationPacketTypesIn.CodeOfConduct } // New in 1.21.9
};
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
{
{ 0x00, ConfigurationPacketTypesOut.ClientInformation },
{ 0x01, ConfigurationPacketTypesOut.CookieResponse },
@ -255,8 +255,8 @@ public class PacketPalette1219 : PacketTypePalette
{ 0x09, ConfigurationPacketTypesOut.AcceptCodeOfConduct } // New in 1.21.9
};
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}

View file

@ -3,8 +3,8 @@ using System.Collections.Generic;
namespace MinecraftClient.Protocol.Handlers.PacketPalettes;
public class PacketPalette261 : PacketTypePalette
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
{
{ 0x00, PacketTypesIn.Bundle }, // Bundle delimiter
{ 0x01, PacketTypesIn.SpawnEntity }, // Add Entity
@ -149,7 +149,7 @@ public class PacketPalette261 : PacketTypePalette
{ 0x8C, PacketTypesIn.ShowDialog } // Show Dialog
};
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
{
{ 0x00, PacketTypesOut.TeleportConfirm }, // Accept Teleportation
{ 0x01, PacketTypesOut.Attack }, // Attack (new in 26.1)
@ -221,7 +221,7 @@ public class PacketPalette261 : PacketTypePalette
{ 0x44, PacketTypesOut.CustomClickAction } // Custom Click Action
};
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
{
{ 0x00, ConfigurationPacketTypesIn.CookieRequest },
{ 0x01, ConfigurationPacketTypesIn.PluginMessage },
@ -245,7 +245,7 @@ public class PacketPalette261 : PacketTypePalette
{ 0x13, ConfigurationPacketTypesIn.CodeOfConduct }
};
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
{
{ 0x00, ConfigurationPacketTypesOut.ClientInformation },
{ 0x01, ConfigurationPacketTypesOut.CookieResponse },
@ -259,8 +259,8 @@ public class PacketPalette261 : PacketTypePalette
{ 0x09, ConfigurationPacketTypesOut.AcceptCodeOfConduct }
};
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
}

View file

@ -836,15 +836,15 @@ namespace MinecraftClient.Protocol.Handlers
dimensionTypeName =
dataTypes.ReadNextString(packetData); // Dimension Type: Identifier
break;
case >= MC_1_16_2_Version:
dimensionType =
dataTypes.ReadNextNbt(
packetData); // Dimension Type: NBT Tag Compound
break;
default:
dimensionTypeName = dataTypes.ReadNextString(packetData);
break;
}
case >= MC_1_16_2_Version:
dimensionType =
dataTypes.ReadNextNbt(
packetData); // Dimension Type: NBT Tag Compound
break;
default:
dimensionTypeName = dataTypes.ReadNextString(packetData);
break;
}
currentDimension = 0;
break;
@ -1409,14 +1409,14 @@ namespace MinecraftClient.Protocol.Handlers
dimensionTypeNameRespawn =
dataTypes.ReadNextString(packetData); // Dimension Type: Identifier
break;
case >= MC_1_16_2_Version:
dimensionTypeRespawn =
dataTypes.ReadNextNbt(packetData); // Dimension Type: NBT Tag Compound
break;
default:
dimensionTypeNameRespawn = dataTypes.ReadNextString(packetData);
break;
}
case >= MC_1_16_2_Version:
dimensionTypeRespawn =
dataTypes.ReadNextNbt(packetData); // Dimension Type: NBT Tag Compound
break;
default:
dimensionTypeNameRespawn = dataTypes.ReadNextString(packetData);
break;
}
currentDimension = 0;
}
@ -2986,71 +2986,71 @@ namespace MinecraftClient.Protocol.Handlers
handler.OnExplosion(explosionLocation, explosionStrength, explosionBlockCount);
break;
case PacketTypesIn.NamedSoundEffect:
{
string? soundName = dataTypes.ReadNextString(packetData);
int category = dataTypes.ReadNextVarInt(packetData);
double x = dataTypes.ReadNextInt(packetData) / 8.0D;
double y = dataTypes.ReadNextInt(packetData) / 8.0D;
double z = dataTypes.ReadNextInt(packetData) / 8.0D;
float volume = dataTypes.ReadNextFloat(packetData);
float pitch = protocolVersion < MC_1_10_Version
? dataTypes.ReadNextByte(packetData) / 63.0f
: dataTypes.ReadNextFloat(packetData);
handler.OnSoundEffect(soundName, new Location(x, y, z), category, volume, pitch, null);
break;
}
case PacketTypesIn.SoundEffect:
{
string? soundName;
if (protocolVersion >= MC_1_19_Version)
soundName = ReadSoundEventHolderName(packetData);
else
{
dataTypes.ReadNextVarInt(packetData); // Sound id
soundName = null;
}
string? soundName = dataTypes.ReadNextString(packetData);
int category = dataTypes.ReadNextVarInt(packetData);
double x = dataTypes.ReadNextInt(packetData) / 8.0D;
double y = dataTypes.ReadNextInt(packetData) / 8.0D;
double z = dataTypes.ReadNextInt(packetData) / 8.0D;
float volume = dataTypes.ReadNextFloat(packetData);
float pitch = protocolVersion < MC_1_10_Version
? dataTypes.ReadNextByte(packetData) / 63.0f
: dataTypes.ReadNextFloat(packetData);
if (protocolVersion < MC_1_19_Version && packetData.Count < 21)
handler.OnSoundEffect(soundName, new Location(x, y, z), category, volume, pitch, null);
break;
int category = dataTypes.ReadNextVarInt(packetData);
double x = dataTypes.ReadNextInt(packetData) / 8.0D;
double y = dataTypes.ReadNextInt(packetData) / 8.0D;
double z = dataTypes.ReadNextInt(packetData) / 8.0D;
float volume = dataTypes.ReadNextFloat(packetData);
float pitch = protocolVersion < MC_1_10_Version
? dataTypes.ReadNextByte(packetData) / 63.0f
: dataTypes.ReadNextFloat(packetData);
if (protocolVersion >= MC_1_19_Version)
dataTypes.ReadNextLong(packetData); // Seed
handler.OnSoundEffect(soundName, new Location(x, y, z), category, volume, pitch, null);
break;
}
case PacketTypesIn.EntitySoundEffect:
{
string? soundName;
if (protocolVersion >= MC_1_19_Version)
soundName = ReadSoundEventHolderName(packetData);
else
{
dataTypes.ReadNextVarInt(packetData); // Sound id
soundName = null;
}
case PacketTypesIn.SoundEffect:
{
string? soundName;
if (protocolVersion >= MC_1_19_Version)
soundName = ReadSoundEventHolderName(packetData);
else
{
dataTypes.ReadNextVarInt(packetData); // Sound id
soundName = null;
}
int category = dataTypes.ReadNextVarInt(packetData);
int entityId = dataTypes.ReadNextVarInt(packetData);
float volume = dataTypes.ReadNextFloat(packetData);
float pitch = dataTypes.ReadNextFloat(packetData);
if (protocolVersion < MC_1_19_Version && packetData.Count < 21)
break;
if (protocolVersion >= MC_1_19_Version)
dataTypes.ReadNextLong(packetData); // Seed
int category = dataTypes.ReadNextVarInt(packetData);
double x = dataTypes.ReadNextInt(packetData) / 8.0D;
double y = dataTypes.ReadNextInt(packetData) / 8.0D;
double z = dataTypes.ReadNextInt(packetData) / 8.0D;
float volume = dataTypes.ReadNextFloat(packetData);
float pitch = protocolVersion < MC_1_10_Version
? dataTypes.ReadNextByte(packetData) / 63.0f
: dataTypes.ReadNextFloat(packetData);
handler.OnSoundEffect(soundName, null, category, volume, pitch, entityId);
break;
}
if (protocolVersion >= MC_1_19_Version)
dataTypes.ReadNextLong(packetData); // Seed
handler.OnSoundEffect(soundName, new Location(x, y, z), category, volume, pitch, null);
break;
}
case PacketTypesIn.EntitySoundEffect:
{
string? soundName;
if (protocolVersion >= MC_1_19_Version)
soundName = ReadSoundEventHolderName(packetData);
else
{
dataTypes.ReadNextVarInt(packetData); // Sound id
soundName = null;
}
int category = dataTypes.ReadNextVarInt(packetData);
int entityId = dataTypes.ReadNextVarInt(packetData);
float volume = dataTypes.ReadNextFloat(packetData);
float pitch = dataTypes.ReadNextFloat(packetData);
if (protocolVersion >= MC_1_19_Version)
dataTypes.ReadNextLong(packetData); // Seed
handler.OnSoundEffect(soundName, null, category, volume, pitch, entityId);
break;
}
case PacketTypesIn.HeldItemChange:
case PacketTypesIn.SetHeldSlot:
handler.OnHeldItemChange(dataTypes.ReadNextByte(packetData)); // Slot

View file

@ -28,7 +28,7 @@ public class AttributeModifiersComponent(DataTypes dataTypes, ItemPalette itemPa
var data = new List<byte>();
data.AddRange(DataTypes.GetVarInt(NumberOfAttributes));
if(Attributes.Count != NumberOfAttributes)
if (Attributes.Count != NumberOfAttributes)
throw new ArgumentNullException($"Can not serialize a AttributeModifiersComponent when the Attributes count != NumberOfAttributes!");
foreach (var attribute in Attributes)

View file

@ -44,7 +44,7 @@ public class BannerPatternsComponent(DataTypes dataTypes, ItemPalette itemPalett
if (bannerLayer.PatternType == 0)
{
if(string.IsNullOrEmpty(bannerLayer.AssetId) || string.IsNullOrEmpty(bannerLayer.TranslationKey))
if (string.IsNullOrEmpty(bannerLayer.AssetId) || string.IsNullOrEmpty(bannerLayer.TranslationKey))
throw new Exception("Can't serialize BannerPatternsComponent because AssetId or TranslationKey is null/empty!");
data.AddRange(DataTypes.GetString(bannerLayer.AssetId));

View file

@ -12,7 +12,7 @@ public class BlockStateComponent(DataTypes dataTypes, ItemPalette itemPalette, S
public override void Parse(Queue<byte> data)
{
var count = DataTypes.ReadNextVarInt(data);
for(var i = 0; i < count; i++)
for (var i = 0; i < count; i++)
Properties.Add((DataTypes.ReadNextString(data), DataTypes.ReadNextString(data)));
}

View file

@ -29,7 +29,7 @@ public class CanBreakComponent(DataTypes dataTypes, ItemPalette itemPalette, Sub
var data = new List<byte>();
data.AddRange(DataTypes.GetVarInt(NumberOfPredicates));
if(NumberOfPredicates > 0 && BlockPredicates.Count == 0)
if (NumberOfPredicates > 0 && BlockPredicates.Count == 0)
throw new ArgumentNullException($"Can not serialize a CanBreakComponent when the BlockPredicates is empty but NumberOfPredicates is > 0!");
foreach (var blockPredicate in BlockPredicates)

View file

@ -29,7 +29,7 @@ public class CanPlaceOnComponent(DataTypes dataTypes, ItemPalette itemPalette, S
var data = new List<byte>();
data.AddRange(DataTypes.GetVarInt(NumberOfPredicates));
if(NumberOfPredicates > 0 && BlockPredicates.Count == 0)
if (NumberOfPredicates > 0 && BlockPredicates.Count == 0)
throw new ArgumentNullException($"Can not serialize a CanPlaceOnComponent when the BlockPredicates is empty but NumberOfPredicates is > 0!");
foreach (var blockPredicate in BlockPredicates)

View file

@ -23,7 +23,9 @@ public class EntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, S
}
public class BucketEntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: EntityDataComponent(dataTypes, itemPalette, subComponentRegistry) {}
: EntityDataComponent(dataTypes, itemPalette, subComponentRegistry)
{ }
public class BlockEntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: EntityDataComponent(dataTypes, itemPalette, subComponentRegistry) {}
: EntityDataComponent(dataTypes, itemPalette, subComponentRegistry)
{ }

View file

@ -24,7 +24,7 @@ public class FireworksComponent(DataTypes dataTypes, ItemPalette itemPalette, Su
if (NumberOfExplosions > 0)
{
for(var i = 0; i < NumberOfExplosions; i++)
for (var i = 0; i < NumberOfExplosions; i++)
Explosions.Add(
(FireworkExplosionSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.FireworkExplosion,
data));
@ -41,7 +41,7 @@ public class FireworksComponent(DataTypes dataTypes, ItemPalette itemPalette, Su
if (NumberOfExplosions != Explosions.Count)
throw new Exception("Can't serialize FireworksComponent because NumberOfExplosions and the lenght of Explosions differ!");
foreach(var explosion in Explosions)
foreach (var explosion in Explosions)
data.AddRange(explosion.Serialize().ToList());
}
return new Queue<byte>(data);

View file

@ -24,7 +24,7 @@ public class FoodComponentComponent(DataTypes dataTypes, ItemPalette itemPalette
SecondsToEat = DataTypes.ReadNextFloat(data);
var numberOfEffects = DataTypes.ReadNextVarInt(data);
for(var i = 0; i < numberOfEffects; i++)
for (var i = 0; i < numberOfEffects; i++)
Effects.Add((EffectSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.Effect, data));
}
@ -37,7 +37,7 @@ public class FoodComponentComponent(DataTypes dataTypes, ItemPalette itemPalette
data.AddRange(DataTypes.GetFloat(SecondsToEat));
data.AddRange(DataTypes.GetVarInt(Effects.Count));
foreach(var effect in Effects)
foreach (var effect in Effects)
data.AddRange(effect.Serialize());
return new Queue<byte>(data);

View file

@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class IntangibleProjectileComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class IntangibleProjectileComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public Dictionary<string, object>? Nbt { get; set; } = new();

View file

@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class MapPostProcessingComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class MapPostProcessingComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int Type { get; set; }

View file

@ -12,7 +12,7 @@ public class PotDecorationsComponent(DataTypes dataTypes, ItemPalette itemPalett
public override void Parse(Queue<byte> data)
{
var count = DataTypes.ReadNextVarInt(data);
for(var i = 0; i < count; i++)
for (var i = 0; i < count; i++)
Items.Add(DataTypes.ReadNextVarInt(data));
}

View file

@ -31,7 +31,7 @@ public class ToolComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComp
var data = new List<byte>();
data.AddRange(DataTypes.GetVarInt(NumberOfRules));
if(Rules.Count != NumberOfRules)
if (Rules.Count != NumberOfRules)
throw new ArgumentNullException($"Can not serialize a ToolComponent1206 when the Rules count != NumberOfRules!");
foreach (var rule in Rules)

View file

@ -80,7 +80,7 @@ public class TrimComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComp
data.AddRange(DataTypes.GetVarInt(NumberOfOverrides));
if (NumberOfOverrides > 0)
{
if(NumberOfOverrides != Overrides?.Count)
if (NumberOfOverrides != Overrides?.Count)
throw new NullReferenceException("Can't serialize the TrimComponent because value of NumberOfOverrides and the size of Overrides don't match!");
foreach (var (armorMaterialType, assetName) in Overrides)

View file

@ -20,7 +20,7 @@ public class WritableBlookContentComponent(DataTypes dataTypes, ItemPalette item
var hasFilteredContent = DataTypes.ReadNextBool(data);
var filteredContent = null as string;
if(hasFilteredContent)
if (hasFilteredContent)
filteredContent = DataTypes.ReadNextString(data);
Pages.Add(new BookPage(rawContent, hasFilteredContent, filteredContent));
@ -40,7 +40,7 @@ public class WritableBlookContentComponent(DataTypes dataTypes, ItemPalette item
if (page.HasFilteredContent)
{
if(page.FilteredContent is null)
if (page.FilteredContent is null)
throw new InvalidOperationException("Can not serialize WritableBlookContentComponent because page.HasFilteredContent = true, but FilteredContent is null!");
data.AddRange(DataTypes.GetString(page.FilteredContent));

View file

@ -59,7 +59,7 @@ public class WrittenBlookContentComponent(DataTypes dataTypes, ItemPalette itemP
if (HasFilteredTitle)
{
if(FilteredTitle is null)
if (FilteredTitle is null)
throw new InvalidOperationException("Can not serialize WrittenBookContentComponent because HasFilteredTitle is true but FilteredTitle is null!");
data.AddRange(DataTypes.GetString(FilteredTitle));

View file

@ -59,7 +59,7 @@ public class JukeBoxPlayableComponent(DataTypes dataTypes, ItemPalette itemPalet
if (DirectMode)
{
if(SongType is null)
if (SongType is null)
throw new ArgumentNullException($"Can not serialize JukeBoxPlayableComponent due to SongType being null!");
data.AddRange(DataTypes.GetVarInt((int)SongType));

View file

@ -26,4 +26,5 @@ public class TypedEntityDataComponent261(DataTypes dataTypes, ItemPalette itemPa
}
public class BlockEntityDataComponent261(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: TypedEntityDataComponent261(dataTypes, itemPalette, subComponentRegistry) {}
: TypedEntityDataComponent261(dataTypes, itemPalette, subComponentRegistry)
{ }

View file

@ -44,7 +44,7 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr
data.AddRange(DataTypes.GetBool(HasBlocks));
if (HasBlocks)
{
if(BlockSet is null)
if (BlockSet is null)
throw new ArgumentNullException($"Can not serialize a BlockPredicate when the BlockSet is empty but HasBlocks is true!");
data.AddRange(BlockSet.Serialize());
@ -54,7 +54,7 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr
data.AddRange(DataTypes.GetBool(HasProperities));
if (HasProperities)
{
if(Properties is null || Properties.Count == 0)
if (Properties is null || Properties.Count == 0)
throw new ArgumentNullException($"Can not serialize a BlockPredicate when the Properties is empty but HasProperties is true!");
data.AddRange(DataTypes.GetVarInt(Properties.Count));
@ -66,7 +66,7 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr
data.AddRange(DataTypes.GetBool(HasNbt));
if (HasNbt)
{
if(Nbt is null)
if (Nbt is null)
throw new ArgumentNullException($"Can not serialize a BlockPredicate when the Nbt is empty but HasNbt is true!");
data.AddRange(DataTypes.GetNbt(Nbt));

View file

@ -39,10 +39,10 @@ public class BlockSetSubcomponent(DataTypes dataTypes, SubComponentRegistry subC
if (Type == 0) return new Queue<byte>(data);
if(BlockIds is null || BlockIds.Count == 0)
if (BlockIds is null || BlockIds.Count == 0)
throw new ArgumentNullException($"Can not serialize an empty list of Block IDs in a Block Set when the type is not 0!");
for(var i = 0; i < Type - 1; i++)
for (var i = 0; i < Type - 1; i++)
data.AddRange(DataTypes.GetVarInt(BlockIds[i]));
return new Queue<byte>(data);

View file

@ -23,7 +23,7 @@ public class DetailsSubComponent(DataTypes dataTypes, SubComponentRegistry subCo
ShowIcon = DataTypes.ReadNextBool(data);
HasHiddenEffects = DataTypes.ReadNextBool(data);
if(HasHiddenEffects)
if (HasHiddenEffects)
Detail = (DetailsSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.Details, data);
}
@ -39,7 +39,7 @@ public class DetailsSubComponent(DataTypes dataTypes, SubComponentRegistry subCo
if (HasHiddenEffects)
{
if(Detail is null)
if (Detail is null)
throw new ArgumentNullException($"Can not serialize a DetailSubComponent1206 when the Detail is empty but HasHiddenEffects is true!");
data.AddRange(Detail.Serialize());

View file

@ -17,12 +17,12 @@ public class RuleSubComponent(DataTypes dataTypes, SubComponentRegistry subCompo
Blocks = (BlockSetSubcomponent)SubComponentRegistry.ParseSubComponent(SubComponents.BlockSet, data);
HasSpeed = DataTypes.ReadNextBool(data);
if(HasSpeed)
if (HasSpeed)
Speed = DataTypes.ReadNextFloat(data);
HasCorrectDropForBlocks = DataTypes.ReadNextBool(data);
if(HasCorrectDropForBlocks)
if (HasCorrectDropForBlocks)
CorrectDropForBlocks = DataTypes.ReadNextBool(data);
}
@ -31,11 +31,11 @@ public class RuleSubComponent(DataTypes dataTypes, SubComponentRegistry subCompo
var data = new List<byte>();
data.AddRange(Blocks.Serialize());
data.AddRange(DataTypes.GetBool(HasSpeed));
if(HasSpeed)
if (HasSpeed)
data.AddRange(DataTypes.GetFloat(Speed));
data.AddRange(DataTypes.GetBool(HasCorrectDropForBlocks));
if(HasCorrectDropForBlocks)
if (HasCorrectDropForBlocks)
data.AddRange(DataTypes.GetBool(CorrectDropForBlocks));
return new Queue<byte>(data);

View file

@ -37,7 +37,7 @@ public class SoundEventSubComponent(DataTypes dataTypes, SubComponentRegistry su
data.AddRange(DataTypes.GetString(SoundName));
data.AddRange(DataTypes.GetBool(HasFixedRange));
if(HasFixedRange)
if (HasFixedRange)
data.AddRange(DataTypes.GetFloat(FixedRange));
return new Queue<byte>(data);

View file

@ -10,7 +10,7 @@ public abstract class SubComponentRegistry(DataTypes dataTypes)
protected void RegisterSubComponent<T>(string name) where T : SubComponent
{
if(_subComponentParsers.TryGetValue(name, out _))
if (_subComponentParsers.TryGetValue(name, out _))
throw new Exception($"Sub component {name} already registered!");
_subComponentParsers.Add(name, typeof(T));
@ -23,10 +23,10 @@ public abstract class SubComponentRegistry(DataTypes dataTypes)
public SubComponent ParseSubComponent(string name, Queue<byte> data)
{
if(!_subComponentParsers.TryGetValue(name, out var subComponentParserType))
if (!_subComponentParsers.TryGetValue(name, out var subComponentParserType))
throw new Exception($"Sub component {name} not registered!");
var instance= Activator.CreateInstance(subComponentParserType, dataTypes, this) as SubComponent ??
var instance = Activator.CreateInstance(subComponentParserType, dataTypes, this) as SubComponent ??
throw new InvalidOperationException($"Could not create instance of a sub component parser type: {subComponentParserType.Name}");
var parseMethod = instance.GetType().GetMethod("Parse", BindingFlags.Instance | BindingFlags.NonPublic);

View file

@ -64,12 +64,15 @@ namespace MinecraftClient.Protocol.Message
Dictionary<int, MessageType> chatTypeDictionary = ChatId2Type ?? new();
// Check if the chat type registry is in the correct format
if (!registryCodec.ContainsKey("minecraft:chat_type")) {
if (!registryCodec.ContainsKey("minecraft:chat_type"))
{
// If not, then we force the registry to be in the correct format
if (registryCodec.ContainsKey("chat_type")) {
if (registryCodec.ContainsKey("chat_type"))
{
foreach (var key in registryCodec.Keys.ToArray()) {
foreach (var key in registryCodec.Keys.ToArray())
{
// Skip entries with a namespace already
if (key.Contains(':', StringComparison.OrdinalIgnoreCase)) continue;
@ -82,9 +85,9 @@ namespace MinecraftClient.Protocol.Message
var chatTypeListNbt = (object[])(((Dictionary<string, object>)registryCodec["minecraft:chat_type"])["value"]);
foreach (var (chatName, chatId) in from Dictionary<string, object> chatTypeNbt in chatTypeListNbt
let chatName = (string)chatTypeNbt["name"]
let chatId = (int)chatTypeNbt["id"]
select (chatName, chatId))
let chatName = (string)chatTypeNbt["name"]
let chatId = (int)chatTypeNbt["id"]
select (chatName, chatId))
{
chatTypeDictionary[chatId] = chatName switch
{

View file

@ -193,7 +193,7 @@ You need to enable Entity Handling to use this bot
<value>Capped between 1 to 4</value>
</data>
<data name="ChatBot.AutoAttack.Cooldown_Time" xml:space="preserve">
<value>How long to wait between each attack. Set "Custom = false" to let MCC calculate it.</value>
<value>Delay between attacks. Set "Custom = false" to let MCC calculate it. When Custom = true, set Min/Max for the cooldown range. If RandomMode = true, a random value between Min and Max is used for each attack.</value>
</data>
<data name="ChatBot.AutoAttack.Entites_List" xml:space="preserve">
<value>All entity types can be found here: https://mccteam.github.io/r/entity/#L15</value>

View file

@ -226,7 +226,8 @@ namespace MinecraftClient.Scripting
/// <param name="pitch">Sound pitch</param>
/// <param name="sourceEntity">Source entity for entity-sound packets when tracked</param>
public virtual void OnSoundEffect(string? soundName, Location? location, int category, float volume, float pitch,
Entity? sourceEntity) { }
Entity? sourceEntity)
{ }
/// <summary>
/// Called when an entity rotates
@ -405,7 +406,8 @@ namespace MinecraftClient.Scripting
/// <param name="players">Player/entity names. Present when method is 0, 3, or 4.</param>
public virtual void OnTeam(string teamName, byte method, string displayName, byte friendlyFlags,
string nameTagVisibility, string collisionRule, int color,
string prefix, string suffix, List<string> players) { }
string prefix, string suffix, List<string> players)
{ }
/// <summary>
/// Called when the client received the Tab Header and Footer

View file

@ -141,7 +141,8 @@ namespace MinecraftClient.Scripting.DynamicRun.Builder
assemblyrefs.Add(new("Microsoft.Win32.Primitives"));
assemblyrefs.Add(new("System.Collections.Concurrent"));
foreach (var refs in assemblyrefs) {
foreach (var refs in assemblyrefs)
{
Assembly? loadedAssembly;
try
{
@ -153,19 +154,22 @@ namespace MinecraftClient.Scripting.DynamicRun.Builder
continue;
}
if (string.IsNullOrEmpty(loadedAssembly.Location)) {
if (string.IsNullOrEmpty(loadedAssembly.Location))
{
// Check if we can access the file from the executable.
var reference = files.FirstOrDefault(x =>
Path.GetFileNameWithoutExtension(x.RelativePath) == refs.Name);
var refCount = files.Count(x => Path.GetFileNameWithoutExtension(x.RelativePath) == refs.Name);
if (refCount > 1) {
if (refCount > 1)
{
// Safety net for the case where the assembly is referenced multiple times.
// Should not happen normally, but we can make exceptions when it does happen.
throw new InvalidOperationException(
"[Script Error] Too many references to the same assembly. Assembly name: " + refs.Name);
}
if (reference is null) {
if (reference is null)
{
// Facade assemblies may not be in the bundle - skip them silently
continue;
}

View file

@ -760,7 +760,7 @@ namespace MinecraftClient
public string AuthUser = "";
public enum LoginType { mojang, microsoft,yggdrasil };
public enum LoginType { mojang, microsoft, yggdrasil };
public enum LoginMethod { mcc, browser };
}

View file

@ -91,7 +91,7 @@ namespace MinecraftClient.Tui
row.Inlines.Add(Value(versionClean, McColors.Aqua));
row.Inlines.Add(new Run(" (") { Foreground = McColors.Gray });
row.Inlines.Add(new Run(string.Format(Translations.mcc_server_info_label_protocol, info.ProtocolVersion))
{ Foreground = McColors.Gray });
{ Foreground = McColors.Gray });
row.Inlines.Add(new Run(")") { Foreground = McColors.Gray });
panel.Children.Add(row);
}
@ -107,7 +107,7 @@ namespace MinecraftClient.Tui
row.Inlines.Add(Value(resolvedMcVer, McColors.Green));
row.Inlines.Add(new Run(" (") { Foreground = McColors.Gray });
row.Inlines.Add(new Run(string.Format(Translations.mcc_server_info_label_protocol, info.ResolvedProtocol))
{ Foreground = McColors.Gray });
{ Foreground = McColors.Gray });
row.Inlines.Add(new Run(")") { Foreground = McColors.Gray });
panel.Children.Add(row);
}
@ -126,7 +126,7 @@ namespace MinecraftClient.Tui
var row = new TextBlock();
row.Inlines!.Add(Label(Translations.mcc_server_info_label_ping));
row.Inlines.Add(new Run(string.Format(Translations.mcc_server_info_label_ping_ms, info.PingMs))
{ Foreground = pingColor });
{ Foreground = pingColor });
panel.Children.Add(row);
}

View file

@ -277,7 +277,8 @@ namespace MinecraftClient.Tui
{
Thread.Sleep(1000);
Environment.Exit(0);
}) { Name = "TUI-Exit-Guard", IsBackground = true }.Start();
})
{ Name = "TUI-Exit-Guard", IsBackground = true }.Start();
}
private volatile bool _shutdownRequested;

View file

@ -354,19 +354,19 @@ redirectFrom:
- **Description:**
How long to wait between each attack in seconds.
Controls the delay between attacks. By default, MCC calculates this based on server TPS. Set `Custom` to `true` to specify your own values:
To enable it, set `Custom` (boolean) to `true` and change `value` (double) to your preferred value (eg. `1.5`).
- `Min` — minimum cooldown in seconds
- `Max` — maximum cooldown in seconds
- `RandomMode` — if enabled, picks a random cooldown between `Min` and `Max` for each attack
By default, this is disabled and MCC calculates it based on the server TPS.
- **Format:** `Cooldown_Time = { Custom = <is enabled (true|false)>, value = <seconds (double)> }`
- **Format:** `Cooldown_Time = { Custom = <true|false>, RandomMode = <true|false>, Min = <seconds>, Max = <seconds> }`
- **Type:** `inline table`
- **Example:** `Cooldown_Time = { Custom = true, value = 1.5 }`
- **Example:** `Cooldown_Time = { Custom = true, RandomMode = true, Min = 1.0, Max = 2.0 }`
- **Default:** `{ Custom = false, value = 1.0 }`
- **Default:** `{ Custom = false, RandomMode = false, Min = 1.5, Max = 2.5 }`
#### `Interaction`