diff options
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonBlaze.java')
-rw-r--r-- | src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonBlaze.java | 51 |
1 files changed, 24 insertions, 27 deletions
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 d0dcf1e1..94a81f15 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonBlaze.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonBlaze.java @@ -1,11 +1,10 @@ package me.xmrvizzy.skyblocker.skyblock.dungeon; import it.unimi.dsi.fastutil.objects.ObjectIntPair; +import me.xmrvizzy.skyblocker.SkyblockerMod; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; -import me.xmrvizzy.skyblocker.utils.RenderHelper; -import me.xmrvizzy.skyblocker.utils.RenderUtils; import me.xmrvizzy.skyblocker.utils.Utils; -import me.xmrvizzy.skyblocker.utils.color.QuadColor; +import me.xmrvizzy.skyblocker.utils.render.RenderHelper; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; import net.minecraft.client.MinecraftClient; @@ -22,31 +21,32 @@ import java.util.List; public class DungeonBlaze { private static final Logger LOGGER = LoggerFactory.getLogger(DungeonBlaze.class.getName()); + private static final float[] GREEN_COLOR_COMPONENTS = {0.0F, 1.0F, 0.0F}; private static final float[] WHITE_COLOR_COMPONENTS = { 1.0f, 1.0f, 1.0f }; static Entity highestBlaze = null; static Entity lowestBlaze = null; static Entity nextHighestBlaze = null; static Entity nextLowestBlaze = null; - static boolean renderHooked = false; - + + public static void init() { + SkyblockerMod.getInstance().scheduler.scheduleCyclic(DungeonBlaze::update, 10); + WorldRenderEvents.BEFORE_DEBUG_RENDER.register(DungeonBlaze::blazeRenderer); + } + public static void update() { + if (!SkyblockerConfig.get().locations.dungeons.blazesolver) return; ClientWorld world = MinecraftClient.getInstance().world; if (world == null || !Utils.isInDungeons()) return; - if (!renderHooked){ - - WorldRenderEvents.BEFORE_DEBUG_RENDER.register(DungeonBlaze::blazeRenderer); - renderHooked = true; - } Iterable<Entity> entities = world.getEntities(); List<ObjectIntPair<Entity>> blazes = new ArrayList<>(); for (Entity entity : entities) { String blazeName = entity.getName().getString(); - + if (blazeName.contains("Blaze") && blazeName.contains("/")) { try { int health = Integer.parseInt(blazeName.substring(blazeName.indexOf("/") + 1, blazeName.length() - 1)); - + blazes.add(ObjectIntPair.of(entity, health)); } catch (NumberFormatException ex) { ex.printStackTrace(); @@ -70,36 +70,33 @@ public class DungeonBlaze { nextHighestBlaze = blazes.get(highestIndex - 1).left(); } } - + } - 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); - QuadColor outlineColorWhite = QuadColor.single(1.0f, 1.0f, 1.0f, 1.0f); - + + public static void blazeRenderer(WorldRenderContext context) { try { - if (highestBlaze != null && lowestBlaze != null && highestBlaze.isAlive() && lowestBlaze.isAlive() && SkyblockerConfig.get().locations.dungeons.blazesolver){ + if (SkyblockerConfig.get().locations.dungeons.blazesolver && highestBlaze != null && lowestBlaze != null && highestBlaze.isAlive() && lowestBlaze.isAlive()) { /* Outline */ if (highestBlaze.getY() < 69) { Box blaze = highestBlaze.getBoundingBox().expand(0.3, 0.9, 0.3).offset(0, -1.1, 0); - RenderUtils.drawBoxOutline(blaze, outlineColorRed, 5f); - + RenderHelper.renderOutline(context, blaze, GREEN_COLOR_COMPONENTS); + if (nextHighestBlaze != null && nextHighestBlaze.isAlive() && nextHighestBlaze != highestBlaze) { Box nextBlaze = nextHighestBlaze.getBoundingBox().expand(0.3, 0.9, 0.3).offset(0, -1.1, 0); - RenderUtils.drawBoxOutline(nextBlaze, outlineColorWhite, 5f); - RenderHelper.renderLinesFromPoints(wrc, new Vec3d[] { blaze.getCenter(), nextBlaze.getCenter() }, WHITE_COLOR_COMPONENTS, 1f, 5f); + RenderHelper.renderOutline(context, nextBlaze, WHITE_COLOR_COMPONENTS); + RenderHelper.renderLinesFromPoints(context, new Vec3d[] { blaze.getCenter(), nextBlaze.getCenter() }, WHITE_COLOR_COMPONENTS, 1f, 5f); } } /* Outline */ if (lowestBlaze.getY() > 69) { Box blaze = lowestBlaze.getBoundingBox().expand(0.3, 0.9, 0.3).offset(0, -1.1, 0); - RenderUtils.drawBoxOutline(blaze, outlineColorRed, 5f); - + RenderHelper.renderOutline(context, blaze, GREEN_COLOR_COMPONENTS); + if (nextLowestBlaze != null && nextLowestBlaze.isAlive() && nextLowestBlaze != lowestBlaze) { Box nextBlaze = nextLowestBlaze.getBoundingBox().expand(0.3, 0.9, 0.3).offset(0, -1.1, 0); - RenderUtils.drawBoxOutline(nextBlaze, outlineColorWhite, 5f); - RenderHelper.renderLinesFromPoints(wrc, new Vec3d[] { blaze.getCenter(), nextBlaze.getCenter() }, WHITE_COLOR_COMPONENTS, 1f, 5f); + RenderHelper.renderOutline(context, nextBlaze, WHITE_COLOR_COMPONENTS); + RenderHelper.renderLinesFromPoints(context, new Vec3d[] { blaze.getCenter(), nextBlaze.getCenter() }, WHITE_COLOR_COMPONENTS, 1f, 5f); } } } |