All around minor cleanups to movement classes

This commit is contained in:
Brady 2018-08-25 18:30:12 -05:00
parent 85cf5322f9
commit 32a0f4eaac
No known key found for this signature in database
GPG Key ID: 73A788379A197567
8 changed files with 94 additions and 80 deletions

View File

@ -33,6 +33,7 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import static baritone.utils.InputOverrideHandler.Input; import static baritone.utils.InputOverrideHandler.Input;
@ -268,15 +269,15 @@ public abstract class Movement implements Helper, MovementHelper {
return state; return state;
} }
public ArrayList<BlockPos> toBreakCached = null; public List<BlockPos> toBreakCached = null;
public ArrayList<BlockPos> toPlaceCached = null; public List<BlockPos> toPlaceCached = null;
public ArrayList<BlockPos> toWalkIntoCached = null; public List<BlockPos> toWalkIntoCached = null;
public ArrayList<BlockPos> toBreak() { public List<BlockPos> toBreak() {
if (toBreakCached != null) { if (toBreakCached != null) {
return toBreakCached; return toBreakCached;
} }
ArrayList<BlockPos> result = new ArrayList<>(); List<BlockPos> result = new ArrayList<>();
for (BlockPos positionToBreak : positionsToBreak) { for (BlockPos positionToBreak : positionsToBreak) {
if (!MovementHelper.canWalkThrough(positionToBreak)) { if (!MovementHelper.canWalkThrough(positionToBreak)) {
result.add(positionToBreak); result.add(positionToBreak);
@ -286,11 +287,11 @@ public abstract class Movement implements Helper, MovementHelper {
return result; return result;
} }
public ArrayList<BlockPos> toPlace() { public List<BlockPos> toPlace() {
if (toPlaceCached != null) { if (toPlaceCached != null) {
return toPlaceCached; return toPlaceCached;
} }
ArrayList<BlockPos> result = new ArrayList<>(); List<BlockPos> result = new ArrayList<>();
for (BlockPos positionToBreak : positionsToPlace) { for (BlockPos positionToBreak : positionsToPlace) {
if (!MovementHelper.canWalkOn(positionToBreak)) { if (!MovementHelper.canWalkOn(positionToBreak)) {
result.add(positionToBreak); result.add(positionToBreak);
@ -300,7 +301,7 @@ public abstract class Movement implements Helper, MovementHelper {
return result; return result;
} }
public ArrayList<BlockPos> toWalkInto() { // overridden by movementdiagonal public List<BlockPos> toWalkInto() { // overridden by movementdiagonal
if (toWalkIntoCached == null) { if (toWalkIntoCached == null) {
toWalkIntoCached = new ArrayList<>(); toWalkIntoCached = new ArrayList<>();
} }

View File

@ -130,9 +130,9 @@ public class MovementAscend extends Movement {
default: default:
return state; return state;
} }
if (playerFeet().equals(dest)) { if (playerFeet().equals(dest)) {
state.setStatus(MovementStatus.SUCCESS); return state.setStatus(MovementStatus.SUCCESS);
return state;
} }
if (!MovementHelper.canWalkOn(positionsToPlace[0])) { if (!MovementHelper.canWalkOn(positionsToPlace[0])) {
@ -146,17 +146,21 @@ public class MovementAscend extends Movement {
double faceZ = (dest.getZ() + anAgainst.getZ() + 1.0D) * 0.5D; double faceZ = (dest.getZ() + anAgainst.getZ() + 1.0D) * 0.5D;
state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), new Vec3d(faceX, faceY, faceZ), playerRotations()), true)); state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), new Vec3d(faceX, faceY, faceZ), playerRotations()), true));
EnumFacing side = Minecraft.getMinecraft().objectMouseOver.sideHit; EnumFacing side = Minecraft.getMinecraft().objectMouseOver.sideHit;
if (Objects.equals(LookBehaviorUtils.getSelectedBlock().orElse(null), anAgainst) && LookBehaviorUtils.getSelectedBlock().get().offset(side).equals(positionsToPlace[0])) {
LookBehaviorUtils.getSelectedBlock().ifPresent(selectedBlock -> {
if (Objects.equals(selectedBlock, anAgainst) && selectedBlock.offset(side).equals(positionsToPlace[0])) {
ticksWithoutPlacement++; ticksWithoutPlacement++;
state.setInput(InputOverrideHandler.Input.SNEAK, true); state.setInput(InputOverrideHandler.Input.SNEAK, true);
if (player().isSneaking()) { if (player().isSneaking()) {
state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true);
} }
if (ticksWithoutPlacement > 20) { if (ticksWithoutPlacement > 20) {
state.setInput(InputOverrideHandler.Input.MOVE_BACK, true);//we might be standing in the way, move back // After 20 ticks without placement, we might be standing in the way, move back
state.setInput(InputOverrideHandler.Input.MOVE_BACK, true);
} }
} }
System.out.println("Trying to look at " + anAgainst + ", actually looking at" + LookBehaviorUtils.getSelectedBlock()); System.out.println("Trying to look at " + anAgainst + ", actually looking at" + selectedBlock);
});
return state; return state;
} }
} }
@ -165,28 +169,22 @@ public class MovementAscend extends Movement {
MovementHelper.moveTowards(state, dest); MovementHelper.moveTowards(state, dest);
if (headBonkClear()) { if (headBonkClear()) {
state.setInput(InputOverrideHandler.Input.JUMP, true); return state.setInput(InputOverrideHandler.Input.JUMP, true);
return state;
} }
int xAxis = Math.abs(src.getX() - dest.getX()); // either 0 or 1 int xAxis = Math.abs(src.getX() - dest.getX()); // either 0 or 1
int zAxis = Math.abs(src.getZ() - dest.getZ()); // either 0 or 1 int zAxis = Math.abs(src.getZ() - dest.getZ()); // either 0 or 1
double flatDistToNext = xAxis * Math.abs((dest.getX() + 0.5D) - player().posX) + zAxis * Math.abs((dest.getZ() + 0.5D) - player().posZ); double flatDistToNext = xAxis * Math.abs((dest.getX() + 0.5D) - player().posX) + zAxis * Math.abs((dest.getZ() + 0.5D) - player().posZ);
double sideDist = zAxis * Math.abs((dest.getX() + 0.5D) - player().posX) + xAxis * Math.abs((dest.getZ() + 0.5D) - player().posZ); double sideDist = zAxis * Math.abs((dest.getX() + 0.5D) - player().posX) + xAxis * Math.abs((dest.getZ() + 0.5D) - player().posZ);
// System.out.println(flatDistToNext + " " + sideDist); // System.out.println(flatDistToNext + " " + sideDist);
if (flatDistToNext > 1.2) { if (flatDistToNext > 1.2 || sideDist > 0.2) {
return state; return state;
} }
if (sideDist > 0.2) { // Once we are pointing the right way and moving, start jumping
return state; // This is slightly more efficient because otherwise we might start jumping before moving, and fall down without moving onto the block we want to jump onto
} // Also wait until we are close enough, because we might jump and hit our head on an adjacent block
//once we are pointing the right way and moving, start jumping return state.setInput(InputOverrideHandler.Input.JUMP, true);
//this is slightly more efficient because otherwise we might start jumping before moving, and fall down without moving onto the block we want to jump onto
//also wait until we are close enough, because we might jump and hit our head on an adjacent block
state.setInput(InputOverrideHandler.Input.JUMP, true);
return state;
} }
private boolean headBonkClear() { private boolean headBonkClear() {
@ -194,7 +192,7 @@ public class MovementAscend extends Movement {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
BlockPos check = startUp.offset(EnumFacing.byHorizontalIndex(i)); BlockPos check = startUp.offset(EnumFacing.byHorizontalIndex(i));
if (!MovementHelper.canWalkThrough(check)) { if (!MovementHelper.canWalkThrough(check)) {
// we might bonk our head // We might bonk our head
return false; return false;
} }
} }

View File

@ -73,6 +73,7 @@ public class MovementDescend extends Movement {
default: default:
return state; return state;
} }
BlockPos playerFeet = playerFeet(); BlockPos playerFeet = playerFeet();
if (playerFeet.equals(dest)) { if (playerFeet.equals(dest)) {
if (BlockStateInterface.isLiquid(dest) || player().posY - playerFeet.getY() < 0.094) { // lilypads if (BlockStateInterface.isLiquid(dest) || player().posY - playerFeet.getY() < 0.094) { // lilypads
@ -91,9 +92,6 @@ public class MovementDescend extends Movement {
double fromStart = Math.sqrt(x * x + z * z); double fromStart = Math.sqrt(x * x + z * z);
if (!playerFeet.equals(dest) || ab > 0.25) { if (!playerFeet.equals(dest) || ab > 0.25) {
BlockPos fakeDest = new BlockPos(dest.getX() * 2 - src.getX(), dest.getY(), dest.getZ() * 2 - src.getZ()); BlockPos fakeDest = new BlockPos(dest.getX() * 2 - src.getX(), dest.getY(), dest.getZ() * 2 - src.getZ());
double diffX2 = player().posX - (fakeDest.getX() + 0.5);
double diffZ2 = player().posZ - (fakeDest.getZ() + 0.5);
double d = Math.sqrt(diffX2 * diffX2 + diffZ2 * diffZ2);
if (numTicks++ < 20) { if (numTicks++ < 20) {
MovementHelper.moveTowards(state, fakeDest); MovementHelper.moveTowards(state, fakeDest);
if (fromStart > 1.25) { if (fromStart > 1.25) {

View File

@ -30,6 +30,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
public class MovementDiagonal extends Movement { public class MovementDiagonal extends Movement {
@ -59,6 +60,7 @@ public class MovementDiagonal extends Movement {
default: default:
return state; return state;
} }
if (playerFeet().equals(dest)) { if (playerFeet().equals(dest)) {
state.setStatus(MovementState.MovementStatus.SUCCESS); state.setStatus(MovementState.MovementStatus.SUCCESS);
return state; return state;
@ -81,7 +83,7 @@ public class MovementDiagonal extends Movement {
} }
double multiplier = WALK_ONE_BLOCK_COST; double multiplier = WALK_ONE_BLOCK_COST;
// for either possible soul sand, that affects half of our walking // For either possible soul sand, that affects half of our walking
if (destWalkOn.getBlock().equals(Blocks.SOUL_SAND)) { if (destWalkOn.getBlock().equals(Blocks.SOUL_SAND)) {
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
} }
@ -117,17 +119,17 @@ public class MovementDiagonal extends Movement {
} }
} }
if (BlockStateInterface.isWater(src) || BlockStateInterface.isWater(dest)) { if (BlockStateInterface.isWater(src) || BlockStateInterface.isWater(dest)) {
// ignore previous multiplier // Ignore previous multiplier
// whatever we were walking on (possibly soul sand) doesn't matter as we're actually floating on water // Whatever we were walking on (possibly soul sand) doesn't matter as we're actually floating on water
// not even touching the blocks below // Not even touching the blocks below
multiplier = WALK_ONE_IN_WATER_COST; multiplier = WALK_ONE_IN_WATER_COST;
} }
if (optionA != 0 || optionB != 0) { if (optionA != 0 || optionB != 0) {
multiplier *= SQRT_2 - 0.001; // TODO tune multiplier *= SQRT_2 - 0.001; // TODO tune
} }
if (multiplier == WALK_ONE_BLOCK_COST && context.canSprint()) { if (multiplier == WALK_ONE_BLOCK_COST && context.canSprint()) {
// if we aren't edging around anything, and we aren't in water or soul sand // If we aren't edging around anything, and we aren't in water or soul sand
// we can sprint =D // We can sprint =D
multiplier = SPRINT_ONE_BLOCK_COST; multiplier = SPRINT_ONE_BLOCK_COST;
} }
return multiplier * SQRT_2; return multiplier * SQRT_2;
@ -139,7 +141,7 @@ public class MovementDiagonal extends Movement {
} }
@Override @Override
public ArrayList<BlockPos> toBreak() { public List<BlockPos> toBreak() {
if (toBreakCached != null) { if (toBreakCached != null) {
return toBreakCached; return toBreakCached;
} }
@ -154,11 +156,11 @@ public class MovementDiagonal extends Movement {
} }
@Override @Override
public ArrayList<BlockPos> toWalkInto() { public List<BlockPos> toWalkInto() {
if (toWalkIntoCached == null) { if (toWalkIntoCached == null) {
toWalkIntoCached = new ArrayList<>(); toWalkIntoCached = new ArrayList<>();
} }
ArrayList<BlockPos> result = new ArrayList<>(); List<BlockPos> result = new ArrayList<>();
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (!MovementHelper.canWalkThrough(positionsToBreak[i])) { if (!MovementHelper.canWalkThrough(positionsToBreak[i])) {
result.add(positionsToBreak[i]); result.add(positionsToBreak[i]);

View File

@ -68,6 +68,7 @@ public class MovementDownward extends Movement {
default: default:
return state; return state;
} }
if (playerFeet().equals(dest)) { if (playerFeet().equals(dest)) {
state.setStatus(MovementState.MovementStatus.SUCCESS); state.setStatus(MovementState.MovementStatus.SUCCESS);
return state; return state;

View File

@ -67,10 +67,10 @@ public class MovementFall extends Movement {
} }
for (int i = 2; i < positionsToBreak.length; i++) { for (int i = 2; i < positionsToBreak.length; i++) {
// TODO is this the right check here? // TODO is this the right check here?
// miningDurationTicks is all right, but shouldn't it be canWalkThrough instead? // MiningDurationTicks is all right, but shouldn't it be canWalkThrough instead?
// lilypads (i think?) are 0 ticks to mine, but they definitely cause fall damage // Lilypads (i think?) are 0 ticks to mine, but they definitely cause fall damage
// same thing for falling through water... we can't actually do that // Same thing for falling through water... we can't actually do that
// and falling through signs is possible, but they do have a mining duration, right? // And falling through signs is possible, but they do have a mining duration, right?
if (MovementHelper.getMiningDurationTicks(context, positionsToBreak[i]) > 0) { if (MovementHelper.getMiningDurationTicks(context, positionsToBreak[i]) > 0) {
//can't break while falling //can't break while falling
return COST_INF; return COST_INF;
@ -90,6 +90,7 @@ public class MovementFall extends Movement {
default: default:
return state; return state;
} }
BlockPos playerFeet = playerFeet(); BlockPos playerFeet = playerFeet();
Optional<Rotation> targetRotation = Optional.empty(); Optional<Rotation> targetRotation = Optional.empty();
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > Baritone.settings().maxFallHeightNoWater.get() && !playerFeet.equals(dest)) { if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > Baritone.settings().maxFallHeightNoWater.get() && !playerFeet.equals(dest)) {

View File

@ -115,6 +115,7 @@ public class MovementPillar extends Movement {
default: default:
return state; return state;
} }
IBlockState fromDown = BlockStateInterface.get(src); IBlockState fromDown = BlockStateInterface.get(src);
boolean ladder = fromDown.getBlock() instanceof BlockLadder || fromDown.getBlock() instanceof BlockVine; boolean ladder = fromDown.getBlock() instanceof BlockLadder || fromDown.getBlock() instanceof BlockVine;
boolean vine = fromDown.getBlock() instanceof BlockVine; boolean vine = fromDown.getBlock() instanceof BlockVine;
@ -123,57 +124,68 @@ public class MovementPillar extends Movement {
Utils.getBlockPosCenter(positionsToPlace[0]), Utils.getBlockPosCenter(positionsToPlace[0]),
new Rotation(mc.player.rotationYaw, mc.player.rotationPitch)), true)); new Rotation(mc.player.rotationYaw, mc.player.rotationPitch)), true));
} }
EntityPlayerSP thePlayer = Minecraft.getMinecraft().player;
boolean blockIsThere = MovementHelper.canWalkOn(src) || ladder; boolean blockIsThere = MovementHelper.canWalkOn(src) || ladder;
if (ladder) { if (ladder) {
BlockPos against = vine ? getAgainst(src) : src.offset(fromDown.getValue(BlockLadder.FACING).getOpposite()); BlockPos against = vine ? getAgainst(src) : src.offset(fromDown.getValue(BlockLadder.FACING).getOpposite());
if (against == null) { if (against == null) {
displayChatMessageRaw("Unable to climb vines"); displayChatMessageRaw("Unable to climb vines");
state.setStatus(MovementState.MovementStatus.UNREACHABLE); return state.setStatus(MovementState.MovementStatus.UNREACHABLE);
return state;
} }
if (playerFeet().equals(against.up()) || playerFeet().equals(dest)) {
state.setStatus(MovementState.MovementStatus.SUCCESS); if (playerFeet().equals(against.up()) || playerFeet().equals(dest))
return state; return state.setStatus(MovementState.MovementStatus.SUCCESS);
}
/*if (thePlayer.getPosition0().getX() != from.getX() || thePlayer.getPosition0().getZ() != from.getZ()) { /*
if (thePlayer.getPosition0().getX() != from.getX() || thePlayer.getPosition0().getZ() != from.getZ()) {
Baritone.moveTowardsBlock(from); Baritone.moveTowardsBlock(from);
}*/ }
*/
MovementHelper.moveTowards(state, against); MovementHelper.moveTowards(state, against);
return state; return state;
} else { } else {
if (!MovementHelper.throwaway(true)) {//get ready to place a throwaway block // Get ready to place a throwaway block
if (!MovementHelper.throwaway(true)) {
state.setStatus(MovementState.MovementStatus.UNREACHABLE); state.setStatus(MovementState.MovementStatus.UNREACHABLE);
return state; return state;
} }
numTicks++; numTicks++;
state.setInput(InputOverrideHandler.Input.JUMP, thePlayer.posY < dest.getY()); //if our Y coordinate is above our goal, stop jumping // If our Y coordinate is above our goal, stop jumping
state.setInput(InputOverrideHandler.Input.JUMP, player().posY < dest.getY());
state.setInput(InputOverrideHandler.Input.SNEAK, true); state.setInput(InputOverrideHandler.Input.SNEAK, true);
//otherwise jump
// Otherwise jump
if (numTicks > 40) { if (numTicks > 40) {
double diffX = thePlayer.posX - (dest.getX() + 0.5); double diffX = player().posX - (dest.getX() + 0.5);
double diffZ = thePlayer.posZ - (dest.getZ() + 0.5); double diffZ = player().posZ - (dest.getZ() + 0.5);
double dist = Math.sqrt(diffX * diffX + diffZ * diffZ); double dist = Math.sqrt(diffX * diffX + diffZ * diffZ);
if (dist > 0.17) {//why 0.17? because it seemed like a good number, that's why if (dist > 0.17) {//why 0.17? because it seemed like a good number, that's why
//[explanation added after baritone port lol] also because it needs to be less than 0.2 because of the 0.3 sneak limit //[explanation added after baritone port lol] also because it needs to be less than 0.2 because of the 0.3 sneak limit
//and 0.17 is reasonably less than 0.2 //and 0.17 is reasonably less than 0.2
state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);//if it's been more than forty ticks of trying to jump and we aren't done yet, go forward, maybe we are stuck
// If it's been more than forty ticks of trying to jump and we aren't done yet, go forward, maybe we are stuck
state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
} }
} }
if (!blockIsThere) { if (!blockIsThere) {
Block fr = BlockStateInterface.get(src).getBlock(); Block fr = BlockStateInterface.get(src).getBlock();
if (!(fr instanceof BlockAir || fr.isReplaceable(Minecraft.getMinecraft().world, src))) { if (!(fr instanceof BlockAir || fr.isReplaceable(Minecraft.getMinecraft().world, src))) {
state.setInput(InputOverrideHandler.Input.CLICK_LEFT, true); state.setInput(InputOverrideHandler.Input.CLICK_LEFT, true);
blockIsThere = false; blockIsThere = false;
} else if (Minecraft.getMinecraft().player.isSneaking()) { } else if (Minecraft.getMinecraft().player.isSneaking()) {
state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true);//constantly right click state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true);
} }
} }
} }
if (playerFeet().equals(dest) && blockIsThere) {//if we are at our goal and the block below us is placed
state.setStatus(MovementState.MovementStatus.SUCCESS); // If we are at our goal and the block below us is placed
return state;//we are done if (playerFeet().equals(dest) && blockIsThere) {
return state.setStatus(MovementState.MovementStatus.SUCCESS);
} }
return state; return state;
} }
} }

View File

@ -92,8 +92,8 @@ public class MovementTraverse extends Movement {
} }
if (MovementHelper.canWalkThrough(positionsToBreak[0], pb0) && MovementHelper.canWalkThrough(positionsToBreak[1], pb1)) { if (MovementHelper.canWalkThrough(positionsToBreak[0], pb0) && MovementHelper.canWalkThrough(positionsToBreak[1], pb1)) {
if (WC == WALK_ONE_BLOCK_COST && context.canSprint()) { if (WC == WALK_ONE_BLOCK_COST && context.canSprint()) {
// if there's nothing in the way, and this isn't water or soul sand, and we aren't sneak placing // If there's nothing in the way, and this isn't water or soul sand, and we aren't sneak placing
// we can sprint =D // We can sprint =D
WC = SPRINT_ONE_BLOCK_COST; WC = SPRINT_ONE_BLOCK_COST;
} }
return WC; return WC;
@ -140,6 +140,7 @@ public class MovementTraverse extends Movement {
default: default:
return state; return state;
} }
Block fd = BlockStateInterface.get(src.down()).getBlock(); Block fd = BlockStateInterface.get(src.down()).getBlock();
boolean ladder = fd instanceof BlockLadder || fd instanceof BlockVine; boolean ladder = fd instanceof BlockLadder || fd instanceof BlockVine;
IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]); IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]);
@ -161,6 +162,7 @@ public class MovementTraverse extends Movement {
} }
} }
} }
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(positionsToPlace[0]) || ladder; boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(positionsToPlace[0]) || ladder;
BlockPos whereAmI = playerFeet(); BlockPos whereAmI = playerFeet();
if (whereAmI.getY() != dest.getY() && !ladder) { if (whereAmI.getY() != dest.getY() && !ladder) {
@ -170,6 +172,7 @@ public class MovementTraverse extends Movement {
} }
return state; return state;
} }
if (isTheBridgeBlockThere) { if (isTheBridgeBlockThere) {
if (playerFeet().equals(dest)) { if (playerFeet().equals(dest)) {
state.setStatus(MovementState.MovementStatus.SUCCESS); state.setStatus(MovementState.MovementStatus.SUCCESS);
@ -202,20 +205,18 @@ public class MovementTraverse extends Movement {
EnumFacing side = Minecraft.getMinecraft().objectMouseOver.sideHit; EnumFacing side = Minecraft.getMinecraft().objectMouseOver.sideHit;
if (Objects.equals(LookBehaviorUtils.getSelectedBlock().orElse(null), against1) && Minecraft.getMinecraft().player.isSneaking()) { if (Objects.equals(LookBehaviorUtils.getSelectedBlock().orElse(null), against1) && Minecraft.getMinecraft().player.isSneaking()) {
if (LookBehaviorUtils.getSelectedBlock().get().offset(side).equals(positionsToPlace[0])) { if (LookBehaviorUtils.getSelectedBlock().get().offset(side).equals(positionsToPlace[0])) {
state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); return state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true);
return state;
} else { } else {
// Out.gui("Wrong. " + side + " " + LookBehaviorUtils.getSelectedBlock().get().offset(side) + " " + positionsToPlace[0], Out.Mode.Debug); // Out.gui("Wrong. " + side + " " + LookBehaviorUtils.getSelectedBlock().get().offset(side) + " " + positionsToPlace[0], Out.Mode.Debug);
} }
} }
state.setInput(InputOverrideHandler.Input.CLICK_LEFT, true);
System.out.println("Trying to look at " + against1 + ", actually looking at" + LookBehaviorUtils.getSelectedBlock()); System.out.println("Trying to look at " + against1 + ", actually looking at" + LookBehaviorUtils.getSelectedBlock());
return state; return state.setInput(InputOverrideHandler.Input.CLICK_LEFT, true);
} }
} }
state.setInput(InputOverrideHandler.Input.SNEAK, true); state.setInput(InputOverrideHandler.Input.SNEAK, true);
if (whereAmI.equals(dest)) { 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 // 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); // Out.log(from + " " + to + " " + faceX + "," + faceY + "," + faceZ + " " + whereAmI);
if (!MovementHelper.throwaway(true)) {// 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"); displayChatMessageRaw("bb pls get me some blocks. dirt or cobble");