Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b6c59fa8a | ||
|
|
21bc830143 | ||
|
|
aa9206381d | ||
|
|
d6d9af65fb | ||
|
|
a3f70e7977 | ||
|
|
6bbdba7a21 |
@@ -54,7 +54,9 @@ Baritone is the pathfinding system used in [Impact](https://impactclient.net/) s
|
||||
|
||||
[Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa)
|
||||
|
||||
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.2.15/baritone-api-forge-1.2.15.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to
|
||||
install the v1.2.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click
|
||||
[here](https://github.com/cabaletta/baritone/releases/download/v1.2.16/baritone-api-forge-1.2.16.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
|
||||
For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge or Fabric 1.16.5, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.3) and get the `api-forge` or `api-fabric` jar. **For 1.16.5 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.6.3/baritone-api-fabric-1.6.3.jar)**.
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
group 'baritone'
|
||||
version '1.2.16'
|
||||
version '1.2.17'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.stream.Stream;
|
||||
public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
|
||||
INSTANCE;
|
||||
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
|
||||
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();
|
||||
|
||||
double offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2).replaceAll(ScalesAliasRegex, ""));
|
||||
|
||||
|
||||
if (matcher.group(2).toLowerCase().contains("k")) {
|
||||
offset *= 1000;
|
||||
}
|
||||
|
||||
@@ -83,10 +83,10 @@ public enum RelativeFile implements IDatatypePost<File, File> {
|
||||
boolean useParent = !currentPathStringThing.isEmpty() && !currentPathStringThing.endsWith(File.separator);
|
||||
File currentFile = currentPath.isAbsolute() ? currentPath.toFile() : new File(base, currentPathStringThing);
|
||||
return Stream.of(Objects.requireNonNull(getCanonicalFileUnchecked(
|
||||
useParent
|
||||
? currentFile.getParentFile()
|
||||
: currentFile
|
||||
).listFiles()))
|
||||
useParent
|
||||
? currentFile.getParentFile()
|
||||
: currentFile
|
||||
).listFiles()))
|
||||
.map(f -> (currentPath.isAbsolute() ? f : basePath.relativize(f.toPath()).toString()) +
|
||||
(f.isDirectory() ? File.separator : ""))
|
||||
.filter(s -> s.toLowerCase(Locale.US).startsWith(currentPathStringThing.toLowerCase(Locale.US)))
|
||||
|
||||
@@ -19,8 +19,8 @@ package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
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.DoubleOpenHashSet;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class GoalNear implements Goal, IGoalRenderPos {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
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.DoubleOpenHashSet;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.block.BlockAir;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -33,7 +34,7 @@ public class SubstituteSchematic extends AbstractSchematic {
|
||||
private final Map<Block, List<Block>> substitutions;
|
||||
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());
|
||||
this.schematic = schematic;
|
||||
this.substitutions = substitutions;
|
||||
@@ -80,9 +81,10 @@ public class SubstituteSchematic extends AbstractSchematic {
|
||||
} 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;
|
||||
}
|
||||
|
||||
private <T extends Comparable<T>> IBlockState copySingleProp(IBlockState fromState, IBlockState toState, IProperty<T> prop) {
|
||||
return toState.withProperty(prop, fromState.getValue(prop));
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ public class SettingsUtil {
|
||||
Parser keyParser = Parser.getParser(keyType);
|
||||
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()))
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(ItemTool.class)
|
||||
public class MixinItemTool implements IItemTool {
|
||||
@Shadow protected Item.ToolMaterial toolMaterial;
|
||||
@Shadow
|
||||
protected Item.ToolMaterial toolMaterial;
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel() {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package baritone.behavior;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.event.events.TickEvent;
|
||||
import baritone.utils.ToolSet;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
@@ -71,21 +71,21 @@ public class WaypointBehavior extends Behavior {
|
||||
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(deathWaypoint);
|
||||
ITextComponent component = new TextComponentString("Death position saved.");
|
||||
component.getStyle()
|
||||
.setColor(TextFormatting.WHITE)
|
||||
.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponentString("Click to goto death")
|
||||
))
|
||||
.setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s goto %s @ %d",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
"wp",
|
||||
deathWaypoint.getTag().getName(),
|
||||
deathWaypoint.getCreationTimestamp()
|
||||
)
|
||||
));
|
||||
.setColor(TextFormatting.WHITE)
|
||||
.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponentString("Click to goto death")
|
||||
))
|
||||
.setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s goto %s @ %d",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
"wp",
|
||||
deathWaypoint.getTag().getName(),
|
||||
deathWaypoint.getCreationTimestamp()
|
||||
)
|
||||
));
|
||||
Helper.HELPER.logDirect(component);
|
||||
}
|
||||
|
||||
|
||||
1
src/main/java/baritone/cache/WorldData.java
vendored
1
src/main/java/baritone/cache/WorldData.java
vendored
@@ -22,7 +22,6 @@ import baritone.api.cache.ICachedWorld;
|
||||
import baritone.api.cache.IWaypointCollection;
|
||||
import baritone.api.cache.IWorldData;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,8 +23,8 @@ import baritone.api.utils.Helper;
|
||||
import baritone.utils.accessor.IAnvilChunkLoader;
|
||||
import baritone.utils.accessor.IChunkProviderServer;
|
||||
import net.minecraft.server.integrated.IntegratedServer;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -18,17 +18,16 @@
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.pathing.calc.IPathingControlManager;
|
||||
import baritone.api.process.IBaritoneProcess;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
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.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ETACommand extends Command {
|
||||
|
||||
@@ -79,10 +79,10 @@ public class FindCommand extends Command {
|
||||
ITextComponent baseComponent = new TextComponentString(pos.toString());
|
||||
ITextComponent hoverComponent = new TextComponentString("Click to set goal to this position");
|
||||
baseComponent.getStyle()
|
||||
.setColor(TextFormatting.GRAY)
|
||||
.setInsertion(positionText)
|
||||
.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command))
|
||||
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent));
|
||||
.setColor(TextFormatting.GRAY)
|
||||
.setInsertion(positionText)
|
||||
.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command))
|
||||
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent));
|
||||
return baseComponent;
|
||||
}
|
||||
|
||||
@@ -90,9 +90,9 @@ public class FindCommand extends Command {
|
||||
public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(
|
||||
CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.stream()
|
||||
.map(Block.REGISTRY::getNameForObject)
|
||||
.map(Object::toString)
|
||||
CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.stream()
|
||||
.map(Block.REGISTRY::getNameForObject)
|
||||
.map(Object::toString)
|
||||
)
|
||||
.filterPrefixNamespaced(args.getString())
|
||||
.sortAlphabetically()
|
||||
|
||||
@@ -36,8 +36,8 @@ import baritone.api.selection.ISelectionManager;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import baritone.api.utils.BlockOptionalMetaLookup;
|
||||
import baritone.utils.IRenderer;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.IRenderer;
|
||||
import baritone.utils.schematic.StaticSchematic;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -193,7 +193,7 @@ public class SelCommand extends Command {
|
||||
}
|
||||
}
|
||||
}
|
||||
ISchematic schematic = new StaticSchematic(){{
|
||||
ISchematic schematic = new StaticSchematic() {{
|
||||
states = blockstates;
|
||||
x = size.getX();
|
||||
y = size.getY();
|
||||
|
||||
@@ -20,8 +20,8 @@ package baritone.command.defaults;
|
||||
import baritone.Baritone;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.cache.IWaypoint;
|
||||
import baritone.api.cache.Waypoint;
|
||||
import baritone.api.cache.IWorldData;
|
||||
import baritone.api.cache.Waypoint;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.datatypes.ForWaypoints;
|
||||
@@ -50,7 +50,7 @@ import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
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) {
|
||||
super(baritone, "waypoints", "waypoint", "wp");
|
||||
|
||||
@@ -37,7 +37,6 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -210,33 +209,10 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
return block.isPassable(bsi.access, bsi.isPassableBlockPos.setPos(x, y, z));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* canWalkThrough but also won't impede movement at all. so not including doors or fence gates (we'd have to right click),
|
||||
* not including water, and not including ladders or vines or cobwebs (they slow us down)
|
||||
*
|
||||
* @param context Calculation context to provide block state lookup
|
||||
* @param x The block's x position
|
||||
* @param y The block's y position
|
||||
* @param z The block's z position
|
||||
* @return Whether or not the block at the specified position
|
||||
*/
|
||||
static boolean fullyPassable(CalculationContext context, int x, int y, int z) {
|
||||
return fullyPassable(
|
||||
context.bsi.access,
|
||||
context.bsi.isPassableBlockPos.setPos(x, y, z),
|
||||
context.bsi.get0(x, y, z)
|
||||
);
|
||||
}
|
||||
|
||||
static boolean fullyPassable(IPlayerContext ctx, BlockPos pos) {
|
||||
return fullyPassable(ctx.world(), pos, ctx.world().getBlockState(pos));
|
||||
}
|
||||
|
||||
static boolean fullyPassable(IBlockAccess access, BlockPos pos, IBlockState state) {
|
||||
static Ternary fullyPassableBlockState(IBlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (block == Blocks.AIR) { // early return for most common case
|
||||
return true;
|
||||
return YES;
|
||||
}
|
||||
// exceptions - blocks that are isPassable true, but we can't actually jump through
|
||||
if (block == Blocks.FIRE
|
||||
@@ -252,10 +228,49 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
|| block instanceof BlockTrapDoor
|
||||
|| block instanceof BlockEndPortal
|
||||
|| block instanceof BlockSkull) {
|
||||
return false;
|
||||
return NO;
|
||||
}
|
||||
// door, fence gate, liquid, trapdoor have been accounted for, nothing else uses the world or pos parameters
|
||||
return block.isPassable(access, pos);
|
||||
// at least in 1.12.2 vanilla, that is.....
|
||||
try { // A dodgy catch-all at the end, for most blocks with default behaviour this will work, however where blocks are special this will error out, and we can handle it when we have this information
|
||||
if (block.isPassable(null, null)) {
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
} catch (Throwable exception) {
|
||||
// see PR #1087 for why
|
||||
System.out.println("The block " + state.getBlock().getLocalizedName() + " requires a special case due to the exception " + exception.getMessage());
|
||||
return MAYBE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* canWalkThrough but also won't impede movement at all. so not including doors or fence gates (we'd have to right click),
|
||||
* not including water, and not including ladders or vines or cobwebs (they slow us down)
|
||||
*/
|
||||
static boolean fullyPassable(CalculationContext context, int x, int y, int z) {
|
||||
return fullyPassable(context, x, y, z, context.get(x, y, z));
|
||||
}
|
||||
|
||||
static boolean fullyPassable(CalculationContext context, int x, int y, int z, IBlockState state) {
|
||||
return context.precomputedData.fullyPassable(context.bsi, x, y, z, state);
|
||||
}
|
||||
|
||||
static boolean fullyPassable(IPlayerContext ctx, BlockPos pos) {
|
||||
IBlockState state = ctx.world().getBlockState(pos);
|
||||
Ternary fullyPassable = fullyPassableBlockState(state);
|
||||
if (fullyPassable == YES) {
|
||||
return true;
|
||||
}
|
||||
if (fullyPassable == NO) {
|
||||
return false;
|
||||
}
|
||||
return fullyPassablePosition(new BlockStateInterface(ctx), pos.getX(), pos.getY(), pos.getZ(), state); // meh
|
||||
}
|
||||
|
||||
static boolean fullyPassablePosition(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
||||
return state.getBlock().isPassable(bsi.access, bsi.isPassableBlockPos.setPos(x, y, z));
|
||||
}
|
||||
|
||||
static boolean isReplaceable(int x, int y, int z, IBlockState state, BlockStateInterface bsi) {
|
||||
@@ -488,7 +503,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
if (context.assumeWalkOnWater) {
|
||||
return false;
|
||||
}
|
||||
Block blockAbove = context.getBlock(x, y+1, z);
|
||||
Block blockAbove = context.getBlock(x, y + 1, z);
|
||||
if (blockAbove instanceof BlockLiquid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -112,13 +112,13 @@ public class MovementParkour extends Movement {
|
||||
maxJump = 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check parkour jumps from smallest to largest for obstacles/walls and landing positions
|
||||
int verifiedMaxJump = 1; // i - 1 (when i = 2)
|
||||
for (int i = 2; i <= maxJump; i++) {
|
||||
int destX = x + xDiff * i;
|
||||
int destZ = z + zDiff * i;
|
||||
|
||||
|
||||
// check head/feet
|
||||
if (!MovementHelper.fullyPassable(context, destX, y + 1, destZ)) {
|
||||
break;
|
||||
@@ -126,10 +126,10 @@ public class MovementParkour extends Movement {
|
||||
if (!MovementHelper.fullyPassable(context, destX, y + 2, destZ)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// check for ascend landing position
|
||||
IBlockState destInto = context.bsi.get0(destX, y, destZ);
|
||||
if (!MovementHelper.fullyPassable(context.bsi.access, context.bsi.isPassableBlockPos.setPos(destX, y, destZ), destInto)) {
|
||||
if (!MovementHelper.fullyPassable(context, destX, y, destZ, destInto)) {
|
||||
if (i <= 3 && context.allowParkourAscend && context.canSprint && MovementHelper.canWalkOn(context, destX, y, destZ, destInto) && checkOvershootSafety(context.bsi, destX + xDiff, y + 1, destZ + zDiff)) {
|
||||
res.x = destX;
|
||||
res.y = y + 1;
|
||||
@@ -139,7 +139,7 @@ public class MovementParkour extends Movement {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// check for flat landing position
|
||||
IBlockState landingOn = context.bsi.get0(destX, y - 1, destZ);
|
||||
// farmland needs to be canWalkOn otherwise farm can never work at all, but we want to specifically disallow ending a jump on farmland haha
|
||||
@@ -156,14 +156,14 @@ public class MovementParkour extends Movement {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!MovementHelper.fullyPassable(context, destX, y + 3, destZ)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
verifiedMaxJump = i;
|
||||
}
|
||||
|
||||
|
||||
// parkour place starts here
|
||||
if (!context.allowParkourPlace) {
|
||||
return;
|
||||
|
||||
@@ -73,7 +73,7 @@ public class MovementTraverse extends Movement {
|
||||
IBlockState destOn = context.get(destX, y - 1, destZ);
|
||||
IBlockState srcDown = context.get(x, y - 1, z);
|
||||
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);
|
||||
if (frostWalker || MovementHelper.canWalkOn(context, destX, y - 1, destZ, destOn)) { //this is a walk, not a bridge
|
||||
double WC = WALK_ONE_BLOCK_COST;
|
||||
|
||||
@@ -25,7 +25,7 @@ import net.minecraft.block.state.IBlockState;
|
||||
import static baritone.pathing.precompute.Ternary.MAYBE;
|
||||
import static baritone.pathing.precompute.Ternary.YES;
|
||||
|
||||
public class PrecomputedData { // TODO add isFullyPassable
|
||||
public class PrecomputedData {
|
||||
|
||||
private final int[] data = new int[Block.BLOCK_STATE_IDS.size()];
|
||||
|
||||
@@ -34,6 +34,8 @@ public class PrecomputedData { // TODO add isFullyPassable
|
||||
private static final int CAN_WALK_ON_SPECIAL_MASK = 1 << 2;
|
||||
private static final int CAN_WALK_THROUGH_MASK = 1 << 3;
|
||||
private static final int CAN_WALK_THROUGH_SPECIAL_MASK = 1 << 4;
|
||||
private static final int FULLY_PASSABLE_MASK = 1 << 5;
|
||||
private static final int FULLY_PASSABLE_SPECIAL_MASK = 1 << 6;
|
||||
|
||||
private int fillData(int id, IBlockState state) {
|
||||
int blockData = 0;
|
||||
@@ -50,10 +52,18 @@ public class PrecomputedData { // TODO add isFullyPassable
|
||||
if (canWalkThroughState == YES) {
|
||||
blockData |= CAN_WALK_THROUGH_MASK;
|
||||
}
|
||||
if (canWalkOnState == MAYBE) {
|
||||
if (canWalkThroughState == MAYBE) {
|
||||
blockData |= CAN_WALK_THROUGH_SPECIAL_MASK;
|
||||
}
|
||||
|
||||
Ternary fullyPassableState = MovementHelper.fullyPassableBlockState(state);
|
||||
if (fullyPassableState == YES) {
|
||||
blockData |= FULLY_PASSABLE_MASK;
|
||||
}
|
||||
if (fullyPassableState == MAYBE) {
|
||||
blockData |= FULLY_PASSABLE_SPECIAL_MASK;
|
||||
}
|
||||
|
||||
blockData |= COMPLETED_MASK;
|
||||
|
||||
data[id] = blockData; // in theory, this is thread "safe" because every thread should compute the exact same int to write?
|
||||
@@ -89,4 +99,19 @@ public class PrecomputedData { // TODO add isFullyPassable
|
||||
return (blockData & CAN_WALK_THROUGH_MASK) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean fullyPassable(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
||||
int id = Block.BLOCK_STATE_IDS.get(state);
|
||||
int blockData = data[id];
|
||||
|
||||
if ((blockData & COMPLETED_MASK) == 0) { // we need to fill in the data
|
||||
blockData = fillData(id, state);
|
||||
}
|
||||
|
||||
if ((blockData & FULLY_PASSABLE_SPECIAL_MASK) != 0) {
|
||||
return MovementHelper.fullyPassablePosition(bsi, x, y, z, state);
|
||||
} else {
|
||||
return (blockData & FULLY_PASSABLE_MASK) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import baritone.cache.CachedChunk;
|
||||
import baritone.cache.WorldScanner;
|
||||
import baritone.pathing.movement.CalculationContext;
|
||||
import baritone.pathing.movement.MovementHelper;
|
||||
import baritone.pathing.precompute.PrecomputedData;
|
||||
import baritone.utils.BaritoneProcessHelper;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heuristic() {
|
||||
return Double.NEGATIVE_INFINITY;
|
||||
@@ -500,9 +500,9 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
}
|
||||
if (!Baritone.settings().allowBreak.value) {
|
||||
BlockOptionalMetaLookup f = new BlockOptionalMetaLookup(this.filter.blocks()
|
||||
.stream()
|
||||
.filter(e -> Baritone.settings().allowBreakAnyway.value.contains(e.getBlock()))
|
||||
.toArray(BlockOptionalMeta[]::new));
|
||||
.stream()
|
||||
.filter(e -> Baritone.settings().allowBreakAnyway.value.contains(e.getBlock()))
|
||||
.toArray(BlockOptionalMeta[]::new));
|
||||
if (f.blocks().isEmpty()) {
|
||||
logDirect("Unable to mine when allowBreak is false and target block is not in allowBreakAnyway!");
|
||||
return null;
|
||||
|
||||
@@ -211,8 +211,7 @@ public final class PathRenderer implements IRenderer {
|
||||
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 = 0.999F;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2));
|
||||
}
|
||||
if (goal instanceof IGoalRenderPos) {
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.init.Enchantments;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.item.Item.ToolMaterial;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.item.ItemTool;
|
||||
@@ -130,7 +129,7 @@ public class ToolSet {
|
||||
if (!Baritone.settings().useSwordToMine.value && itemStack.getItem() instanceof ItemSword) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (Baritone.settings().itemSaver.value && (itemStack.getItemDamage() + Baritone.settings().itemSaverThreshold.value) >= itemStack.getMaxDamage() && itemStack.getMaxDamage() > 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ public class SelectionSchematic extends MaskSchematic {
|
||||
public SelectionSchematic(ISchematic schematic, Vec3i origin, ISelection[] selections) {
|
||||
super(schematic);
|
||||
this.selections = Stream.of(selections).map(
|
||||
sel -> sel
|
||||
.shift(EnumFacing.WEST, origin.getX())
|
||||
.shift(EnumFacing.DOWN, origin.getY())
|
||||
.shift(EnumFacing.NORTH, origin.getZ()))
|
||||
sel -> sel
|
||||
.shift(EnumFacing.WEST, origin.getX())
|
||||
.shift(EnumFacing.DOWN, origin.getY())
|
||||
.shift(EnumFacing.NORTH, origin.getZ()))
|
||||
.toArray(ISelection[]::new);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class SelectionSchematic extends MaskSchematic {
|
||||
protected boolean partOfMask(int x, int y, int z, IBlockState currentState) {
|
||||
for (ISelection selection : selections) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public final class LitematicaSchematic extends StaticSchematic {
|
||||
* @return amount of bits used to encode a block.
|
||||
*/
|
||||
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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user