From 1beff941d230102362dcd3484f6d0e29eb637b45 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 6 Aug 2018 19:43:20 -0500 Subject: [PATCH] Add fallback item constant to ToolSet --- src/main/java/baritone/bot/utils/ToolSet.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/bot/utils/ToolSet.java b/src/main/java/baritone/bot/utils/ToolSet.java index 83449af6..c1643f85 100644 --- a/src/main/java/baritone/bot/utils/ToolSet.java +++ b/src/main/java/baritone/bot/utils/ToolSet.java @@ -4,6 +4,7 @@ import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemAir; import net.minecraft.item.ItemStack; @@ -23,6 +24,8 @@ import java.util.Map; */ public class ToolSet { + private static final Item FALLBACK_ITEM = Items.APPLE; + /** * A list of tools on the hotbar that should be considered. * Note that if there are no tools on the hotbar this list will still have one (null) entry. @@ -83,7 +86,7 @@ public class ToolSet { for (byte i = 0; i < tools.size(); i++) { Item item = tools.get(i); if (item == null) { - item = Item.getByNameOrId("minecraft:apple"); + item = FALLBACK_ITEM; } float v = item.getDestroySpeed(new ItemStack(item), b); if (v < value || value == -1) { @@ -118,7 +121,7 @@ public class ToolSet { public double getStrVsBlock(IBlockState b, BlockPos pos) { Item item = this.getBestTool(b); if (item == null) { - item = Item.getByNameOrId("minecraft:apple"); + item = FALLBACK_ITEM; } float f = b.getBlockHardness(Minecraft.getMinecraft().world, pos); return f < 0.0F ? 0.0F : (!canHarvest(b, item) ? item.getDestroySpeed(new ItemStack(item), b) / f / 100.0F : item.getDestroySpeed(new ItemStack(item), b) / f / 30.0F);