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);
|
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
|
* 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 {
|
public interface IRenderer {
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder buffer = tessellator.getBuffer();
|
BufferBuilder buffer = tessellator.getBuffer();
|
||||||
|
RenderManager renderManager = Helper.mc.getRenderManager();
|
||||||
IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone();
|
IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||||
Settings settings = BaritoneAPI.getSettings();
|
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.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);
|
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.glLineWidth(lineWidth);
|
||||||
GlStateManager.disableTexture2D();
|
GlStateManager.disableTexture2D();
|
||||||
GlStateManager.depthMask(false);
|
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) {
|
static void endLines(boolean ignoredDepth) {
|
||||||
if (ignoredDepth) {
|
if (ignoredDepth) {
|
||||||
GlStateManager.enableDepth();
|
GlStateManager.enableDepth();
|
||||||
@ -50,10 +55,10 @@ public interface IRenderer {
|
|||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawAABB(AxisAlignedBB aabb) {
|
static void drawAABB(AxisAlignedBB aabb, float expand) {
|
||||||
float expand = 0.002F;
|
AxisAlignedBB toDraw = aabb
|
||||||
RenderManager renderManager = Helper.mc.getRenderManager();
|
.offset(-renderManager.viewerPosX, -renderManager.viewerPosY, -renderManager.viewerPosZ)
|
||||||
AxisAlignedBB toDraw = aabb.expand(expand, expand, expand).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
|
||||||
@ -85,4 +90,8 @@ public interface IRenderer {
|
|||||||
buffer.pos(toDraw.minX, toDraw.maxY, toDraw.maxZ).endVertex();
|
buffer.pos(toDraw.minX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||||
tessellator.draw();
|
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;
|
Color color = settings.colorSelectionPos1.value;
|
||||||
|
float opacity = settings.selectionOpacity.value;
|
||||||
float lineWidth = settings.selectionRenderLineWidthPixels.value;
|
float lineWidth = settings.selectionRenderLineWidthPixels.value;
|
||||||
boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value;
|
boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value;
|
||||||
|
|
||||||
IRenderer.startLines(color, lineWidth, ignoreDepth);
|
IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
|
||||||
IRenderer.drawAABB(new AxisAlignedBB(pos1, pos1.add(1, 1, 1)));
|
IRenderer.drawAABB(new AxisAlignedBB(pos1, pos1.add(1, 1, 1)), -.01f);
|
||||||
IRenderer.endLines(ignoreDepth);
|
IRenderer.endLines(ignoreDepth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void renderSelections(ISelection[] selections) {
|
public static void renderSelections(ISelection[] selections) {
|
||||||
|
float opacity = settings.selectionOpacity.value;
|
||||||
boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value;
|
boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value;
|
||||||
float lineWidth = settings.selectionRenderLineWidthPixels.value;
|
float lineWidth = settings.selectionRenderLineWidthPixels.value;
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IRenderer.startLines(settings.colorSelection.value, 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());
|
||||||
@ -34,17 +35,17 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IRenderer.startLines(settings.colorSelectionPos1.value, lineWidth, ignoreDepth);
|
IRenderer.startLines(settings.colorSelectionPos1.value, opacity, lineWidth, ignoreDepth);
|
||||||
|
|
||||||
for (ISelection selection : selections) {
|
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.endLines(ignoreDepth);
|
||||||
IRenderer.startLines(settings.colorSelectionPos2.value, lineWidth, ignoreDepth);
|
IRenderer.startLines(settings.colorSelectionPos2.value, opacity, lineWidth, ignoreDepth);
|
||||||
|
|
||||||
for (ISelection selection : selections) {
|
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);
|
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) {
|
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 vpX = renderManager.viewerPosX;
|
||||||
double vpY = renderManager.viewerPosY;
|
double vpY = renderManager.viewerPosY;
|
||||||
double vpZ = renderManager.viewerPosZ;
|
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) {
|
public static void drawDankLitGoalBox(Entity player, Goal goal, float partialTicks, Color color) {
|
||||||
RenderManager renderManager = Helper.mc.getRenderManager();
|
|
||||||
double renderPosX = renderManager.viewerPosX;
|
double renderPosX = renderManager.viewerPosX;
|
||||||
double renderPosY = renderManager.viewerPosY;
|
double renderPosY = renderManager.viewerPosY;
|
||||||
double renderPosZ = renderManager.viewerPosZ;
|
double renderPosZ = renderManager.viewerPosZ;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user