DrawAABB changes, set command bugfix, sel rendering change, selection setting name changes

This commit is contained in:
Logan Darklock 2019-09-03 23:46:20 -07:00
parent 8dc4ff26d6
commit 382ad0079c
No known key found for this signature in database
GPG Key ID: B8C37CEDE1AC60EA
6 changed files with 54 additions and 65 deletions

View File

@ -528,21 +528,6 @@ public final class Settings {
*/ */
public final Setting<Boolean> renderPathIgnoreDepth = new Setting<>(true); public final Setting<Boolean> renderPathIgnoreDepth = new Setting<>(true);
/**
* Ignore depth when rendering selections
*/
public final Setting<Boolean> renderSelectionIgnoreDepth = new Setting<>(true);
/**
* Render selections
*/
public final Setting<Boolean> renderSelection = new Setting<>(true);
/**
* Render selection corners
*/
public final Setting<Boolean> renderSelectionCorners = new Setting<>(true);
/** /**
* Line width of the path when rendered, in pixels * Line width of the path when rendered, in pixels
*/ */
@ -553,11 +538,6 @@ public final class Settings {
*/ */
public final Setting<Float> goalRenderLineWidthPixels = new Setting<>(3F); public final Setting<Float> goalRenderLineWidthPixels = new Setting<>(3F);
/**
* Line width of the goal when rendered, in pixels
*/
public final Setting<Float> selectionRenderLineWidthPixels = new Setting<>(3F);
/** /**
* Start fading out the path at 20 movements ahead, and stop rendering it entirely 30 movements ahead. * Start fading out the path at 20 movements ahead, and stop rendering it entirely 30 movements ahead.
* Improves FPS. * Improves FPS.
@ -958,22 +938,42 @@ public final class Settings {
/** /**
* The color of all selections * The color of all selections
*/ */
public final Setting<Color> colorSelection = new Setting<>(Color.GREEN); public final Setting<Color> colorSelection = new Setting<>(Color.CYAN);
/** /**
* The color of the selection pos 1 * The color of the selection pos 1
*/ */
public final Setting<Color> colorSelectionPos1 = new Setting<>(Color.PINK); public final Setting<Color> colorSelectionPos1 = new Setting<>(Color.BLACK);
/** /**
* The color of the selection pos 2 * The color of the selection pos 2
*/ */
public final Setting<Color> colorSelectionPos2 = new Setting<>(Color.PINK); public final Setting<Color> colorSelectionPos2 = new Setting<>(Color.ORANGE);
/** /**
* The opacity of the selection. The default (0.4) is what's used for goals and such * The opacity of the selection. 0 is completely transparent, 1 is completely opaque
*/ */
public final Setting<Float> selectionOpacity = new Setting<>(.4f); public final Setting<Float> selectionOpacity = new Setting<>(.5f);
/**
* Line width of the goal when rendered, in pixels
*/
public final Setting<Float> selectionLineWidth = new Setting<>(1F);
/**
* Render selections
*/
public final Setting<Boolean> renderSelection = new Setting<>(true);
/**
* Ignore depth when rendering selections
*/
public final Setting<Boolean> renderSelectionIgnoreDepth = new Setting<>(true);
/**
* Render selection corners
*/
public final Setting<Boolean> renderSelectionCorners = new Setting<>(true);
/** /**

View File

@ -25,12 +25,16 @@ public interface IRenderer {
IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone(); IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone();
Settings settings = BaritoneAPI.getSettings(); Settings settings = BaritoneAPI.getSettings();
static void glColor(Color color, float alpha) {
float[] colorComponents = color.getColorComponents(null);
GlStateManager.color(colorComponents[0], colorComponents[1], colorComponents[2], alpha);
}
static void startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) { static void startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) {
GlStateManager.enableBlend(); GlStateManager.enableBlend();
GlStateManager.disableLighting(); GlStateManager.disableLighting();
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
float[] colorComponents = color.getColorComponents(null); glColor(color, alpha);
GlStateManager.color(colorComponents[0], colorComponents[1], colorComponents[2], alpha);
GlStateManager.glLineWidth(lineWidth); GlStateManager.glLineWidth(lineWidth);
GlStateManager.disableTexture2D(); GlStateManager.disableTexture2D();
GlStateManager.depthMask(false); GlStateManager.depthMask(false);
@ -55,10 +59,8 @@ public interface IRenderer {
GlStateManager.disableBlend(); GlStateManager.disableBlend();
} }
static void drawAABB(AxisAlignedBB aabb, float expand) { static void drawAABB(AxisAlignedBB aabb) {
AxisAlignedBB toDraw = aabb AxisAlignedBB toDraw = aabb.offset(-renderManager.viewerPosX, -renderManager.viewerPosY, -renderManager.viewerPosZ);
.offset(-renderManager.viewerPosX, -renderManager.viewerPosY, -renderManager.viewerPosZ)
.grow(expand, expand, expand);
buffer.begin(GL_LINES, DefaultVertexFormats.POSITION); buffer.begin(GL_LINES, DefaultVertexFormats.POSITION);
// bottom // bottom
@ -91,7 +93,7 @@ public interface IRenderer {
tessellator.draw(); tessellator.draw();
} }
static void drawAABB(AxisAlignedBB aabb) { static void drawAABB(AxisAlignedBB aabb, float expand) {
drawAABB(aabb, 0.002f); drawAABB(aabb.grow(expand, expand, expand));
} }
} }

View File

@ -365,11 +365,11 @@ public class SelCommand extends Command {
Color color = settings.colorSelectionPos1.value; Color color = settings.colorSelectionPos1.value;
float opacity = settings.selectionOpacity.value; float opacity = settings.selectionOpacity.value;
float lineWidth = settings.selectionRenderLineWidthPixels.value; float lineWidth = settings.selectionLineWidth.value;
boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value; boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value;
IRenderer.startLines(color, opacity, lineWidth, ignoreDepth); IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
IRenderer.drawAABB(new AxisAlignedBB(pos1, pos1.add(1, 1, 1)), -.01f); IRenderer.drawAABB(new AxisAlignedBB(pos1, pos1.add(1, 1, 1)));
IRenderer.endLines(ignoreDepth); IRenderer.endLines(ignoreDepth);
} }
} }

View File

@ -61,30 +61,24 @@ public class SetCommand extends Command {
boolean viewModified = asList("m", "mod", "modified").contains(arg); boolean viewModified = asList("m", "mod", "modified").contains(arg);
boolean viewAll = asList("all", "l", "list").contains(arg); boolean viewAll = asList("all", "l", "list").contains(arg);
boolean paginate = viewModified | viewAll; boolean paginate = viewModified || viewAll;
if (paginate) { if (paginate) {
String search = args.has() && args.peekAsOrNull(Integer.class) == null ? args.getString() : ""; String search = args.has() && args.peekAsOrNull(Integer.class) == null ? args.getString() : "";
args.requireMax(1); args.requireMax(1);
List<? extends Settings.Setting> toPaginate = List<? extends Settings.Setting> toPaginate =
viewModified (viewModified ? SettingsUtil.modifiedSettings(settings) : settings.allSettings).stream()
? SettingsUtil.modifiedSettings(settings)
: settings.allSettings.stream()
.filter(s -> !s.getName().equals("logger")) .filter(s -> !s.getName().equals("logger"))
.filter(s -> s.getName().toLowerCase(Locale.US).contains(search.toLowerCase(Locale.US))) .filter(s -> s.getName().toLowerCase(Locale.US).contains(search.toLowerCase(Locale.US)))
.sorted((s1, s2) -> String.CASE_INSENSITIVE_ORDER.compare(s1.getName(), s2.getName()))
.collect(Collectors.toCollection(ArrayList<Settings.Setting>::new)); .collect(Collectors.toCollection(ArrayList<Settings.Setting>::new));
toPaginate.sort((setting1, setting2) -> String.CASE_INSENSITIVE_ORDER.compare(
setting1.getName(),
setting2.getName()
));
Paginator.paginate( Paginator.paginate(
args, args,
new Paginator<>(toPaginate), new Paginator<>(toPaginate),
() -> logDirect( () -> logDirect(
!search.isEmpty() !search.isEmpty()
? String.format("All settings containing the string '%s':", search) ? String.format("All %ssettings containing the string '%s':", viewModified ? "modified " : "", search)
: String.format("All %ssettings:", viewModified ? "modified " : "") : String.format("All %ssettings:", viewModified ? "modified " : "")
), ),
setting -> new TextComponentString(setting.getName()) {{ setting -> new TextComponentString(setting.getName()) {{

View File

@ -17,7 +17,7 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
public static void renderSelections(ISelection[] selections) { public static void renderSelections(ISelection[] selections) {
float opacity = settings.selectionOpacity.value; float opacity = settings.selectionOpacity.value;
boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value; boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value;
float lineWidth = settings.selectionRenderLineWidthPixels.value; float lineWidth = settings.selectionLineWidth.value;
if (!settings.renderSelection.value) { if (!settings.renderSelection.value) {
return; return;
@ -26,26 +26,21 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
IRenderer.startLines(settings.colorSelection.value, opacity, lineWidth, ignoreDepth); IRenderer.startLines(settings.colorSelection.value, opacity, lineWidth, ignoreDepth);
for (ISelection selection : selections) { for (ISelection selection : selections) {
IRenderer.drawAABB(selection.aabb()); IRenderer.drawAABB(selection.aabb(), .005f);
} }
IRenderer.endLines(ignoreDepth); if (settings.renderSelectionCorners.value) {
IRenderer.glColor(settings.colorSelectionPos1.value, opacity);
if (!settings.renderSelectionCorners.value) { for (ISelection selection : selections) {
return; IRenderer.drawAABB(new AxisAlignedBB(selection.pos1(), selection.pos1().add(1, 1, 1)));
} }
IRenderer.startLines(settings.colorSelectionPos1.value, opacity, lineWidth, ignoreDepth); IRenderer.glColor(settings.colorSelectionPos2.value, opacity);
for (ISelection selection : selections) { for (ISelection selection : selections) {
IRenderer.drawAABB(new AxisAlignedBB(selection.pos1(), selection.pos1().add(1, 1, 1)), -.01f); IRenderer.drawAABB(new AxisAlignedBB(selection.pos2(), selection.pos2().add(1, 1, 1)));
} }
IRenderer.endLines(ignoreDepth);
IRenderer.startLines(settings.colorSelectionPos2.value, opacity, lineWidth, ignoreDepth);
for (ISelection selection : selections) {
IRenderer.drawAABB(new AxisAlignedBB(selection.pos2(), selection.pos2().add(1, 1, 1)), -.01f);
} }
IRenderer.endLines(ignoreDepth); IRenderer.endLines(ignoreDepth);

View File

@ -35,7 +35,6 @@ import baritone.behavior.PathingBehavior;
import baritone.pathing.path.PathExecutor; import baritone.pathing.path.PathExecutor;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer; import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -162,8 +161,7 @@ public final class PathRenderer implements IRenderer {
alpha = 0.4F * (1.0F - (float) (i - fadeStart) / (float) (fadeEnd - fadeStart)); alpha = 0.4F * (1.0F - (float) (i - fadeStart) / (float) (fadeEnd - fadeStart));
} }
float[] components = color.getComponents(null); IRenderer.glColor(color, alpha);
GlStateManager.color(components[0], components[1], components[2], alpha);
} }
drawLine(start.x, start.y, start.z, end.x, end.y, end.z); drawLine(start.x, start.y, start.z, end.x, end.y, end.z);
@ -207,7 +205,7 @@ public final class PathRenderer implements IRenderer {
toDraw = state.getSelectedBoundingBox(player.world, pos); toDraw = state.getSelectedBoundingBox(player.world, pos);
} }
IRenderer.drawAABB(toDraw); IRenderer.drawAABB(toDraw, .002f);
}); });
IRenderer.endLines(settings.renderSelectionBoxesIgnoreDepth.value); IRenderer.endLines(settings.renderSelectionBoxesIgnoreDepth.value);