mirror of https://github.com/cabaletta/baritone
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: 'commons-io'
|
||||||
exclude module: 'log4j-core'
|
exclude module: 'log4j-core'
|
||||||
}
|
}
|
||||||
|
runtime launchCompile('dev.babbaj:nether-pathfinder:1.3')
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
|
implementation 'dev.babbaj:nether-pathfinder:1.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
mixin {
|
mixin {
|
||||||
|
@ -153,16 +155,16 @@ install {
|
||||||
def jarSAForgeName = String.format("%s-standalone-forge-%s", rootProject.name, version.toString())
|
def jarSAForgeName = String.format("%s-standalone-forge-%s", rootProject.name, version.toString())
|
||||||
|
|
||||||
artifacts {
|
artifacts {
|
||||||
archives file("$buildDir/libs/"+jarApiName+".jar")
|
archives file("$buildDir/libs/" + jarApiName + ".jar")
|
||||||
archives file("$buildDir/libs/"+jarApiForgeName+".jar")
|
archives file("$buildDir/libs/" + jarApiForgeName + ".jar")
|
||||||
archives file("$buildDir/libs/"+jarSAName+".jar")
|
archives file("$buildDir/libs/" + jarSAName + ".jar")
|
||||||
archives file("$buildDir/libs/"+jarSAForgeName+".jar")
|
archives file("$buildDir/libs/" + jarSAForgeName + ".jar")
|
||||||
}
|
}
|
||||||
repositories.mavenInstaller {
|
repositories.mavenInstaller {
|
||||||
addFilter('api') { artifact, file -> artifact.name == "baritone-api" }
|
addFilter('api') { artifact, file -> artifact.name == "baritone-api" }
|
||||||
addFilter('api-forge') { artifact, file -> artifact.name == "baritone-api-forge" }
|
addFilter('api-forge') { artifact, file -> artifact.name == "baritone-api-forge" }
|
||||||
addFilter('standalone') { artifact, file -> artifact.name == "baritone-standalone" }
|
addFilter('standalone') { artifact, file -> artifact.name == "baritone-standalone" }
|
||||||
addFilter('standalone-forge') { artifact, file -> artifact.name == "baritone-standalone-forge" }
|
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.behavior.Behavior;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import com.mojang.realmsclient.util.Pair;
|
import com.mojang.realmsclient.util.Pair;
|
||||||
|
import dev.babbaj.pathfinder.NetherPathfinder;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.item.EntityFireworkRocket;
|
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.RayTraceResult;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Elytra extends Behavior implements Helper {
|
public class Elytra extends Behavior implements Helper {
|
||||||
|
|
||||||
public static List<BetterBlockPos> path = new ArrayList<>();
|
public List<BetterBlockPos> path = new ArrayList<>();
|
||||||
|
|
||||||
static {
|
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());
|
||||||
try {
|
removeBacktracks();
|
||||||
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 int playerNear;
|
public int playerNear;
|
||||||
|
@ -211,6 +200,9 @@ public class Elytra extends Behavior implements Helper {
|
||||||
if (event.getType() == TickEvent.Type.OUT) {
|
if (event.getType() == TickEvent.Type.OUT) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
fixNearPlayer();
|
fixNearPlayer();
|
||||||
baritone.getInputOverrideHandler().clearAllKeys();
|
baritone.getInputOverrideHandler().clearAllKeys();
|
||||||
lines.clear();
|
lines.clear();
|
||||||
|
@ -425,7 +417,7 @@ public class Elytra extends Behavior implements Helper {
|
||||||
//System.out.println(playerNear);
|
//System.out.println(playerNear);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeBacktracks() {
|
public void removeBacktracks() {
|
||||||
Map<BetterBlockPos, Integer> positionFirstSeen = new HashMap<>();
|
Map<BetterBlockPos, Integer> positionFirstSeen = new HashMap<>();
|
||||||
for (int i = 0; i < path.size(); i++) {
|
for (int i = 0; i < path.size(); i++) {
|
||||||
BetterBlockPos pos = path.get(i);
|
BetterBlockPos pos = path.get(i);
|
||||||
|
|
|
@ -66,7 +66,8 @@ public final class DefaultCommands {
|
||||||
new WaypointsCommand(baritone),
|
new WaypointsCommand(baritone),
|
||||||
new CommandAlias(baritone, "sethome", "Sets your home waypoint", "waypoints save home"),
|
new CommandAlias(baritone, "sethome", "Sets your home waypoint", "waypoints save home"),
|
||||||
new CommandAlias(baritone, "home", "Path to your home waypoint", "waypoints goto 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);
|
ExecutionControlCommands prc = new ExecutionControlCommands(baritone);
|
||||||
commands.add(prc.pauseCommand);
|
commands.add(prc.pauseCommand);
|
||||||
|
|
|
@ -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;
|
package baritone.utils;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.Elytra;
|
|
||||||
import baritone.api.BaritoneAPI;
|
import baritone.api.BaritoneAPI;
|
||||||
import baritone.api.event.events.RenderEvent;
|
import baritone.api.event.events.RenderEvent;
|
||||||
import baritone.api.pathing.goals.*;
|
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(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) {
|
if (behavior.baritone.elytra.goal != null) {
|
||||||
drawGoal(renderView, new GoalBlock(behavior.baritone.elytra.goal), partialTicks, Color.GREEN);
|
drawGoal(renderView, new GoalBlock(behavior.baritone.elytra.goal), partialTicks, Color.GREEN);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue