From 1bc2e6fe7a478657e1b880f3653b6b04580530a4 Mon Sep 17 00:00:00 2001 From: Howard Stark Date: Sat, 4 Aug 2018 18:17:53 -0400 Subject: [PATCH] Fix enough to compile --- ...ovementBehavior.java => LookBehavior.java} | 2 +- .../bot/pathing/movement/Movement.java | 30 ++++++++++++------- .../bot/pathing/movement/MovementHelper.java | 16 +++++----- 3 files changed, 29 insertions(+), 19 deletions(-) rename src/main/java/baritone/bot/behavior/impl/{MovementBehavior.java => LookBehavior.java} (61%) diff --git a/src/main/java/baritone/bot/behavior/impl/MovementBehavior.java b/src/main/java/baritone/bot/behavior/impl/LookBehavior.java similarity index 61% rename from src/main/java/baritone/bot/behavior/impl/MovementBehavior.java rename to src/main/java/baritone/bot/behavior/impl/LookBehavior.java index 27ea3fb7..db3d9cb8 100644 --- a/src/main/java/baritone/bot/behavior/impl/MovementBehavior.java +++ b/src/main/java/baritone/bot/behavior/impl/LookBehavior.java @@ -2,5 +2,5 @@ package baritone.bot.behavior.impl; import baritone.bot.behavior.Behavior; -public class MovementBehavior extends Behavior { +public class LookBehavior extends Behavior { } diff --git a/src/main/java/baritone/bot/pathing/movement/Movement.java b/src/main/java/baritone/bot/pathing/movement/Movement.java index dcf915f5..566c7e68 100644 --- a/src/main/java/baritone/bot/pathing/movement/Movement.java +++ b/src/main/java/baritone/bot/pathing/movement/Movement.java @@ -2,6 +2,7 @@ package baritone.bot.pathing.movement; import baritone.bot.Baritone; import baritone.bot.pathing.movement.MovementState.MovementStatus; +import baritone.bot.utils.BlockStateInterface; import baritone.bot.utils.Helper; import baritone.bot.utils.ToolSet; import baritone.bot.utils.Utils; @@ -13,7 +14,7 @@ import java.util.Optional; public abstract class Movement implements IMovement, Helper, MovementHelper { - protected MovementState currentState = new MovementState().setStatus(MovementStatus.PREPPING); + private MovementState currentState = new MovementState().setStatus(MovementStatus.PREPPING); protected final BlockPos src; protected final BlockPos dest; @@ -45,17 +46,17 @@ public abstract class Movement implements IMovement, Helper, MovementHelper { public abstract double calculateCost(ToolSet ts); // TODO pass in information like whether it's allowed to place throwaway blocks public MovementStatus update() { - if(isPrepared(state)) { - if (!currentState.isPresent()) { - currentState = Optional.of(new MovementState() - .setStatus(MovementStatus.WAITING) - .setGoal()); - } - } +// if(isPrepared(state)) { +// if (!currentState.isPresent()) { +// currentState = Optional.of(new MovementState() +// .setStatus(MovementStatus.WAITING) +// .setGoal()); +// } +// } if(isFinished()) { } - MovementState latestState = updateState(); + MovementState latestState = updateState(currentState); Tuple rotation = Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F), latestState.getGoal().rotation); mc.player.setPositionAndRotation(mc.player.posX, mc.player.posY, mc.player.posZ, @@ -68,14 +69,21 @@ public abstract class Movement implements IMovement, Helper, MovementHelper { if (isFinished()) onFinish(); - return; + + return currentState.getStatus(); } private boolean prepare(MovementState state) { + if(state.getStatus() == MovementStatus.WAITING) { + return true; + } Optional cruftPos; for(BlockPos blockPos : positionsToBreak) { - world().getBlockState(blockPos).getBlock()(world()) + if(MovementHelper.canWalkThrough(blockPos, BlockStateInterface.get(blockPos))) { + + } } + return true; } public boolean isFinished() { diff --git a/src/main/java/baritone/bot/pathing/movement/MovementHelper.java b/src/main/java/baritone/bot/pathing/movement/MovementHelper.java index 19539063..9a4d1e83 100644 --- a/src/main/java/baritone/bot/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/bot/pathing/movement/MovementHelper.java @@ -73,6 +73,7 @@ public interface MovementHelper extends ActionCosts, Helper { Block b = BlockStateInterface.get(pos).getBlock(); Block below = BlockStateInterface.get(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock(); return Blocks.ICE.equals(b) // ice becomes water, and water can mess up the path + || b instanceof BlockSilverfish || isLiquid(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()))//don't break anything touching liquid on any side || isLiquid(new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ())) || isLiquid(new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ())) @@ -89,22 +90,23 @@ public interface MovementHelper extends ActionCosts, Helper { */ static boolean canWalkThrough(BlockPos pos, IBlockState state) { Block block = state.getBlock(); - if (block instanceof BlockLilyPad || block instanceof BlockFire) {//you can't actually walk through a lilypad from the side, and you shouldn't walk through fire + if (block instanceof BlockLilyPad + || block instanceof BlockFire + || block instanceof BlockTripWire) {//you can't actually walk through a lilypad from the side, and you shouldn't walk through fire return false; } - if (isFlowing(state)) { + if (isFlowing(state) || isLiquid(pos.up())) { return false; // Don't walk through flowing liquids } - if (isLiquid(pos.up())) { - return false; // You could drown - } return block.isPassable(Minecraft.getMinecraft().world, pos); } static boolean avoidWalkingInto(Block block) { return isLava(block) || block instanceof BlockCactus - || block instanceof BlockFire; + || block instanceof BlockFire + || block instanceof BlockEndPortal + || block instanceof BlockWeb; } /** @@ -122,7 +124,7 @@ public interface MovementHelper extends ActionCosts, Helper { return true; } if (isWater(block)) { - return isWater(pos.up());//you can only walk on water if there is water above it + return isWater(pos.up()); // You can only walk on water if there is water above it } return state.isBlockNormalCube() && !isLava(block); }