aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/renderer
diff options
context:
space:
mode:
authornextdaydelivery <12willettsh@gmail.com>2022-03-20 11:37:24 +0000
committernextdaydelivery <12willettsh@gmail.com>2022-03-20 11:37:24 +0000
commit72118423d214b964ea9bd3d2a1411c72941c5f90 (patch)
tree90569b2d1a5fb2b6ac64fcf9141aeec518a8ddfc /src/main/java/io/polyfrost/oneconfig/renderer
parentfe04136d705ca5f946ee8353c7f7c67e284c9ca5 (diff)
downloadOneConfig-72118423d214b964ea9bd3d2a1411c72941c5f90.tar.gz
OneConfig-72118423d214b964ea9bd3d2a1411c72941c5f90.tar.bz2
OneConfig-72118423d214b964ea9bd3d2a1411c72941c5f90.zip
a few small things and a couple GUI starting things
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/renderer')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/renderer/Renderer.java36
-rw-r--r--src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java2
2 files changed, 31 insertions, 7 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/renderer/Renderer.java b/src/main/java/io/polyfrost/oneconfig/renderer/Renderer.java
index 44e1b34..86c63f6 100644
--- a/src/main/java/io/polyfrost/oneconfig/renderer/Renderer.java
+++ b/src/main/java/io/polyfrost/oneconfig/renderer/Renderer.java
@@ -1,5 +1,7 @@
package io.polyfrost.oneconfig.renderer;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonParser;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
@@ -22,11 +24,33 @@ public class Renderer extends Gui {
private static final WorldRenderer worldRenderer = tessellator.getWorldRenderer();
- public static void drawRectangle(int left, int top, int right, int bottom, int color) {
- Gui.drawRect(left, top, right, bottom, color);
+
+ /**
+ * Draw a basic rectangle. Please note that this is to be used WITH a {@link net.minecraft.client.renderer.GlStateManager#color(float, float, float)} before to color it.
+ */
+ public static void drawRectangle(int x, int y, int width, int height) {
+ int right = x + width;
+ int bottom = y + height;
+ if (x < right) {
+ x = right;
+ }
+ if (y < bottom) {
+ y = bottom;
+ }
+ GlStateManager.enableBlend();
+ GlStateManager.disableTexture2D();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ worldRenderer.begin(7, DefaultVertexFormats.POSITION);
+ worldRenderer.pos(x, bottom, 0.0D).endVertex();
+ worldRenderer.pos(right, bottom, 0.0D).endVertex();
+ worldRenderer.pos(right, y, 0.0D).endVertex();
+ worldRenderer.pos(x, y, 0.0D).endVertex();
+ tessellator.draw();
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
}
- public static void drawTextScale(String text, float x, float y, int color, boolean shadow, float scale) {
+ public static void drawScaledString(String text, float x, float y, int color, boolean shadow, float scale) {
GlStateManager.pushMatrix();
GlStateManager.scale(scale, scale, 1);
mc.fontRendererObj.drawString(text, x * (1 / scale), y * (1 / scale), color, shadow);
@@ -42,7 +66,7 @@ public class Renderer extends Gui {
public static void drawRegularPolygon(double x, double y, int radius, int sides, int color, double lowerAngle, double upperAngle) {
GL11.glDisable(GL11.GL_TEXTURE_2D);
- setGlColor(color);
+ color(color);
GlStateManager.enableBlend();
GlStateManager.disableAlpha();
worldRenderer.begin(GL11.GL_POLYGON, DefaultVertexFormats.POSITION);
@@ -120,14 +144,14 @@ public class Renderer extends Gui {
/**
* Set GL color from the given Color variable.
*/
- public static void setGlColor(Color color) {
+ public static void color(Color color) {
GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f);
}
/**
* Set GL color from the given color as an Integer.
*/
- public static void setGlColor(int color) {
+ public static void color(int color) {
float f1 = (float) (color >> 8 & 255) / 255.0F;
float f = (float) (color >> 16 & 255) / 255.0F;
float f2 = (float) (color & 255) / 255.0F;
diff --git a/src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java b/src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java
index 9a51e68..544a7d2 100644
--- a/src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java
+++ b/src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java
@@ -356,7 +356,7 @@ public class TrueTypeFont {
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
- Renderer.setGlColor(color);
+ Renderer.color(color);
while (i >= startIndex && i <= endIndex) {
charCurrent = text.charAt(i);
if (charCurrent < 256) {