diff options
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java | 78 | ||||
-rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java | 3 |
2 files changed, 80 insertions, 1 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java new file mode 100644 index 00000000..b969ba0b --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java @@ -0,0 +1,78 @@ +package de.hysky.skyblocker.skyblock.entity; + +import java.util.List; + +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.Utils; +import de.hysky.skyblocker.utils.render.FrustumUtils; +import de.hysky.skyblocker.utils.render.RenderHelper; +import de.hysky.skyblocker.utils.render.Renderable; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; +import net.minecraft.entity.Entity; +import net.minecraft.entity.decoration.ArmorStandEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.math.Box; + +public class MobBoundingBoxes { + /** + * These boxes will be rendered before the debug render phase which happens after entities are rendered; + */ + private static final ObjectOpenHashSet<RenderableBox> BOXES_2_RENDER = new ObjectOpenHashSet<>(); + + public static void init() { + WorldRenderEvents.BEFORE_DEBUG_RENDER.register(MobBoundingBoxes::render); + } + + public static boolean shouldDrawMobBoundingBox(Entity entity) { + Box box = entity.getBoundingBox(); + + if (Utils.isInDungeons() && FrustumUtils.isVisible(box) && !entity.isInvisible()) { + String name = entity.getName().getString(); + + // Minibosses + if (entity instanceof PlayerEntity) { + switch (name) { + case "Lost Adventurer", "Shadow Assassin", "Diamond Guy": return SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes; + } + } + + // Regular Mobs + if (!(entity instanceof ArmorStandEntity)) { + List<ArmorStandEntity> armorStands = MobGlow.getArmorStands(entity); + + if (!armorStands.isEmpty() && armorStands.get(0).getName().getString().contains("✯")) + return SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes; + } + } + + return false; + } + + public static float[] getBoxColor(Entity entity) { + int color = MobGlow.getGlowColor(entity); + + return new float[] { ((color >> 16) & 0xFF) / 255f, ((color >> 8) & 0xFF) / 255f, (color & 0xFF) / 255f }; + } + + public static void submitBox2BeRendered(Box box, float[] colorComponents) { + BOXES_2_RENDER.add(new RenderableBox(box, colorComponents)); + } + + private static void render(WorldRenderContext context) { + for (RenderableBox box : BOXES_2_RENDER) { + box.render(context); + } + + BOXES_2_RENDER.clear(); + } + + private record RenderableBox(Box box, float[] colorComponents) implements Renderable { + + @Override + public void render(WorldRenderContext context) { + RenderHelper.renderOutline(context, box, colorComponents, 6, false); + } + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java index 85b41bd2..12ae468f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java @@ -22,6 +22,7 @@ import net.minecraft.world.World; import java.util.List; public class MobGlow { + public static boolean shouldMobGlow(Entity entity) { Box box = entity.getBoundingBox(); @@ -51,7 +52,7 @@ public class MobGlow { } // Bats - return SkyblockerConfigManager.get().locations.dungeons.starredMobGlow && entity instanceof BatEntity; + return (SkyblockerConfigManager.get().locations.dungeons.starredMobGlow || SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes) && entity instanceof BatEntity; } // Rift |