throwaway context
This commit is contained in:
parent
b4d389d432
commit
df8e0d313b
@ -47,6 +47,7 @@ import baritone.bot.pathing.movement.movements.MovementDiagonal;
|
||||
import baritone.bot.pathing.movement.movements.MovementDownward;
|
||||
import baritone.bot.pathing.movement.movements.MovementTraverse;
|
||||
import baritone.bot.pathing.path.IPath;
|
||||
import baritone.bot.utils.Helper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@ -60,7 +61,7 @@ import java.util.Random;
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public class AStarPathFinder extends AbstractNodeCostSearch {
|
||||
public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
||||
|
||||
public static boolean slowPath = false;
|
||||
|
||||
@ -186,7 +187,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch {
|
||||
}
|
||||
}
|
||||
System.out.println("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + bestDist + " blocks =(");
|
||||
System.out.println("No path found =(");
|
||||
displayChatMessageRaw("No path found =(");
|
||||
currentlyRunning = null;
|
||||
return Optional.empty();
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ public class CalculationContext implements Helper {
|
||||
|
||||
private final ToolSet toolSet;
|
||||
private final boolean hasWaterBucket;
|
||||
private final boolean hasThrowaway;
|
||||
|
||||
public CalculationContext() {
|
||||
this(new ToolSet());
|
||||
@ -41,6 +42,7 @@ public class CalculationContext implements Helper {
|
||||
public CalculationContext(ToolSet toolSet) {
|
||||
this.toolSet = toolSet;
|
||||
this.hasWaterBucket = InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) && !world().provider.isNether();
|
||||
this.hasThrowaway = MovementHelper.throwaway(false);
|
||||
}
|
||||
|
||||
public ToolSet getToolSet() {
|
||||
@ -50,4 +52,8 @@ public class CalculationContext implements Helper {
|
||||
public boolean hasWaterBucket() {
|
||||
return hasWaterBucket;
|
||||
}
|
||||
|
||||
public boolean hasThrowaway() {
|
||||
return hasThrowaway;
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,8 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
|
||||
List<Item> ACCEPTABLE_THROWAWAY_ITEMS = Arrays.asList(
|
||||
Item.getItemFromBlock(Blocks.DIRT),
|
||||
Item.getItemFromBlock(Blocks.COBBLESTONE)
|
||||
Item.getItemFromBlock(Blocks.COBBLESTONE),
|
||||
Item.getItemFromBlock(Blocks.NETHERRACK)
|
||||
);
|
||||
|
||||
static boolean avoidBreaking(BlockPos pos) {
|
||||
@ -94,7 +95,8 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
|| block instanceof BlockCactus
|
||||
|| block instanceof BlockFire
|
||||
|| block instanceof BlockEndPortal
|
||||
|| block instanceof BlockWeb;
|
||||
|| block instanceof BlockWeb
|
||||
|| block instanceof BlockMagma;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,6 +118,9 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
if (BlockStateInterface.isWater(block)) {
|
||||
return BlockStateInterface.isWater(pos.up()); // You can only walk on water if there is water above it
|
||||
}
|
||||
if (block.equals(Blocks.MAGMA)) {
|
||||
return false;
|
||||
}
|
||||
return state.isBlockNormalCube() && !BlockStateInterface.isLava(block);
|
||||
}
|
||||
|
||||
@ -188,13 +193,15 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
mc.player.inventory.currentItem = ts.getBestSlot(b);
|
||||
}
|
||||
|
||||
static boolean switchtothrowaway() {
|
||||
static boolean throwaway(boolean select) {
|
||||
EntityPlayerSP p = Minecraft.getMinecraft().player;
|
||||
NonNullList<ItemStack> inv = p.inventory.mainInventory;
|
||||
for (byte i = 0; i < 9; i++) {
|
||||
ItemStack item = inv.get(i);
|
||||
if (ACCEPTABLE_THROWAWAY_ITEMS.contains(item.getItem())) {
|
||||
if (select) {
|
||||
p.inventory.currentItem = i;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -245,16 +252,4 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static boolean hasthrowaway() {
|
||||
EntityPlayerSP p = Minecraft.getMinecraft().player;
|
||||
NonNullList<ItemStack> inv = p.inventory.mainInventory;
|
||||
for (byte i = 0; i < 9; i++) {
|
||||
ItemStack item = inv.get(i);
|
||||
if (ACCEPTABLE_THROWAWAY_ITEMS.contains(item.getItem())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,9 @@ public class MovementTraverse extends Movement {
|
||||
}
|
||||
IBlockState pp0 = BlockStateInterface.get(positionsToPlace[0]);
|
||||
if (pp0.getBlock().equals(Blocks.AIR) || (!BlockStateInterface.isWater(pp0.getBlock()) && pp0.getBlock().isReplaceable(Minecraft.getMinecraft().world, positionsToPlace[0]))) {
|
||||
if (!context.hasThrowaway()) {
|
||||
return COST_INF;
|
||||
}
|
||||
for (BlockPos against1 : against) {
|
||||
if (BlockStateInterface.get(against1).isBlockNormalCube()) {
|
||||
return WC + PLACE_ONE_BLOCK_COST + getTotalHardnessOfBlocksToBreak(context.getToolSet());
|
||||
@ -137,7 +140,7 @@ public class MovementTraverse extends Movement {
|
||||
wasTheBridgeBlockAlwaysThere = false;
|
||||
for (BlockPos against1 : against) {
|
||||
if (BlockStateInterface.get(against1).isBlockNormalCube()) {
|
||||
if (!MovementHelper.switchtothrowaway()) { // 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");
|
||||
return state;
|
||||
}
|
||||
@ -163,7 +166,7 @@ public class MovementTraverse extends Movement {
|
||||
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
|
||||
// Out.log(from + " " + to + " " + faceX + "," + faceY + "," + faceZ + " " + whereAmI);
|
||||
if (!MovementHelper.switchtothrowaway()) {// 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");
|
||||
return state;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user