From ff929b92603026a139898cba7ed81c0ce6651c7e Mon Sep 17 00:00:00 2001 From: Brady Date: Fri, 10 Aug 2018 22:24:26 -0500 Subject: [PATCH] Add hotbar check for presence of water bucket --- .../baritone/bot/pathing/movement/CalculationContext.java | 5 ++++- .../bot/pathing/movement/movements/MovementFall.java | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/bot/pathing/movement/CalculationContext.java b/src/main/java/baritone/bot/pathing/movement/CalculationContext.java index 3f5e6783..2e63e112 100644 --- a/src/main/java/baritone/bot/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/bot/pathing/movement/CalculationContext.java @@ -19,6 +19,7 @@ package baritone.bot.pathing.movement; import baritone.bot.utils.Helper; import baritone.bot.utils.ToolSet; +import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -28,6 +29,8 @@ import net.minecraft.item.ItemStack; */ public class CalculationContext implements Helper { + private static final ItemStack STACK_BUCKET_WATER = new ItemStack(Items.WATER_BUCKET); + private final ToolSet toolSet; private final boolean hasWaterBucket; @@ -37,7 +40,7 @@ public class CalculationContext implements Helper { public CalculationContext(ToolSet toolSet) { this.toolSet = toolSet; - this.hasWaterBucket = player().inventory.hasItemStack(new ItemStack(Items.WATER_BUCKET)); // TODO check if water bucket is on hotbar or main inventory + this.hasWaterBucket = InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)); } public ToolSet getToolSet() { diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementFall.java index daf37c3f..8881b371 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementFall.java @@ -35,7 +35,7 @@ import java.util.Optional; public class MovementFall extends Movement { private static final ItemStack STACK_BUCKET_WATER = new ItemStack(Items.WATER_BUCKET); - private static final ItemStack STACK_BUCKET_AIR = new ItemStack(Items.BUCKET); + private static final ItemStack STACK_BUCKET_EMPTY = new ItemStack(Items.BUCKET); public MovementFall(BlockPos src, BlockPos dest) { super(src, dest, MovementFall.buildPositionsToBreak(src, dest), new BlockPos[]{dest.down()}); @@ -89,8 +89,8 @@ public class MovementFall extends Movement { } if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.01 || BlockStateInterface.isWater(dest))) { - if (BlockStateInterface.isWater(dest) && player().inventory.hasItemStack(STACK_BUCKET_AIR)) { - player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_AIR); + if (BlockStateInterface.isWater(dest) && player().inventory.hasItemStack(STACK_BUCKET_EMPTY)) { + player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_EMPTY); if (player().motionY >= 0) { return state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); } else {