mirror of
https://github.com/cabaletta/baritone
synced 2025-02-23 07:37:01 +00:00
Add renderElytraSimulation
setting
This commit is contained in:
parent
32b7c82650
commit
a1a3d93dc1
@ -56,6 +56,7 @@ public final class Settings {
|
||||
public final Setting<Boolean> conserveFireworks = new Setting<>(true);
|
||||
public final Setting<Boolean> renderRaytraces = new Setting<>(false);
|
||||
public final Setting<Boolean> renderHitboxRaytraces = new Setting<>(false);
|
||||
public final Setting<Boolean> renderElytraSimulation = new Setting<>(false);
|
||||
public final Setting<Boolean> elytraFreeLook = new Setting<>(false);
|
||||
|
||||
// Experimental Elytra Settings
|
||||
|
@ -56,6 +56,7 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
|
||||
// Used exclusively for PathRenderer
|
||||
public List<Pair<Vec3d, Vec3d>> clearLines;
|
||||
public List<Pair<Vec3d, Vec3d>> blockedLines;
|
||||
public List<Vec3d> simulationLine;
|
||||
public BlockPos aimPos;
|
||||
public List<BetterBlockPos> visiblePath;
|
||||
|
||||
@ -407,6 +408,7 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
|
||||
// Reset rendered elements
|
||||
this.clearLines.clear();
|
||||
this.blockedLines.clear();
|
||||
this.simulationLine = null;
|
||||
this.aimPos = null;
|
||||
|
||||
final List<BetterBlockPos> path = this.pathManager.getPath();
|
||||
@ -763,6 +765,7 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
|
||||
|
||||
Float bestPitch = null;
|
||||
double bestDot = Double.NEGATIVE_INFINITY;
|
||||
List<Vec3d> bestLine = null;
|
||||
|
||||
final Vec3d initialMotion = ctx.playerMotion();
|
||||
final AxisAlignedBB initialBB = ctx.player().getEntityBoundingBox();
|
||||
@ -776,6 +779,8 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
|
||||
Vec3d motion = initialMotion;
|
||||
AxisAlignedBB hitbox = initialBB;
|
||||
Vec3d totalMotion = Vec3d.ZERO;
|
||||
List<Vec3d> line = new ArrayList<>();
|
||||
line.add(totalMotion);
|
||||
|
||||
for (int i = 0; i < steps; i++) {
|
||||
if (MC_1_12_Collision_Fix.bonk(ctx, hitbox)) {
|
||||
@ -802,6 +807,7 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
|
||||
|
||||
hitbox = hitbox.offset(motion.x, motion.y, motion.z);
|
||||
totalMotion = totalMotion.add(motion);
|
||||
line.add(totalMotion);
|
||||
}
|
||||
double directionalGoodness = goalDirection.dotProduct(totalMotion.normalize());
|
||||
// tried to incorporate a "speedGoodness" but it kept making it do stupid stuff (aka always losing altitude)
|
||||
@ -809,8 +815,12 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
|
||||
if (goodness > bestDot) {
|
||||
bestDot = goodness;
|
||||
bestPitch = pitch;
|
||||
bestLine = line;
|
||||
}
|
||||
}
|
||||
if (bestLine != null) {
|
||||
this.simulationLine = bestLine;
|
||||
}
|
||||
return bestPitch;
|
||||
}
|
||||
|
||||
|
@ -122,6 +122,17 @@ public final class PathRenderer implements IRenderer {
|
||||
}
|
||||
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
|
||||
}
|
||||
if (elytra.simulationLine != null && Baritone.settings().renderElytraSimulation.value) {
|
||||
IRenderer.startLines(new Color(0x36CCDC), settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
for (int i = 0; i < elytra.simulationLine.size() - 1; i++) {
|
||||
Vec3d src = elytra.simulationLine.get(i);
|
||||
Vec3d dst = elytra.simulationLine.get(i + 1);
|
||||
// Center line on viewer pos
|
||||
buffer.pos(src.x, src.y, src.z).color(color[0], color[1], color[2], color[3]).endVertex();
|
||||
buffer.pos(dst.x, dst.y, dst.z).color(color[0], color[1], color[2], color[3]).endVertex();
|
||||
}
|
||||
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
|
||||
}
|
||||
|
||||
|
||||
// If there is a path calculation currently running, render the path calculation process
|
||||
|
Loading…
Reference in New Issue
Block a user