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.MovementDownward;
|
||||||
import baritone.bot.pathing.movement.movements.MovementTraverse;
|
import baritone.bot.pathing.movement.movements.MovementTraverse;
|
||||||
import baritone.bot.pathing.path.IPath;
|
import baritone.bot.pathing.path.IPath;
|
||||||
|
import baritone.bot.utils.Helper;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@ -60,7 +61,7 @@ import java.util.Random;
|
|||||||
*
|
*
|
||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
public class AStarPathFinder extends AbstractNodeCostSearch {
|
public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
||||||
|
|
||||||
public static boolean slowPath = false;
|
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("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;
|
currentlyRunning = null;
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ public class CalculationContext implements Helper {
|
|||||||
|
|
||||||
private final ToolSet toolSet;
|
private final ToolSet toolSet;
|
||||||
private final boolean hasWaterBucket;
|
private final boolean hasWaterBucket;
|
||||||
|
private final boolean hasThrowaway;
|
||||||
|
|
||||||
public CalculationContext() {
|
public CalculationContext() {
|
||||||
this(new ToolSet());
|
this(new ToolSet());
|
||||||
@ -41,6 +42,7 @@ public class CalculationContext implements Helper {
|
|||||||
public CalculationContext(ToolSet toolSet) {
|
public CalculationContext(ToolSet toolSet) {
|
||||||
this.toolSet = toolSet;
|
this.toolSet = toolSet;
|
||||||
this.hasWaterBucket = InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) && !world().provider.isNether();
|
this.hasWaterBucket = InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) && !world().provider.isNether();
|
||||||
|
this.hasThrowaway = MovementHelper.throwaway(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToolSet getToolSet() {
|
public ToolSet getToolSet() {
|
||||||
@ -50,4 +52,8 @@ public class CalculationContext implements Helper {
|
|||||||
public boolean hasWaterBucket() {
|
public boolean hasWaterBucket() {
|
||||||
return 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(
|
List<Item> ACCEPTABLE_THROWAWAY_ITEMS = Arrays.asList(
|
||||||
Item.getItemFromBlock(Blocks.DIRT),
|
Item.getItemFromBlock(Blocks.DIRT),
|
||||||
Item.getItemFromBlock(Blocks.COBBLESTONE)
|
Item.getItemFromBlock(Blocks.COBBLESTONE),
|
||||||
|
Item.getItemFromBlock(Blocks.NETHERRACK)
|
||||||
);
|
);
|
||||||
|
|
||||||
static boolean avoidBreaking(BlockPos pos) {
|
static boolean avoidBreaking(BlockPos pos) {
|
||||||
@ -94,7 +95,8 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
|| block instanceof BlockCactus
|
|| block instanceof BlockCactus
|
||||||
|| block instanceof BlockFire
|
|| block instanceof BlockFire
|
||||||
|| block instanceof BlockEndPortal
|
|| 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)) {
|
if (BlockStateInterface.isWater(block)) {
|
||||||
return BlockStateInterface.isWater(pos.up()); // You can only walk on water if there is water above it
|
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);
|
return state.isBlockNormalCube() && !BlockStateInterface.isLava(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,13 +193,15 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
mc.player.inventory.currentItem = ts.getBestSlot(b);
|
mc.player.inventory.currentItem = ts.getBestSlot(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean switchtothrowaway() {
|
static boolean throwaway(boolean select) {
|
||||||
EntityPlayerSP p = Minecraft.getMinecraft().player;
|
EntityPlayerSP p = Minecraft.getMinecraft().player;
|
||||||
NonNullList<ItemStack> inv = p.inventory.mainInventory;
|
NonNullList<ItemStack> inv = p.inventory.mainInventory;
|
||||||
for (byte i = 0; i < 9; i++) {
|
for (byte i = 0; i < 9; i++) {
|
||||||
ItemStack item = inv.get(i);
|
ItemStack item = inv.get(i);
|
||||||
if (ACCEPTABLE_THROWAWAY_ITEMS.contains(item.getItem())) {
|
if (ACCEPTABLE_THROWAWAY_ITEMS.contains(item.getItem())) {
|
||||||
|
if (select) {
|
||||||
p.inventory.currentItem = i;
|
p.inventory.currentItem = i;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,16 +252,4 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
}
|
}
|
||||||
return null;
|
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]);
|
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 (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) {
|
for (BlockPos against1 : against) {
|
||||||
if (BlockStateInterface.get(against1).isBlockNormalCube()) {
|
if (BlockStateInterface.get(against1).isBlockNormalCube()) {
|
||||||
return WC + PLACE_ONE_BLOCK_COST + getTotalHardnessOfBlocksToBreak(context.getToolSet());
|
return WC + PLACE_ONE_BLOCK_COST + getTotalHardnessOfBlocksToBreak(context.getToolSet());
|
||||||
@ -137,7 +140,7 @@ public class MovementTraverse extends Movement {
|
|||||||
wasTheBridgeBlockAlwaysThere = false;
|
wasTheBridgeBlockAlwaysThere = false;
|
||||||
for (BlockPos against1 : against) {
|
for (BlockPos against1 : against) {
|
||||||
if (BlockStateInterface.get(against1).isBlockNormalCube()) {
|
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");
|
displayChatMessageRaw("bb pls get me some blocks. dirt or cobble");
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -163,7 +166,7 @@ public class MovementTraverse extends Movement {
|
|||||||
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.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");
|
displayChatMessageRaw("bb pls get me some blocks. dirt or cobble");
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user