Fix GetToBlockProcess rescan
This commit is contained in:
parent
bae34e5b80
commit
71e7f0a04c
@ -29,6 +29,7 @@ import net.minecraft.block.Block;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess {
|
public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess {
|
||||||
@ -96,7 +97,6 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void rescan(List<BlockPos> known) {
|
private void rescan(List<BlockPos> known) {
|
||||||
// TODO-yeet
|
knownLocations = MineProcess.searchWorld(baritone, Collections.singletonList(gettingTo), 64, known);
|
||||||
// knownLocations = MineProcess.searchWorld(ctx, Collections.singletonList(gettingTo), 64, baritone.getWorldProvider(), known);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,6 +18,7 @@
|
|||||||
package baritone.process;
|
package baritone.process;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
|
import baritone.api.IBaritone;
|
||||||
import baritone.api.pathing.goals.*;
|
import baritone.api.pathing.goals.*;
|
||||||
import baritone.api.process.IMineProcess;
|
import baritone.api.process.IMineProcess;
|
||||||
import baritone.api.process.PathingCommand;
|
import baritone.api.process.PathingCommand;
|
||||||
@ -119,7 +120,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
private Goal updateGoal() {
|
private Goal updateGoal() {
|
||||||
List<BlockPos> locs = knownOreLocations;
|
List<BlockPos> locs = knownOreLocations;
|
||||||
if (!locs.isEmpty()) {
|
if (!locs.isEmpty()) {
|
||||||
List<BlockPos> locs2 = prune(new ArrayList<>(locs), mining, ORE_LOCATIONS_COUNT);
|
List<BlockPos> locs2 = prune(baritone, new ArrayList<>(locs), mining, ORE_LOCATIONS_COUNT);
|
||||||
// can't reassign locs, gotta make a new var locs2, because we use it in a lambda right here, and variables you use in a lambda must be effectively final
|
// can't reassign locs, gotta make a new var locs2, because we use it in a lambda right here, and variables you use in a lambda must be effectively final
|
||||||
Goal goal = new GoalComposite(locs2.stream().map(loc -> coalesce(loc, locs2)).toArray(Goal[]::new));
|
Goal goal = new GoalComposite(locs2.stream().map(loc -> coalesce(loc, locs2)).toArray(Goal[]::new));
|
||||||
knownOreLocations = locs2;
|
knownOreLocations = locs2;
|
||||||
@ -161,7 +162,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
if (Baritone.settings().legitMine.get()) {
|
if (Baritone.settings().legitMine.get()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<BlockPos> locs = searchWorld(mining, ORE_LOCATIONS_COUNT, baritone.getWorldProvider(), already);
|
List<BlockPos> locs = searchWorld(baritone, mining, ORE_LOCATIONS_COUNT, already);
|
||||||
locs.addAll(droppedItemsScan(mining, ctx.world()));
|
locs.addAll(droppedItemsScan(mining, ctx.world()));
|
||||||
if (locs.isEmpty()) {
|
if (locs.isEmpty()) {
|
||||||
logDebug("No locations for " + mining + " known, cancelling");
|
logDebug("No locations for " + mining + " known, cancelling");
|
||||||
@ -219,13 +220,15 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
/*public static List<BlockPos> searchWorld(List<Block> mining, int max, World world) {
|
/*public static List<BlockPos> searchWorld(List<Block> mining, int max, World world) {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
public List<BlockPos> searchWorld(List<Block> mining, int max, WorldProvider provider, List<BlockPos> alreadyKnown) {
|
public static List<BlockPos> searchWorld(IBaritone baritone, List<Block> mining, int max, List<BlockPos> alreadyKnown) {
|
||||||
|
IPlayerContext ctx = baritone.getPlayerContext();
|
||||||
|
|
||||||
List<BlockPos> locs = new ArrayList<>();
|
List<BlockPos> locs = new ArrayList<>();
|
||||||
List<Block> uninteresting = new ArrayList<>();
|
List<Block> uninteresting = new ArrayList<>();
|
||||||
//long b = System.currentTimeMillis();
|
//long b = System.currentTimeMillis();
|
||||||
for (Block m : mining) {
|
for (Block m : mining) {
|
||||||
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) {
|
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) {
|
||||||
locs.addAll(provider.getCurrentWorld().getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 1));
|
locs.addAll(baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 1));
|
||||||
} else {
|
} else {
|
||||||
uninteresting.add(m);
|
uninteresting.add(m);
|
||||||
}
|
}
|
||||||
@ -240,7 +243,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
//System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms");
|
//System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms");
|
||||||
}
|
}
|
||||||
locs.addAll(alreadyKnown);
|
locs.addAll(alreadyKnown);
|
||||||
return prune(locs, mining, max);
|
return prune(baritone, locs, mining, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNearby() {
|
public void addNearby() {
|
||||||
@ -258,10 +261,12 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
knownOreLocations = prune(knownOreLocations, mining, ORE_LOCATIONS_COUNT);
|
knownOreLocations = prune(baritone, knownOreLocations, mining, ORE_LOCATIONS_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BlockPos> prune(List<BlockPos> locs2, List<Block> mining, int max) {
|
public static List<BlockPos> prune(IBaritone baritone, List<BlockPos> locs2, List<Block> mining, int max) {
|
||||||
|
IPlayerContext ctx = baritone.getPlayerContext();
|
||||||
|
|
||||||
List<BlockPos> dropped = droppedItemsScan(mining, ctx.world());
|
List<BlockPos> dropped = droppedItemsScan(mining, ctx.world());
|
||||||
List<BlockPos> locs = locs2
|
List<BlockPos> locs = locs2
|
||||||
.stream()
|
.stream()
|
||||||
@ -271,7 +276,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
.filter(pos -> ctx.world().getChunk(pos) instanceof EmptyChunk || mining.contains(BlockStateInterface.get(pos).getBlock()) || dropped.contains(pos))
|
.filter(pos -> ctx.world().getChunk(pos) instanceof EmptyChunk || mining.contains(BlockStateInterface.get(pos).getBlock()) || dropped.contains(pos))
|
||||||
|
|
||||||
// remove any that are implausible to mine (encased in bedrock, or touching lava)
|
// remove any that are implausible to mine (encased in bedrock, or touching lava)
|
||||||
.filter(this::plausibleToBreak)
|
.filter(pos -> MineProcess.plausibleToBreak(baritone, pos))
|
||||||
|
|
||||||
.sorted(Comparator.comparingDouble(ctx.playerFeet()::distanceSq))
|
.sorted(Comparator.comparingDouble(ctx.playerFeet()::distanceSq))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@ -282,7 +287,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
return locs;
|
return locs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean plausibleToBreak(BlockPos pos) {
|
public static boolean plausibleToBreak(IBaritone baritone, BlockPos pos) {
|
||||||
if (MovementHelper.avoidBreaking(new CalculationContext(baritone), pos.getX(), pos.getY(), pos.getZ(), BlockStateInterface.get(pos))) {
|
if (MovementHelper.avoidBreaking(new CalculationContext(baritone), pos.getX(), pos.getY(), pos.getZ(), BlockStateInterface.get(pos))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user