mirror of https://github.com/cabaletta/baritone
Add `experimentalRaytrace` setting for native raytrace
Update `nether-pathfinder` to 0.15
This commit is contained in:
parent
1da7ab2c22
commit
67efb7a5b6
|
@ -175,9 +175,9 @@ dependencies {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
launchAnnotationProcessor 'org.spongepowered:mixin:0.8.4-SNAPSHOT:processor'
|
launchAnnotationProcessor 'org.spongepowered:mixin:0.8.4-SNAPSHOT:processor'
|
||||||
launchImplementation('dev.babbaj:nether-pathfinder:0.12')
|
launchImplementation('dev.babbaj:nether-pathfinder:0.15')
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
implementation 'dev.babbaj:nether-pathfinder:0.12'
|
implementation 'dev.babbaj:nether-pathfinder:0.15'
|
||||||
}
|
}
|
||||||
|
|
||||||
mixin {
|
mixin {
|
||||||
|
|
|
@ -62,7 +62,10 @@ public final class Settings {
|
||||||
public final Setting<Boolean> conserveFireworks = new Setting<>(true);
|
public final Setting<Boolean> conserveFireworks = new Setting<>(true);
|
||||||
public final Setting<Boolean> renderRaytraces = new Setting<>(false);
|
public final Setting<Boolean> renderRaytraces = new Setting<>(false);
|
||||||
public final Setting<Boolean> elytraFreeLook = new Setting<>(false);
|
public final Setting<Boolean> elytraFreeLook = new Setting<>(false);
|
||||||
|
|
||||||
|
// Experimental Elytra Settings
|
||||||
public final Setting<Boolean> experimentalTakeoff = new Setting<>(false);
|
public final Setting<Boolean> experimentalTakeoff = new Setting<>(false);
|
||||||
|
public final Setting<Boolean> experimentalRaytrace = new Setting<>(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow Baritone to break blocks
|
* Allow Baritone to break blocks
|
||||||
|
|
|
@ -40,7 +40,6 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -169,9 +168,9 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
|
||||||
|
|
||||||
private Vec3d pathAt(int i) {
|
private Vec3d pathAt(int i) {
|
||||||
return new Vec3d(
|
return new Vec3d(
|
||||||
this.path.get(i).x + 0.000123,
|
this.path.get(i).x,
|
||||||
this.path.get(i).y + 0.000456,
|
this.path.get(i).y,
|
||||||
this.path.get(i).z + 0.000789
|
this.path.get(i).z
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,6 +501,44 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
|
||||||
}
|
}
|
||||||
|
|
||||||
final AxisAlignedBB bb = ctx.player().getEntityBoundingBox().grow(growAmount);
|
final AxisAlignedBB bb = ctx.player().getEntityBoundingBox().grow(growAmount);
|
||||||
|
|
||||||
|
if (Baritone.settings().experimentalRaytrace.value) {
|
||||||
|
final double ox = dest.x - start.x;
|
||||||
|
final double oy = dest.y - start.y;
|
||||||
|
final double oz = dest.z - start.z;
|
||||||
|
|
||||||
|
final double[] src = new double[] {
|
||||||
|
bb.minX, bb.minY, bb.minZ,
|
||||||
|
bb.minX, bb.minY, bb.maxZ,
|
||||||
|
bb.minX, bb.maxY, bb.minZ,
|
||||||
|
bb.minX, bb.maxY, bb.maxZ,
|
||||||
|
bb.maxX, bb.minY, bb.minZ,
|
||||||
|
bb.maxX, bb.minY, bb.maxZ,
|
||||||
|
bb.maxX, bb.maxY, bb.minZ,
|
||||||
|
bb.maxX, bb.maxY, bb.maxZ,
|
||||||
|
};
|
||||||
|
final double[] dst = new double[] {
|
||||||
|
bb.minX + ox, bb.minY + oy, bb.minZ + oz,
|
||||||
|
bb.minX + ox, bb.minY + oy, bb.maxZ + oz,
|
||||||
|
bb.minX + ox, bb.maxY + oy, bb.minZ + oz,
|
||||||
|
bb.minX + ox, bb.maxY + oy, bb.maxZ + oz,
|
||||||
|
bb.maxX + ox, bb.minY + oy, bb.minZ + oz,
|
||||||
|
bb.maxX + ox, bb.minY + oy, bb.maxZ + oz,
|
||||||
|
bb.maxX + ox, bb.maxY + oy, bb.minZ + oz,
|
||||||
|
bb.maxX + ox, bb.maxY + oy, bb.maxZ + oz,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Batch together all 8 traces
|
||||||
|
final boolean[] hitOut = new boolean[8];
|
||||||
|
this.context.raytrace(src, dst, hitOut);
|
||||||
|
for (boolean hit : hitOut) {
|
||||||
|
if (hit) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
final Vec3d[] corners = new Vec3d[]{
|
final Vec3d[] corners = new Vec3d[]{
|
||||||
new Vec3d(bb.minX, bb.minY, bb.minZ),
|
new Vec3d(bb.minX, bb.minY, bb.minZ),
|
||||||
new Vec3d(bb.minX, bb.minY, bb.maxZ),
|
new Vec3d(bb.minX, bb.minY, bb.maxZ),
|
||||||
|
@ -522,12 +559,12 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean clearView(Vec3d start, Vec3d dest) {
|
private boolean clearView(Vec3d start, Vec3d dest) {
|
||||||
boolean oxy = !rayTraceBlocks(start.x, start.y, start.z, dest.x, dest.y, dest.z);
|
boolean clear = !(Baritone.settings().experimentalRaytrace.value
|
||||||
boolean meow = !rayTraceBlocks(start, dest);
|
? this.context.raytrace(start.x, start.y, start.z, dest.x, dest.y, dest.z)
|
||||||
if (oxy != meow) {
|
: this.rayTraceBlocks(start.x, start.y, start.z, dest.x, dest.y, dest.z) // ox method
|
||||||
logDirect(start + " " + dest + " " + oxy + " " + meow);
|
);
|
||||||
}
|
|
||||||
if (oxy) {
|
if (clear) {
|
||||||
clearLines.add(new Pair<>(start, dest));
|
clearLines.add(new Pair<>(start, dest));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import dev.babbaj.pathfinder.NetherPathfinder;
|
||||||
import dev.babbaj.pathfinder.PathSegment;
|
import dev.babbaj.pathfinder.PathSegment;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.chunk.BlockStateContainer;
|
import net.minecraft.world.chunk.BlockStateContainer;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||||
|
@ -57,10 +58,30 @@ public final class NetherPathfinderContext {
|
||||||
this.context,
|
this.context,
|
||||||
src.getX(), src.getY(), src.getZ(),
|
src.getX(), src.getY(), src.getZ(),
|
||||||
dst.getX(), dst.getY(), dst.getZ(),
|
dst.getX(), dst.getY(), dst.getZ(),
|
||||||
true
|
true,
|
||||||
|
10000
|
||||||
), this.executor);
|
), this.executor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean raytrace(final double startX, final double startY, final double startZ,
|
||||||
|
final double endX, final double endY, final double endZ) {
|
||||||
|
final boolean[] hitOut = new boolean[1];
|
||||||
|
NetherPathfinder.raytrace(
|
||||||
|
this.context,
|
||||||
|
true,
|
||||||
|
1,
|
||||||
|
new double[] { startX, startY, startZ },
|
||||||
|
new double[] { endX, endY, endZ },
|
||||||
|
hitOut,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
return hitOut[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void raytrace(final double[] src, final double[] dst, final boolean[] hitOut) {
|
||||||
|
NetherPathfinder.raytrace(this.context, true, hitOut.length, src, dst, hitOut, null);
|
||||||
|
}
|
||||||
|
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
NetherPathfinder.cancel(this.context);
|
NetherPathfinder.cancel(this.context);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue