diff --git a/Minebot/src/net/famzangl/minecraft/minebot/ai/task/ThrowFishingRodTask.java b/Minebot/src/net/famzangl/minecraft/minebot/ai/task/ThrowFishingRodTask.java index c83636d1..3a11810b 100644 --- a/Minebot/src/net/famzangl/minecraft/minebot/ai/task/ThrowFishingRodTask.java +++ b/Minebot/src/net/famzangl/minecraft/minebot/ai/task/ThrowFishingRodTask.java @@ -18,6 +18,8 @@ import net.famzangl.minecraft.minebot.ai.AIHelper; import net.famzangl.minecraft.minebot.ai.ClassItemFilter; +import net.famzangl.minecraft.minebot.ai.tools.ToolRater; +import net.famzangl.minecraft.minebot.settings.MinebotSettings; import net.minecraft.item.ItemFishingRod; public class ThrowFishingRodTask extends AITask { @@ -31,7 +33,8 @@ public boolean isFinished(AIHelper h) { @Override public void runTick(AIHelper h, TaskOperations o) { - if (h.selectCurrentItem(new ClassItemFilter(ItemFishingRod.class))) { + ToolRater settings = MinebotSettings.getSettings().getFishingRater(); + if (h.selectToolFor(null, new ToolRater(ToolRater.ToolType.FISHING_ROD)) > 0) { time--; if (time == 2) { h.overrideUseItem(); @@ -41,7 +44,7 @@ public void runTick(AIHelper h, TaskOperations o) { @Override public int getGameTickTimeout(AIHelper helper) { - return 950; + return 40; } } diff --git a/Minebot/src/net/famzangl/minecraft/minebot/ai/tools/ToolRater.java b/Minebot/src/net/famzangl/minecraft/minebot/ai/tools/ToolRater.java index 79213124..20034683 100644 --- a/Minebot/src/net/famzangl/minecraft/minebot/ai/tools/ToolRater.java +++ b/Minebot/src/net/famzangl/minecraft/minebot/ai/tools/ToolRater.java @@ -24,6 +24,7 @@ import net.famzangl.minecraft.minebot.ai.ItemFilter.NotItemFilter; import net.famzangl.minecraft.minebot.ai.path.world.BlockFloatMap; import net.famzangl.minecraft.minebot.ai.path.world.BlockSet; +import net.famzangl.minecraft.minebot.ai.tools.ToolRater.ToolType; import net.famzangl.minecraft.minebot.ai.tools.rate.AndRater; import net.famzangl.minecraft.minebot.ai.tools.rate.EnchantmentRater; import net.famzangl.minecraft.minebot.ai.tools.rate.FilterRater; @@ -181,6 +182,16 @@ public String getName() { } } + public ToolRater() { + } + + public ToolRater(ToolType requiredToolType) { + BlockFloatMap allBad = new BlockFloatMap(); + allBad.setDefault(0); + raters.add(new NotRater(allBad, new FilterRater(requiredToolType, + requiredToolType.getName(), allBad))); + } + private static Rater getCompoundRater(String name, BlockFloatMap values) { // todo: advanced boolean parsing, parentheses, ... String[] orPartStrings = name.split("\\s*\\|\\s*"); diff --git a/Minebot/src/net/famzangl/minecraft/minebot/ai/tools/rate/Rater.java b/Minebot/src/net/famzangl/minecraft/minebot/ai/tools/rate/Rater.java index 1b97b5c8..3a72ce2f 100644 --- a/Minebot/src/net/famzangl/minecraft/minebot/ai/tools/rate/Rater.java +++ b/Minebot/src/net/famzangl/minecraft/minebot/ai/tools/rate/Rater.java @@ -25,7 +25,7 @@ protected double getPow(ItemStack item, int forBlockAndMeta) { public float rate(ItemStack item, int forBlockAndMeta) { if (isAppleciable(item, forBlockAndMeta)) { - return values.get(forBlockAndMeta); + return forBlockAndMeta < 0 ? values.getDefaultValue() : values.get(forBlockAndMeta); } else { return 1; } diff --git a/Minebot/src/net/famzangl/minecraft/minebot/settings/MinebotSettingsRoot.java b/Minebot/src/net/famzangl/minecraft/minebot/settings/MinebotSettingsRoot.java index 72e8f15d..07aa1d8b 100644 --- a/Minebot/src/net/famzangl/minecraft/minebot/settings/MinebotSettingsRoot.java +++ b/Minebot/src/net/famzangl/minecraft/minebot/settings/MinebotSettingsRoot.java @@ -1,6 +1,7 @@ package net.famzangl.minecraft.minebot.settings; import net.famzangl.minecraft.minebot.ai.tools.ToolRater; +import net.famzangl.minecraft.minebot.ai.tools.ToolRater.ToolType; /** * This is the root object for our json settings file. @@ -17,6 +18,8 @@ public class MinebotSettingsRoot { private MiningSettings mining = new MiningSettings(); private ToolRater toolRater = ToolRater.createDefaultRater(); + + private ToolRater fishingRater = new ToolRater(ToolType.FISHING_ROD); public PathfindingSettings getPathfinding() { return pathfinding; @@ -29,4 +32,8 @@ public MiningSettings getMining() { public ToolRater getToolRater() { return toolRater ; } + + public ToolRater getFishingRater() { + return fishingRater; + } }