fixed walking through fire

This commit is contained in:
Leijurv 2018-08-12 08:17:23 -07:00
parent 524a32375d
commit df1f6da526
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
4 changed files with 29 additions and 8 deletions

View File

@ -21,6 +21,7 @@ import baritone.bot.utils.BlockStateInterface;
import baritone.bot.utils.Helper; import baritone.bot.utils.Helper;
import baritone.bot.utils.Rotation; import baritone.bot.utils.Rotation;
import baritone.bot.utils.Utils; import baritone.bot.utils.Utils;
import net.minecraft.block.BlockFire;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.*; import net.minecraft.util.math.*;
@ -61,6 +62,7 @@ public final class LookBehaviorUtils implements Helper {
return Optional.of(new Rotation(mc.player.rotationYaw, mc.player.rotationPitch + 0.0001f)); return Optional.of(new Rotation(mc.player.rotationYaw, mc.player.rotationPitch + 0.0001f));
} }
Optional<Rotation> possibleRotation = reachableCenter(pos); Optional<Rotation> possibleRotation = reachableCenter(pos);
System.out.println("center: " + possibleRotation);
if (possibleRotation.isPresent()) if (possibleRotation.isPresent())
return possibleRotation; return possibleRotation;
@ -99,10 +101,17 @@ public final class LookBehaviorUtils implements Helper {
protected static Optional<Rotation> reachableOffset(BlockPos pos, Vec3d offsetPos) { protected static Optional<Rotation> reachableOffset(BlockPos pos, Vec3d offsetPos) {
Rotation rotation = Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F), offsetPos); Rotation rotation = Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F), offsetPos);
RayTraceResult result = rayTraceTowards(rotation); RayTraceResult result = rayTraceTowards(rotation);
if (result != null System.out.println(result);
&& result.typeOfHit == RayTraceResult.Type.BLOCK if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) {
&& result.getBlockPos().equals(pos)) if (result.getBlockPos().equals(pos)) {
return Optional.of(rotation); return Optional.of(rotation);
}
if (BlockStateInterface.get(pos).getBlock() instanceof BlockFire) {
if (result.getBlockPos().equals(pos.down())) {
return Optional.of(rotation);
}
}
}
return Optional.empty(); return Optional.empty();
} }

View File

@ -111,8 +111,10 @@ public abstract class Movement implements Helper, MovementHelper {
if (state.getStatus() == MovementStatus.WAITING) if (state.getStatus() == MovementStatus.WAITING)
return true; return true;
boolean somethingInTheWay = false;
for (BlockPos blockPos : positionsToBreak) { for (BlockPos blockPos : positionsToBreak) {
if (!MovementHelper.canWalkThrough(blockPos)) { if (!MovementHelper.canWalkThrough(blockPos)) {
somethingInTheWay = true;
Optional<Rotation> reachable = LookBehaviorUtils.reachable(blockPos); Optional<Rotation> reachable = LookBehaviorUtils.reachable(blockPos);
if (reachable.isPresent()) { if (reachable.isPresent()) {
state.setTarget(new MovementState.MovementTarget(reachable.get())).setInput(Input.CLICK_LEFT, true); state.setTarget(new MovementState.MovementTarget(reachable.get())).setInput(Input.CLICK_LEFT, true);
@ -120,6 +122,12 @@ public abstract class Movement implements Helper, MovementHelper {
} }
} }
} }
if (somethingInTheWay) {
// There's a block or blocks that we can't walk through, but we have no target rotation to reach any
// So don't return true, actually set state to unreachable
state.setStatus(MovementStatus.UNREACHABLE);
return true;
}
return true; return true;
} }

View File

@ -50,11 +50,10 @@ public class MovementFall extends Movement {
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > 3) { if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > 3) {
placeBucketCost = ActionCosts.PLACE_ONE_BLOCK_COST; placeBucketCost = ActionCosts.PLACE_ONE_BLOCK_COST;
} }
double cost = getTotalHardnessOfBlocksToBreak(context.getToolSet()); if (getTotalHardnessOfBlocksToBreak(context.getToolSet()) != 0) {
if (cost != 0) {
return COST_INF; return COST_INF;
} }
return WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[positionsToBreak.length - 1] + cost + placeBucketCost; return WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[positionsToBreak.length - 1] + placeBucketCost;
} }
@Override @Override
@ -75,7 +74,7 @@ public class MovementFall extends Movement {
state.setStatus(MovementStatus.UNREACHABLE); state.setStatus(MovementStatus.UNREACHABLE);
return state; return state;
} }
if (playerFeet().getY() - dest.getY() < mc.playerController.getBlockReachDistance()) { if (player().posY - dest.getY() < mc.playerController.getBlockReachDistance()) {
player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_WATER); player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_WATER);
targetRotation = LookBehaviorUtils.reachable(dest.down()); targetRotation = LookBehaviorUtils.reachable(dest.down());
} }

View File

@ -17,6 +17,7 @@
package baritone.bot.utils; package baritone.bot.utils;
import net.minecraft.block.BlockFire;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -79,6 +80,10 @@ public final class Utils {
double xDiff = (bbox.minX + bbox.maxX) / 2; double xDiff = (bbox.minX + bbox.maxX) / 2;
double yDiff = (bbox.minY + bbox.maxY) / 2; double yDiff = (bbox.minY + bbox.maxY) / 2;
double zDiff = (bbox.minZ + bbox.maxZ) / 2; double zDiff = (bbox.minZ + bbox.maxZ) / 2;
if (b.getBlock() instanceof BlockFire) {//look at bottom of fire when putting it out
yDiff = 0;
}
System.out.println(xDiff + " " + yDiff + " " + zDiff);
return new Vec3d( return new Vec3d(
orig.getX() + xDiff, orig.getX() + xDiff,
orig.getY() + yDiff, orig.getY() + yDiff,