First version of selection stuff; nothing supports it yet
This commit is contained in:
@@ -28,6 +28,7 @@ import baritone.behavior.*;
|
||||
import baritone.cache.WorldProvider;
|
||||
import baritone.event.GameEventHandler;
|
||||
import baritone.process.*;
|
||||
import baritone.selection.SelectionManager;
|
||||
import baritone.utils.*;
|
||||
import baritone.utils.player.PrimaryPlayerContext;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -83,6 +84,7 @@ public class Baritone implements IBaritone {
|
||||
private FarmProcess farmProcess;
|
||||
|
||||
private PathingControlManager pathingControlManager;
|
||||
private SelectionManager selectionManager;
|
||||
|
||||
private IPlayerContext playerContext;
|
||||
private WorldProvider worldProvider;
|
||||
@@ -125,6 +127,7 @@ public class Baritone implements IBaritone {
|
||||
}
|
||||
|
||||
this.worldProvider = new WorldProvider();
|
||||
this.selectionManager = new SelectionManager();
|
||||
|
||||
if (BaritoneAutoTest.ENABLE_AUTO_TEST) {
|
||||
this.gameEventHandler.registerEventListener(BaritoneAutoTest.INSTANCE);
|
||||
@@ -203,6 +206,11 @@ public class Baritone implements IBaritone {
|
||||
return this.pathingBehavior;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectionManager getSelectionManager() {
|
||||
return selectionManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldProvider getWorldProvider() {
|
||||
return this.worldProvider;
|
||||
|
||||
129
src/main/java/baritone/selection/Selection.java
Normal file
129
src/main/java/baritone/selection/Selection.java
Normal file
@@ -0,0 +1,129 @@
|
||||
package baritone.selection;
|
||||
|
||||
import baritone.api.selection.ISelection;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
public class Selection implements ISelection {
|
||||
private final BetterBlockPos pos1;
|
||||
private final BetterBlockPos pos2;
|
||||
private final BetterBlockPos min;
|
||||
private final BetterBlockPos max;
|
||||
private final Vec3i size;
|
||||
private final AxisAlignedBB aabb;
|
||||
|
||||
public Selection(BetterBlockPos pos1, BetterBlockPos pos2) {
|
||||
this.pos1 = pos1;
|
||||
this.pos2 = pos2;
|
||||
|
||||
this.min = new BetterBlockPos(
|
||||
Math.min(pos1.x, pos2.x),
|
||||
Math.min(pos1.y, pos2.y),
|
||||
Math.min(pos1.z, pos2.z)
|
||||
);
|
||||
|
||||
this.max = new BetterBlockPos(
|
||||
Math.max(pos1.x, pos2.x),
|
||||
Math.max(pos1.y, pos2.y),
|
||||
Math.max(pos1.z, pos2.z)
|
||||
);
|
||||
|
||||
this.size = new Vec3i(
|
||||
max.x - min.x + 1,
|
||||
max.y - min.y + 1,
|
||||
max.z - min.z + 1
|
||||
);
|
||||
|
||||
this.aabb = new AxisAlignedBB(this.min, this.max.add(1, 1, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BetterBlockPos pos1() {
|
||||
return pos1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BetterBlockPos pos2() {
|
||||
return pos2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BetterBlockPos min() {
|
||||
return min;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BetterBlockPos max() {
|
||||
return max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3i size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB aabb() {
|
||||
return aabb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return pos1.hashCode() ^ pos2.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Selection{pos1=%s,pos2=%s}", pos1, pos2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Since it might not be immediately obvious what this does, let me explain.
|
||||
*
|
||||
* Let's say you specify EnumFacing.UP, this functions returns if pos2 is the highest BlockPos.
|
||||
* If you specify EnumFacing.DOWN, it returns if pos2 is the lowest BlockPos.
|
||||
*
|
||||
* @param facing The direction to check.
|
||||
* @return {@code true} if pos2 is further in that direction than pos1, {@code false} if it isn't, and something
|
||||
* else if they're both at the same position on that axis (it really doesn't matter)
|
||||
*/
|
||||
private boolean isPos2(EnumFacing facing) {
|
||||
boolean negative = facing.getAxisDirection().getOffset() < 0;
|
||||
|
||||
switch (facing.getAxis()) {
|
||||
case X:
|
||||
return (pos2.x > pos1.x) ^ negative;
|
||||
case Y:
|
||||
return (pos2.y > pos1.y) ^ negative;
|
||||
case Z:
|
||||
return (pos2.z > pos1.z) ^ negative;
|
||||
default:
|
||||
throw new IllegalStateException("Bad EnumFacing.Axis");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISelection expand(EnumFacing direction, int blocks) {
|
||||
if (isPos2(direction)) {
|
||||
return new Selection(pos1, pos2.offset(direction, blocks));
|
||||
} else {
|
||||
return new Selection(pos1.offset(direction, blocks), pos2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISelection contract(EnumFacing direction, int blocks) {
|
||||
if (isPos2(direction)) {
|
||||
return new Selection(pos1.offset(direction, -blocks), pos2);
|
||||
} else {
|
||||
return new Selection(pos1, pos2.offset(direction, -blocks));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISelection shift(EnumFacing direction, int blocks) {
|
||||
return new Selection(pos1.offset(direction, blocks), pos2.offset(direction, blocks));
|
||||
}
|
||||
}
|
||||
62
src/main/java/baritone/selection/SelectionManager.java
Normal file
62
src/main/java/baritone/selection/SelectionManager.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package baritone.selection;
|
||||
|
||||
import baritone.api.selection.ISelection;
|
||||
import baritone.api.selection.ISelectionManager;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class SelectionManager implements ISelectionManager {
|
||||
private final Set<ISelection> selections = new LinkedHashSet<>();
|
||||
private ISelection[] selectionsArr = new ISelection[0];
|
||||
|
||||
public SelectionManager() {
|
||||
new SelectionRenderer(this);
|
||||
}
|
||||
|
||||
private void resetSelectionsArr() {
|
||||
selectionsArr = selections.toArray(new ISelection[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ISelection addSelection(ISelection selection) {
|
||||
selections.add(selection);
|
||||
resetSelectionsArr();
|
||||
return selection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISelection addSelection(BetterBlockPos pos1, BetterBlockPos pos2) {
|
||||
return addSelection(new Selection(pos1, pos2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ISelection removeSelection(ISelection selection) {
|
||||
selections.remove(selection);
|
||||
resetSelectionsArr();
|
||||
return selection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ISelection[] removeAllSelections() {
|
||||
ISelection[] selectionsArr = getSelections();
|
||||
selections.clear();
|
||||
resetSelectionsArr();
|
||||
return selectionsArr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISelection[] getSelections() {
|
||||
return selectionsArr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ISelection getOnlySelection() {
|
||||
if (selections.size() == 1) {
|
||||
return selections.iterator().next();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
57
src/main/java/baritone/selection/SelectionRenderer.java
Normal file
57
src/main/java/baritone/selection/SelectionRenderer.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package baritone.selection;
|
||||
|
||||
import baritone.api.event.events.RenderEvent;
|
||||
import baritone.api.event.listener.AbstractGameEventListener;
|
||||
import baritone.api.selection.ISelection;
|
||||
import baritone.api.utils.IRenderer;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
||||
public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
|
||||
private final SelectionManager manager;
|
||||
|
||||
SelectionRenderer(SelectionManager manager) {
|
||||
this.manager = manager;
|
||||
baritone.getGameEventHandler().registerEventListener(this);
|
||||
}
|
||||
|
||||
public static void renderSelections(ISelection[] selections) {
|
||||
boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value;
|
||||
float lineWidth = settings.selectionRenderLineWidthPixels.value;
|
||||
|
||||
if (!settings.renderSelection.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
IRenderer.startLines(settings.colorSelection.value, lineWidth, ignoreDepth);
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
IRenderer.drawAABB(selection.aabb());
|
||||
}
|
||||
|
||||
IRenderer.endLines(ignoreDepth);
|
||||
|
||||
if (!settings.renderSelectionCorners.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
IRenderer.startLines(settings.colorSelectionPos1.value, lineWidth, ignoreDepth);
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
IRenderer.drawAABB(new AxisAlignedBB(selection.pos1(), selection.pos1().add(1, 1, 1)));
|
||||
}
|
||||
|
||||
IRenderer.endLines(ignoreDepth);
|
||||
IRenderer.startLines(settings.colorSelectionPos2.value, lineWidth, ignoreDepth);
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
IRenderer.drawAABB(new AxisAlignedBB(selection.pos2(), selection.pos2().add(1, 1, 1)));
|
||||
}
|
||||
|
||||
IRenderer.endLines(ignoreDepth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderPass(RenderEvent event) {
|
||||
renderSelections(manager.getSelections());
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import baritone.api.BaritoneAPI;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.pathing.goals.GoalTwoBlocks;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.IRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -110,7 +111,7 @@ public class GuiClick extends GuiScreen {
|
||||
GlStateManager.disableDepth();
|
||||
BetterBlockPos a = new BetterBlockPos(currentMouseOver);
|
||||
BetterBlockPos b = new BetterBlockPos(clickStart);
|
||||
PathRenderer.drawAABB(new AxisAlignedBB(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z), Math.max(a.x, b.x) + 1, Math.max(a.y, b.y) + 1, Math.max(a.z, b.z) + 1));
|
||||
IRenderer.drawAABB(new AxisAlignedBB(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z), Math.max(a.x, b.x) + 1, Math.max(a.y, b.y) + 1, Math.max(a.z, b.z) + 1));
|
||||
GlStateManager.enableDepth();
|
||||
|
||||
GlStateManager.depthMask(true);
|
||||
|
||||
@@ -17,20 +17,25 @@
|
||||
|
||||
package baritone.utils;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.event.events.RenderEvent;
|
||||
import baritone.api.pathing.calc.IPath;
|
||||
import baritone.api.pathing.goals.*;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalComposite;
|
||||
import baritone.api.pathing.goals.GoalGetToBlock;
|
||||
import baritone.api.pathing.goals.GoalInverted;
|
||||
import baritone.api.pathing.goals.GoalTwoBlocks;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.pathing.goals.GoalYLevel;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.utils.IRenderer;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import baritone.behavior.PathingBehavior;
|
||||
import baritone.pathing.path.PathExecutor;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -39,29 +44,30 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL11.GL_LIGHTING_BIT;
|
||||
import static org.lwjgl.opengl.GL11.GL_LINES;
|
||||
import static org.lwjgl.opengl.GL11.GL_LINE_LOOP;
|
||||
import static org.lwjgl.opengl.GL11.GL_LINE_STRIP;
|
||||
import static org.lwjgl.opengl.GL11.glPopAttrib;
|
||||
import static org.lwjgl.opengl.GL11.glPushAttrib;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/9/2018
|
||||
*/
|
||||
public final class PathRenderer implements Helper {
|
||||
|
||||
private static final Tessellator TESSELLATOR = Tessellator.getInstance();
|
||||
private static final BufferBuilder BUFFER = TESSELLATOR.getBuffer();
|
||||
|
||||
public final class PathRenderer implements IRenderer {
|
||||
private PathRenderer() {}
|
||||
|
||||
public static void render(RenderEvent event, PathingBehavior behavior) {
|
||||
float partialTicks = event.getPartialTicks();
|
||||
Goal goal = behavior.getGoal();
|
||||
if (mc.currentScreen instanceof GuiClick) {
|
||||
((GuiClick) mc.currentScreen).onRender();
|
||||
if (Helper.mc.currentScreen instanceof GuiClick) {
|
||||
((GuiClick) Helper.mc.currentScreen).onRender();
|
||||
}
|
||||
|
||||
int thisPlayerDimension = behavior.baritone.getPlayerContext().world().provider.getDimensionType().getId();
|
||||
@@ -72,7 +78,7 @@ public final class PathRenderer implements Helper {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity renderView = mc.getRenderViewEntity();
|
||||
Entity renderView = Helper.mc.getRenderViewEntity();
|
||||
|
||||
if (renderView.world != BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world()) {
|
||||
System.out.println("I have no idea what's going on");
|
||||
@@ -81,19 +87,20 @@ public final class PathRenderer implements Helper {
|
||||
return;
|
||||
}
|
||||
|
||||
if (goal != null && Baritone.settings().renderGoal.value) {
|
||||
drawDankLitGoalBox(renderView, goal, partialTicks, Baritone.settings().colorGoalBox.value);
|
||||
if (goal != null && settings.renderGoal.value) {
|
||||
drawDankLitGoalBox(renderView, goal, partialTicks, settings.colorGoalBox.value);
|
||||
}
|
||||
|
||||
if (!Baritone.settings().renderPath.value) {
|
||||
if (!settings.renderPath.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
PathExecutor current = behavior.getCurrent(); // this should prevent most race conditions?
|
||||
PathExecutor next = behavior.getNext(); // like, now it's not possible for current!=null to be true, then suddenly false because of another thread
|
||||
if (current != null && Baritone.settings().renderSelectionBoxes.value) {
|
||||
drawManySelectionBoxes(renderView, current.toBreak(), Baritone.settings().colorBlocksToBreak.value);
|
||||
drawManySelectionBoxes(renderView, current.toPlace(), Baritone.settings().colorBlocksToPlace.value);
|
||||
drawManySelectionBoxes(renderView, current.toWalkInto(), Baritone.settings().colorBlocksToWalkInto.value);
|
||||
if (current != null && settings.renderSelectionBoxes.value) {
|
||||
drawManySelectionBoxes(renderView, current.toBreak(), settings.colorBlocksToBreak.value);
|
||||
drawManySelectionBoxes(renderView, current.toPlace(), settings.colorBlocksToPlace.value);
|
||||
drawManySelectionBoxes(renderView, current.toWalkInto(), settings.colorBlocksToWalkInto.value);
|
||||
}
|
||||
|
||||
//drawManySelectionBoxes(player, Collections.singletonList(behavior.pathStart()), partialTicks, Color.WHITE);
|
||||
@@ -101,63 +108,51 @@ public final class PathRenderer implements Helper {
|
||||
// Render the current path, if there is one
|
||||
if (current != null && current.getPath() != null) {
|
||||
int renderBegin = Math.max(current.getPosition() - 3, 0);
|
||||
drawPath(current.getPath(), renderBegin, renderView, partialTicks, Baritone.settings().colorCurrentPath.value, Baritone.settings().fadePath.value, 10, 20);
|
||||
drawPath(current.getPath(), renderBegin, settings.colorCurrentPath.value, settings.fadePath.value, 10, 20);
|
||||
}
|
||||
|
||||
if (next != null && next.getPath() != null) {
|
||||
drawPath(next.getPath(), 0, renderView, partialTicks, Baritone.settings().colorNextPath.value, Baritone.settings().fadePath.value, 10, 20);
|
||||
drawPath(next.getPath(), 0, settings.colorNextPath.value, settings.fadePath.value, 10, 20);
|
||||
}
|
||||
|
||||
// If there is a path calculation currently running, render the path calculation process
|
||||
behavior.getInProgress().ifPresent(currentlyRunning -> {
|
||||
currentlyRunning.bestPathSoFar().ifPresent(p -> {
|
||||
drawPath(p, 0, renderView, partialTicks, Baritone.settings().colorBestPathSoFar.value, Baritone.settings().fadePath.value, 10, 20);
|
||||
drawPath(p, 0, settings.colorBestPathSoFar.value, settings.fadePath.value, 10, 20);
|
||||
});
|
||||
currentlyRunning.pathToMostRecentNodeConsidered().ifPresent(mr -> {
|
||||
|
||||
drawPath(mr, 0, renderView, partialTicks, Baritone.settings().colorMostRecentConsidered.value, Baritone.settings().fadePath.value, 10, 20);
|
||||
drawManySelectionBoxes(renderView, Collections.singletonList(mr.getDest()), Baritone.settings().colorMostRecentConsidered.value);
|
||||
currentlyRunning.pathToMostRecentNodeConsidered().ifPresent(mr -> {
|
||||
drawPath(mr, 0, settings.colorMostRecentConsidered.value, settings.fadePath.value, 10, 20);
|
||||
drawManySelectionBoxes(renderView, Collections.singletonList(mr.getDest()), settings.colorMostRecentConsidered.value);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static void drawPath(IPath path, int startIndex, Entity player, float partialTicks, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||
GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F);
|
||||
GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.depthMask(false);
|
||||
if (Baritone.settings().renderPathIgnoreDepth.value) {
|
||||
GlStateManager.disableDepth();
|
||||
}
|
||||
List<BetterBlockPos> positions = path.positions();
|
||||
int next;
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
public static void drawPath(IPath path, int startIndex, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) {
|
||||
IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
|
||||
int fadeStart = fadeStart0 + startIndex;
|
||||
int fadeEnd = fadeEnd0 + startIndex;
|
||||
for (int i = startIndex; i < positions.size() - 1; i = next) {
|
||||
BetterBlockPos start = positions.get(i);
|
||||
|
||||
next = i + 1;
|
||||
BetterBlockPos end = positions.get(next);
|
||||
List<BetterBlockPos> positions = path.positions();
|
||||
for (int i = startIndex, next; i < positions.size() - 1; i = next) {
|
||||
BetterBlockPos start = positions.get(i);
|
||||
BetterBlockPos end = positions.get(next = i + 1);
|
||||
|
||||
int dirX = end.x - start.x;
|
||||
int dirY = end.y - start.y;
|
||||
int dirZ = end.z - start.z;
|
||||
while (next + 1 < positions.size() && (!fadeOut || next + 1 < fadeStart) && (dirX == positions.get(next + 1).x - end.x && dirY == positions.get(next + 1).y - end.y && dirZ == positions.get(next + 1).z - end.z)) {
|
||||
next++;
|
||||
end = positions.get(next);
|
||||
}
|
||||
double x1 = start.x;
|
||||
double y1 = start.y;
|
||||
double z1 = start.z;
|
||||
double x2 = end.x;
|
||||
double y2 = end.y;
|
||||
double z2 = end.z;
|
||||
if (fadeOut) {
|
||||
|
||||
while (next + 1 < positions.size() && (!fadeOut || next + 1 < fadeStart) &&
|
||||
(dirX == positions.get(next + 1).x - end.x &&
|
||||
dirY == positions.get(next + 1).y - end.y &&
|
||||
dirZ == positions.get(next + 1).z - end.z)) {
|
||||
end = positions.get(++next);
|
||||
}
|
||||
|
||||
if (fadeOut) {
|
||||
float alpha;
|
||||
|
||||
if (i <= fadeStart) {
|
||||
alpha = 0.4F;
|
||||
} else {
|
||||
@@ -166,114 +161,68 @@ public final class PathRenderer implements Helper {
|
||||
}
|
||||
alpha = 0.4F * (1.0F - (float) (i - fadeStart) / (float) (fadeEnd - fadeStart));
|
||||
}
|
||||
GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], alpha);
|
||||
|
||||
float[] components = color.getComponents(null);
|
||||
GlStateManager.color(components[0], components[1], components[2], alpha);
|
||||
}
|
||||
drawLine(x1, y1, z1, x2, y2, z2);
|
||||
|
||||
drawLine(start.x, start.y, start.z, end.x, end.y, end.z);
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
if (Baritone.settings().renderPathIgnoreDepth.value) {
|
||||
GlStateManager.enableDepth();
|
||||
}
|
||||
//GlStateManager.color(0.0f, 0.0f, 0.0f, 0.4f);
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.disableBlend();
|
||||
|
||||
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
|
||||
}
|
||||
|
||||
public static void drawLine(double bp1x, double bp1y, double bp1z, double bp2x, double bp2y, double bp2z) {
|
||||
double d0 = mc.getRenderManager().viewerPosX;
|
||||
double d1 = mc.getRenderManager().viewerPosY;
|
||||
double d2 = mc.getRenderManager().viewerPosZ;
|
||||
boolean renderPathAsFrickinThingy = !Baritone.settings().renderPathAsLine.value;
|
||||
public static void drawLine(double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
RenderManager renderManager = Helper.mc.getRenderManager();
|
||||
double vpX = renderManager.viewerPosX;
|
||||
double vpY = renderManager.viewerPosY;
|
||||
double vpZ = renderManager.viewerPosZ;
|
||||
boolean renderPathAsFrickinThingy = !settings.renderPathAsLine.value;
|
||||
|
||||
BUFFER.begin(renderPathAsFrickinThingy ? GL_LINE_STRIP : GL_LINES, DefaultVertexFormats.POSITION);
|
||||
BUFFER.pos(bp1x + 0.5D - d0, bp1y + 0.5D - d1, bp1z + 0.5D - d2).endVertex();
|
||||
BUFFER.pos(bp2x + 0.5D - d0, bp2y + 0.5D - d1, bp2z + 0.5D - d2).endVertex();
|
||||
buffer.begin(renderPathAsFrickinThingy ? GL_LINE_STRIP : GL_LINES, DefaultVertexFormats.POSITION);
|
||||
buffer.pos(x1 + 0.5D - vpX, y1 + 0.5D - vpY, z1 + 0.5D - vpZ).endVertex();
|
||||
buffer.pos(x2 + 0.5D - vpX, y2 + 0.5D - vpY, z2 + 0.5D - vpZ).endVertex();
|
||||
|
||||
if (renderPathAsFrickinThingy) {
|
||||
BUFFER.pos(bp2x + 0.5D - d0, bp2y + 0.53D - d1, bp2z + 0.5D - d2).endVertex();
|
||||
BUFFER.pos(bp1x + 0.5D - d0, bp1y + 0.53D - d1, bp1z + 0.5D - d2).endVertex();
|
||||
BUFFER.pos(bp1x + 0.5D - d0, bp1y + 0.5D - d1, bp1z + 0.5D - d2).endVertex();
|
||||
buffer.pos(x2 + 0.5D - vpX, y2 + 0.53D - vpY, z2 + 0.5D - vpZ).endVertex();
|
||||
buffer.pos(x1 + 0.5D - vpX, y1 + 0.53D - vpY, z1 + 0.5D - vpZ).endVertex();
|
||||
buffer.pos(x1 + 0.5D - vpX, y1 + 0.5D - vpY, z1 + 0.5D - vpZ).endVertex();
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawManySelectionBoxes(Entity player, Collection<BlockPos> positions, Color color) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F);
|
||||
GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.depthMask(false);
|
||||
|
||||
if (Baritone.settings().renderSelectionBoxesIgnoreDepth.value) {
|
||||
GlStateManager.disableDepth();
|
||||
}
|
||||
|
||||
IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderSelectionBoxesIgnoreDepth.value);
|
||||
|
||||
//BlockPos blockpos = movingObjectPositionIn.getBlockPos();
|
||||
BlockStateInterface bsi = new BlockStateInterface(BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext()); // TODO this assumes same dimension between primary baritone and render view? is this safe?
|
||||
|
||||
positions.forEach(pos -> {
|
||||
IBlockState state = bsi.get0(pos);
|
||||
AxisAlignedBB toDraw;
|
||||
|
||||
if (state.getBlock().equals(Blocks.AIR)) {
|
||||
toDraw = Blocks.DIRT.getDefaultState().getSelectedBoundingBox(player.world, pos);
|
||||
} else {
|
||||
toDraw = state.getSelectedBoundingBox(player.world, pos);
|
||||
}
|
||||
drawAABB(toDraw);
|
||||
|
||||
IRenderer.drawAABB(toDraw);
|
||||
});
|
||||
|
||||
if (Baritone.settings().renderSelectionBoxesIgnoreDepth.value) {
|
||||
GlStateManager.enableDepth();
|
||||
}
|
||||
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
|
||||
public static void drawAABB(AxisAlignedBB aabb) {
|
||||
float expand = 0.002F;
|
||||
AxisAlignedBB toDraw = aabb.expand(expand, expand, expand).offset(-mc.getRenderManager().viewerPosX, -mc.getRenderManager().viewerPosY, -mc.getRenderManager().viewerPosZ);
|
||||
BUFFER.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION);
|
||||
BUFFER.pos(toDraw.minX, toDraw.minY, toDraw.minZ).endVertex();
|
||||
BUFFER.pos(toDraw.maxX, toDraw.minY, toDraw.minZ).endVertex();
|
||||
BUFFER.pos(toDraw.maxX, toDraw.minY, toDraw.maxZ).endVertex();
|
||||
BUFFER.pos(toDraw.minX, toDraw.minY, toDraw.maxZ).endVertex();
|
||||
BUFFER.pos(toDraw.minX, toDraw.minY, toDraw.minZ).endVertex();
|
||||
TESSELLATOR.draw();
|
||||
BUFFER.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION);
|
||||
BUFFER.pos(toDraw.minX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||
BUFFER.pos(toDraw.maxX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||
BUFFER.pos(toDraw.maxX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||
BUFFER.pos(toDraw.minX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||
BUFFER.pos(toDraw.minX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||
TESSELLATOR.draw();
|
||||
BUFFER.begin(GL_LINES, DefaultVertexFormats.POSITION);
|
||||
BUFFER.pos(toDraw.minX, toDraw.minY, toDraw.minZ).endVertex();
|
||||
BUFFER.pos(toDraw.minX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||
BUFFER.pos(toDraw.maxX, toDraw.minY, toDraw.minZ).endVertex();
|
||||
BUFFER.pos(toDraw.maxX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||
BUFFER.pos(toDraw.maxX, toDraw.minY, toDraw.maxZ).endVertex();
|
||||
BUFFER.pos(toDraw.maxX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||
BUFFER.pos(toDraw.minX, toDraw.minY, toDraw.maxZ).endVertex();
|
||||
BUFFER.pos(toDraw.minX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||
TESSELLATOR.draw();
|
||||
IRenderer.endLines(settings.renderSelectionBoxesIgnoreDepth.value);
|
||||
}
|
||||
|
||||
public static void drawDankLitGoalBox(Entity player, Goal goal, float partialTicks, Color color) {
|
||||
double renderPosX = mc.getRenderManager().viewerPosX;
|
||||
double renderPosY = mc.getRenderManager().viewerPosY;
|
||||
double renderPosZ = mc.getRenderManager().viewerPosZ;
|
||||
double minX;
|
||||
double maxX;
|
||||
double minZ;
|
||||
double maxZ;
|
||||
double minY;
|
||||
double maxY;
|
||||
double y1;
|
||||
double y2;
|
||||
RenderManager renderManager = Helper.mc.getRenderManager();
|
||||
double renderPosX = renderManager.viewerPosX;
|
||||
double renderPosY = renderManager.viewerPosY;
|
||||
double renderPosZ = renderManager.viewerPosZ;
|
||||
double minX, maxX;
|
||||
double minZ, maxZ;
|
||||
double minY, maxY;
|
||||
double y1, y2;
|
||||
double y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2));
|
||||
if (goal instanceof IGoalRenderPos) {
|
||||
BlockPos goalPos = ((IGoalRenderPos) goal).getGoalPos();
|
||||
@@ -296,28 +245,28 @@ public final class PathRenderer implements Helper {
|
||||
} else if (goal instanceof GoalXZ) {
|
||||
GoalXZ goalPos = (GoalXZ) goal;
|
||||
|
||||
if (Baritone.settings().renderGoalXZBeacon.value) {
|
||||
if (settings.renderGoalXZBeacon.value) {
|
||||
glPushAttrib(GL_LIGHTING_BIT);
|
||||
|
||||
mc.getTextureManager().bindTexture(TileEntityBeaconRenderer.TEXTURE_BEACON_BEAM);
|
||||
Helper.mc.getTextureManager().bindTexture(TileEntityBeaconRenderer.TEXTURE_BEACON_BEAM);
|
||||
|
||||
if (Baritone.settings().renderGoalIgnoreDepth.value) {
|
||||
if (settings.renderGoalIgnoreDepth.value) {
|
||||
GlStateManager.disableDepth();
|
||||
}
|
||||
|
||||
TileEntityBeaconRenderer.renderBeamSegment(
|
||||
goalPos.getX() - renderPosX,
|
||||
-renderPosY,
|
||||
goalPos.getZ() - renderPosZ,
|
||||
partialTicks,
|
||||
1.0,
|
||||
player.world.getTotalWorldTime(),
|
||||
0,
|
||||
256,
|
||||
color.getColorComponents(null)
|
||||
goalPos.getX() - renderPosX,
|
||||
-renderPosY,
|
||||
goalPos.getZ() - renderPosZ,
|
||||
partialTicks,
|
||||
1.0,
|
||||
player.world.getTotalWorldTime(),
|
||||
0,
|
||||
256,
|
||||
color.getColorComponents(null)
|
||||
);
|
||||
|
||||
if (Baritone.settings().renderGoalIgnoreDepth.value) {
|
||||
if (settings.renderGoalIgnoreDepth.value) {
|
||||
GlStateManager.enableDepth();
|
||||
}
|
||||
|
||||
@@ -340,14 +289,14 @@ public final class PathRenderer implements Helper {
|
||||
}
|
||||
return;
|
||||
} else if (goal instanceof GoalInverted) {
|
||||
drawDankLitGoalBox(player, ((GoalInverted) goal).origin, partialTicks, Baritone.settings().colorInvertedGoalBox.value);
|
||||
drawDankLitGoalBox(player, ((GoalInverted) goal).origin, partialTicks, settings.colorInvertedGoalBox.value);
|
||||
return;
|
||||
} else if (goal instanceof GoalYLevel) {
|
||||
GoalYLevel goalpos = (GoalYLevel) goal;
|
||||
minX = player.posX - Baritone.settings().yLevelBoxSize.value - renderPosX;
|
||||
minZ = player.posZ - Baritone.settings().yLevelBoxSize.value - renderPosZ;
|
||||
maxX = player.posX + Baritone.settings().yLevelBoxSize.value - renderPosX;
|
||||
maxZ = player.posZ + Baritone.settings().yLevelBoxSize.value - renderPosZ;
|
||||
minX = player.posX - settings.yLevelBoxSize.value - renderPosX;
|
||||
minZ = player.posZ - settings.yLevelBoxSize.value - renderPosZ;
|
||||
maxX = player.posX + settings.yLevelBoxSize.value - renderPosX;
|
||||
maxZ = player.posZ + settings.yLevelBoxSize.value - renderPosZ;
|
||||
minY = ((GoalYLevel) goal).level - renderPosY;
|
||||
maxY = minY + 2;
|
||||
y1 = 1 + y + goalpos.level - renderPosY;
|
||||
@@ -356,46 +305,33 @@ public final class PathRenderer implements Helper {
|
||||
return;
|
||||
}
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.6F);
|
||||
GlStateManager.glLineWidth(Baritone.settings().goalRenderLineWidthPixels.value);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.depthMask(false);
|
||||
if (Baritone.settings().renderGoalIgnoreDepth.value) {
|
||||
GlStateManager.disableDepth();
|
||||
}
|
||||
IRenderer.startLines(color, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
|
||||
|
||||
renderHorizontalQuad(minX, maxX, minZ, maxZ, y1);
|
||||
renderHorizontalQuad(minX, maxX, minZ, maxZ, y2);
|
||||
|
||||
BUFFER.begin(GL_LINES, DefaultVertexFormats.POSITION);
|
||||
BUFFER.pos(minX, minY, minZ).endVertex();
|
||||
BUFFER.pos(minX, maxY, minZ).endVertex();
|
||||
BUFFER.pos(maxX, minY, minZ).endVertex();
|
||||
BUFFER.pos(maxX, maxY, minZ).endVertex();
|
||||
BUFFER.pos(maxX, minY, maxZ).endVertex();
|
||||
BUFFER.pos(maxX, maxY, maxZ).endVertex();
|
||||
BUFFER.pos(minX, minY, maxZ).endVertex();
|
||||
BUFFER.pos(minX, maxY, maxZ).endVertex();
|
||||
TESSELLATOR.draw();
|
||||
buffer.begin(GL_LINES, DefaultVertexFormats.POSITION);
|
||||
buffer.pos(minX, minY, minZ).endVertex();
|
||||
buffer.pos(minX, maxY, minZ).endVertex();
|
||||
buffer.pos(maxX, minY, minZ).endVertex();
|
||||
buffer.pos(maxX, maxY, minZ).endVertex();
|
||||
buffer.pos(maxX, minY, maxZ).endVertex();
|
||||
buffer.pos(maxX, maxY, maxZ).endVertex();
|
||||
buffer.pos(minX, minY, maxZ).endVertex();
|
||||
buffer.pos(minX, maxY, maxZ).endVertex();
|
||||
tessellator.draw();
|
||||
|
||||
if (Baritone.settings().renderGoalIgnoreDepth.value) {
|
||||
GlStateManager.enableDepth();
|
||||
}
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.disableBlend();
|
||||
IRenderer.endLines(settings.renderGoalIgnoreDepth.value);
|
||||
}
|
||||
|
||||
private static void renderHorizontalQuad(double minX, double maxX, double minZ, double maxZ, double y) {
|
||||
if (y != 0) {
|
||||
BUFFER.begin(GL_LINE_LOOP, DefaultVertexFormats.POSITION);
|
||||
BUFFER.pos(minX, y, minZ).endVertex();
|
||||
BUFFER.pos(maxX, y, minZ).endVertex();
|
||||
BUFFER.pos(maxX, y, maxZ).endVertex();
|
||||
BUFFER.pos(minX, y, maxZ).endVertex();
|
||||
TESSELLATOR.draw();
|
||||
buffer.begin(GL_LINE_LOOP, DefaultVertexFormats.POSITION);
|
||||
buffer.pos(minX, y, minZ).endVertex();
|
||||
buffer.pos(maxX, y, minZ).endVertex();
|
||||
buffer.pos(maxX, y, maxZ).endVertex();
|
||||
buffer.pos(minX, y, maxZ).endVertex();
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user