package com.irtimaled.bbor.client;
-import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.interop.ClientInterop;
import com.irtimaled.bbor.client.models.*;
import com.irtimaled.bbor.client.providers.*;
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
import com.irtimaled.bbor.common.models.BoundingBoxCuboid;
import com.irtimaled.bbor.common.models.DimensionId;
-import org.lwjgl.opengl.GL11;
import java.util.*;
import java.util.stream.Stream;
public static void render(DimensionId dimensionId) {
if (!active) return;
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GL11.glLineWidth(2.0f);
- GL11.glDisable(GL11.GL_TEXTURE_2D);
- GL11.glDisable(GL11.GL_CULL_FACE);
- GL11.glEnable(GL11.GL_DEPTH_TEST);
-
- if (ConfigManager.alwaysVisible.get()) {
- GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
- }
+ RenderHelper.beforeRender();
getBoundingBoxes(dimensionId).forEach(key -> {
AbstractRenderer renderer = boundingBoxRendererMap.get(key.getClass());
if (renderer != null) renderer.render(key);
});
- GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
- GL11.glEnable(GL11.GL_CULL_FACE);
- GL11.glEnable(GL11.GL_TEXTURE_2D);
+ RenderHelper.afterRender();
}
public static Stream<AbstractBoundingBox> getBoundingBoxes(DimensionId dimensionId) {
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.util.math.MathHelper;
-import org.lwjgl.opengl.GL11;
abstract class AbstractSlider extends AbstractControl {
private final int optionCount;
@Override
protected void renderBackground(int mouseX, int mouseY) {
this.minecraft.getTextureManager().bindTexture(WIDGETS_LOCATION);
- GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int hoverState = super.getYImage(this.isHovered());
this.blit(this.x + (int) getProgressPercentage(), this.y, 0, 46 + hoverState * 20, 4, this.height);
this.blit(this.x + (int) getProgressPercentage() + 4, this.y, 196, 46 + hoverState * 20, 4, 20);
package com.irtimaled.bbor.client.gui;
+import com.irtimaled.bbor.client.renderers.RenderHelper;
import com.irtimaled.bbor.client.renderers.Renderer;
-import com.mojang.blaze3d.platform.GLX;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.util.math.MathHelper;
-import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.List;
public void render(int mouseX, int mouseY) {
this.amountScrolled = MathHelper.clamp(this.amountScrolled, 0.0D, this.getMaxScroll());
- GL11.glDisable(GL11.GL_LIGHTING);
- GL11.glDisable(GL11.GL_FOG);
+ RenderHelper.disableLighting();
+ RenderHelper.disableFog();
if (!transparentBackground) drawListBackground();
int listTop = this.top + PADDING - (int) this.amountScrolled;
drawEntries(mouseX, mouseY, listTop);
- GL11.glDisable(GL11.GL_DEPTH_TEST);
+ RenderHelper.disableDepthTest();
this.overlayBackground(0, this.top);
this.overlayBackground(this.bottom, this.height);
- GL11.glEnable(GL11.GL_BLEND);
- GLX.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE);
- GL11.glDisable(GL11.GL_ALPHA_TEST);
- GL11.glShadeModel(GL11.GL_SMOOTH);
- GL11.glDisable(GL11.GL_TEXTURE_2D);
+ RenderHelper.enableBlend();
+ RenderHelper.blendFuncGui();
+ RenderHelper.disableAlphaTest();
+ RenderHelper.shadeModelSmooth();
+ RenderHelper.disableTexture();
drawOverlayShadows();
int maxScroll = this.getMaxScroll();
drawScrollBar(maxScroll);
}
- GL11.glEnable(GL11.GL_TEXTURE_2D);
- GL11.glShadeModel(GL11.GL_FLAT);
- GL11.glEnable(GL11.GL_ALPHA_TEST);
- GL11.glDisable(GL11.GL_BLEND);
+ RenderHelper.enableTexture();
+ RenderHelper.shadeModelFlat();
+ RenderHelper.enableAlphaTest();
+ RenderHelper.disableBlend();
}
private void drawListBackground() {
private void overlayBackground(int top, int bottom) {
this.minecraft.getTextureManager().bindTexture(AbstractGui.BACKGROUND_LOCATION);
- GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Renderer.startTextured()
.setColor(64, 64, 64)
.setAlpha(255)
package com.irtimaled.bbor.client.gui;
+import com.irtimaled.bbor.client.renderers.RenderHelper;
import com.irtimaled.bbor.client.renderers.Renderer;
-import org.lwjgl.opengl.GL11;
public class SelectableControlList extends ControlList {
private final int listRight;
@Override
protected void drawEntry(int mouseX, int mouseY, int top, ControlListEntry entry, int height) {
if (this.selectedElement == entry.index) {
- GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- GL11.glDisable(GL11.GL_TEXTURE_2D);
+ RenderHelper.disableTexture();
int color = this.isFocused ? 255 : 128;
Renderer.startTextured()
.setAlpha(255)
.addPoint(this.listRight + 1, top - 1, 0.0D, 1.0D, 0.0D)
.addPoint(this.listLeft - 1, top - 1, 0.0D, 0.0D, 0.0D)
.render();
- GL11.glEnable(GL11.GL_TEXTURE_2D);
+ RenderHelper.enableTexture();
}
super.drawEntry(mouseX, mouseY, top, entry, height);
}
import com.google.common.hash.Hashing;
import com.irtimaled.bbor.client.interop.ClientInterop;
+import com.irtimaled.bbor.client.renderers.RenderHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.world.storage.WorldSummary;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.lwjgl.opengl.GL11;
import java.io.File;
import java.io.FileInputStream;
this.client.fontRenderer.drawString(displayName, (float) (x + ICON_SIZE + 3), (float) (y + 1), 16777215);
this.client.fontRenderer.drawString(details, (float) (x + ICON_SIZE + 3), (float) (y + 1 + this.client.fontRenderer.FONT_HEIGHT + 1), 8421504);
this.client.getTextureManager().bindTexture(this.icon != null ? this.iconLocation : ICON_MISSING);
- GL11.glEnable(GL11.GL_BLEND);
+ RenderHelper.enableBlend();
AbstractGui.blit(x, y, 0.0F, 0.0F, ICON_SIZE, ICON_SIZE, 32, 32);
- GL11.glDisable(GL11.GL_BLEND);
+ RenderHelper.disableBlend();
}
@Override
import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.models.Point;
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
-import com.mojang.blaze3d.platform.GLX;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
-import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.util.function.Supplier;
void renderCuboid(OffsetBox bb, Color color) {
OffsetBox nudge = bb.nudge();
renderOutlinedCuboid(nudge, color);
- renderFilledFaces(nudge.getMin(), nudge.getMax(), color, 30);
+ renderFilledFaces(nudge.getMin(), nudge.getMax(), color);
}
void renderOutlinedCuboid(OffsetBox bb, Color color) {
- GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
+ RenderHelper.polygonModeLine();
OffsetPoint min = bb.getMin();
OffsetPoint max = bb.getMax();
renderFaces(min, max, color, 255, min.getY() == max.getY() ? Renderer::startLineLoop : Renderer::startLines);
}
void renderLine(OffsetPoint startPoint, OffsetPoint endPoint, Color color) {
- GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
+ RenderHelper.polygonModeLine();
Renderer.startLines()
.setColor(color)
.addPoint(startPoint)
.render();
}
- void renderFilledFaces(OffsetPoint min, OffsetPoint max, Color color, int alpha) {
+ void renderFilledFaces(OffsetPoint min, OffsetPoint max, Color color) {
if (!ConfigManager.fill.get()) return;
- GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
- GL11.glEnable(GL11.GL_BLEND);
- renderFaces(min, max, color, alpha, Renderer::startQuads);
- GL11.glDisable(GL11.GL_BLEND);
- GL11.glEnable(GL11.GL_POLYGON_OFFSET_LINE);
- GL11.glPolygonOffset(-1.f, -1.f);
+ RenderHelper.polygonModeFill();
+ RenderHelper.enableBlend();
+ renderFaces(min, max, color, 30, Renderer::startQuads);
+ RenderHelper.disableBlend();
+ RenderHelper.enablePolygonOffsetLine();
+ RenderHelper.polygonOffsetMinusOne();
}
void renderText(OffsetPoint offsetPoint, String... texts) {
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
- GL11.glDisable(GL11.GL_DEPTH_TEST);
- GL11.glPushMatrix();
- GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
- GL11.glTranslated(offsetPoint.getX(), offsetPoint.getY() + 0.002D, offsetPoint.getZ());
- GL11.glNormal3f(0.0F, 1.0F, 0.0F);
- GL11.glRotatef(0.0F, 0.0F, 1.0F, 0.0F);
- GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
- GL11.glScalef(-0.0175F, -0.0175F, 0.0175F);
- GL11.glEnable(GL11.GL_TEXTURE_2D);
- GL11.glEnable(GL11.GL_BLEND);
- GLX.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
-
- GL11.glDepthMask(true);
+ RenderHelper.beforeRenderFont(offsetPoint);
float top = -(fontRenderer.FONT_HEIGHT * texts.length) / 2f;
for (String text : texts) {
float left = fontRenderer.getStringWidth(text) / 2f;
fontRenderer.drawString(text, -left, top, -1);
top += fontRenderer.FONT_HEIGHT;
}
- GL11.glDisable(GL11.GL_TEXTURE_2D);
- GL11.glDisable(GL11.GL_BLEND);
- GL11.glPopMatrix();
- GL11.glEnable(GL11.GL_DEPTH_TEST);
+ RenderHelper.afterRenderFont();
}
- void renderSphere(Point center, double radius, Color color, int density, int dotSize) {
+ void renderSphere(Point center, double radius, Color color) {
if (ConfigManager.renderSphereAsDots.get()) {
- renderDotSphere(center, radius, color, density, dotSize);
+ renderDotSphere(center, radius, color);
} else {
- renderLineSphere(center, radius, color, density);
+ renderLineSphere(center, radius, color);
}
}
- private void renderLineSphere(Point center, double radius, Color color, int density) {
- GL11.glLineWidth(2f);
- int segments = 24 + (density * 8);
+ private void renderLineSphere(Point center, double radius, Color color) {
+ RenderHelper.lineWidth2();
double offset = ((radius - (int) radius) == 0) ? center.getY() - (int) center.getY() : 0;
for (double dy = offset - radius; dy <= radius + 1; dy++) {
double circleRadius = Math.sqrt((radius * radius) - (dy * dy));
if (circleRadius == 0) circleRadius = Math.sqrt(2) / 2;
- renderCircle(center, circleRadius, color, segments, dy + 0.001F);
+ renderCircle(center, circleRadius, color, dy + 0.001F);
}
}
- private void renderCircle(Point center, double radius, Color color, int segments, double dy) {
+ private void renderCircle(Point center, double radius, Color color, double dy) {
Renderer renderer = Renderer.startLineLoop()
.setColor(color);
- for (int a = 0; a < 360; a += 360 / segments) {
+ for (int a = 0; a < 360; a += 5) {
double heading = a * PI / 180;
renderer.addPoint(new OffsetPoint(center.offset(Math.cos(heading) * radius, dy, Math.sin(heading) * radius)));
}
renderer.render();
}
- private void renderDotSphere(Point center, double radius, Color color, int density, int dotSize) {
- GL11.glEnable(GL11.GL_POINT_SMOOTH);
- GL11.glPointSize(dotSize);
+ private void renderDotSphere(Point center, double radius, Color color) {
+ RenderHelper.enablePointSmooth();
+ RenderHelper.pointSize5();
Renderer renderer = Renderer.startPoints()
.setColor(color);
- int segments = 24 + (density * 8);
+ int segments = 64;
double thetaSegment = PI / (double) segments;
double phiSegment = TAU / (double) segments;
renderLine(topCorner1, topCorner2, color);
OffsetPoint bottomCorner2 = topCorner2.offset(0, 1, 0);
- renderFilledFaces(topCorner1, bottomCorner2, color, 30);
+ renderFilledFaces(topCorner1, bottomCorner2, color);
OffsetPoint bottomCorner1 = topCorner1.offset(0, 1, 0);
renderLine(bottomCorner1, bottomCorner2, color);
}
Color color = BoundingBoxTypeHelper.getColor(boundingBox.getType());
if (level != 0) {
- renderSphere(point, boundingBox.getRadius() + 0.5, color, 5, 5);
+ renderSphere(point, boundingBox.getRadius() + 0.5, color);
}
OffsetPoint center = new OffsetPoint(point);
import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.models.BoundingBoxLine;
-import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.util.Arrays;
map(point -> new OffsetPoint(point).offset(0, 0.001f, 0)).
toArray(OffsetPoint[]::new);
- GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
+ RenderHelper.polygonModeLine();
Renderer.startQuads()
.setColor(color)
.addPoints(cornerPoints)
if (!ConfigManager.fill.get()) return;
- GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
- GL11.glEnable(GL11.GL_BLEND);
+ RenderHelper.polygonModeFill();
+ RenderHelper.enableBlend();
Renderer.startQuads()
.setColor(color)
.setAlpha(30)
.addPoints(cornerPoints)
.render();
- GL11.glDisable(GL11.GL_BLEND);
- GL11.glEnable(GL11.GL_POLYGON_OFFSET_LINE);
- GL11.glPolygonOffset(-1.f, -1.f);
+ RenderHelper.disableBlend();
+ RenderHelper.enablePolygonOffsetLine();
+ RenderHelper.polygonOffsetMinusOne();
}
}
--- /dev/null
+package com.irtimaled.bbor.client.renderers;
+
+import com.irtimaled.bbor.client.config.ConfigManager;
+import com.mojang.blaze3d.platform.GlStateManager;
+import net.minecraft.client.Minecraft;
+import org.lwjgl.opengl.GL11;
+
+public class RenderHelper {
+ public static final int QUADS = GL11.GL_QUADS;
+ public static final int LINES = GL11.GL_LINES;
+ public static final int LINE_LOOP = GL11.GL_LINE_LOOP;
+ public static final int POINTS = GL11.GL_POINTS;
+
+ public static void beforeRender() {
+ enableBlend();
+ GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ lineWidth2();
+ disableTexture();
+ GlStateManager.disableCull();
+ enableDepthTest();
+
+ if (ConfigManager.alwaysVisible.get()) {
+ GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT, Minecraft.IS_RUNNING_ON_MAC);
+ }
+ }
+
+ public static void afterRender() {
+ polygonModeFill();
+ GlStateManager.enableCull();
+ enableTexture();
+ }
+
+ public static void beforeRenderFont(OffsetPoint offsetPoint) {
+ disableDepthTest();
+ GlStateManager.pushMatrix();
+ polygonModeFill();
+ GlStateManager.translated(offsetPoint.getX(), offsetPoint.getY() + 0.002D, offsetPoint.getZ());
+ GlStateManager.normal3f(0.0F, 1.0F, 0.0F);
+ GlStateManager.rotatef(0.0F, 0.0F, 1.0F, 0.0F);
+ GlStateManager.rotatef(90.0F, 1.0F, 0.0F, 0.0F);
+ GlStateManager.scalef(-0.0175F, -0.0175F, 0.0175F);
+ enableTexture();
+ enableBlend();
+ GlStateManager.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
+
+ depthMaskTrue();
+ }
+
+ public static void afterRenderFont() {
+ disableTexture();
+ disableBlend();
+ GlStateManager.popMatrix();
+ enableDepthTest();
+ }
+
+ public static void disableLighting() {
+ GlStateManager.disableLighting();
+ }
+
+ public static void disableDepthTest() {
+ GlStateManager.disableDepthTest();
+ }
+
+ public static void enableDepthTest() {
+ GlStateManager.enableDepthTest();
+ }
+
+ public static void disableFog() {
+ GlStateManager.disableFog();
+ }
+
+ public static void disableBlend() {
+ GlStateManager.disableBlend();
+ }
+
+ public static void enableBlend() {
+ GlStateManager.enableBlend();
+ }
+
+ public static void disableAlphaTest() {
+ GlStateManager.disableAlphaTest();
+ }
+
+ public static void enableAlphaTest() {
+ GlStateManager.enableAlphaTest();
+ }
+
+ public static void disableTexture() {
+ GlStateManager.disableTexture();
+ }
+
+ public static void enableTexture() {
+ GlStateManager.enableTexture();
+ }
+
+ public static void shadeModelSmooth() {
+ GlStateManager.shadeModel(GL11.GL_SMOOTH);
+ }
+
+ public static void shadeModelFlat() {
+ GlStateManager.shadeModel(GL11.GL_FLAT);
+ }
+
+ public static void enablePointSmooth() {
+ GL11.glEnable(GL11.GL_POINT_SMOOTH);
+ }
+
+ public static void lineWidth2() {
+ GlStateManager.lineWidth(2f);
+ }
+
+ public static void polygonModeLine() {
+ GlStateManager.polygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
+ }
+
+ public static void polygonModeFill() {
+ GlStateManager.polygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
+ }
+
+ public static void polygonOffsetMinusOne() {
+ GlStateManager.polygonOffset(-1.f, -1.f);
+ }
+
+ public static void enablePolygonOffsetLine() {
+ GlStateManager.enableLineOffset();
+ }
+
+ public static void depthMaskTrue() {
+ GlStateManager.depthMask(true);
+ }
+
+ public static void pointSize5() {
+ GL11.glPointSize(5);
+ }
+
+ public static void blendFuncGui() {
+ GlStateManager.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE);
+ }
+}
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;
-import org.lwjgl.opengl.GL11;
import java.awt.*;
private final int glMode;
static Renderer startLines() {
- return new Renderer(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
+ return new Renderer(RenderHelper.LINES, DefaultVertexFormats.POSITION_COLOR);
}
static Renderer startLineLoop() {
- return new Renderer(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION_COLOR);
+ return new Renderer(RenderHelper.LINE_LOOP, DefaultVertexFormats.POSITION_COLOR);
}
static Renderer startQuads() {
- return new Renderer(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
+ return new Renderer(RenderHelper.QUADS, DefaultVertexFormats.POSITION_COLOR);
}
static Renderer startPoints() {
- return new Renderer(GL11.GL_POINTS, DefaultVertexFormats.POSITION_COLOR);
+ return new Renderer(RenderHelper.POINTS, DefaultVertexFormats.POSITION_COLOR);
}
public static Renderer startTextured() {
- return new Renderer(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
+ return new Renderer(RenderHelper.QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
}
private static final Tessellator tessellator = new Tessellator(2097152);
}
public void render() {
- if (glMode == GL11.GL_QUADS) {
+ if (glMode == RenderHelper.QUADS) {
bufferBuilder.sortVertexData((float) Camera.getX(), (float) Camera.getY(), (float) Camera.getZ());
}
tessellator.draw();
OffsetPoint sphereCenter = new OffsetPoint(point);
Color safeAreaColor = ColorHelper.getColor(ConfigManager.colorAFKSpheresSafeArea);
- renderSphere(point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor, 5, 5);
+ renderSphere(point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor);
renderOuterSphere(boundingBox, point);
I18n.format("bbor.renderer.spawningSphere.none") :
String.format("%,d", spawnableSpacesCount));
}
+ renderSphere(point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor);
if (ConfigManager.renderAFKSpawnableBlocks.get() && boundingBox.isWithinSphere(Player.getPoint())) {
renderSpawnableSpaces(boundingBox);
private void renderOuterSphere(BoundingBoxSpawningSphere boundingBox, Point point) {
Color color = BoundingBoxTypeHelper.getColor(boundingBox.getType());
- renderSphere(point, BoundingBoxSpawningSphere.SPAWN_RADIUS, color, 5, 5);
+ renderSphere(point, BoundingBoxSpawningSphere.SPAWN_RADIUS, color);
}
private void renderSpawnableSpaces(BoundingBoxSpawningSphere boundingBox) {
public void render(BoundingBoxSphere boundingBox) {
Point point = boundingBox.getPoint();
double radius = boundingBox.getRadius();
- renderSphere(point, radius, BoundingBoxTypeHelper.getColor(boundingBox.getType()), 5, 5);
+ renderSphere(point, radius, BoundingBoxTypeHelper.getColor(boundingBox.getType()));
}
}