aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/utils
diff options
context:
space:
mode:
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/chat/ChatFilterResult.java18
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/chat/ChatMessageListener.java88
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/chat/ChatPatternListener.java30
-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/discord/DiscordRPCManager.java122
-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)71
-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
25 files changed, 529 insertions, 658 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/chat/ChatFilterResult.java b/src/main/java/me/xmrvizzy/skyblocker/utils/chat/ChatFilterResult.java
new file mode 100644
index 00000000..cd364eb5
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/chat/ChatFilterResult.java
@@ -0,0 +1,18 @@
+package me.xmrvizzy.skyblocker.utils.chat;
+
+import net.minecraft.client.resource.language.I18n;
+public enum ChatFilterResult {
+ // Skip this one / no action
+ PASS,
+ // Filter
+ FILTER,
+ // Move to action bar
+ ACTION_BAR;
+ // Skip remaining checks, don't filter
+ // null
+
+ @Override
+ public String toString() {
+ return I18n.translate("text.autoconfig.skyblocker.option.messages.chatFilterResult." + name());
+ }
+}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/chat/ChatMessageListener.java b/src/main/java/me/xmrvizzy/skyblocker/utils/chat/ChatMessageListener.java
new file mode 100644
index 00000000..7bb75947
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/chat/ChatMessageListener.java
@@ -0,0 +1,88 @@
+package me.xmrvizzy.skyblocker.utils.chat;
+
+import me.xmrvizzy.skyblocker.skyblock.barn.HungryHiker;
+import me.xmrvizzy.skyblocker.skyblock.barn.TreasureHunter;
+import me.xmrvizzy.skyblocker.skyblock.dungeon.Reparty;
+import me.xmrvizzy.skyblocker.skyblock.dungeon.ThreeWeirdos;
+import me.xmrvizzy.skyblocker.skyblock.dungeon.Trivia;
+import me.xmrvizzy.skyblocker.skyblock.dwarven.Fetchur;
+import me.xmrvizzy.skyblocker.skyblock.dwarven.Puzzler;
+import me.xmrvizzy.skyblocker.skyblock.filters.*;
+import me.xmrvizzy.skyblocker.utils.Utils;
+import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
+import net.fabricmc.fabric.api.event.Event;
+import net.fabricmc.fabric.api.event.EventFactory;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.network.ClientPlayerEntity;
+import net.minecraft.text.Text;
+
+@FunctionalInterface
+public interface ChatMessageListener {
+ /**
+ * An event called when a game message is received. Register your listeners in {@link ChatMessageListener#init()}.
+ */
+ Event<ChatMessageListener> EVENT = EventFactory.createArrayBacked(ChatMessageListener.class,
+ (listeners) -> (message, asString) -> {
+ for (ChatMessageListener listener : listeners) {
+ ChatFilterResult result = listener.onMessage(message, asString);
+ if (result != ChatFilterResult.PASS) return result;
+ }
+ return ChatFilterResult.PASS;
+ });
+
+ /**
+ * Registers {@link ChatMessageListener}s to {@link ChatMessageListener#EVENT} and registers {@link ChatMessageListener#EVENT} to {@link ClientReceiveMessageEvents#ALLOW_GAME}
+ */
+ static void init() {
+ ChatMessageListener[] listeners = new ChatMessageListener[]{
+ // Features
+ new Fetchur(),
+ new Puzzler(),
+ new Reparty(),
+ new ThreeWeirdos(),
+ new Trivia(),
+ new TreasureHunter(),
+ new HungryHiker(),
+ // Filters
+ new AbilityFilter(),
+ new AdFilter(),
+ new AoteFilter(),
+ new ComboFilter(),
+ new HealFilter(),
+ new ImplosionFilter(),
+ new MoltenWaveFilter(),
+ new TeleportPadFilter(),
+ new AutopetFilter(),
+ new ShowOffFilter()
+ };
+ // Register all listeners to EVENT
+ for (ChatMessageListener listener : listeners) {
+ EVENT.register(listener);
+ }
+ // Register EVENT to ClientReceiveMessageEvents.ALLOW_GAME from fabric api
+ ClientReceiveMessageEvents.ALLOW_GAME.register((message, overlay) -> {
+ if (!Utils.isOnSkyblock()) {
+ return true;
+ }
+ ChatFilterResult result = EVENT.invoker().onMessage(message, message.getString());
+ switch (result) {
+ case ACTION_BAR -> {
+ if (overlay) {
+ return true;
+ }
+ ClientPlayerEntity player = MinecraftClient.getInstance().player;
+ if (player != null) {
+ player.sendMessage(message, true);
+ return false;
+ }
+ }
+ case FILTER -> {
+ return false;
+ }
+ }
+ return true;
+ });
+ }
+
+ ChatFilterResult onMessage(Text message, String asString);
+}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/chat/ChatPatternListener.java b/src/main/java/me/xmrvizzy/skyblocker/utils/chat/ChatPatternListener.java
new file mode 100644
index 00000000..3b363a85
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/chat/ChatPatternListener.java
@@ -0,0 +1,30 @@
+package me.xmrvizzy.skyblocker.utils.chat;
+
+import net.minecraft.text.Text;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public abstract class ChatPatternListener implements ChatMessageListener {
+ protected static final String NUMBER = "-?[0-9]{1,3}(?>,[0-9]{3})*(?:\\.[1-9])?";
+ public final Pattern pattern;
+
+ public ChatPatternListener(String pattern) {
+ this.pattern = Patter