water drop works

This commit is contained in:
Leijurv 2018-08-06 19:48:09 -07:00
parent beb56dca5b
commit 703c3b766b
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
5 changed files with 61 additions and 19 deletions

View File

@ -161,8 +161,8 @@ public class PathingBehavior extends Behavior {
});
});
long end = System.currentTimeMillis();
if (end - start > 0)
System.out.println("Frame took " + (split - start) + " " + (end - split));
// if (end - start > 0)
// System.out.println("Frame took " + (split - start) + " " + (end - split));
}
public void drawPath(IPath path, EntityPlayerSP player, float partialTicks, Color color) {

View File

@ -5,10 +5,14 @@ import baritone.bot.pathing.calc.openset.IOpenSet;
import baritone.bot.pathing.goals.Goal;
import baritone.bot.pathing.movement.ActionCosts;
import baritone.bot.pathing.movement.Movement;
import baritone.bot.pathing.movement.movements.*;
import baritone.bot.pathing.movement.movements.MovementAscend;
import baritone.bot.pathing.movement.movements.MovementDownward;
import baritone.bot.pathing.movement.movements.MovementFall;
import baritone.bot.pathing.movement.movements.MovementTraverse;
import baritone.bot.pathing.path.IPath;
import baritone.bot.utils.ToolSet;
import net.minecraft.client.Minecraft;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.EmptyChunk;
@ -74,6 +78,9 @@ public class AStarPathFinder extends AbstractNodeCostSearch {
//long constructEnd = System.nanoTime();
//System.out.println(constructEnd - constructStart);
for (Movement movementToGetToNeighbor : possibleMovements) {
if (movementToGetToNeighbor == null) {
continue;
}
if (Minecraft.getMinecraft().world.getChunk(movementToGetToNeighbor.getDest()) instanceof EmptyChunk) {
numEmptyChunk++;
continue;
@ -147,7 +154,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch {
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
Movement[] movements = new Movement[21];
Movement[] movements = new Movement[13];
movements[0] = new MovementTraverse(pos, new BlockPos(x + 1, y, z));
movements[1] = new MovementTraverse(pos, new BlockPos(x - 1, y, z));
movements[2] = new MovementTraverse(pos, new BlockPos(x, y, z + 1));
@ -156,19 +163,11 @@ public class AStarPathFinder extends AbstractNodeCostSearch {
movements[5] = new MovementAscend(pos, new BlockPos(x - 1, y + 1, z));
movements[6] = new MovementAscend(pos, new BlockPos(x, y + 1, z + 1));
movements[7] = new MovementAscend(pos, new BlockPos(x, y + 1, z - 1));
movements[8] = new MovementDescend(pos, new BlockPos(x + 1, y - 1, z));
movements[9] = new MovementDescend(pos, new BlockPos(x - 1, y - 1, z));
movements[10] = new MovementDescend(pos, new BlockPos(x, y - 1, z + 1));
movements[11] = new MovementDescend(pos, new BlockPos(x, y - 1, z - 1));
movements[8] = MovementFall.generateMovementFallOrDescend(pos, EnumFacing.NORTH);
movements[9] = MovementFall.generateMovementFallOrDescend(pos, EnumFacing.SOUTH);
movements[10] = MovementFall.generateMovementFallOrDescend(pos, EnumFacing.EAST);
movements[11] = MovementFall.generateMovementFallOrDescend(pos, EnumFacing.WEST);
movements[12] = new MovementDownward(pos);
movements[13] = new MovementFall(pos, new BlockPos(x, y - 2, z - 1));
movements[14] = new MovementFall(pos, new BlockPos(x, y - 2, z + 1));
movements[15] = new MovementFall(pos, new BlockPos(x - 1, y - 2, z));
movements[16] = new MovementFall(pos, new BlockPos(x + 1, y - 2, z));
movements[17] = new MovementFall(pos, new BlockPos(x, y - 3, z - 1));
movements[18] = new MovementFall(pos, new BlockPos(x, y - 3, z + 1));
movements[19] = new MovementFall(pos, new BlockPos(x - 1, y - 3, z));
movements[20] = new MovementFall(pos, new BlockPos(x + 1, y - 3, z));
/*Action[] actions = new Action[26];
actions[0] = new ActionPillar(pos);
actions[1] = new ActionBridge(pos, new BlockPos(x + 1, y, z));

View File

@ -80,8 +80,8 @@ public interface MovementHelper extends ActionCosts, Helper {
*
* @return
*/
static boolean canWalkOn(BlockPos pos) {
IBlockState state = BlockStateInterface.get(pos);
static boolean canWalkOn(BlockPos pos, IBlockState state) {
Block block = state.getBlock();
if (block instanceof BlockLadder || block instanceof BlockVine) {
return true;
@ -95,6 +95,11 @@ public interface MovementHelper extends ActionCosts, Helper {
return state.isBlockNormalCube() && !BlockStateInterface.isLava(block);
}
static boolean canWalkOn(BlockPos pos) {
IBlockState state = BlockStateInterface.get(pos);
return canWalkOn(pos, state);
}
static boolean canFall(BlockPos pos) {
return BlockStateInterface.get(pos).getBlock() instanceof BlockFalling;
}

View File

@ -12,9 +12,12 @@ import baritone.bot.utils.BlockStateInterface;
import baritone.bot.utils.Rotation;
import baritone.bot.utils.ToolSet;
import baritone.bot.utils.Utils;
import net.minecraft.block.BlockAir;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
@ -37,6 +40,41 @@ public class MovementFall extends Movement {
super(src, dest, MovementFall.buildPositionsToBreak(src, dest), new BlockPos[]{dest.down()});
}
public static Movement generateMovementFallOrDescend(BlockPos pos, EnumFacing direction) {
BlockPos dest = pos.offset(direction);
BlockPos destUp = dest.up();
BlockPos destDown = dest.down();
for (int i = 0; i < 4; i++) {
if (!(BlockStateInterface.get(destUp.down(i)).getBlock() instanceof BlockAir)) {
//if any of these four aren't air, that means that a fall N isn't possible
//so try a movementdescend
//if all four of them are air, a movementdescend isn't possible anyway
return new MovementDescend(pos, destDown);
}
}
// we're clear for a fall 2
// let's see how far we can fall
for (int fallHeight = 3; true; fallHeight++) {
BlockPos onto = dest.down(fallHeight);
if (onto.getY() <= 0) {
break;
}
IBlockState fallOn = BlockStateInterface.get(onto);
if (fallOn.getBlock() instanceof BlockAir) {
continue;
}
if (BlockStateInterface.isWater(fallOn.getBlock())) {
return new MovementFall(pos, onto);
}
if (MovementHelper.canWalkOn(onto)) {
return new MovementFall(pos, onto);
}
break;
}
return null;
}
@Override
protected double calculateCost(ToolSet ts) {
if (!MovementHelper.canWalkOn(positionsToPlace[0])) {

View File

@ -141,7 +141,7 @@ public class MovementTraverse extends Movement {
//Out.gui("Wrong. " + side + " " + LookBehaviorUtils.getSelectedBlock().get().offset(side) + " " + positionsToPlace[0], Out.Mode.Debug);
}
}
displayChatMessageRaw("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;
}
}