mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Switched to a faster implementation of FindBlock proposed by Daenges, tested on Farmer Bot.
Tweaked the amount of bone mealing in the Farmer Bot.
This commit is contained in:
parent
ee57d101c0
commit
730990cee5
2 changed files with 11 additions and 21 deletions
|
|
@ -420,7 +420,7 @@ namespace MinecraftClient.ChatBots
|
|||
LogDebug("Trying to bonemeal: " + location2);
|
||||
|
||||
// Send like 4 bonemeal attempts, it should do the job with 2-3, but sometimes doesn't do
|
||||
for (int boneMealTimes = 0; boneMealTimes < 4; boneMealTimes++)
|
||||
for (int boneMealTimes = 0; boneMealTimes < (cropType == CropType.Beetroot ? 6 : 5); boneMealTimes++)
|
||||
{
|
||||
// TODO: Do a check if the carrot/potato is on the first growth stage
|
||||
// if so, use: new Location(location.X, (double)(location.Y - 1) + (double)0.93750, location.Z)
|
||||
|
|
|
|||
|
|
@ -169,26 +169,16 @@ namespace MinecraftClient.Mapping
|
|||
/// <returns>Block matching the specified block type</returns>
|
||||
public List<Location> FindBlock(Location from, Material block, int radiusx, int radiusy, int radiusz)
|
||||
{
|
||||
Location minPoint = new(from.X - radiusx, from.Y - radiusy, from.Z - radiusz);
|
||||
Location maxPoint = new(from.X + radiusx, from.Y + radiusy, from.Z + radiusz);
|
||||
List<Location> list = new() { };
|
||||
for (double x = minPoint.X; x <= maxPoint.X; x++)
|
||||
{
|
||||
for (double y = minPoint.Y; y <= maxPoint.Y; y++)
|
||||
{
|
||||
for (double z = minPoint.Z; z <= maxPoint.Z; z++)
|
||||
{
|
||||
Location doneloc = new(x, y, z);
|
||||
Block doneblock = GetBlock(doneloc);
|
||||
Material blockType = doneblock.Type;
|
||||
if (blockType == block)
|
||||
{
|
||||
list.Add(doneloc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
Location minPoint = new Location(from.X - radiusx, from.Y - radiusy, from.Z - radiusz);
|
||||
Location maxPoint = new Location(from.X + radiusx, from.Y + radiusy, from.Z + radiusz);
|
||||
|
||||
List<int> xRange = Enumerable.Range(Convert.ToInt32(Math.Floor(minPoint.X)), Convert.ToInt32(Math.Floor(maxPoint.X - minPoint.X)) + 1).ToList();
|
||||
List<int> yRange = Enumerable.Range(Convert.ToInt32(Math.Floor(minPoint.Y)), Convert.ToInt32(Math.Floor(maxPoint.Y - minPoint.Y)) + 1).ToList();
|
||||
List<int> zRange = Enumerable.Range(Convert.ToInt32(Math.Floor(minPoint.Z)), Convert.ToInt32(Math.Floor(maxPoint.Z - minPoint.Z)) + 1).ToList();
|
||||
|
||||
List<Location> listOfBlocks = xRange.SelectMany(x => yRange.SelectMany(y => zRange.Select(z => new Location(x, y, z)))).ToList();
|
||||
|
||||
return listOfBlocks.Where(loc => GetBlock(loc).Type == block).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue