From 9549743c6d82a44b2e3546c4776f0c92297bb8ca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 17 Apr 2026 07:55:25 +0000 Subject: [PATCH 1/2] Implement legacy Farmer support updates Agent-Logs-Url: https://github.com/MCCTeam/Minecraft-Console-Client/sessions/395596c2-cc40-4295-8100-a8408243f45b Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com> --- MinecraftClient/ChatBots/Farmer.cs | 22 +++++++++++++++++-- .../Mapping/BlockPalettes/Palette112.cs | 1 + .../Protocol/Handlers/Protocol18.cs | 1 + .../Resources/Translations/Translations.resx | 2 +- docs/guide/chat-bots.md | 2 +- docs/guide/configuration.md | 2 +- docs/guide/usage.md | 6 ++--- 7 files changed, 28 insertions(+), 8 deletions(-) diff --git a/MinecraftClient/ChatBots/Farmer.cs b/MinecraftClient/ChatBots/Farmer.cs index 7c15791c23..8a21ae5cb7 100644 --- a/MinecraftClient/ChatBots/Farmer.cs +++ b/MinecraftClient/ChatBots/Farmer.cs @@ -73,7 +73,7 @@ public enum CropType public override void Initialize() { - if (GetProtocolVersion() < Protocol18Handler.MC_1_13_Version) + if (GetProtocolVersion() < Protocol18Handler.MC_1_8_Version) { LogToConsole(Translations.bot_farmer_not_implemented); return; @@ -626,6 +626,9 @@ private bool IsCropFullyGrown(Block block, CropType cropType) { var protocolVersion = GetProtocolVersion(); + if (protocolVersion < Protocol18Handler.MC_1_13_Version) + return IsLegacyCropFullyGrown(block, cropType); + switch (cropType) { case CropType.Beetroot: @@ -781,6 +784,21 @@ private bool IsCropFullyGrown(Block block, CropType cropType) return false; } + private static bool IsLegacyCropFullyGrown(Block block, CropType cropType) + { + return cropType switch + { + CropType.Beetroot => block.BlockId == 207 && block.BlockMeta >= 3, + CropType.Carrot => block.BlockId == 141 && block.BlockMeta >= 7, + CropType.Melon => block.BlockId == 105 && block.BlockMeta >= 7, + CropType.NetherWart => block.BlockId == 115 && block.BlockMeta >= 3, + CropType.Pumpkin => block.BlockId == 104 && block.BlockMeta >= 7, + CropType.Potato => block.BlockId == 142 && block.BlockMeta >= 7, + CropType.Wheat => block.BlockId == 59 && block.BlockMeta >= 7, + _ => false + }; + } + // Yoinked from ReinforceZwei's AutoTree and adapted to search the whole of inventory in additon to the hotbar private bool SwitchToItem(ItemType itemType) { @@ -854,4 +872,4 @@ private void LogDebug(object text) else LogDebugToConsole(text); } } -} \ No newline at end of file +} diff --git a/MinecraftClient/Mapping/BlockPalettes/Palette112.cs b/MinecraftClient/Mapping/BlockPalettes/Palette112.cs index cdfd4a5386..0a9aa9473d 100644 --- a/MinecraftClient/Mapping/BlockPalettes/Palette112.cs +++ b/MinecraftClient/Mapping/BlockPalettes/Palette112.cs @@ -183,6 +183,7 @@ public class Palette112 : BlockPalette { 173, Material.CoalBlock }, { 174, Material.PackedIce }, { 175, Material.TallGrass }, // DoublePlant + { 207, Material.Beetroots }, // BeetrootBlock }; protected override Dictionary GetDict() diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 50e7b91ae4..5c69f037dd 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -5506,6 +5506,7 @@ public bool SendPlayerBlockPlacement(int hand, Location location, Direction face packet.Add(0); // cursorY packet.Add(0); // cursorZ + SendPacket(PacketTypesOut.PlayerBlockPlacement, packet); return true; case < MC_1_14_Version: packet.AddRange(dataTypes.GetLocation(location)); diff --git a/MinecraftClient/Resources/Translations/Translations.resx b/MinecraftClient/Resources/Translations/Translations.resx index 2e9da34af4..cc0333b9ce 100644 --- a/MinecraftClient/Resources/Translations/Translations.resx +++ b/MinecraftClient/Resources/Translations/Translations.resx @@ -521,7 +521,7 @@ cooldown: {6} The Farmer bot needs Terrain Handling in order to work, please enable it! - Not implemented bellow 1.13! + Not implemented below 1.8! Radius diff --git a/docs/guide/chat-bots.md b/docs/guide/chat-bots.md index 8a5a39eb44..d0383717fb 100644 --- a/docs/guide/chat-bots.md +++ b/docs/guide/chat-bots.md @@ -1957,7 +1957,7 @@ redirectFrom:

Warning

-**This a newly added bot, it is not perfect and was only tested in 1.19.2, there are some minor issues with it and you should treat it as an experimental bot.** +**This bot is still experimental, has some known issues, and should be treated with extra caution on legacy versions.**
diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md index 715108d33a..a21c40e3bd 100644 --- a/docs/guide/configuration.md +++ b/docs/guide/configuration.md @@ -555,7 +555,7 @@ Coordinate = { x = 145, y = 64, z = 2045 }

Warning

- **This feature is currently not supported in `1.4.6 - 1.9`. But we are working on getting it supported in 1.8 and 1.9.** + **This feature is currently supported on `1.8+` and is unavailable on `1.4.6 - 1.7.10`.**
diff --git a/docs/guide/usage.md b/docs/guide/usage.md index d6dcfaebb7..cff5824c60 100644 --- a/docs/guide/usage.md +++ b/docs/guide/usage.md @@ -1016,7 +1016,7 @@ In scripts and remote control, no slash is needed to perform the command, eg. `q

Warning

- **The [Inventory Handling](configuration.md#inventoryhandling) is currently not supported in `1.4.6 - 1.9`** + **The [Inventory Handling](configuration.md#inventoryhandling) is currently supported on `1.8+` and is unavailable on `1.4.6 - 1.7.10`.**
@@ -1063,7 +1063,7 @@ In scripts and remote control, no slash is needed to perform the command, eg. `q

Warning

- **The [Inventory Handling](configuration.md#inventoryhandling) is currently not supported in `1.4.6 - 1.9`.** + **The [Inventory Handling](configuration.md#inventoryhandling) is currently supported on `1.8+` and is unavailable on `1.4.6 - 1.7.10`.**
@@ -1298,7 +1298,7 @@ In scripts and remote control, no slash is needed to perform the command, eg. `q

Warning

- **The [Inventory Handling](configuration.md#inventoryhandling) is currently not supported in `1.4.6 - 1.9`.** + **The [Inventory Handling](configuration.md#inventoryhandling) is currently supported on `1.8+` and is unavailable on `1.4.6 - 1.7.10`.**
From 5279609561880d5424b3a383bbd22740941a36d0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 17 Apr 2026 08:00:41 +0000 Subject: [PATCH 2/2] Polish legacy Farmer validation logic Agent-Logs-Url: https://github.com/MCCTeam/Minecraft-Console-Client/sessions/395596c2-cc40-4295-8100-a8408243f45b Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com> --- MinecraftClient/ChatBots/Farmer.cs | 35 +++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/MinecraftClient/ChatBots/Farmer.cs b/MinecraftClient/ChatBots/Farmer.cs index 8a21ae5cb7..5d50ac5558 100644 --- a/MinecraftClient/ChatBots/Farmer.cs +++ b/MinecraftClient/ChatBots/Farmer.cs @@ -616,18 +616,18 @@ private List findCrops(int radius, CropType cropType, bool fullyGrown) if (fullyGrown && material is Material.Melon or Material.Pumpkin) return true; - var isFullyGrown = IsCropFullyGrown(GetWorld().GetBlock(location), cropType); + var isFullyGrown = IsCropFullyGrown(GetWorld().GetBlock(location), cropType, location); return fullyGrown ? isFullyGrown : !isFullyGrown; }) .ToList(); } - private bool IsCropFullyGrown(Block block, CropType cropType) + private bool IsCropFullyGrown(Block block, CropType cropType, Location? location = null) { var protocolVersion = GetProtocolVersion(); if (protocolVersion < Protocol18Handler.MC_1_13_Version) - return IsLegacyCropFullyGrown(block, cropType); + return IsLegacyCropFullyGrown(block, cropType, location); switch (cropType) { @@ -784,21 +784,44 @@ private bool IsCropFullyGrown(Block block, CropType cropType) return false; } - private static bool IsLegacyCropFullyGrown(Block block, CropType cropType) + private bool IsLegacyCropFullyGrown(Block block, CropType cropType, Location? location) { return cropType switch { CropType.Beetroot => block.BlockId == 207 && block.BlockMeta >= 3, CropType.Carrot => block.BlockId == 141 && block.BlockMeta >= 7, - CropType.Melon => block.BlockId == 105 && block.BlockMeta >= 7, + CropType.Melon => block.BlockId == 105 + && (block.BlockMeta >= 7 || HasAdjacentBlock(location, Material.Melon)), CropType.NetherWart => block.BlockId == 115 && block.BlockMeta >= 3, - CropType.Pumpkin => block.BlockId == 104 && block.BlockMeta >= 7, + CropType.Pumpkin => block.BlockId == 104 + && (block.BlockMeta >= 7 || HasAdjacentBlock(location, Material.Pumpkin)), CropType.Potato => block.BlockId == 142 && block.BlockMeta >= 7, CropType.Wheat => block.BlockId == 59 && block.BlockMeta >= 7, _ => false }; } + private bool HasAdjacentBlock(Location? location, Material material) + { + if (location is not Location stemLocation) + return false; + + var world = GetWorld(); + int x = (int)Math.Floor(stemLocation.X); + int y = (int)Math.Floor(stemLocation.Y); + int z = (int)Math.Floor(stemLocation.Z); + + Location[] adjacentLocations = + [ + new(x + 1, y, z), + new(x - 1, y, z), + new(x, y, z + 1), + new(x, y, z - 1) + ]; + + return adjacentLocations.Any(adjacentLocation => world.GetBlock(adjacentLocation).Type == material); + } + // Yoinked from ReinforceZwei's AutoTree and adapted to search the whole of inventory in additon to the hotbar private bool SwitchToItem(ItemType itemType) {