Persistent renderManager, selection transparency setting, drawAABB fixes
This commit is contained in:
parent
755a3f0154
commit
8dc4ff26d6
@ -970,6 +970,11 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Color> colorSelectionPos2 = new Setting<>(Color.PINK);
|
||||
|
||||
/**
|
||||
* The opacity of the selection. The default (0.4) is what's used for goals and such
|
||||
*/
|
||||
public final Setting<Float> selectionOpacity = new Setting<>(.4f);
|
||||
|
||||
|
||||
/**
|
||||
* A map of lowercase setting field names to their respective setting
|
||||
|
@ -21,15 +21,16 @@ import static org.lwjgl.opengl.GL11.GL_ZERO;
|
||||
public interface IRenderer {
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
RenderManager renderManager = Helper.mc.getRenderManager();
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||
Settings settings = BaritoneAPI.getSettings();
|
||||
|
||||
static void startLines(Color color, float lineWidth, boolean ignoreDepth) {
|
||||
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], 0.4f);
|
||||
GlStateManager.color(colorComponents[0], colorComponents[1], colorComponents[2], alpha);
|
||||
GlStateManager.glLineWidth(lineWidth);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.depthMask(false);
|
||||
@ -39,6 +40,10 @@ public interface IRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
static void startLines(Color color, float lineWidth, boolean ignoreDepth) {
|
||||
startLines(color, .4f, lineWidth, ignoreDepth);
|
||||
}
|
||||
|
||||
static void endLines(boolean ignoredDepth) {
|
||||
if (ignoredDepth) {
|
||||
GlStateManager.enableDepth();
|
||||
@ -50,10 +55,10 @@ public interface IRenderer {
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
|
||||
static void drawAABB(AxisAlignedBB aabb) {
|
||||
float expand = 0.002F;
|
||||
RenderManager renderManager = Helper.mc.getRenderManager();
|
||||
AxisAlignedBB toDraw = aabb.expand(expand, expand, expand).offset(-renderManager.viewerPosX, -renderManager.viewerPosY, -renderManager.viewerPosZ);
|
||||
static void drawAABB(AxisAlignedBB aabb, float expand) {
|
||||
AxisAlignedBB toDraw = aabb
|
||||
.offset(-renderManager.viewerPosX, -renderManager.viewerPosY, -renderManager.viewerPosZ)
|
||||
.grow(expand, expand, expand);
|
||||
|
||||
buffer.begin(GL_LINES, DefaultVertexFormats.POSITION);
|
||||
// bottom
|
||||
@ -85,4 +90,8 @@ public interface IRenderer {
|
||||
buffer.pos(toDraw.minX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
static void drawAABB(AxisAlignedBB aabb) {
|
||||
drawAABB(aabb, 0.002f);
|
||||
}
|
||||
}
|
||||
|
@ -364,11 +364,12 @@ public class SelCommand extends Command {
|
||||
}
|
||||
|
||||
Color color = settings.colorSelectionPos1.value;
|
||||
float opacity = settings.selectionOpacity.value;
|
||||
float lineWidth = settings.selectionRenderLineWidthPixels.value;
|
||||
boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value;
|
||||
|
||||
IRenderer.startLines(color, lineWidth, ignoreDepth);
|
||||
IRenderer.drawAABB(new AxisAlignedBB(pos1, pos1.add(1, 1, 1)));
|
||||
IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
|
||||
IRenderer.drawAABB(new AxisAlignedBB(pos1, pos1.add(1, 1, 1)), -.01f);
|
||||
IRenderer.endLines(ignoreDepth);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,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;
|
||||
|
||||
@ -22,7 +23,7 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
|
||||
return;
|
||||
}
|
||||
|
||||
IRenderer.startLines(settings.colorSelection.value, lineWidth, ignoreDepth);
|
||||
IRenderer.startLines(settings.colorSelection.value, opacity, lineWidth, ignoreDepth);
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
IRenderer.drawAABB(selection.aabb());
|
||||
@ -34,17 +35,17 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
|
||||
return;
|
||||
}
|
||||
|
||||
IRenderer.startLines(settings.colorSelectionPos1.value, lineWidth, ignoreDepth);
|
||||
IRenderer.startLines(settings.colorSelectionPos1.value, opacity, lineWidth, ignoreDepth);
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
IRenderer.drawAABB(new AxisAlignedBB(selection.pos1(), selection.pos1().add(1, 1, 1)));
|
||||
IRenderer.drawAABB(new AxisAlignedBB(selection.pos1(), selection.pos1().add(1, 1, 1)), -.01f);
|
||||
}
|
||||
|
||||
IRenderer.endLines(ignoreDepth);
|
||||
IRenderer.startLines(settings.colorSelectionPos2.value, lineWidth, 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)));
|
||||
IRenderer.drawAABB(new AxisAlignedBB(selection.pos2(), selection.pos2().add(1, 1, 1)), -.01f);
|
||||
}
|
||||
|
||||
IRenderer.endLines(ignoreDepth);
|
||||
|
@ -175,7 +175,6 @@ public final class PathRenderer implements IRenderer {
|
||||
}
|
||||
|
||||
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;
|
||||
@ -215,7 +214,6 @@ public final class PathRenderer implements IRenderer {
|
||||
}
|
||||
|
||||
public static void drawDankLitGoalBox(Entity player, Goal goal, float partialTicks, Color color) {
|
||||
RenderManager renderManager = Helper.mc.getRenderManager();
|
||||
double renderPosX = renderManager.viewerPosX;
|
||||
double renderPosY = renderManager.viewerPosY;
|
||||
double renderPosZ = renderManager.viewerPosZ;
|
||||
|
Loading…
x
Reference in New Issue
Block a user