aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy
diff options
context:
space:
mode:
authorLifeIsAParadox <LifeIsAParadox@users.noreply.github.com>2021-09-14 08:47:32 +0200
committerLifeIsAParadox <LifeIsAParadox@users.noreply.github.com>2021-09-14 08:47:32 +0200
commit7d2446cdc4bac31cb29709068b2f874da87d4ea9 (patch)
tree13117dbf6a53e1ca8a474d4fce85c21b09c698f1 /src/main/java/me/xmrvizzy
parentb23331eb654e2e26d17d13616c05ffe3af822290 (diff)
downloadSkyblocker-7d2446cdc4bac31cb29709068b2f874da87d4ea9.tar.gz
Skyblocker-7d2446cdc4bac31cb29709068b2f874da87d4ea9.tar.bz2
Skyblocker-7d2446cdc4bac31cb29709068b2f874da87d4ea9.zip
Bugfixing and Blaze solver
Diffstat (limited to 'src/main/java/me/xmrvizzy')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java8
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/mixin/AccessorWorldRenderer.java15
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/mixin/ItemRendererMixin.java2
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonBlaze.java50
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonMap.java5
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java27
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/Boxes.java47
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/FrustumUtils.java17
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtils.java235
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtilsLiving.java181
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java6
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/Vertexer.java156
-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.java115
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/color/RenderColor.java27
15 files changed, 612 insertions, 345 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java
index f81135de..6a9048d2 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java
@@ -1,19 +1,11 @@
package me.xmrvizzy.skyblocker;
-import java.util.Map;
-
-import com.google.gson.JsonObject;
-
-import org.apache.commons.lang3.ObjectUtils.Null;
-
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import me.xmrvizzy.skyblocker.skyblock.HotbarSlotLock;
import me.xmrvizzy.skyblocker.skyblock.dungeon.DungeonBlaze;
import me.xmrvizzy.skyblocker.utils.Utils;
import net.fabricmc.api.ClientModInitializer;
-import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
import net.minecraft.client.MinecraftClient;
-import me.xmrvizzy.skyblocker.skyblock.item.PriceInfoTooltip;
public class SkyblockerMod implements ClientModInitializer {
public static final String NAMESPACE = "skyblocker";
private static int TICKS = 0;
diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/AccessorWorldRenderer.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/AccessorWorldRenderer.java
new file mode 100644
index 00000000..02990ea9
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/AccessorWorldRenderer.java
@@ -0,0 +1,15 @@
+package me.xmrvizzy.skyblocker.mixin;
+
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+import net.minecraft.client.render.Frustum;
+import net.minecraft.client.render.WorldRenderer;
+
+@Mixin(WorldRenderer.class)
+public interface AccessorWorldRenderer {
+
+ @Accessor
+ Frustum getFrustum();
+
+} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/ItemRendererMixin.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/ItemRendererMixin.java
index 90f82da6..002497ce 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/mixin/ItemRendererMixin.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/ItemRendererMixin.java
@@ -4,14 +4,12 @@ import com.mojang.blaze3d.systems.RenderSystem;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import me.xmrvizzy.skyblocker.utils.ItemUtils;
import me.xmrvizzy.skyblocker.utils.Utils;
-import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
-import net.minecraft.text.LiteralText;
import net.minecraft.util.math.MathHelper;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonBlaze.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonBlaze.java
index fd20c3a4..621c5cc4 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonBlaze.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonBlaze.java
@@ -1,51 +1,16 @@
package me.xmrvizzy.skyblocker.skyblock.dungeon;
-import java.util.List;
-
-import com.mojang.blaze3d.systems.RenderCall;
-
-import org.lwjgl.opengl.GL11;
-
+import me.xmrvizzy.skyblocker.utils.color.QuadColor;
import me.xmrvizzy.skyblocker.utils.RenderUtils;
-import me.xmrvizzy.skyblocker.utils.RenderUtilsLiving;
-import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;
-import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
-import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
-import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents.AfterEntities;
-import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents.BeforeEntities;
-import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents.DebugRender;
-import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents.Start;
-import net.fabricmc.fabric.api.renderer.v1.RendererAccess;
-import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderContext;
-import net.fabricmc.fabric.impl.client.rendering.WorldRenderContextImpl;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
-import net.minecraft.client.gui.Drawable;
-import net.minecraft.client.gui.DrawableHelper;
-import net.minecraft.client.gui.hud.InGameHud;
-import net.minecraft.client.render.BufferBuilder;
-import net.minecraft.client.render.GameRenderer;
-import net.minecraft.client.render.Tessellator;
-import net.minecraft.client.render.VertexFormats;
-import net.minecraft.client.render.WorldRenderer;
-import net.minecraft.client.render.block.BlockModelRenderer;
-import net.minecraft.client.render.block.BlockRenderManager;
-import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
-import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.debug.DebugRenderer;
-import net.minecraft.client.render.debug.DebugRenderer.Renderer;
-import net.minecraft.client.render.entity.EntityRenderDispatcher;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.util.math.Vec3f;
import net.minecraft.entity.Entity;
-import net.minecraft.entity.mob.BlazeEntity;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Formatting;
-import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
-import net.minecraft.util.math.Vec3d;
public class DungeonBlaze {
static Entity highestBlaze = null;
@@ -98,23 +63,26 @@ public class DungeonBlaze {
}
}
public static void blazeRenderer(WorldRenderContext wrc) {
+ QuadColor outlineColorRed = QuadColor.single( 0.0F, 1.0F, 0.0F, 1f);
+ QuadColor outlineColorGreen = QuadColor.single(1.0F, 0.0F, 0.0F, 1f);
try {
TextRenderer tr = MinecraftClient.getInstance().textRenderer;
DebugRenderer wc = MinecraftClient.getInstance().debugRenderer;
if(highestBlaze != null){
- /* Outline */
+ /* Outline */
Box blaze = highestBlaze.getBoundingBox().expand(1);
- RenderUtils.drawOutlineBox(blaze, 0.0F, 1.0F, 0.0F, 1f);
+ RenderUtils.drawBoxOutline(blaze,outlineColorRed,2.5f);
}
if(lowestBlaze != null){
- /* Outline */
+ /* Outline */
Box blaze = lowestBlaze.getBoundingBox().expand(1);
- RenderUtils.drawOutlineBox(blaze, 1.0F, 0.0F, 0.0F, 1f);
+ RenderUtils.drawBoxOutline(blaze,outlineColorGreen,2.5f);
}
}catch(Exception e) {
- System.out.println("BlazeRenderer: " + e.getStackTrace());
+ //System.out.println("BlazeRenderer: " + e.getStackTrace());
+ System.out.println("BlazeRenderer: " + e);
}
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonMap.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonMap.java
index c6da694b..3531094a 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonMap.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonMap.java
@@ -18,9 +18,12 @@ public class DungeonMap {
NbtCompound tag = item.getNbt();
if (tag != null && tag.contains("map")) {
+ String tag2 = tag.asString();
+ tag2 = tag2.substring(tag2.indexOf(":") + 1, tag2.indexOf("}"));
+ int tagid = Integer.parseInt(tag2);
VertexConsumerProvider.Immediate vertices = client.getBufferBuilders().getEffectVertexConsumers();
MapRenderer map = client.gameRenderer.getMapRenderer();
- MapState state = FilledMapItem.getOrCreateMapState(item, client.world);
+ MapState state = FilledMapItem.getMapState(tagid, client.world);
if (state == null) return;
matrices.push();
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java
index 59ff2e45..36b83670 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java
@@ -1,6 +1,17 @@
package me.xmrvizzy.skyblocker.skyblock.item;
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.item.TooltipContext;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NbtCompound;
+import net.minecraft.text.LiteralText;
+import net.minecraft.text.Text;
+import net.minecraft.util.Formatting;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -9,24 +20,8 @@ import java.math.RoundingMode;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.List;
-import java.util.Map;
import java.util.zip.GZIPInputStream;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.item.TooltipContext;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NbtCompound;
-import net.minecraft.text.LiteralText;
-import net.minecraft.text.Text;
-import net.minecraft.util.Formatting;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-
-import me.xmrvizzy.skyblocker.SkyblockerMod;
-
public class PriceInfoTooltip {
private JsonObject auctionPricesJson = null;
private JsonObject bazaarPricesJson = null;
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/Boxes.java b/src/main/java/me/xmrvizzy/skyblocker/utils/Boxes.java
new file mode 100644
index 00000000..445bcbe5
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/Boxes.java
@@ -0,0 +1,47 @@
+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);
+ }
+
+ /** Returns the vector of the max pos of this box. **/
+ public static Vec3d getMaxVec(Box box) {
+ return new Vec3d(box.maxX, box.maxY, box.maxZ);
+ }
+
+ /** Offsets this box so that minX, minY and minZ are all zero. **/
+ public static Box moveToZero(Box box) {
+ return box.offset(getMinVec(box).negate());
+ }
+
+ /** Returns the distance between to oppisite corners of the box. **/
+ public static double getCornerLength(Box box) {
+ return getMinVec(box).distanceTo(getMaxVec(box));
+ }
+
+ /** Returns the length of an axis in the box. **/
+ public static double getAxisLength(Box box, Axis axis) {
+ return box.getMax(axis) - box.getMin(axis);
+ }
+
+ /** Returns a box with each axis multiplied by the amount specified. **/
+ public static Box multiply(Box box, double amount) {
+ return multiply(box, amount, amount, amount);
+ }
+
+ /** Returns a box with each axis multiplied by the amount specified. **/
+ public static Box multiply(Box box, double x, double y, double z) {
+ return box.expand(
+ getAxisLength(box, Axis.X) * (x - 1) / 2d,
+ getAxisLength(box, Axis.Y) * (y - 1) / 2d,
+ getAxisLength(box, Axis.Z) * (z - 1) / 2d);
+ }
+}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/FrustumUtils.java b/src/main/java/me/xmrvizzy/skyblocker/utils/FrustumUtils.java
new file mode 100644
index 00000000..6973aa1e
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/FrustumUtils.java
@@ -0,0 +1,17 @@
+package me.xmrvizzy.skyblocker.utils;
+
+import me.xmrvizzy.skyblocker.mixin.AccessorWorldRenderer;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.render.Frustum;
+import net.minecraft.util.math.Box;
+
+public class FrustumUtils {
+
+ public static Frustum getFrustum() {
+ return ((AccessorWorldRenderer) MinecraftClient.getInstance().worldRenderer).getFrustum();
+ }
+
+ public static boolean isBoxVisible(Box box) {
+ return getFrustum().isVisible(box);
+ }
+} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtils.java b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtils.java
index 472c41d6..05044ba0 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtils.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtils.java
@@ -1,224 +1,89 @@
package me.xmrvizzy.skyblocker.utils;
-import com.mojang.blaze3d.platform.GlStateManager;
+import com.mojang.blaze3d.systems.RenderSystem;
+import me.xmrvizzy.skyblocker.utils.color.QuadColor;
import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.render.*;
-import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
+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 org.lwjgl.opengl.GL11;
-import org.lwjgl.opengl.GL14;
+import net.minecraft.util.math.Vec3f;
public class RenderUtils {
- public static void drawFilledBox(BlockPos blockPos, float r, float g, float b, float a) {
- drawFilledBox(new Box(blockPos), r, g, b, a);
- }
-
- public static void drawFilledBox(Box box, float r, float g, float b, float a) {
- gl11Setup();
-
- // Fill
- Tessellator tessellator = Tessellator.getInstance();
- BufferBuilder buffer = tessellator.getBuffer();
- VertexFormat.DrawMode drawMode = VertexFormat.DrawMode.QUADS;
- buffer.begin(drawMode, VertexFormats.POSITION_COLOR);
-// buffer.begin(5, VertexFormats.POSITION_COLOR);
- WorldRenderer.drawBox(buffer,
- box.minX, box.minY, box.minZ,
- box.maxX, box.maxY, box.maxZ, r, g, b, a / 2f);
- tessellator.draw();
+ // -------------------- Outline Boxes --------------------
- // Outline
- buffer.begin(drawMode, VertexFormats.POSITION_COLOR);
-
-// buffer.begin(3, VertexFormats.POSITION_COLOR);
- buffer.vertex(box.minX, box.minY, box.minZ).color(r, g, b, a).next();
- buffer.vertex(box.minX, box.minY, box.maxZ).color(r, g, b, a).next();
- buffer.vertex(box.maxX, box.minY, box.maxZ).color(r, g, b, a).next();
- buffer.vertex(box.maxX, box.minY, box.minZ).color(r, g, b, a).next();
- buffer.vertex(box.minX, box.minY, box.minZ).color(r, g, b, a).next();
- buffer.vertex(box.minX, box.maxY, box.minZ).color(r, g, b, a).next();
- buffer.vertex(box.maxX, box.maxY, box.minZ).color(r, g, b, a).next();
- buffer.vertex(box.maxX, box.maxY, box.maxZ).color(r, g, b, a).next();
- buffer.vertex(box.minX, box.maxY, box.maxZ).color(r, g, b, a).next();
- buffer.vertex(box.minX, box.maxY, box.minZ).color(r, g, b, a).next();
- buffer.vertex(box.minX, box.minY, box.maxZ).color(r, g, b, 0f).next();
- buffer.vertex(box.minX, box.maxY, box.maxZ).color(r, g, b, a).next();
- buffer.vertex(box.maxX, box.minY, box.maxZ).color(r, g, b, 0f).next();
- buffer.vertex(box.maxX, box.maxY, box.maxZ).color(r, g, b, a).next();
- buffer.vertex(box.maxX, box.minY, box.minZ).color(r, g, b, 0f).next();
- buffer.vertex(box.maxX, box.maxY, box.minZ).color(r, g, b, a).next();
- tessellator.draw();
-
- gl11Cleanup();
- }
-
- public static void drawOutlineBox(BlockPos blockPos, float r, float g, float b, float a) {
- drawOutlineBox(new Box(blockPos), r, g, b, a);
- }
-
- public static void fillGradient(MatrixStack matrix, int x1, int y1, int x2, int y2, int color1, int color2) {
- float float_1 = (color1 >> 24 & 255) / 255.0F;
- float float_2 = (color1 >> 16 & 255) / 255.0F;
- float float_3 = (color1 >> 8 & 255) / 255.0F;
- float float_4 = (color1 & 255) / 255.0F;
- float float_5 = (color2 >> 24 & 255) / 255.0F;
- float float_6 = (color2 >> 16 & 255) / 255.0F;
- float float_7 = (color2 >> 8 & 255) / 255.0F;
- float float_8 = (color2 & 255) / 255.0F;
- Tessellator tessellator_1 = Tessellator.getInstance();
- BufferBuilder bufferBuilder_1 = tessellator_1.getBuffer();
-
- VertexFormat.DrawMode drawMode = VertexFormat.DrawMode.QUADS;
- bufferBuilder_1.begin(drawMode, VertexFormats.POSITION_COLOR);
-
-// bufferBuilder_1.begin(7, VertexFormats.POSITION_COLOR);
- bufferBuilder_1.vertex(x1, y1, 0).color(float_2, float_3, float_4, float_1).next();
- bufferBuilder_1.vertex(x1, y2, 0).color(float_2, float_3, float_4, float_1).next();
- bufferBuilder_1.vertex(x2, y2, 0).color(float_6, float_7, float_8, float_5).next();
- bufferBuilder_1.vertex(x2, y1, 0).color(float_6, float_7, float_8, float_5).next();
- tessellator_1.draw();
- }
+ public static void drawBoxOutline(Box box, QuadColor color, float lineWidth, Direction... excludeDirs) {
+ if (!FrustumUtils.isBoxVisible(box)) {
+ return;
+ }
+ setup();
- public static void drawOutlineBox(Box box, float r, float g, float b, float a) {
- gl11Setup();
+ MatrixStack matrices = matrixFrom(box.minX, box.minY, box.minZ);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
// Outline
- VertexFormat.DrawMode drawMode = VertexFormat.DrawMode.QUADS;
- buffer.begin(drawMode, VertexFormats.POSITION_COLOR);
-
-// buffer.begin(3, VertexFormats.POSITION_COLOR);
- buffer.vertex(box.minX, box.minY, box.minZ).color(r, g, b, a).next();
- buffer.vertex(box.minX, box.minY, box.maxZ).color(r, g, b, a).next();
- buffer.vertex(box.maxX, box.minY, box.maxZ).color(r, g, b, a).next();
- buffer.vertex(box.maxX, box.minY, box.minZ).color(r, g, b, a).next();
- buffer.vertex(box.minX, box.minY, box.minZ).color(r, g, b, a).next();
- buffer.vertex(box.minX, box.maxY, box.minZ).color(r, g, b, a).next();
- buffer.vertex(box.maxX, box.maxY, box.minZ).color(r, g, b, a).next();
- buffer.vertex(box.maxX, box.maxY, box.maxZ).color(r, g, b, a).next();
- buffer.vertex(box.minX, box.maxY, box.maxZ).color(r, g, b, a).next();
- buffer.vertex(box.minX, box.maxY, box.minZ).color(r, g, b, a).next();
- buffer.vertex(box.minX, box.minY, box.maxZ).color(r, g, b, 0f).next();
- buffer.vertex(box.minX, box.maxY, box.maxZ).color(r, g, b, a).next();
- buffer.vertex(box.maxX, box.minY, box.maxZ).color(r, g, b, 0f).next();
- buffer.vertex(box.maxX, box.maxY, box.maxZ).color(r, g, b, a).next();
- buffer.vertex(box.maxX, box.minY, box.minZ).color(r, g, b, 0f).next();
- buffer.vertex(box.maxX, box.maxY, box.minZ).color(r, g, b, a).next();
- tessellator.draw();
-
- gl11Cleanup();
- }
-
- public static void drawLine(double x1, double y1, double z1, double x2, double y2, double z2, float r, float g, float b, float t) {
- gl11Setup();
- GL11.glLineWidth(t);
+ RenderSystem.disableCull();
+ RenderSystem.setShader(GameRenderer::getRenderTypeLinesShader);
+ RenderSystem.lineWidth(lineWidth);
- Tessellator tessellator = Tessellator.getInstance();
- BufferBuilder buffer = tessellator.getBuffer();
-
- VertexFormat.DrawMode drawMode = VertexFormat.DrawMode.QUADS;
- buffer.begin(drawMode, VertexFormats.POSITION_COLOR);
-
-// buffer.begin(3, VertexFormats.POSITION_COLOR);
- buffer.vertex(x1, y1, z1).color(r, g, b, 0.0F).next();
- buffer.vertex(x1, y1, z1).color(r, g, b, 1.0F).next();
- buffer.vertex(x2, y2, z2).color(r, g, b, 1.0F).next();
+ buffer.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES);
+ Vertexer.vertexBoxLines(matrices, buffer, Boxes.moveToZero(box), color, excludeDirs);
tessellator.draw();
- gl11Cleanup();
+ RenderSystem.enableCull();
+ cleanup();
}
- public static void drawRect(float x, float y, float w, float h, int color, float alpha) {
- float red = (float) (color >> 16 & 255) / 255.0F;
- float green = (float) (color >> 8 & 255) / 255.0F;
- float blue = (float) (color & 255) / 255.0F;
- final Tessellator tessellator = Tessellator.getInstance();
- final BufferBuilder bufferbuilder = tessellator.getBuffer();
- GlStateManager._enableBlend();
- GlStateManager._disableTexture();
- GlStateManager._blendFuncSeparate(770, 771, 1, 0);
-
- VertexFormat.DrawMode drawMode = VertexFormat.DrawMode.QUADS;
- bufferbuilder.begin(drawMode, VertexFormats.POSITION_COLOR);
-
-// bufferbuilder.begin(7, VertexFormats.POSITION_COLOR);
- bufferbuilder.vertex(x, h, 0.0D).color(red, green, blue, alpha).next();
- bufferbuilder.vertex(w, h, 0.0D).color(red, green, blue, alpha).next();
- bufferbuilder.vertex(w, y, 0.0D).color(red, green, blue, alpha).next();
- bufferbuilder.vertex(x, y, 0.0D).color(red, green, blue, alpha).next();
- tessellator.draw();
- GlStateManager._enableTexture();
- GlStateManager._disableBlend();
- }
+ // -------------------- Utils --------------------
+
+ public static MatrixStack matrixFrom(double x, double y, double z) {
+ MatrixStack matrices = new MatrixStack();
- public static void offsetRender() {
- //debg
Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera();
- Vec3d camPos = camera.getPos();
- GL11.glRotated(MathHelper.wrapDegrees(camera.getPitch()), 1, 0, 0);
- GL11.glRotated(MathHelper.wrapDegrees(camera.getYaw() + 180.0), 0, 1, 0);
- GL11.glTranslated(-camPos.x, -camPos.y, -camPos.z);
- }
+ matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
+ matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(camera.getYaw() + 180.0F));
- public static void gl11Setup() {
- GL11.glPushMatrix();
- GL11.glEnable(GL11.GL_BLEND);
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
- GL11.glLineWidth(2.5F);
- GL11.glDisable(GL11.GL_TEXTURE_2D);
- GL11.glEnable(GL11.GL_LINE_SMOOTH);
- offsetRender();
- }
+ matrices.translate(x - camera.getPos().x, y - camera.getPos().y, z - camera.getPos().z);
- public static void gl11Cleanup() {
- GL11.glDisable(GL11.GL_LINE_SMOOTH);
- GL11.glEnable(GL11.GL_TEXTURE_2D);
- GL11.glDisable(GL11.GL_BLEND);
- GL11.glPopMatrix();
+ return matrices;
}
+ public static Vec3d getInterpolationOffset(Entity e) {
+ if (MinecraftClient.getInstance().isPaused()) {
+ return Vec3d.ZERO;
+ }
- public static void DrawPolygon(double x, double y, int radius, int sides, int color) {
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glDisable(GL11.GL_TEXTURE_2D);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
-
- final Tessellator tessellator = Tessellator.getInstance();
- final BufferBuilder bufferbuilder = tessellator.getBuffer();
-
- VertexFormat.DrawMode drawMode = VertexFormat.DrawMode.TRIANGLE_FAN;
- bufferbuilder.begin(drawMode, VertexFormats.POSITION_COLOR);
-
-// bufferbuilder.begin(GL11.GL_TRIANGLE_FAN, VertexFormats.POSITION);
-
- float alpha = (float) (color >> 24 & 255) / 255.0F;
- float red = (float) (color >> 16 & 255) / 255.0F;
- float green = (float) (color >> 8 & 255) / 255.0F;
- float blue = (float) (color & 255) / 255.0F;
-
- bufferbuilder.vertex(x, y, 0).next();
- final double TWICE_PI = Math.PI * 2;
+ double tickDelta = (double) 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()));
+ }
- for (int i = 0; i <= sides; i++) {
- double angle = (TWICE_PI * i / sides) + Math.toRadians(180);
- bufferbuilder.vertex(x + Math.sin(angle) * radius, y + Math.cos(angle) * radius, 0).next();
- }
- tessellator.draw();
+ public static void setup() {
+ RenderSystem.enableBlend();
+ RenderSystem.defaultBlendFunc();
+ RenderSystem.disableTexture();
+ }
- GL11.glEnable(GL11.GL_TEXTURE_2D);
- GL11.glDisable(GL11.GL_BLEND);
+ public static void cleanup() {
+ RenderSystem.disableBlend();
+ RenderSystem.enableTexture();
}
} \ 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
index 6fca52a0..f6fb1bc1 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtilsLiving.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtilsLiving.java
@@ -19,124 +19,127 @@ package me.xmrvizzy.skyblocker.utils;
*/
+import java.lang.reflect.Field;
+
+import org.apache.commons.lang3.reflect.FieldUtils;
+
+import com.mojang.blaze3d.systems.RenderSystem;
+
import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.render.BufferBuilder;
+import net.minecraft.client.render.Camera;
+import net.minecraft.client.render.DiffuseLighting;
+import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.Tessellator;
-import net.minecraft.client.render.VertexFormat;
-import net.minecraft.client.render.VertexFormats;
-import net.minecraft.client.render.model.json.ModelTransformation.Mode;
-import net.minecraft.client.resource.language.I18n;
+import net.minecraft.client.render.VertexConsumerProvider;
+import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.enchantment.Enchantment;
-import net.minecraft.enchantment.EnchantmentHelper;
-import net.minecraft.enchantment.Enchantments;
-import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
-import net.minecraft.util.math.MathHelper;
-import org.lwjgl.opengl.GL11;
-import org.lwjgl.opengl.GL14;
-
-import java.awt.*;
-import java.util.Map.Entry;
+import net.minecraft.text.Text;
+import net.minecraft.util.math.Vec3f;
public class RenderUtilsLiving {
- private static MinecraftClient mc = MinecraftClient.getInstance();
- public static void drawText(String str, double x, double y, double z, double scale)
- {
- drawText(str, x, y, z, scale, 0.0F, 0.0F, 0.0F);
+ 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);
}
- public static void drawText(String str, double x, double y, double z, double scale, float red, float green, float blue) {
- glSetup(x, y, z);
- GL11.glScaled(-0.025 * scale, -0.025 * scale, 0.025 * scale);
+ /** 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(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
- int i = mc.textRenderer.getWidth(str) / 2;
- GL11.glDisable(GL11.GL_TEXTURE_2D);
- Tessellator tessellator = Tessellator.getInstance();
- BufferBuilder bufferbuilder = tessellator.getBuffer();
+ RenderSystem.enableBlend();
+ RenderSystem.defaultBlendFunc();
- VertexFormat.DrawMode drawMode = VertexFormat.DrawMode.QUADS;
- bufferbuilder.begin(drawMode, VertexFormats.POSITION_COLOR);
+ matrices.translate(offX, offY, 0);
+ matrices.scale(-0.025f * (float) scale, -0.025f * (float) scale, 1);
-// bufferbuilder.begin(7, VertexFormats.POSITION_COLOR);
- float f = mc.options.getTextBackgroundOpacity(0.25F);
- bufferbuilder.vertex(-i - 1, -1, 0.0D).color(red, green, blue, f).next();
- bufferbuilder.vertex(-i - 1, 8, 0.0D).color(red, green, blue, f).next();
- bufferbuilder.vertex(i + 1, 8, 0.0D).color(red, green, blue, f).next();
- bufferbuilder.vertex(i + 1, -1, 0.0D).color(red, green, blue, f).next();
- tessellator.draw();
- GL11.glEnable(GL11.GL_TEXTURE_2D);
+ int halfWidth = mc.textRenderer.getWidth(text) / 2;
- mc.textRenderer.draw(new MatrixStack(), str, -i, 0, 553648127);
- mc.textRenderer.draw(new MatrixStack(), str, -i, 0, -1);
+ VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
- glCleanup();
+ if (fill) {
+ int opacity = (int) (MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F) * 255.0F) << 24;
+ mc.textRenderer.draw(text, -halfWidth, 0f, 553648127, false, matrices.peek().getModel(), immediate, true, opacity, 0xf000f0);
+ immediate.draw();
+ } else {
+ matrices.push();
+ matrices.translate(1, 1, 0);
+ mc.textRenderer.draw(text.copy(), -halfWidth, 0f, 0x202020, false, matrices.peek().getModel(), immediate, true, 0, 0xf000f0);
+ immediate.draw();
+ matrices.pop();
+ }
+
+ mc.textRenderer.draw(text, -halfWidth, 0f, -1, false, matrices.peek().getModel(), immediate, true, 0, 0xf000f0);
+ immediate.draw();
+
+ RenderSystem.disableBlend();
}
- public static void drawItem(double x, double y, double z, double offX, double offY, double scale, ItemStack item) {
- glSetup(x, y, z);
+ /** 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;
+ }
- GL11.glScaled(0.4 * scale, 0.4 * scale, 0);
+ MatrixStack matrices = matrixFrom(x, y, z);
- GL11.glTranslated(offX, offY, 0);
- if (item.getItem() instanceof BlockItem) GL11.glRotatef(180F, 1F, 180F, 10F);
- mc.getItemRenderer().renderItem(new ItemStack(item.getItem()), Mode.GUI, 0, 0, new MatrixStack(), mc.getBufferBuilders().getEntityVertexConsumers(),42);
- if (item.getItem() instanceof BlockItem) GL11.glRotatef(-180F, -1F, -180F, -10F);
- GL11.glDisable(GL11.GL_LIGHTING);
+ Camera camera = mc.gameRenderer.getCamera();
+ matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw()));
+ matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
- GL11.glScalef(-0.05F, -0.05F, 0);
+ matrices.translate(offX, offY, 0);
+ matrices.scale((float) scale, (float) scale, 0.001f);
- if (item.getCount() > 0) {
- int w = mc.textRenderer.getWidth("x" + item.getCount()) / 2;
- mc.textRenderer.drawWithShadow(new MatrixStack(), "x" + item.getCount(), 7 - w, 5, 0xffffff);
- }
+ matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180f));
- GL11.glScalef(0.85F, 0.85F, 0.85F);
+ //mc.getBufferBuilders().getEntityVertexConsumers().draw();
- int c = 0;
- for (Entry<Enchantment, Integer> m : EnchantmentHelper.get(item).entrySet()) {
- int w1 = mc.textRenderer.getWidth(I18n.translate(m.getKey().getName(2).asString()).substring(0, 2) + m.getValue()) / 2;
- mc.textRenderer.drawWithShadow(new MatrixStack(),
- I18n.translate(m.getKey().getName(2).asString()).substring(0, 2) + m.getValue(), -4 - w1, c * 10 - 1,
- m.getKey() == Enchantments.VANISHING_CURSE || m.getKey() == Enchantments.BINDING_CURSE
- ? 0xff5050 : 0xffb0e0);
- c--;
- }
+ RenderSystem.enableBlend();
+ RenderSystem.defaultBlendFunc();
- GL11.glScalef(0.6F, 0.6F, 0.6F);
- String dur = item.getMaxDamage() - item.getDamage() + "";
- int color = 0x000000;
- try {
- color = MathHelper.hsvToRgb(((float) (item.getMaxDamage() - item.getDamage()) / item.getMaxDamage()) / 3.0F, 1.0F, 1.0F);
- } catch (Exception e) {
- }
- if (item.isDamageable()) mc.textRenderer.drawWithShadow(new MatrixStack(), dur, -8 - dur.length() * 3, 15,
- new Color(color >> 16 & 255, color >> 8 & 255, color & 255).getRGB());
+ Vec3f[] currentLight = getCurrentLight();
+ DiffuseLighting.disableGuiDepthLighting();
+
+ mc.getBufferBuilders().getEntityVertexConsumers().draw();
+
+ mc.getItemRenderer().renderItem(item, ModelTransformation.Mode.GUI, 0xF000F0,
+ OverlayTexture.DEFAULT_UV, matrices, mc.getBufferBuilders().getEntityVertexConsumers(), 0);
+
+ mc.getBufferBuilders().getEntityVertexConsumers().draw();
- glCleanup();
+ RenderSystem.setShaderLights(currentLight[0], currentLight[1]);
+ RenderSystem.disableBlend();
}
- public static void glSetup(double x, double y, double z) {
- GL11.glPushMatrix();
- RenderUtils.offsetRender();
- GL11.glTranslated(x, y, z);
- GL11.glNormal3f(0.0F, 1.0F, 0.0F);
- GL11.glRotatef(-mc.player.getYaw(), 0.0F, 1.0F, 0.0F);
- GL11.glRotatef(mc.player.getPitch(), 1.0F, 0.0F, 0.0F);
- //GL11.glDisable(GL11.GL_LIGHTING);
- GL11.glDisable(GL11.GL_DEPTH_TEST);
+ public static MatrixStack matrixFrom(double x, double y, double z) {
+ MatrixStack matrices = new MatrixStack();
- GL11.glEnable(GL11.GL_BLEND);
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
+ Camera camera = mc.gameRenderer.getCamera();
+ matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
+ matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(camera.getYaw() + 180.0F));
+ matrices.translate(x - camera.getPos().x, y - camera.getPos().y, z - camera.getPos().z);
+
+ return matrices;
}
- public static void glCleanup() {
- //GL11.glEnable(GL11.GL_LIGHTING);
- GL11.glDisable(GL11.GL_BLEND);
- GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- GL11.glEnable(GL11.GL_DEPTH_TEST);
- GL11.glPopMatrix();
+ public static Vec3f[] getCurrentLight() {
+ if (shaderLightField == null) {
+ shaderLightField = FieldUtils.getField(RenderSystem.class, "shaderLightDirections", true);
+ }
+
+ try {
+ return (Vec3f[]) 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/Utils.java b/src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java
index 538de291..7c3e44e6 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java
@@ -60,7 +60,7 @@ public class Utils {
if (sidebar.isEmpty()) return;
if (sidebar.get(sidebar.size() - 1).equals("www.hypixel.net")) {
if (sidebar.get(0).contains("SKYBLOCK")){
- if(isInjected == false){
+ if(!isInjected){
isInjected = true;
ItemTooltipCallback.EVENT.register(PriceInfoTooltip::onInjectTooltip);
}
@@ -68,8 +68,8 @@ public class Utils {
}
else isSkyblock = false;
- if (isSkyblock && string.contains("The Catacombs")) isDungeons = true;
- else isDungeons = false;
+ isDungeons = isSkyblock && string.contains("The Catacombs");
+
} else {
isSkyblock = false;
isDungeons = false;
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/Vertexer.java b/src/main/java/me/xmrvizzy/skyblocker/utils/Vertexer.java
new file mode 100644
index 00000000..f9ac629e
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/Vertexer.java
@@ -0,0 +1,156 @@
+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.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().getModel(), x1, y1, z1).color(color[0], color[1], color[2], color[3]).next();
+ vertexConsumer.vertex(matrices.peek().getModel(), x2, y2, z2).color(color[4], color[5], color[6], color[7]).next();
+ vertexConsumer.vertex(matrices.peek().getModel(), x3, y3, z3).color(color[8], color[9], color[10], color[11]).next();
+ vertexConsumer.vertex(matrices.peek().getModel(), x4, y4, z4).color(color[12], color[13], color[14], color[15]).next();
+ }
+
+ if (cullMode != CULL_BACK) {
+ vertexConsumer.vertex(matrices.peek().getModel(), x4, y4, z4).color(color[0], color[1], color[2], color[3]).next();
+ vertexConsumer.vertex(matrices.peek().getModel(), x3, y3, z3).color(color[4], color[5], color[6], color[7]).next();
+ vertexConsumer.vertex(matrices.peek().getModel(), x2, y2, z2).color(color[8], color[9], color[10], color[11]).next();
+ vertexConsumer.vertex(matrices.peek().getModel(), 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().getModel();
+ Matrix3f normal = matrices.peek().getNormal();
+
+ Vec3f 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, x2, y2, z2).color(color2[0], color2[1], color2[2], color2[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
+ }
+
+ public static Vec3f 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);
+ }
+
+} \ 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
new file mode 100644
index 00000000..b22a6602
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/color/LineColor.java
@@ -0,0 +1,66 @@
+package me.xmrvizzy.skyblocker.utils.color;
+
+import com.mojang.datafixers.util.Function4;
+
+public class LineColor extends RenderColor {
+
+ private 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
new file mode 100644
index 00000000..29a28cb5
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/color/QuadColor.java
@@ -0,0 +1,115 @@
+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:
+ return new int[]{red1, green1, blue1, alpha1};
+ case 1:
+ return new int[]{red2, green2, blue2, alpha2};
+ case 2:
+ return new int[]{red3, green3, blue3, alpha3};
+ default:
+ return 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);
+
+ for (int j = 0; j < 4; j++) {
+ outColor[i * 4 + j] = curColor[j];
+ }
+ }
+
+ return outColor;
+ }
+
+ public QuadColor clone() {
+ QuadColor newColor = new QuadColor(getColorFunc);
+ cloneOverwriteTo(newColor);
+
+ return newColor;
+ }
+
+ public enum CardinalDirection {
+ NORTH(3, 0),
+ EAST(0, 1),
+ SOUTH(1, 2),
+ WEST(2, 3);
+
+ public final int vertex1;
+ public final int vertex2;
+
+ CardinalDirection(int vertex1, int vertex2) {
+ this.vertex1 = vertex1;
+ this.vertex2 = vertex2;
+ }
+
+ public boolean isStartVertex(int vertex) {
+ return vertex == vertex1 || vertex == vertex2;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/color/RenderColor.java b/src/main/java/me/xmrvizzy/skyblocker/utils/color/RenderColor.java
new file mode 100644
index 00000000..89dc37ca
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/color/RenderColor.java
@@ -0,0 +1,27 @@
+package me.xmrvizzy.skyblocker.utils.color;
+
+public abstract class RenderColor implements Cloneable {
+
+ protected Integer[] overwriteColor = new Integer[4];
+
+ public void overwriteRed(Integer red) {
+ overwriteColor[0] = red;
+ }
+
+ public void overwriteGreen(Integer green) {
+ overwriteColor[1] = green;
+ }
+
+ public void overwriteBlue(Integer blue) {
+ overwriteColor[2] = blue;
+ }
+
+ public void overwriteAlpha(Integer alpha) {
+ overwriteColor[3] = alpha;
+ }
+
+ protected void cloneOverwriteTo(RenderColor otherColor) {
+ otherColor.overwriteColor = overwriteColor.clone();
+ }
+
+} \ No newline at end of file