mirror of
https://github.com/cabaletta/baritone
synced 2025-02-19 21:46:56 +00:00
sort of integrated nether pathfinder
This commit is contained in:
parent
9672bd2c6d
commit
8df6778641
18
build.gradle
18
build.gradle
@ -100,7 +100,9 @@ dependencies {
|
||||
exclude module: 'commons-io'
|
||||
exclude module: 'log4j-core'
|
||||
}
|
||||
runtime launchCompile('dev.babbaj:nether-pathfinder:1.3')
|
||||
testImplementation 'junit:junit:4.12'
|
||||
implementation 'dev.babbaj:nether-pathfinder:1.3'
|
||||
}
|
||||
|
||||
mixin {
|
||||
@ -153,16 +155,16 @@ install {
|
||||
def jarSAForgeName = String.format("%s-standalone-forge-%s", rootProject.name, version.toString())
|
||||
|
||||
artifacts {
|
||||
archives file("$buildDir/libs/"+jarApiName+".jar")
|
||||
archives file("$buildDir/libs/"+jarApiForgeName+".jar")
|
||||
archives file("$buildDir/libs/"+jarSAName+".jar")
|
||||
archives file("$buildDir/libs/"+jarSAForgeName+".jar")
|
||||
archives file("$buildDir/libs/" + jarApiName + ".jar")
|
||||
archives file("$buildDir/libs/" + jarApiForgeName + ".jar")
|
||||
archives file("$buildDir/libs/" + jarSAName + ".jar")
|
||||
archives file("$buildDir/libs/" + jarSAForgeName + ".jar")
|
||||
}
|
||||
repositories.mavenInstaller {
|
||||
addFilter('api') { artifact, file -> artifact.name == "baritone-api" }
|
||||
addFilter('api-forge') { artifact, file -> artifact.name == "baritone-api-forge" }
|
||||
addFilter('standalone') { artifact, file -> artifact.name == "baritone-standalone" }
|
||||
addFilter('standalone-forge') { artifact, file -> artifact.name == "baritone-standalone-forge" }
|
||||
addFilter('api') { artifact, file -> artifact.name == "baritone-api" }
|
||||
addFilter('api-forge') { artifact, file -> artifact.name == "baritone-api-forge" }
|
||||
addFilter('standalone') { artifact, file -> artifact.name == "baritone-standalone" }
|
||||
addFilter('standalone-forge') { artifact, file -> artifact.name == "baritone-standalone-forge" }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ import baritone.api.utils.RotationUtils;
|
||||
import baritone.behavior.Behavior;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import com.mojang.realmsclient.util.Pair;
|
||||
import dev.babbaj.pathfinder.NetherPathfinder;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.item.EntityFireworkRocket;
|
||||
@ -36,28 +37,16 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Elytra extends Behavior implements Helper {
|
||||
|
||||
public static List<BetterBlockPos> path = new ArrayList<>();
|
||||
public List<BetterBlockPos> path = new ArrayList<>();
|
||||
|
||||
static {
|
||||
|
||||
try {
|
||||
DataInputStream in = new DataInputStream(new FileInputStream(new File("/Users/leijurv/Dropbox/nether-pathfinder/build/test")));
|
||||
int count = in.readInt();
|
||||
System.out.println("Count: " + count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
path.add(new BetterBlockPos((int) in.readDouble(), (int) in.readDouble(), (int) in.readDouble()));
|
||||
}
|
||||
removeBacktracks();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
public void path(BlockPos destination) {
|
||||
path = Arrays.stream(NetherPathfinder.pathFind(146008555100680L, false, false, ctx.playerFeet().x, ctx.playerFeet().y, ctx.playerFeet().z, destination.getX(), destination.getY(), destination.getZ())).mapToObj(BlockPos::fromLong).map(BetterBlockPos::new).collect(Collectors.toList());
|
||||
removeBacktracks();
|
||||
}
|
||||
|
||||
public int playerNear;
|
||||
@ -211,6 +200,9 @@ public class Elytra extends Behavior implements Helper {
|
||||
if (event.getType() == TickEvent.Type.OUT) {
|
||||
return;
|
||||
}
|
||||
if (path.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
fixNearPlayer();
|
||||
baritone.getInputOverrideHandler().clearAllKeys();
|
||||
lines.clear();
|
||||
@ -425,7 +417,7 @@ public class Elytra extends Behavior implements Helper {
|
||||
//System.out.println(playerNear);
|
||||
}
|
||||
|
||||
public static void removeBacktracks() {
|
||||
public void removeBacktracks() {
|
||||
Map<BetterBlockPos, Integer> positionFirstSeen = new HashMap<>();
|
||||
for (int i = 0; i < path.size(); i++) {
|
||||
BetterBlockPos pos = path.get(i);
|
||||
|
@ -66,7 +66,8 @@ public final class DefaultCommands {
|
||||
new WaypointsCommand(baritone),
|
||||
new CommandAlias(baritone, "sethome", "Sets your home waypoint", "waypoints save home"),
|
||||
new CommandAlias(baritone, "home", "Path to your home waypoint", "waypoints goto home"),
|
||||
new SelCommand(baritone)
|
||||
new SelCommand(baritone),
|
||||
new ElytraCommand(baritone)
|
||||
));
|
||||
ExecutionControlCommands prc = new ExecutionControlCommands(baritone);
|
||||
commands.add(prc.pauseCommand);
|
||||
|
61
src/main/java/baritone/command/defaults/ElytraCommand.java
Normal file
61
src/main/java/baritone/command/defaults/ElytraCommand.java
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.process.ICustomGoalProcess;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ElytraCommand extends Command {
|
||||
|
||||
public ElytraCommand(IBaritone baritone) {
|
||||
super(baritone, "elytra");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
||||
args.requireMax(0);
|
||||
GoalXZ goal = (GoalXZ) customGoalProcess.getGoal();
|
||||
((Baritone) baritone).elytra.path(new BlockPos(goal.getX(), 64, goal.getZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortDesc() {
|
||||
return "elytra time";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return Arrays.asList();
|
||||
}
|
||||
}
|
@ -18,7 +18,6 @@
|
||||
package baritone.utils;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.Elytra;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.event.events.RenderEvent;
|
||||
import baritone.api.pathing.goals.*;
|
||||
@ -106,7 +105,7 @@ public final class PathRenderer implements IRenderer {
|
||||
drawPath(next.getPath().positions(), 0, settings.colorNextPath.value, settings.fadePath.value, 10, 20);
|
||||
}
|
||||
|
||||
drawPath(Elytra.path.subList(Math.max(behavior.baritone.elytra.playerNear - 30, 0), Math.min(behavior.baritone.elytra.playerNear + 30, Elytra.path.size())), 0, Color.RED, false, 0, 0);
|
||||
drawPath(behavior.baritone.elytra.path.subList(Math.max(behavior.baritone.elytra.playerNear - 30, 0), Math.min(behavior.baritone.elytra.playerNear + 30, behavior.baritone.elytra.path.size())), 0, Color.RED, false, 0, 0);
|
||||
if (behavior.baritone.elytra.goal != null) {
|
||||
drawGoal(renderView, new GoalBlock(behavior.baritone.elytra.goal), partialTicks, Color.GREEN);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user