chore: polish recipe book support

Agent-Logs-Url: https://github.com/MCCTeam/Minecraft-Console-Client/sessions/00c8527f-5755-43c1-8916-8d571d28860b

Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-29 18:07:09 +00:00
parent d5308ba8c6
commit 893be203e5
5 changed files with 71 additions and 10 deletions

View file

@ -1411,7 +1411,7 @@ namespace MinecraftClient
if (inventories.Count == 0)
return null;
Container activeInventory = inventories.Values.Last();
Container activeInventory = inventories.MaxBy(static pair => pair.Key).Value;
return SupportsRecipeBook(activeInventory.Type) ? activeInventory : null;
}
@ -2728,7 +2728,11 @@ namespace MinecraftClient
if (activeInventory is null)
return false;
return handler.SendPlaceRecipe(activeInventory.ID, NormalizeRecipeId(recipeId), makeAll);
string normalizedRecipeId = NormalizeRecipeId(recipeId);
if (normalizedRecipeId.Length == 0)
return false;
return handler.SendPlaceRecipe(activeInventory.ID, normalizedRecipeId, makeAll);
}
#endregion
@ -4172,6 +4176,9 @@ namespace MinecraftClient
private static string NormalizeRecipeId(string recipeId)
{
string trimmedRecipeId = recipeId.Trim();
if (trimmedRecipeId.Length == 0)
return string.Empty;
return trimmedRecipeId.Contains(':', StringComparison.Ordinal)
? trimmedRecipeId
: "minecraft:" + trimmedRecipeId;