diff --git a/src/main/java/baritone/bot/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/bot/pathing/calc/AStarPathFinder.java index 664934f7..c7e1d4ef 100644 --- a/src/main/java/baritone/bot/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/bot/pathing/calc/AStarPathFinder.java @@ -47,6 +47,7 @@ import baritone.bot.pathing.movement.movements.MovementDiagonal; import baritone.bot.pathing.movement.movements.MovementDownward; import baritone.bot.pathing.movement.movements.MovementTraverse; import baritone.bot.pathing.path.IPath; +import baritone.bot.utils.Helper; import net.minecraft.client.Minecraft; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; @@ -60,7 +61,7 @@ import java.util.Random; * * @author leijurv */ -public class AStarPathFinder extends AbstractNodeCostSearch { +public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { public static boolean slowPath = false; @@ -186,7 +187,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch { } } System.out.println("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + bestDist + " blocks =("); - System.out.println("No path found =("); + displayChatMessageRaw("No path found =("); currentlyRunning = null; return Optional.empty(); } diff --git a/src/main/java/baritone/bot/pathing/movement/CalculationContext.java b/src/main/java/baritone/bot/pathing/movement/CalculationContext.java index ed221888..52fa03b2 100644 --- a/src/main/java/baritone/bot/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/bot/pathing/movement/CalculationContext.java @@ -33,6 +33,7 @@ public class CalculationContext implements Helper { private final ToolSet toolSet; private final boolean hasWaterBucket; + private final boolean hasThrowaway; public CalculationContext() { this(new ToolSet()); @@ -41,6 +42,7 @@ public class CalculationContext implements Helper { public CalculationContext(ToolSet toolSet) { this.toolSet = toolSet; this.hasWaterBucket = InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) && !world().provider.isNether(); + this.hasThrowaway = MovementHelper.throwaway(false); } public ToolSet getToolSet() { @@ -50,4 +52,8 @@ public class CalculationContext implements Helper { public boolean hasWaterBucket() { return hasWaterBucket; } + + public boolean hasThrowaway() { + return hasThrowaway; + } } diff --git a/src/main/java/baritone/bot/pathing/movement/MovementHelper.java b/src/main/java/baritone/bot/pathing/movement/MovementHelper.java index 2349f856..9547e044 100644 --- a/src/main/java/baritone/bot/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/bot/pathing/movement/MovementHelper.java @@ -49,7 +49,8 @@ public interface MovementHelper extends ActionCosts, Helper { List ACCEPTABLE_THROWAWAY_ITEMS = Arrays.asList( Item.getItemFromBlock(Blocks.DIRT), - Item.getItemFromBlock(Blocks.COBBLESTONE) + Item.getItemFromBlock(Blocks.COBBLESTONE), + Item.getItemFromBlock(Blocks.NETHERRACK) ); static boolean avoidBreaking(BlockPos pos) { @@ -94,7 +95,8 @@ public interface MovementHelper extends ActionCosts, Helper { || block instanceof BlockCactus || block instanceof BlockFire || block instanceof BlockEndPortal - || block instanceof BlockWeb; + || block instanceof BlockWeb + || block instanceof BlockMagma; } /** @@ -116,6 +118,9 @@ public interface MovementHelper extends ActionCosts, Helper { if (BlockStateInterface.isWater(block)) { return BlockStateInterface.isWater(pos.up()); // You can only walk on water if there is water above it } + if (block.equals(Blocks.MAGMA)) { + return false; + } return state.isBlockNormalCube() && !BlockStateInterface.isLava(block); } @@ -188,13 +193,15 @@ public interface MovementHelper extends ActionCosts, Helper { mc.player.inventory.currentItem = ts.getBestSlot(b); } - static boolean switchtothrowaway() { + static boolean throwaway(boolean select) { EntityPlayerSP p = Minecraft.getMinecraft().player; NonNullList inv = p.inventory.mainInventory; for (byte i = 0; i < 9; i++) { ItemStack item = inv.get(i); if (ACCEPTABLE_THROWAWAY_ITEMS.contains(item.getItem())) { - p.inventory.currentItem = i; + if (select) { + p.inventory.currentItem = i; + } return true; } } @@ -245,16 +252,4 @@ public interface MovementHelper extends ActionCosts, Helper { } return null; } - - static boolean hasthrowaway() { - EntityPlayerSP p = Minecraft.getMinecraft().player; - NonNullList inv = p.inventory.mainInventory; - for (byte i = 0; i < 9; i++) { - ItemStack item = inv.get(i); - if (ACCEPTABLE_THROWAWAY_ITEMS.contains(item.getItem())) { - return true; - } - } - return false; - } } diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java index 398c8a57..957f9d89 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java @@ -85,6 +85,9 @@ public class MovementTraverse extends Movement { } IBlockState pp0 = BlockStateInterface.get(positionsToPlace[0]); if (pp0.getBlock().equals(Blocks.AIR) || (!BlockStateInterface.isWater(pp0.getBlock()) && pp0.getBlock().isReplaceable(Minecraft.getMinecraft().world, positionsToPlace[0]))) { + if (!context.hasThrowaway()) { + return COST_INF; + } for (BlockPos against1 : against) { if (BlockStateInterface.get(against1).isBlockNormalCube()) { return WC + PLACE_ONE_BLOCK_COST + getTotalHardnessOfBlocksToBreak(context.getToolSet()); @@ -137,7 +140,7 @@ public class MovementTraverse extends Movement { wasTheBridgeBlockAlwaysThere = false; for (BlockPos against1 : against) { if (BlockStateInterface.get(against1).isBlockNormalCube()) { - if (!MovementHelper.switchtothrowaway()) { // get ready to place a throwaway block + if (!MovementHelper.throwaway(true)) { // get ready to place a throwaway block displayChatMessageRaw("bb pls get me some blocks. dirt or cobble"); return state; } @@ -163,7 +166,7 @@ public class MovementTraverse extends Movement { if (whereAmI.equals(dest)) { // if we are in the block that we are trying to get to, we are sneaking over air and we need to place a block beneath us against the one we just walked off of // Out.log(from + " " + to + " " + faceX + "," + faceY + "," + faceZ + " " + whereAmI); - if (!MovementHelper.switchtothrowaway()) {// get ready to place a throwaway block + if (!MovementHelper.throwaway(true)) {// get ready to place a throwaway block displayChatMessageRaw("bb pls get me some blocks. dirt or cobble"); return state; }