major unscuff of builder
This commit is contained in:
parent
1c36bf3300
commit
b9f0da7d27
@ -697,6 +697,26 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> goalBreakFromAbove = new Setting<>(false);
|
public final Setting<Boolean> goalBreakFromAbove = new Setting<>(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build in map art mode, which makes baritone only care about the top block in each column
|
||||||
|
*/
|
||||||
|
public final Setting<Boolean> mapArtMode = new Setting<>(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override builder's behavior to not attempt to correct blocks that are currently water
|
||||||
|
*/
|
||||||
|
public final Setting<Boolean> okIfWater = new Setting<>(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The set of incorrect blocks can never grow beyond this size
|
||||||
|
*/
|
||||||
|
public final Setting<Integer> incorrectSize = new Setting<>(100);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiply the cost of breaking a block that's correct in the builder's schematic by this coefficient
|
||||||
|
*/
|
||||||
|
public final Setting<Double> breakCorrectBlockPenaltyMultiplier = new Setting<>(10d);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* While mining, should it also consider dropped items of the correct type as a pathing destination (as well as ore blocks)?
|
* While mining, should it also consider dropped items of the correct type as a pathing destination (as well as ore blocks)?
|
||||||
*/
|
*/
|
||||||
|
@ -26,6 +26,7 @@ import net.minecraft.client.entity.EntityPlayerSP;
|
|||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.inventory.ClickType;
|
import net.minecraft.inventory.ClickType;
|
||||||
import net.minecraft.item.*;
|
import net.minecraft.item.*;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -132,9 +133,12 @@ public final class InventoryBehavior extends Behavior {
|
|||||||
|
|
||||||
public boolean selectThrowawayForLocation(boolean select, int x, int y, int z) {
|
public boolean selectThrowawayForLocation(boolean select, int x, int y, int z) {
|
||||||
IBlockState maybe = baritone.getBuilderProcess().placeAt(x, y, z);
|
IBlockState maybe = baritone.getBuilderProcess().placeAt(x, y, z);
|
||||||
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock().equals(maybe.getBlock()))) {
|
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof ItemBlock && maybe.equals(((ItemBlock) stack.getItem()).getBlock().getStateForPlacement(ctx.world(), ctx.playerFeet(), EnumFacing.UP, (float) ctx.player().posX, (float) ctx.player().posY, (float) ctx.player().posZ, stack.getItem().getMetadata(stack.getMetadata()), ctx.player())))) {
|
||||||
return true; // gotem
|
return true; // gotem
|
||||||
}
|
}
|
||||||
|
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock().equals(maybe.getBlock()))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
for (Item item : Baritone.settings().acceptableThrowawayItems.value) {
|
for (Item item : Baritone.settings().acceptableThrowawayItems.value) {
|
||||||
if (throwaway(select, stack -> item.equals(stack.getItem()))) {
|
if (throwaway(select, stack -> item.equals(stack.getItem()))) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -34,6 +34,7 @@ import baritone.utils.BaritoneProcessHelper;
|
|||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.PathingCommandContext;
|
import baritone.utils.PathingCommandContext;
|
||||||
import baritone.utils.schematic.AirSchematic;
|
import baritone.utils.schematic.AirSchematic;
|
||||||
|
import baritone.utils.schematic.MapArtSchematic;
|
||||||
import baritone.utils.schematic.Schematic;
|
import baritone.utils.schematic.Schematic;
|
||||||
import baritone.utils.schematic.schematica.SchematicaHelper;
|
import baritone.utils.schematic.schematica.SchematicaHelper;
|
||||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||||
@ -130,7 +131,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static ISchematic parse(NBTTagCompound schematic) {
|
private static ISchematic parse(NBTTagCompound schematic) {
|
||||||
return new Schematic(schematic);
|
return Baritone.settings().mapArtMode.value ? new MapArtSchematic(schematic) : new Schematic(schematic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -512,6 +513,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
} else {
|
} else {
|
||||||
incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ));
|
incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ));
|
||||||
observedCompleted.remove(BetterBlockPos.longHash(blockX, blockY, blockZ));
|
observedCompleted.remove(BetterBlockPos.longHash(blockX, blockY, blockZ));
|
||||||
|
if (incorrectPositions.size() > Baritone.settings().incorrectSize.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -520,6 +524,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
// and we've never seen this position be correct
|
// and we've never seen this position be correct
|
||||||
// therefore mark as incorrect
|
// therefore mark as incorrect
|
||||||
incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ));
|
incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ));
|
||||||
|
if (incorrectPositions.size() > Baritone.settings().incorrectSize.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -618,7 +625,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
boolean allowSameLevel = ctx.world().getBlockState(pos.up()).getBlock() != Blocks.AIR;
|
boolean allowSameLevel = ctx.world().getBlockState(pos.up()).getBlock() != Blocks.AIR;
|
||||||
for (EnumFacing facing : Movement.HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP) {
|
for (EnumFacing facing : Movement.HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP) {
|
||||||
if (MovementHelper.canPlaceAgainst(ctx, pos.offset(facing)) && ctx.world().mayPlace(bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()).getBlock(), pos, false, facing, null)) {
|
if (MovementHelper.canPlaceAgainst(ctx, pos.offset(facing)) && ctx.world().mayPlace(bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()).getBlock(), pos, false, facing, null)) {
|
||||||
return new GoalAdjacent(pos, allowSameLevel);
|
return new GoalAdjacent(pos, pos.offset(facing), allowSameLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new GoalPlace(pos);
|
return new GoalPlace(pos);
|
||||||
@ -641,9 +648,11 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
|
|
||||||
public static class GoalAdjacent extends GoalGetToBlock {
|
public static class GoalAdjacent extends GoalGetToBlock {
|
||||||
private boolean allowSameLevel;
|
private boolean allowSameLevel;
|
||||||
|
private BlockPos no;
|
||||||
|
|
||||||
public GoalAdjacent(BlockPos pos, boolean allowSameLevel) {
|
public GoalAdjacent(BlockPos pos, BlockPos no, boolean allowSameLevel) {
|
||||||
super(pos);
|
super(pos);
|
||||||
|
this.no = no;
|
||||||
this.allowSameLevel = allowSameLevel;
|
this.allowSameLevel = allowSameLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +660,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
if (x == this.x && y == this.y && z == this.z) {
|
if (x == this.x && y == this.y && z == this.z) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (x == no.getX() && y == no.getY() && z == no.getZ()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!allowSameLevel && y == this.y - 1) {
|
if (!allowSameLevel && y == this.y - 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -710,6 +722,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
|
|
||||||
private boolean valid(IBlockState current, IBlockState desired) {
|
private boolean valid(IBlockState current, IBlockState desired) {
|
||||||
// TODO more complicated comparison logic I guess
|
// TODO more complicated comparison logic I guess
|
||||||
|
if (current.getBlock() instanceof BlockLiquid && Baritone.settings().okIfWater.value) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return desired == null || current.equals(desired);
|
return desired == null || current.equals(desired);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -789,7 +804,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
// it should be a real block
|
// it should be a real block
|
||||||
// is it already that block?
|
// is it already that block?
|
||||||
if (valid(bsi.get0(x, y, z), sch)) {
|
if (valid(bsi.get0(x, y, z), sch)) {
|
||||||
return 3;
|
return Baritone.settings().breakCorrectBlockPenaltyMultiplier.value;
|
||||||
} else {
|
} else {
|
||||||
// can break if it's wrong
|
// can break if it's wrong
|
||||||
// would be great to return less than 1 here, but that would actually make the cost calculation messed up
|
// would be great to return less than 1 here, but that would actually make the cost calculation messed up
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package baritone.utils.schematic;
|
package baritone.utils.schematic;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockAir;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
@ -36,7 +36,7 @@ public class MapArtSchematic extends Schematic {
|
|||||||
for (int z = 0; z < lengthZ; z++) {
|
for (int z = 0; z < lengthZ; z++) {
|
||||||
IBlockState[] column = states[x][z];
|
IBlockState[] column = states[x][z];
|
||||||
|
|
||||||
OptionalInt lowestBlockY = lastIndexMatching(column, block -> block != Blocks.AIR);
|
OptionalInt lowestBlockY = lastIndexMatching(column, state -> !(state.getBlock() instanceof BlockAir));
|
||||||
if (lowestBlockY.isPresent()) {
|
if (lowestBlockY.isPresent()) {
|
||||||
heightMap[x][z] = lowestBlockY.getAsInt();
|
heightMap[x][z] = lowestBlockY.getAsInt();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user