This commit is contained in:
Leijurv 2023-01-15 01:02:52 -08:00
parent a3f70e7977
commit d6d9af65fb
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
21 changed files with 58 additions and 60 deletions

View File

@ -27,7 +27,7 @@ import java.util.stream.Stream;
public enum RelativeCoordinate implements IDatatypePost<Double, Double> { public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
INSTANCE; INSTANCE;
private static String ScalesAliasRegex = "[kKmM]"; private static String ScalesAliasRegex = "[kKmM]";
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)("+ScalesAliasRegex+"?)|)$"); private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(" + ScalesAliasRegex + "?)|)$");
@Override @Override
public Double apply(IDatatypeContext ctx, Double origin) throws CommandException { public Double apply(IDatatypeContext ctx, Double origin) throws CommandException {
@ -43,7 +43,7 @@ public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
boolean isRelative = !matcher.group(1).isEmpty(); boolean isRelative = !matcher.group(1).isEmpty();
double offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2).replaceAll(ScalesAliasRegex, "")); double offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2).replaceAll(ScalesAliasRegex, ""));
if (matcher.group(2).toLowerCase().contains("k")) { if (matcher.group(2).toLowerCase().contains("k")) {
offset *= 1000; offset *= 1000;
} }

View File

@ -83,10 +83,10 @@ public enum RelativeFile implements IDatatypePost<File, File> {
boolean useParent = !currentPathStringThing.isEmpty() && !currentPathStringThing.endsWith(File.separator); boolean useParent = !currentPathStringThing.isEmpty() && !currentPathStringThing.endsWith(File.separator);
File currentFile = currentPath.isAbsolute() ? currentPath.toFile() : new File(base, currentPathStringThing); File currentFile = currentPath.isAbsolute() ? currentPath.toFile() : new File(base, currentPathStringThing);
return Stream.of(Objects.requireNonNull(getCanonicalFileUnchecked( return Stream.of(Objects.requireNonNull(getCanonicalFileUnchecked(
useParent useParent
? currentFile.getParentFile() ? currentFile.getParentFile()
: currentFile : currentFile
).listFiles())) ).listFiles()))
.map(f -> (currentPath.isAbsolute() ? f : basePath.relativize(f.toPath()).toString()) + .map(f -> (currentPath.isAbsolute() ? f : basePath.relativize(f.toPath()).toString()) +
(f.isDirectory() ? File.separator : "")) (f.isDirectory() ? File.separator : ""))
.filter(s -> s.toLowerCase(Locale.US).startsWith(currentPathStringThing.toLowerCase(Locale.US))) .filter(s -> s.toLowerCase(Locale.US).startsWith(currentPathStringThing.toLowerCase(Locale.US)))

View File

@ -19,8 +19,8 @@ package baritone.api.pathing.goals;
import baritone.api.utils.SettingsUtil; import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos; import baritone.api.utils.interfaces.IGoalRenderPos;
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
import it.unimi.dsi.fastutil.doubles.DoubleIterator; import it.unimi.dsi.fastutil.doubles.DoubleIterator;
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
public class GoalNear implements Goal, IGoalRenderPos { public class GoalNear implements Goal, IGoalRenderPos {

View File

@ -18,8 +18,8 @@
package baritone.api.pathing.goals; package baritone.api.pathing.goals;
import baritone.api.utils.SettingsUtil; import baritone.api.utils.SettingsUtil;
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
import it.unimi.dsi.fastutil.doubles.DoubleIterator; import it.unimi.dsi.fastutil.doubles.DoubleIterator;
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import java.util.Arrays; import java.util.Arrays;

View File

@ -22,6 +22,7 @@ import net.minecraft.block.BlockAir;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -33,7 +34,7 @@ public class SubstituteSchematic extends AbstractSchematic {
private final Map<Block, List<Block>> substitutions; private final Map<Block, List<Block>> substitutions;
private final Map<IBlockState, Map<Block, IBlockState>> blockStateCache = new HashMap<>(); private final Map<IBlockState, Map<Block, IBlockState>> blockStateCache = new HashMap<>();
public SubstituteSchematic(ISchematic schematic, Map<Block,List<Block>> substitutions) { public SubstituteSchematic(ISchematic schematic, Map<Block, List<Block>> substitutions) {
super(schematic.widthX(), schematic.heightY(), schematic.lengthZ()); super(schematic.widthX(), schematic.heightY(), schematic.lengthZ());
this.schematic = schematic; this.schematic = schematic;
this.substitutions = substitutions; this.substitutions = substitutions;
@ -80,9 +81,10 @@ public class SubstituteSchematic extends AbstractSchematic {
} catch (IllegalArgumentException e) { //property does not exist for target block } catch (IllegalArgumentException e) { //property does not exist for target block
} }
} }
blockStateCache.computeIfAbsent(state, s -> new HashMap<Block,IBlockState>()).put(block, newState); blockStateCache.computeIfAbsent(state, s -> new HashMap<Block, IBlockState>()).put(block, newState);
return newState; return newState;
} }
private <T extends Comparable<T>> IBlockState copySingleProp(IBlockState fromState, IBlockState toState, IProperty<T> prop) { private <T extends Comparable<T>> IBlockState copySingleProp(IBlockState fromState, IBlockState toState, IProperty<T> prop) {
return toState.withProperty(prop, fromState.getValue(prop)); return toState.withProperty(prop, fromState.getValue(prop));
} }

View File

@ -299,7 +299,7 @@ public class SettingsUtil {
Parser keyParser = Parser.getParser(keyType); Parser keyParser = Parser.getParser(keyType);
Parser valueParser = Parser.getParser(valueType); Parser valueParser = Parser.getParser(valueType);
return ((Map<?,?>) value).entrySet().stream() return ((Map<?, ?>) value).entrySet().stream()
.map(o -> keyParser.toString(context, o.getKey()) + "->" + valueParser.toString(context, o.getValue())) .map(o -> keyParser.toString(context, o.getKey()) + "->" + valueParser.toString(context, o.getValue()))
.collect(Collectors.joining(",")); .collect(Collectors.joining(","));
} }

View File

@ -25,7 +25,8 @@ import org.spongepowered.asm.mixin.Shadow;
@Mixin(ItemTool.class) @Mixin(ItemTool.class)
public class MixinItemTool implements IItemTool { public class MixinItemTool implements IItemTool {
@Shadow protected Item.ToolMaterial toolMaterial; @Shadow
protected Item.ToolMaterial toolMaterial;
@Override @Override
public int getHarvestLevel() { public int getHarvestLevel() {

View File

@ -18,7 +18,6 @@
package baritone.behavior; package baritone.behavior;
import baritone.Baritone; import baritone.Baritone;
import baritone.api.BaritoneAPI;
import baritone.api.event.events.TickEvent; import baritone.api.event.events.TickEvent;
import baritone.utils.ToolSet; import baritone.utils.ToolSet;
import net.minecraft.block.Block; import net.minecraft.block.Block;

View File

@ -71,21 +71,21 @@ public class WaypointBehavior extends Behavior {
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(deathWaypoint); baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(deathWaypoint);
ITextComponent component = new TextComponentString("Death position saved."); ITextComponent component = new TextComponentString("Death position saved.");
component.getStyle() component.getStyle()
.setColor(TextFormatting.WHITE) .setColor(TextFormatting.WHITE)
.setHoverEvent(new HoverEvent( .setHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT, HoverEvent.Action.SHOW_TEXT,
new TextComponentString("Click to goto death") new TextComponentString("Click to goto death")
)) ))
.setClickEvent(new ClickEvent( .setClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND, ClickEvent.Action.RUN_COMMAND,
String.format( String.format(
"%s%s goto %s @ %d", "%s%s goto %s @ %d",
FORCE_COMMAND_PREFIX, FORCE_COMMAND_PREFIX,
"wp", "wp",
deathWaypoint.getTag().getName(), deathWaypoint.getTag().getName(),
deathWaypoint.getCreationTimestamp() deathWaypoint.getCreationTimestamp()
) )
)); ));
Helper.HELPER.logDirect(component); Helper.HELPER.logDirect(component);
} }

View File

@ -22,7 +22,6 @@ import baritone.api.cache.ICachedWorld;
import baritone.api.cache.IWaypointCollection; import baritone.api.cache.IWaypointCollection;
import baritone.api.cache.IWorldData; import baritone.api.cache.IWorldData;
import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
/** /**

View File

@ -23,8 +23,8 @@ import baritone.api.utils.Helper;
import baritone.utils.accessor.IAnvilChunkLoader; import baritone.utils.accessor.IAnvilChunkLoader;
import baritone.utils.accessor.IChunkProviderServer; import baritone.utils.accessor.IChunkProviderServer;
import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.world.WorldServer;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.SystemUtils;
import java.io.File; import java.io.File;

View File

@ -18,17 +18,16 @@
package baritone.command.defaults; package baritone.command.defaults;
import baritone.api.IBaritone; import baritone.api.IBaritone;
import baritone.api.pathing.calc.IPathingControlManager;
import baritone.api.process.IBaritoneProcess;
import baritone.api.behavior.IPathingBehavior; import baritone.api.behavior.IPathingBehavior;
import baritone.api.command.Command; import baritone.api.command.Command;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.exception.CommandException; import baritone.api.command.exception.CommandException;
import baritone.api.command.exception.CommandInvalidStateException; import baritone.api.command.exception.CommandInvalidStateException;
import baritone.api.command.argument.IArgConsumer; import baritone.api.pathing.calc.IPathingControlManager;
import baritone.api.process.IBaritoneProcess;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Stream; import java.util.stream.Stream;
public class ETACommand extends Command { public class ETACommand extends Command {

View File

@ -79,10 +79,10 @@ public class FindCommand extends Command {
ITextComponent baseComponent = new TextComponentString(pos.toString()); ITextComponent baseComponent = new TextComponentString(pos.toString());
ITextComponent hoverComponent = new TextComponentString("Click to set goal to this position"); ITextComponent hoverComponent = new TextComponentString("Click to set goal to this position");
baseComponent.getStyle() baseComponent.getStyle()
.setColor(TextFormatting.GRAY) .setColor(TextFormatting.GRAY)
.setInsertion(positionText) .setInsertion(positionText)
.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)) .setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command))
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent)); .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent));
return baseComponent; return baseComponent;
} }
@ -90,9 +90,9 @@ public class FindCommand extends Command {
public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException { public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException {
return new TabCompleteHelper() return new TabCompleteHelper()
.append( .append(
CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.stream() CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.stream()
.map(Block.REGISTRY::getNameForObject) .map(Block.REGISTRY::getNameForObject)
.map(Object::toString) .map(Object::toString)
) )
.filterPrefixNamespaced(args.getString()) .filterPrefixNamespaced(args.getString())
.sortAlphabetically() .sortAlphabetically()

View File

@ -36,8 +36,8 @@ import baritone.api.selection.ISelectionManager;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.BlockOptionalMeta; import baritone.api.utils.BlockOptionalMeta;
import baritone.api.utils.BlockOptionalMetaLookup; import baritone.api.utils.BlockOptionalMetaLookup;
import baritone.utils.IRenderer;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
import baritone.utils.IRenderer;
import baritone.utils.schematic.StaticSchematic; import baritone.utils.schematic.StaticSchematic;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
@ -193,7 +193,7 @@ public class SelCommand extends Command {
} }
} }
} }
ISchematic schematic = new StaticSchematic(){{ ISchematic schematic = new StaticSchematic() {{
states = blockstates; states = blockstates;
x = size.getX(); x = size.getX();
y = size.getY(); y = size.getY();

View File

@ -20,8 +20,8 @@ package baritone.command.defaults;
import baritone.Baritone; import baritone.Baritone;
import baritone.api.IBaritone; import baritone.api.IBaritone;
import baritone.api.cache.IWaypoint; import baritone.api.cache.IWaypoint;
import baritone.api.cache.Waypoint;
import baritone.api.cache.IWorldData; import baritone.api.cache.IWorldData;
import baritone.api.cache.Waypoint;
import baritone.api.command.Command; import baritone.api.command.Command;
import baritone.api.command.argument.IArgConsumer; import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.datatypes.ForWaypoints; import baritone.api.command.datatypes.ForWaypoints;
@ -50,7 +50,7 @@ import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
public class WaypointsCommand extends Command { public class WaypointsCommand extends Command {
private Map<IWorldData,List<IWaypoint>> deletedWaypoints = new HashMap<>(); private Map<IWorldData, List<IWaypoint>> deletedWaypoints = new HashMap<>();
public WaypointsCommand(IBaritone baritone) { public WaypointsCommand(IBaritone baritone) {
super(baritone, "waypoints", "waypoint", "wp"); super(baritone, "waypoints", "waypoint", "wp");

View File

@ -73,7 +73,7 @@ public class MovementTraverse extends Movement {
IBlockState destOn = context.get(destX, y - 1, destZ); IBlockState destOn = context.get(destX, y - 1, destZ);
IBlockState srcDown = context.get(x, y - 1, z); IBlockState srcDown = context.get(x, y - 1, z);
Block srcDownBlock = srcDown.getBlock(); Block srcDownBlock = srcDown.getBlock();
boolean standingOnABlock = MovementHelper.mustBeSolidToWalkOn(context, x, y-1, z, srcDown); boolean standingOnABlock = MovementHelper.mustBeSolidToWalkOn(context, x, y - 1, z, srcDown);
boolean frostWalker = standingOnABlock && !context.assumeWalkOnWater && MovementHelper.canUseFrostWalker(context, destOn); boolean frostWalker = standingOnABlock && !context.assumeWalkOnWater && MovementHelper.canUseFrostWalker(context, destOn);
if (frostWalker || MovementHelper.canWalkOn(context, destX, y - 1, destZ, destOn)) { //this is a walk, not a bridge if (frostWalker || MovementHelper.canWalkOn(context, destX, y - 1, destZ, destOn)) { //this is a walk, not a bridge
double WC = WALK_ONE_BLOCK_COST; double WC = WALK_ONE_BLOCK_COST;

View File

@ -28,7 +28,6 @@ import baritone.cache.CachedChunk;
import baritone.cache.WorldScanner; import baritone.cache.WorldScanner;
import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.CalculationContext;
import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementHelper;
import baritone.pathing.precompute.PrecomputedData;
import baritone.utils.BaritoneProcessHelper; import baritone.utils.BaritoneProcessHelper;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -215,6 +214,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
public boolean isInGoal(int x, int y, int z) { public boolean isInGoal(int x, int y, int z) {
return false; return false;
} }
@Override @Override
public double heuristic() { public double heuristic() {
return Double.NEGATIVE_INFINITY; return Double.NEGATIVE_INFINITY;
@ -500,9 +500,9 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
} }
if (!Baritone.settings().allowBreak.value) { if (!Baritone.settings().allowBreak.value) {
BlockOptionalMetaLookup f = new BlockOptionalMetaLookup(this.filter.blocks() BlockOptionalMetaLookup f = new BlockOptionalMetaLookup(this.filter.blocks()
.stream() .stream()
.filter(e -> Baritone.settings().allowBreakAnyway.value.contains(e.getBlock())) .filter(e -> Baritone.settings().allowBreakAnyway.value.contains(e.getBlock()))
.toArray(BlockOptionalMeta[]::new)); .toArray(BlockOptionalMeta[]::new));
if (f.blocks().isEmpty()) { if (f.blocks().isEmpty()) {
logDirect("Unable to mine when allowBreak is false and target block is not in allowBreakAnyway!"); logDirect("Unable to mine when allowBreak is false and target block is not in allowBreakAnyway!");
return null; return null;

View File

@ -211,8 +211,7 @@ public final class PathRenderer implements IRenderer {
if (!settings.renderGoalAnimated.value) { if (!settings.renderGoalAnimated.value) {
// y = 1 causes rendering issues when the player is at the same y as the top of a block for some reason // y = 1 causes rendering issues when the player is at the same y as the top of a block for some reason
y = 0.999F; y = 0.999F;
} } else {
else {
y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2)); y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2));
} }
if (goal instanceof IGoalRenderPos) { if (goal instanceof IGoalRenderPos) {

View File

@ -25,7 +25,6 @@ import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.init.Enchantments; import net.minecraft.init.Enchantments;
import net.minecraft.init.MobEffects; import net.minecraft.init.MobEffects;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword; import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool; import net.minecraft.item.ItemTool;
@ -130,7 +129,7 @@ public class ToolSet {
if (!Baritone.settings().useSwordToMine.value && itemStack.getItem() instanceof ItemSword) { if (!Baritone.settings().useSwordToMine.value && itemStack.getItem() instanceof ItemSword) {
continue; continue;
} }
if (Baritone.settings().itemSaver.value && (itemStack.getItemDamage() + Baritone.settings().itemSaverThreshold.value) >= itemStack.getMaxDamage() && itemStack.getMaxDamage() > 1) { if (Baritone.settings().itemSaver.value && (itemStack.getItemDamage() + Baritone.settings().itemSaverThreshold.value) >= itemStack.getMaxDamage() && itemStack.getMaxDamage() > 1) {
continue; continue;
} }

View File

@ -33,10 +33,10 @@ public class SelectionSchematic extends MaskSchematic {
public SelectionSchematic(ISchematic schematic, Vec3i origin, ISelection[] selections) { public SelectionSchematic(ISchematic schematic, Vec3i origin, ISelection[] selections) {
super(schematic); super(schematic);
this.selections = Stream.of(selections).map( this.selections = Stream.of(selections).map(
sel -> sel sel -> sel
.shift(EnumFacing.WEST, origin.getX()) .shift(EnumFacing.WEST, origin.getX())
.shift(EnumFacing.DOWN, origin.getY()) .shift(EnumFacing.DOWN, origin.getY())
.shift(EnumFacing.NORTH, origin.getZ())) .shift(EnumFacing.NORTH, origin.getZ()))
.toArray(ISelection[]::new); .toArray(ISelection[]::new);
} }
@ -44,7 +44,7 @@ public class SelectionSchematic extends MaskSchematic {
protected boolean partOfMask(int x, int y, int z, IBlockState currentState) { protected boolean partOfMask(int x, int y, int z, IBlockState currentState) {
for (ISelection selection : selections) { for (ISelection selection : selections) {
if (x >= selection.min().x && y >= selection.min().y && z >= selection.min().z if (x >= selection.min().x && y >= selection.min().y && z >= selection.min().z
&& x <= selection.max().x && y <= selection.max().y && z <= selection.max().z) { && x <= selection.max().x && y <= selection.max().y && z <= selection.max().z) {
return true; return true;
} }
} }

View File

@ -136,7 +136,7 @@ public final class LitematicaSchematic extends StaticSchematic {
* @return amount of bits used to encode a block. * @return amount of bits used to encode a block.
*/ */
private static int getBitsPerBlock(int amountOfBlockTypes) { private static int getBitsPerBlock(int amountOfBlockTypes) {
return (int) Math.max(2,Math.ceil(Math.log(amountOfBlockTypes) / Math.log(2))); return (int) Math.max(2, Math.ceil(Math.log(amountOfBlockTypes) / Math.log(2)));
} }
/** /**