From 382ad0079c7ff9253ce8a4d092cbb5b1f29c02cc Mon Sep 17 00:00:00 2001 From: Logan Darklock Date: Tue, 3 Sep 2019 23:46:20 -0700 Subject: [PATCH] DrawAABB changes, set command bugfix, sel rendering change, selection setting name changes --- src/api/java/baritone/api/Settings.java | 50 +++++++++---------- .../java/baritone/api/utils/IRenderer.java | 18 ++++--- .../utils/command/defaults/SelCommand.java | 4 +- .../utils/command/defaults/SetCommand.java | 14 ++---- .../baritone/selection/SelectionRenderer.java | 27 ++++------ .../java/baritone/utils/PathRenderer.java | 6 +-- 6 files changed, 54 insertions(+), 65 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 67f5496e..1bdb1e39 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -528,21 +528,6 @@ public final class Settings { */ public final Setting renderPathIgnoreDepth = new Setting<>(true); - /** - * Ignore depth when rendering selections - */ - public final Setting renderSelectionIgnoreDepth = new Setting<>(true); - - /** - * Render selections - */ - public final Setting renderSelection = new Setting<>(true); - - /** - * Render selection corners - */ - public final Setting renderSelectionCorners = new Setting<>(true); - /** * Line width of the path when rendered, in pixels */ @@ -553,11 +538,6 @@ public final class Settings { */ public final Setting goalRenderLineWidthPixels = new Setting<>(3F); - /** - * Line width of the goal when rendered, in pixels - */ - public final Setting selectionRenderLineWidthPixels = new Setting<>(3F); - /** * Start fading out the path at 20 movements ahead, and stop rendering it entirely 30 movements ahead. * Improves FPS. @@ -958,22 +938,42 @@ public final class Settings { /** * The color of all selections */ - public final Setting colorSelection = new Setting<>(Color.GREEN); + public final Setting colorSelection = new Setting<>(Color.CYAN); /** * The color of the selection pos 1 */ - public final Setting colorSelectionPos1 = new Setting<>(Color.PINK); + public final Setting colorSelectionPos1 = new Setting<>(Color.BLACK); /** * The color of the selection pos 2 */ - public final Setting colorSelectionPos2 = new Setting<>(Color.PINK); + public final Setting 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 selectionOpacity = new Setting<>(.4f); + public final Setting selectionOpacity = new Setting<>(.5f); + + /** + * Line width of the goal when rendered, in pixels + */ + public final Setting selectionLineWidth = new Setting<>(1F); + + /** + * Render selections + */ + public final Setting renderSelection = new Setting<>(true); + + /** + * Ignore depth when rendering selections + */ + public final Setting renderSelectionIgnoreDepth = new Setting<>(true); + + /** + * Render selection corners + */ + public final Setting renderSelectionCorners = new Setting<>(true); /** diff --git a/src/api/java/baritone/api/utils/IRenderer.java b/src/api/java/baritone/api/utils/IRenderer.java index 7bdb970e..5fb024ea 100644 --- a/src/api/java/baritone/api/utils/IRenderer.java +++ b/src/api/java/baritone/api/utils/IRenderer.java @@ -25,12 +25,16 @@ public interface IRenderer { IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone(); 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) { GlStateManager.enableBlend(); GlStateManager.disableLighting(); GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); - float[] colorComponents = color.getColorComponents(null); - GlStateManager.color(colorComponents[0], colorComponents[1], colorComponents[2], alpha); + glColor(color, alpha); GlStateManager.glLineWidth(lineWidth); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); @@ -55,10 +59,8 @@ public interface IRenderer { GlStateManager.disableBlend(); } - static void drawAABB(AxisAlignedBB aabb, float expand) { - AxisAlignedBB toDraw = aabb - .offset(-renderManager.viewerPosX, -renderManager.viewerPosY, -renderManager.viewerPosZ) - .grow(expand, expand, expand); + static void drawAABB(AxisAlignedBB aabb) { + AxisAlignedBB toDraw = aabb.offset(-renderManager.viewerPosX, -renderManager.viewerPosY, -renderManager.viewerPosZ); buffer.begin(GL_LINES, DefaultVertexFormats.POSITION); // bottom @@ -91,7 +93,7 @@ public interface IRenderer { tessellator.draw(); } - static void drawAABB(AxisAlignedBB aabb) { - drawAABB(aabb, 0.002f); + static void drawAABB(AxisAlignedBB aabb, float expand) { + drawAABB(aabb.grow(expand, expand, expand)); } } diff --git a/src/api/java/baritone/api/utils/command/defaults/SelCommand.java b/src/api/java/baritone/api/utils/command/defaults/SelCommand.java index eb09895d..446724dc 100644 --- a/src/api/java/baritone/api/utils/command/defaults/SelCommand.java +++ b/src/api/java/baritone/api/utils/command/defaults/SelCommand.java @@ -365,11 +365,11 @@ public class SelCommand extends Command { Color color = settings.colorSelectionPos1.value; float opacity = settings.selectionOpacity.value; - float lineWidth = settings.selectionRenderLineWidthPixels.value; + float lineWidth = settings.selectionLineWidth.value; boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value; 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); } } diff --git a/src/api/java/baritone/api/utils/command/defaults/SetCommand.java b/src/api/java/baritone/api/utils/command/defaults/SetCommand.java index f343c56e..90f4e351 100644 --- a/src/api/java/baritone/api/utils/command/defaults/SetCommand.java +++ b/src/api/java/baritone/api/utils/command/defaults/SetCommand.java @@ -61,30 +61,24 @@ public class SetCommand extends Command { boolean viewModified = asList("m", "mod", "modified").contains(arg); boolean viewAll = asList("all", "l", "list").contains(arg); - boolean paginate = viewModified | viewAll; + boolean paginate = viewModified || viewAll; if (paginate) { String search = args.has() && args.peekAsOrNull(Integer.class) == null ? args.getString() : ""; args.requireMax(1); List toPaginate = - viewModified - ? SettingsUtil.modifiedSettings(settings) - : settings.allSettings.stream() + (viewModified ? SettingsUtil.modifiedSettings(settings) : settings.allSettings).stream() .filter(s -> !s.getName().equals("logger")) .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::new)); - toPaginate.sort((setting1, setting2) -> String.CASE_INSENSITIVE_ORDER.compare( - setting1.getName(), - setting2.getName() - )); - Paginator.paginate( args, new Paginator<>(toPaginate), () -> logDirect( !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 " : "") ), setting -> new TextComponentString(setting.getName()) {{ diff --git a/src/main/java/baritone/selection/SelectionRenderer.java b/src/main/java/baritone/selection/SelectionRenderer.java index 4d0fd9a7..a696fe67 100644 --- a/src/main/java/baritone/selection/SelectionRenderer.java +++ b/src/main/java/baritone/selection/SelectionRenderer.java @@ -17,7 +17,7 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener { public static void renderSelections(ISelection[] selections) { float opacity = settings.selectionOpacity.value; boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value; - float lineWidth = settings.selectionRenderLineWidthPixels.value; + float lineWidth = settings.selectionLineWidth.value; if (!settings.renderSelection.value) { return; @@ -26,26 +26,21 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener { IRenderer.startLines(settings.colorSelection.value, opacity, lineWidth, ignoreDepth); 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) { - return; - } + for (ISelection selection : selections) { + 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) { - IRenderer.drawAABB(new AxisAlignedBB(selection.pos1(), selection.pos1().add(1, 1, 1)), -.01f); - } - - 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); + for (ISelection selection : selections) { + IRenderer.drawAABB(new AxisAlignedBB(selection.pos2(), selection.pos2().add(1, 1, 1))); + } } IRenderer.endLines(ignoreDepth); diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 9ebb58d4..3d141216 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -35,7 +35,6 @@ import baritone.behavior.PathingBehavior; import baritone.pathing.path.PathExecutor; import net.minecraft.block.state.IBlockState; 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.vertex.DefaultVertexFormats; 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)); } - float[] components = color.getComponents(null); - GlStateManager.color(components[0], components[1], components[2], alpha); + IRenderer.glColor(color, alpha); } 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); } - IRenderer.drawAABB(toDraw); + IRenderer.drawAABB(toDraw, .002f); }); IRenderer.endLines(settings.renderSelectionBoxesIgnoreDepth.value);