aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/utils
diff options
context:
space:
mode:
authorKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2023-07-22 14:43:00 +0800
committerKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2023-08-18 18:05:10 +0800
commitfc65ff5b469fb384d2df422a5a6d8437012a819b (patch)
tree0b967fa17e1f791b9efc9c630d54546fcc14a615 /src/main/java/me/xmrvizzy/skyblocker/utils
parent6069d3cf7d2e96ca7ef1975a3dd04e2121a6e3c9 (diff)
downloadSkyblocker-fc65ff5b469fb384d2df422a5a6d8437012a819b.tar.gz
Skyblocker-fc65ff5b469fb384d2df422a5a6d8437012a819b.tar.bz2
Skyblocker-fc65ff5b469fb384d2df422a5a6d8437012a819b.zip
Refactor utils package
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/utils')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/Boxes.java7
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/ItemUtils.java8
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtils.java99
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtilsLiving.java151
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/Vertexer.java164
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/color/LineColor.java66
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/color/QuadColor.java107
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/color/RenderColor.java27
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/FrustumUtils.java (renamed from src/main/java/me/xmrvizzy/skyblocker/utils/FrustumUtils.java)5
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/RenderHelper.java (renamed from src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java)172
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/OcclusionCulling.java (renamed from src/main/java/me/xmrvizzy/skyblocker/utils/culling/OcclusionCulling.java)11
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/WorldProvider.java (renamed from src/main/java/me/xmrvizzy/skyblocker/utils/culling/WorldProvider.java)3
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/package-info.java (renamed from src/main/java/me/xmrvizzy/skyblocker/utils/culling/package-info.java)2
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/gui/ColorHighlight.java24
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/gui/ContainerSolver.java44
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/gui/ContainerSolverManager.java124
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/title/Title.java (renamed from src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java)2
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainer.java (renamed from src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java)4
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainerConfigScreen.java (renamed from src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java)6
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/scheduler/MessageScheduler.java (renamed from src/main/java/me/xmrvizzy/skyblocker/utils/MessageScheduler.java)2
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/scheduler/Scheduler.java (renamed from src/main/java/me/xmrvizzy/skyblocker/utils/Scheduler.java)2
21 files changed, 301 insertions, 729 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/Boxes.java b/src/main/java/me/xmrvizzy/skyblocker/utils/Boxes.java
index 445bcbe5..17874c9c 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/Boxes.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/Boxes.java
@@ -1,12 +1,10 @@
package me.xmrvizzy.skyblocker.utils;
-
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction.Axis;
import net.minecraft.util.math.Vec3d;
public class Boxes {
-
/** Returns the vector of the min pos of this box. **/
public static Vec3d getMinVec(Box box) {
return new Vec3d(box.minX, box.minY, box.minZ);
@@ -17,6 +15,11 @@ public class Boxes {
return new Vec3d(box.maxX, box.maxY, box.maxZ);
}
+ /** Returns the vector of the side lengths of this box. **/
+ public static Vec3d getLengthVec(Box box) {
+ return new Vec3d(box.getXLength(), box.getYLength(), box.getZLength());
+ }
+
/** Offsets this box so that minX, minY and minZ are all zero. **/
public static Box moveToZero(Box box) {
return box.offset(getMinVec(box).negate());
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/ItemUtils.java b/src/main/java/me/xmrvizzy/skyblocker/utils/ItemUtils.java
index a4d1ee7b..4f74ce3a 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/ItemUtils.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/ItemUtils.java
@@ -11,17 +11,13 @@ import java.util.List;
import java.util.regex.Pattern;
public class ItemUtils {
+ private final static Pattern WHITESPACES = Pattern.compile("^\\s*$");
public static List<Text> getTooltip(ItemStack item) {
MinecraftClient client = MinecraftClient.getInstance();
- if (client.player != null && item != null)
- // return item.getTooltip(client.player, TooltipContext.Default.NORMAL);
- return item.getTooltip(client.player, TooltipContext.Default.BASIC);
- return Collections.emptyList();
+ return client.player == null || item == null ? Collections.emptyList() : item.getTooltip(client.player, TooltipContext.Default.BASIC);
}
- private final static Pattern WHITESPACES = Pattern.compile("^\\s*$");
-
public static List<String> getTooltipStrings(ItemStack item) {
List<Text> lines = getTooltip(item);
List<String> list = new ArrayList<>();
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtils.java b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtils.java
deleted file mode 100644
index d20cfefe..00000000
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtils.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package me.xmrvizzy.skyblocker.utils;
-
-import com.mojang.blaze3d.systems.RenderSystem;
-
-import me.xmrvizzy.skyblocker.utils.color.QuadColor;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.render.BufferBuilder;
-import net.minecraft.client.render.Camera;
-import net.minecraft.client.render.GameRenderer;
-import net.minecraft.client.render.Tessellator;
-import net.minecraft.client.render.VertexFormat;
-import net.minecraft.client.render.VertexFormats;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.entity.Entity;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.Box;
-import net.minecraft.util.math.Direction;
-import net.minecraft.util.math.MathHelper;
-import net.minecraft.util.math.Vec3d;
-// import net.minecraft.util.math.Vec3f;
-import net.minecraft.util.math.RotationAxis;
-
-public class RenderUtils {
-
- // -------------------- Outline Boxes --------------------
-
- public static void drawBoxOutline(BlockPos blockPos, QuadColor color, float lineWidth, Direction... excludeDirs) {
- drawBoxOutline(new Box(blockPos), color, lineWidth, excludeDirs);
- }
-
- public static void drawBoxOutline(Box box, QuadColor color, float lineWidth, Direction... excludeDirs) {
- if (!FrustumUtils.isBoxVisible(box)) {
- return;
- }
-
- setup();
-
- MatrixStack matrices = matrixFrom(box.minX, box.minY, box.minZ);
-
- Tessellator tessellator = Tessellator.getInstance();
- BufferBuilder buffer = tessellator.getBuffer();
-
- // Outline
- RenderSystem.enableDepthTest();
- RenderSystem.disableCull();
- RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram);
- RenderSystem.lineWidth(lineWidth);
-
- buffer.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES);
- Vertexer.vertexBoxLines(matrices, buffer, Boxes.moveToZero(box), color, excludeDirs);
- tessellator.draw();
-
- RenderSystem.enableCull();
- RenderSystem.disableDepthTest();
-
- cleanup();
- }
-
- // -------------------- Utils --------------------
-
- public static MatrixStack matrixFrom(double x, double y, double z) {
- MatrixStack matrices = new MatrixStack();
-
- Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera();
- // matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
- matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch()));
- // matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(camera.getYaw() + 180.0F));
- matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(camera.getYaw() + 180.0F));
-
- matrices.translate(x - camera.getPos().x, y - camera.getPos().y, z - camera.getPos().z);
-
- return matrices;
- }
-
- public static Vec3d getInterpolationOffset(Entity e) {
- if (MinecraftClient.getInstance().isPaused()) {
- return Vec3d.ZERO;
- }
-
- double tickDelta = MinecraftClient.getInstance().getTickDelta();
- return new Vec3d(
- e.getX() - MathHelper.lerp(tickDelta, e.lastRenderX, e.getX()),
- e.getY() - MathHelper.lerp(tickDelta, e.lastRenderY, e.getY()),
- e.getZ() - MathHelper.lerp(tickDelta, e.lastRenderZ, e.getZ()));
- }
-
- public static boolean pointExistsInArea(int x, int y, int x1, int y1, int x2, int y2) {
- return x >= x1 && x <= x2 && y >= y1 && y <= y2;
- }
-
- public static void setup() {
- RenderSystem.enableBlend();
- RenderSystem.defaultBlendFunc();
- }
-
- public static void cleanup() {
- RenderSystem.disableBlend();
- }
-} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtilsLiving.java b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtilsLiving.java
deleted file mode 100644
index 79ec18e9..00000000
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtilsLiving.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package me.xmrvizzy.skyblocker.utils;
-
-/*
- * This file is part of the MacHack distribution (https://github.com/BleachDrinker420/bleachhack-1.14/).
- * Copyright (c) 2019 Bleach.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-import com.mojang.blaze3d.systems.RenderSystem;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.font.TextRenderer;
-import net.minecraft.client.render.*;
-import net.minecraft.client.render.model.json.ModelTransformationMode;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.item.ItemStack;
-import net.minecraft.text.Text;
-import net.minecraft.util.math.RotationAxis;
-import org.apache.commons.lang3.reflect.FieldUtils;
-import org.joml.Vector3f;
-
-import java.lang.reflect.Field;
-
-public class RenderUtilsLiving {
-
- private static final MinecraftClient mc = MinecraftClient.getInstance();
- private static Field shaderLightField;
-
- /** Draws text in the world. **/
- public static void drawText(Text text, double x, double y, double z, double scale, boolean shadow) {
- drawText(text, x, y, z, 0, 0, scale, shadow);
- }
-
- /** Draws text in the world. **/
- public static void drawText(Text text, double x, double y, double z, double offX, double offY, double scale, boolean fill) {
- MatrixStack matrices = matrixFrom(x, y, z);
-
- Camera camera = mc.gameRenderer.getCamera();
- // matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw()));
- matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-camera.getYaw()));
- // matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
- matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch()));
-
- RenderSystem.enableBlend();
- RenderSystem.defaultBlendFunc();
-
- matrices.translate(offX, offY, 0);
- matrices.scale(-0.025f * (float) scale, -0.025f * (float) scale, 1);
-
- int halfWidth = mc.textRenderer.getWidth(text) / 2;
-
- VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
-
- if (fill) {
- int opacity = (int) (MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F) * 255.0F) << 24;
- mc.textRenderer.draw(text, -halfWidth, 0f, 553648127, false, matrices.peek().getPositionMatrix(), immediate, TextRenderer.TextLayerType.NORMAL, opacity, 0xf000f0);
- immediate.draw();
- } else {
- matrices.push();
- matrices.translate(1, 1, 0);
- mc.textRenderer.draw(text.copyContentOnly(), -halfWidth, 0f, 0x202020, false, matrices.peek().getPositionMatrix(), immediate, TextRenderer.TextLayerType.NORMAL, 0, 0xf000f0);
- immediate.draw();
- matrices.pop();
- }
-
- mc.textRenderer.draw(text, -halfWidth, 0f, -1, false, matrices.peek().getPositionMatrix(), immediate, TextRenderer.TextLayerType.NORMAL, 0, 0xf000f0);
- immediate.draw();
-
- RenderSystem.disableBlend();
- }
-
- /** Draws a 2D gui items somewhere in the world. **/
- public static void drawGuiItem(double x, double y, double z, double offX, double offY, double scale, ItemStack item) {
- if (item.isEmpty()) {
- return;
- }
-
- MatrixStack matrices = matrixFrom(x, y, z);
-
- Camera camera = mc.gameRenderer.getCamera();
- // matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw()));
- matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-camera.getYaw()));
- // matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
- matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch()));
-
- matrices.translate(offX, offY, 0);
- matrices.scale((float) scale, (float) scale, 0.001f);
-
- // matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180f));
- matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180f));
-
- //mc.getBufferBuilders().getEntityVertexConsumers().draw();
-
- RenderSystem.enableBlend();
- RenderSystem.defaultBlendFunc();
-
- // Vec3f[] currentLight = getCurrentLight();
- Vector3f[] currentLight = getCurrentLight();
- DiffuseLighting.disableGuiDepthLighting();
-
- mc.getBufferBuilders().getEntityVertexConsumers().draw();
-
- mc.getItemRenderer().renderItem(item, ModelTransformationMode.GUI, 0xF000F0,
- OverlayTexture.DEFAULT_UV, matrices, mc.getBufferBuilders().getEntityVertexConsumers(), mc.world, 0);
-
- mc.getBufferBuilders().getEntityVertexConsumers().draw();
-
- RenderSystem.setShaderLights(currentLight[0], currentLight[1]);
- RenderSystem.disableBlend();
- }
-
- public static MatrixStack matrixFrom(double x, double y, double z) {
- MatrixStack matrices = new MatrixStack();
-
- Camera camera = mc.gameRenderer.getCamera();
- // matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
- matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch()));
- // matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(camera.getYaw() + 180.0F));
- matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(camera.getYaw() + 180.0F));
-
- matrices.translate(x - camera.getPos().x, y - camera.getPos().y, z - camera.getPos().z);
-
- return matrices;
- }
-
- // public static Vec3f[] getCurrentLight() {
- public static Vector3f[] getCurrentLight() {
- if (shaderLightField == null) {
- shaderLightField = FieldUtils.getField(RenderSystem.class, "shaderLightDirections", true);
- }
-
- try {
- // return (Vec3f[]) shaderLightField.get(null);
- return (Vector3f[]) shaderLightField.get(null);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/Vertexer.java b/src/main/java/me/xmrvizzy/skyblocker/utils/Vertexer.java
deleted file mode 100644
index cf6d90b6..00000000
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/Vertexer.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package me.xmrvizzy.skyblocker.utils;
-
-import me.xmrvizzy.skyblocker.utils.color.LineColor;
-import me.xmrvizzy.skyblocker.utils.color.QuadColor;
-import net.minecraft.client.render.VertexConsumer;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.util.math.Box;
-import net.minecraft.util.math.Direction;
-import net.minecraft.util.math.MathHelper;
-// import net.minecraft.util.math.Matrix3f;
-// import net.minecraft.util.math.Matrix4f;
-// import net.minecraft.util.math.Vec3f;
-import org.joml.Matrix3f;
-import org.joml.Matrix4f;
-import org.joml.Vector3f;
-import org.apache.commons.lang3.ArrayUtils;
-
-public class Vertexer {
-
- public static final int CULL_BACK = 0;
- public static final int CULL_FRONT = 1;
- public static final int CULL_NONE = 2;
-
- public static void vertexBoxQuads(MatrixStack matrices, VertexConsumer vertexConsumer, Box box, QuadColor quadColor, Direction... excludeDirs) {
- float x1 = (float) box.minX;
- float y1 = (float) box.minY;
- float z1 = (float) box.minZ;
- float x2 = (float) box.maxX;
- float y2 = (float) box.maxY;
- float z2 = (float) box.maxZ;
-
- int cullMode = excludeDirs.length == 0 ? CULL_BACK : CULL_NONE;
-
- if (!ArrayUtils.contains(excludeDirs, Direction.DOWN)) {
- vertexQuad(matrices, vertexConsumer, x1, y1, z1, x2, y1, z1, x2, y1, z2, x1, y1, z2, cullMode, quadColor);
- }
-
- if (!ArrayUtils.contains(excludeDirs, Direction.WEST)) {
- vertexQuad(matrices, vertexConsumer, x1, y1, z2, x1, y2, z2, x1, y2, z1, x1, y1, z1, cullMode, quadColor);
- }
-
- if (!ArrayUtils.contains(excludeDirs, Direction.EAST)) {
- vertexQuad(matrices, vertexConsumer, x2, y1, z1, x2, y2, z1, x2, y2, z2, x2, y1, z2, cullMode, quadColor);
- }
-
- if (!ArrayUtils.contains(excludeDirs, Direction.NORTH)) {
- vertexQuad(matrices, vertexConsumer, x1, y1, z1, x1, y2, z1, x2, y2, z1, x2, y1, z1, cullMode, quadColor);
- }
-
- if (!ArrayUtils.contains(excludeDirs, Direction.SOUTH)) {
- vertexQuad(matrices, vertexConsumer, x2, y1, z2, x2, y2, z2, x1, y2, z2, x1, y1, z2, cullMode, quadColor);
- }
-
- if (!ArrayUtils.contains(excludeDirs, Direction.UP)) {
- vertexQuad(matrices, vertexConsumer, x1, y2, z2, x2, y2, z2, x2, y2, z1, x1, y2, z1, cullMode, quadColor);
- }
- }
-
- public static void vertexQuad(MatrixStack matrices, VertexConsumer vertexConsumer, float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, int cullMode, QuadColor quadColor) {
- int[] color = quadColor.getAllColors();
-
- if (cullMode != CULL_FRONT) {
- vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x1, y1, z1).color(color[0], color[1], color[2], color[3]).next();
- vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x2, y2, z2).color(color[4], color[5], color[6], color[7]).next();
- vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x3, y3, z3).color(color[8], color[9], color[10], color[11]).next();
- vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x4, y4, z4).color(color[12], color[13], color[14], color[15]).next();
- }
-
- if (cullMode != CULL_BACK) {
- vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x4, y4, z4).color(color[0], color[1], color[2], color[3]).next();
- vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x3, y3, z3).color(color[4], color[5], color[6], color[7]).next();
- vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x2, y2, z2).color(color[8], color[9], color[10], color[11]).next();
- vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x1, y1, z1).color(color[12], color[13], color[14], color[15]).next();
- }
- }
-
- public static void vertexBoxLines(MatrixStack matrices, VertexConsumer vertexConsumer, Box box, QuadColor quadColor, Direction... excludeDirs) {
- float x1 = (float) box.minX;
- float y1 = (float) box.minY;
- float z1 = (float) box.minZ;
- float x2 = (float) box.maxX;
- float y2 = (float) box.maxY;
- float z2 = (float) box.maxZ;
-
- boolean exDown = ArrayUtils.contains(excludeDirs, Direction.DOWN);
- boolean exWest = ArrayUtils.contains(excludeDirs, Direction.WEST);
- boolean exEast = ArrayUtils.contains(excludeDirs, Direction.EAST);
- boolean exNorth = ArrayUtils.contains(excludeDirs, Direction.NORTH);
- boolean exSouth = ArrayUtils.contains(excludeDirs, Direction.SOUTH);
- boolean exUp = ArrayUtils.contains(excludeDirs, Direction.UP);
-
- int[] color = quadColor.getAllColors();
-
- if (!exDown) {
- vertexLine(matrices, vertexConsumer, x1, y1, z1, x2, y1, z1, LineColor.single(color[0], color[1], color[2], color[3]));
- vertexLine(matrices, vertexConsumer, x2, y1, z1, x2, y1, z2, LineColor.single(color[4], color[5], color[6], color[7]));
- vertexLine(matrices, vertexConsumer, x2, y1, z2, x1, y1, z2, LineColor.single(color[8], color[9], color[10], color[11]));
- vertexLine(matrices, vertexConsumer, x1, y1, z2, x1, y1, z1, LineColor.single(color[12], color[13], color[14], color[15]));
- }
-
- if (!exWest) {
- if (exDown) vertexLine(matrices, vertexConsumer, x1, y1, z1, x1, y1, z2, LineColor.single(color[0], color[1], color[2], color[3]));
- vertexLine(matrices, vertexConsumer, x1, y1, z2, x1, y2, z2, LineColor.single(color[4], color[5], color[6], color[7]));
- vertexLine(matrices, vertexConsumer, x1, y1, z1, x1, y2, z1, LineColor.single(color[8], color[9], color[10], color[11]));
- if (exUp) vertexLine(matrices, vertexConsumer, x1, y2, z1, x1, y2, z2, LineColor.single(color[12], color[13], color[14], color[15]));
- }
-
- if (!exEast) {
- if (exDown) vertexLine(matrices, vertexConsumer, x2, y1, z1, x2, y1, z2, LineColor.single(color[0], color[1], color[2], color[3]));
- vertexLine(matrices, vertexConsumer, x2, y1, z2, x2, y2, z2, LineColor.single(color[4], color[5], color[6], color[7]));
- vertexLine(matrices, vertexConsumer, x2, y1, z1, x2, y2, z1, LineColor.single(color[8], color[9], color[10], color[11]));
- if (exUp) vertexLine(matrices, vertexConsumer, x2, y2, z1, x2, y2, z2, LineColor.single(color[12], color[13], color[14], color[15]));
- }
-
- if (!exNorth) {
- if (exDown) vertexLine(matrices, vertexConsumer, x1, y1, z1, x2, y1, z1, LineColor.single(color[0], color[1], color[2], color[3]));
- if (exEast) vertexLine(matrices, vertexConsumer, x2, y1, z1, x2, y2, z1, LineColor.single(color[4], color[5], color[6], color[7]));
- if (exWest) vertexLine(matrices, vertexConsumer, x1, y1, z1, x1, y2, z1, LineColor.single(color[8], color[9], color[10], color[11]));
- if (exUp) vertexLine(matrices, vertexConsumer, x1, y2, z1, x2, y2, z1, LineColor.single(color[12], color[13], color[14], color[15]));
- }
-
- if (!exSouth) {
- if (exDown) vertexLine(matrices, vertexConsumer, x1, y1, z2, x2, y1, z2, LineColor.single(color[0], color[1], color[2], color[3]));
- if (exEast) vertexLine(matrices, vertexConsumer, x2, y1, z2, x2, y2, z2, LineColor.single(color[4], color[5], color[6], color[7]));
- if (exWest) vertexLine(matrices, vertexConsumer, x1, y1, z2, x1, y2, z2, LineColor.single(color[8], color[9], color[10], color[11]));
- if (exUp) vertexLine(matrices, vertexConsumer, x1, y2, z2, x2, y2, z2, LineColor.single(color[12], color[13], color[14], color[15]));
- }
-
- if (!exUp) {
- vertexLine(matrices, vertexConsumer, x1, y2, z1, x2, y2, z1, LineColor.single(color[0], color[1], color[2], color[3]));
- vertexLine(matrices, vertexConsumer, x2, y2, z1, x2, y2, z2, LineColor.single(color[4], color[5], color[6], color[7]));
- vertexLine(matrices, vertexConsumer, x2, y2, z2, x1, y2, z2, LineColor.single(color[8], color[9], color[10], color[11]));
- vertexLine(matrices, vertexConsumer, x1, y2, z2, x1, y2, z1, LineColor.single(color[12], color[13], color[14], color[15]));
- }
- }
-
- public static void vertexLine(MatrixStack matrices, VertexConsumer vertexConsumer, float x1, float y1, float z1, float x2, float y2, float z2, LineColor lineColor) {
- Matrix4f model = matrices.peek().getPositionMatrix();
- Matrix3f normal = matrices.peek().getNormalMatrix();
-
- // Vec3f normalVec = getNormal(normal, x1, y1, z1, x2, y2, z2);
- Vector3f normalVec = getNormal(normal, x1, y1, z1, x2, y2, z2);
-
- int[] color1 = lineColor.getColor(x1, y1, z1, 0);
- int[] color2 = lineColor.getColor(x2, y2, z2, 1);
-
- // vertexConsumer.vertex(model, x1, y1, z1).color(color1[0], color1[1], color1[2], color1[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
- vertexConsumer.vertex(model, x1, y1, z1).color(color1[0], color1[1], color1[2], color1[3]).normal(normal, normalVec.x(), normalVec.y(), normalVec.z()).next();
- // vertexConsumer.vertex(model, x2, y2, z2).color(color2[0], color2[1], color2[2], color2[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
- vertexConsumer.vertex(model, x2, y2, z2).color(color2[0], color2[1], color2[2], color2[3]).normal(normal, normalVec.x(), normalVec.y(), normalVec.z()).next();
- }
-
- // public static Vec3f getNormal(Matrix3f normal, float x1, float y1, float z1, float x2, float y2, float z2) {
- public static Vector3f getNormal(Matrix3f normal, float x1, float y1, float z1, float x2, float y2, float z2) {
- float xNormal = x2 - x1;
- float yNormal = y2 - y1;
- float zNormal = z2 - z1;
- float normalSqrt = MathHelper.sqrt(xNormal * xNormal + yNormal * yNormal + zNormal * zNormal);
-
- // return new Vec3f(xNormal / normalSqrt, yNormal / normalSqrt, zNormal / normalSqrt);
- return new Vector3f(xNormal / normalSqrt, yNormal / normalSqrt, zNormal / normalSqrt);
- }
-
-} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/color/LineColor.java b/src/main/java/me/xmrvizzy/skyblocker/utils/color/LineColor.java
deleted file mode 100644
index 42cf5926..00000000
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/color/LineColor.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package me.xmrvizzy.skyblocker.utils.color;
-
-import com.mojang.datafixers.util.Function4;
-
-public class LineColor extends RenderColor {
-
- private final Function4<Float, Float, Float, Integer, int[]> getColorFunc;
-
- public static LineColor single(float red, float green, float blue, float alpha) {
- return LineColor.single((int) (red * 255f), (int) (green * 255f), (int) (blue * 255f), (int) (alpha * 255f));
- }
-
- public static LineColor single(int color) {
- return LineColor.single((color & 0xff0000) >> 16, (color & 0xff00) >> 8, color & 0xff, color >> 24 & 0xff);
- }
-
- public static LineColor single(int red, int green, int blue, int alpha) {
- return new LineColor((x, y, z, curVertex) -> new int[] { red, green, blue, alpha });
- }
-
- public static LineColor gradient(float red1, float green1, float blue1, float alpha1, float red2, float green2, float blue2, float alpha2) {
- return LineColor.gradient(
- (int) (red1 * 255f), (int) (green1 * 255f), (int) (blue1 * 255f), (int) (alpha1 * 255f),
- (int) (red2 * 255f), (int) (green2 * 255f), (int) (blue2 * 255f), (int) (alpha2 * 255f));
- }
-
- public static LineColor gradient(int color1, int color2) {
- return LineColor.gradient(
- (color1 & 0xff0000) >> 16, (color1 & 0xff00) >> 8, color1 & 0xff, color1 >> 24 & 0xff,
- (color2 & 0xff0000) >> 16, (color2 & 0xff00) >> 8, color2 & 0xff, color2 >> 24 & 0xff);
- }
-
- public static LineColor gradient(int red1, int green1, int blue1, int alpha1, int red2, int green2, int blue2, int alpha2) {
- return new LineColor((x, y, z, curVertex) -> {
- if (curVertex == 0) {
- return new int[] { red1, green1, blue1, alpha1 };
- }
-
- return new int[] { red2, green2, blue2, alpha2 };
- });
- }
-
- private LineColor(Function4<Float, Float, Float, Integer, int[]> getColorFunc) {
- this.getColorFunc = getColorFunc;
- }
-
- public int[] getColor(float x, float y, float z, int curVertex) {
- int[] outColor = getColorFunc.apply(x, y, z, curVertex);
-
- for (int i = 0; i < 4; i++) {
- if (overwriteColor[i] != null) {
- outColor[i] = overwriteColor[i];
- }
- }
-
- return outColor;
- }
-
- public LineColor clone() {
- LineColor newColor = new LineColor(getColorFunc);
- cloneOverwriteTo(newColor);
-
- return newColor;
- }
-
-} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/color/QuadColor.java b/src/main/java/me/xmrvizzy/skyblocker/utils/color/QuadColor.java
deleted file mode 100644
index cb1ce66e..00000000
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/color/QuadColor.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package me.xmrvizzy.skyblocker.utils.color;
-
-
-import java.util.function.Function;
-
-public class QuadColor extends RenderColor {
-
- private final Function<Integer, int[]> getColorFunc;
-
- public static QuadColor single(float red, float green, float blue, float alpha) {
- return QuadColor.single((int) (red * 255f), (int) (green * 255f), (int) (blue * 255f), (int) (alpha * 255f));
- }
-
- public static QuadColor single(int red, int green, int blue, int alpha) {
- return new QuadColor(curVertex -> new int[]{red, green, blue, alpha});
- }
-
- public static QuadColor gradient(int red1, int green1, int blue1, int alpha1, int red2, int green2, int blue2, int alpha2, CardinalDirection direction) {
- return new QuadColor(curVertex -> {
- if (direction.isStartVertex(curVertex)) {
- return new int[]{red1, green1, blue1, alpha1};
- }
-
- return new int[]{red2, green2, blue2, alpha2};
- });
- }
-
- public static QuadColor custom(float red1, float green1, float blue1, float alpha1, float red2, float green2, float blue2, float alpha2, float red3, float green3, float blue3, float alpha3, float red4, float green4, float blue4, float alpha4) {
- return QuadColor.custom(
- (int) (red1 * 255f), (int) (green1 * 255f), (int) (blue1 * 255f), (int) (alpha1 * 255f),
- (int) (red2 * 255f), (int) (green2 * 255f), (int) (blue2 * 255f), (int) (alpha2 * 255f),
- (int) (red3 * 255f), (int) (green3 * 255f), (int) (blue3 * 255f), (int) (alpha3 * 255f),
- (int) (red4 * 255f), (int) (green4 * 255f), (int) (blue4 * 255f), (int) (alpha4 * 255f));
- }
-
- public static QuadColor custom(int color1, int color2, int color3, int color4) {
- return QuadColor.custom(
- (color1 & 0xff0000) >> 16, (color1 & 0xff00) >> 8, color1 & 0xff, color1 >> 24 & 0xff,
- (color2 & 0xff0000) >> 16, (color2 & 0xff00) >> 8, color2 & 0xff, color2 >> 24 & 0xff,
- (color3 & 0xff0000) >> 16, (color3 & 0xff00) >> 8, color3 & 0xff, color3 >> 24 & 0xff,
- (color4 & 0xff0000) >> 16, (color4 & 0xff00) >> 8, color4 & 0xff, color4 >> 24 & 0xff);
- }
-
- public static QuadColor custom(int red1, int green1, int blue1, int alpha1, int red2, int green2, int blue2, int alpha2, int red3, int green3, int blue3, int alpha3, int red4, int green4, int blue4, int alpha4) {
- return new QuadColor(curVertex -> switch (curVertex) {
- case 0 -> new int[]{red1, green1, blue1, alpha1};
- case 1 -> new int[]{red2, green2, blue2, alpha2};
- case 2 -> new int[]{red3, green3, blue3, alpha3};
- default -> new int[]{red4, green4, blue4, alpha4};
- });
- }
-
- private QuadColor(Function<Integer, int[]> getColorFunc) {
- this.getColorFunc = getColorFunc;
- }
-
- public int[] getColor(int curVertex) {
- int[] outColor = getColorFunc.apply(curVertex);
-
- for (int i = 0; i < 4; i++) {
- if (overwriteColor[i] != null) {
- outColor[i] = overwriteColor[i];
- }
- }
-
- return outColor;
- }
-
- public int[] getAllColors() {
- int[] outColor = new int[16];
-
- for (int i = 0; i < 4; i++) {
- int[] curColor = getColor(i);
-
- System.arraycopy(curColor, 0, outColor, i * 4, 4);
- }
-
- return outColor;
- }
-
- public QuadColor clone() {
- QuadColor n