Skip to content

Commit

Permalink
Merge pull request #888 from BigloBot/new-slayer-highlighting-pr
Browse files Browse the repository at this point in the history
[Slayer Helpers] Slayer Highlights, Blaze Helpers and Glow Caching
  • Loading branch information
AzureAaron authored Aug 12, 2024
2 parents 11fc3c2 + 507e962 commit 3830cea
Show file tree
Hide file tree
Showing 12 changed files with 518 additions and 52 deletions.
4 changes: 4 additions & 0 deletions src/main/java/de/hysky/skyblocker/SkyblockerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import de.hysky.skyblocker.skyblock.end.EnderNodes;
import de.hysky.skyblocker.skyblock.end.TheEnd;
import de.hysky.skyblocker.skyblock.entity.MobBoundingBoxes;
import de.hysky.skyblocker.skyblock.entity.MobGlow;
import de.hysky.skyblocker.skyblock.events.EventNotifications;
import de.hysky.skyblocker.skyblock.fancybars.FancyStatusBars;
import de.hysky.skyblocker.skyblock.garden.FarmingHud;
Expand All @@ -48,6 +49,7 @@
import de.hysky.skyblocker.skyblock.rift.TheRift;
import de.hysky.skyblocker.skyblock.searchoverlay.SearchOverManager;
import de.hysky.skyblocker.skyblock.shortcut.Shortcuts;
import de.hysky.skyblocker.skyblock.slayers.SlayerEntitiesGlow;
import de.hysky.skyblocker.skyblock.special.SpecialEffects;
import de.hysky.skyblocker.skyblock.tabhud.TabHud;
import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.ScreenMaster;
Expand Down Expand Up @@ -212,6 +214,8 @@ public void onInitializeClient() {
TooltipManager.init();
SlotTextManager.init();
BazaarHelper.init();
MobGlow.init();
SlayerEntitiesGlow.init();

Scheduler.INSTANCE.scheduleCyclic(Utils::update, 20);
Scheduler.INSTANCE.scheduleCyclic(DiscordRPCManager::updateDataAndPresence, 200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.hysky.skyblocker.config.ConfigUtils;
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.configs.SlayersConfig;
import dev.isxander.yacl3.api.ConfigCategory;
import dev.isxander.yacl3.api.Option;
import dev.isxander.yacl3.api.OptionDescription;
Expand All @@ -17,6 +18,31 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
return ConfigCategory.createBuilder()
.name(Text.translatable("skyblocker.config.slayer"))

//General Slayers Options
.option(Option.<SlayersConfig.HighlightSlayerEntities>createBuilder()
.name(Text.translatable("skyblocker.config.slayer.highlightMinis"))
.description(OptionDescription.of(
Text.translatable("skyblocker.config.slayer.highlightMinis.@Tooltip[0]"),
Text.translatable("skyblocker.config.slayer.highlightMinis.@Tooltip[1]"),
Text.translatable("skyblocker.config.slayer.highlightMinis.@Tooltip[2]")))
.binding(defaults.slayers.highlightMinis,
() -> config.slayers.highlightMinis,
newValue -> config.slayers.highlightMinis = newValue)
.controller(ConfigUtils::createEnumCyclingListController)
.build())
.option(Option.<SlayersConfig.HighlightSlayerEntities>createBuilder()
.name(Text.translatable("skyblocker.config.slayer.highlightBosses"))
.description(OptionDescription.of(
Text.translatable("skyblocker.config.slayer.highlightBosses.@Tooltip[0]"),
Text.translatable("skyblocker.config.slayer.highlightBosses.@Tooltip[1]"),
Text.translatable("skyblocker.config.slayer.highlightBosses.@Tooltip[2]"),
Text.translatable("skyblocker.config.slayer.highlightBosses.@Tooltip[3]")))
.binding(defaults.slayers.highlightBosses,
() -> config.slayers.highlightBosses,
newValue -> config.slayers.highlightBosses = newValue)
.controller(ConfigUtils::createEnumCyclingListController)
.build())

//Enderman Slayer
.group(OptionGroup.createBuilder()
.name(Text.translatable("skyblocker.config.slayer.endermanSlayer"))
Expand Down Expand Up @@ -138,6 +164,28 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.build())
.build())

//Blaze Slayer
.group(OptionGroup.createBuilder()
.name(Text.translatable("skyblocker.config.slayer.blazeSlayer"))
.collapsed(true)
.option(Option.<SlayersConfig.BlazeSlayer.FirePillar>createBuilder()
.name(Text.translatable("skyblocker.config.slayer.blazeSlayer.enableFirePillarAnnouncer"))
.description(OptionDescription.of(Text.translatable("skyblocker.config.slayer.blazeSlayer.enableFirePillarAnnouncer.@Tooltip")))
.binding(defaults.slayers.blazeSlayer.firePillarCountdown,
() -> config.slayers.blazeSlayer.firePillarCountdown,
newValue -> config.slayers.blazeSlayer.firePillarCountdown = newValue)
.controller(ConfigUtils::createEnumCyclingListController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.slayer.blazeSlayer.attunementHighlights"))
.description(OptionDescription.of(Text.translatable("skyblocker.config.slayer.blazeSlayer.attunementHighlights.@Tooltip")))
.binding(defaults.slayers.blazeSlayer.attunementHighlights,
() -> config.slayers.blazeSlayer.attunementHighlights,
newValue -> config.slayers.blazeSlayer.attunementHighlights = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.build())

.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,25 @@
import dev.isxander.yacl3.config.v2.api.SerialEntry;

public class SlayersConfig {
@SerialEntry
public HighlightSlayerEntities highlightMinis = HighlightSlayerEntities.OFF;

@SerialEntry
public HighlightSlayerEntities highlightBosses = HighlightSlayerEntities.OFF;

public enum HighlightSlayerEntities {
OFF, GLOW, HITBOX
}

@SerialEntry
public EndermanSlayer endermanSlayer = new EndermanSlayer();

@SerialEntry
public VampireSlayer vampireSlayer = new VampireSlayer();

@SerialEntry
public BlazeSlayer blazeSlayer = new BlazeSlayer();

public static class EndermanSlayer {
@SerialEntry
public boolean enableYangGlyphsNotification = true;
Expand Down Expand Up @@ -57,4 +70,29 @@ public static class VampireSlayer {
@SerialEntry
public int maniaUpdateFrequency = 5;
}

public static class BlazeSlayer {
@SerialEntry
public FirePillar firePillarCountdown = FirePillar.SOUND_AND_VISUAL;

@SerialEntry
public Boolean attunementHighlights = true;

public enum FirePillar {
OFF("Off"),
VISUAL("Visual Indicator"),
SOUND_AND_VISUAL("Sound and Visual Indicator");

private final String description;

FirePillar(String description) {
this.description = description;
}

@Override
public String toString() {
return description;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.llamalad7.mixinextras.sugar.Local;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.config.configs.SlayersConfig;
import de.hysky.skyblocker.skyblock.CompactDamage;
import de.hysky.skyblocker.skyblock.FishingHelper;
import de.hysky.skyblocker.skyblock.chocolatefactory.EggFinder;
import de.hysky.skyblocker.skyblock.crimson.dojo.DojoManager;
import de.hysky.skyblocker.skyblock.crimson.slayer.FirePillarAnnouncer;
import de.hysky.skyblocker.skyblock.dungeon.DungeonScore;
import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager;
import de.hysky.skyblocker.skyblock.dwarven.WishingCompassSolver;
import de.hysky.skyblocker.skyblock.dwarven.CrystalsChestHighlighter;
import de.hysky.skyblocker.skyblock.end.BeaconHighlighter;
import de.hysky.skyblocker.skyblock.end.EnderNodes;
import de.hysky.skyblocker.skyblock.end.TheEnd;
import de.hysky.skyblocker.skyblock.slayers.SlayerEntitiesGlow;
import de.hysky.skyblocker.skyblock.waypoint.MythologicalRitual;
import de.hysky.skyblocker.utils.SlayerUtils;
import de.hysky.skyblocker.utils.Utils;
Expand Down Expand Up @@ -112,6 +116,7 @@ public abstract class ClientPlayNetworkHandlerMixin {
if (packet.getStatus() == EntityStatuses.PLAY_DEATH_SOUND_OR_ADD_PROJECTILE_HIT_PARTICLES) {
DungeonScore.handleEntityDeath(entity);
TheEnd.onEntityDeath(entity);
SlayerEntitiesGlow.onEntityDeath(entity);
}
return entity;
}
Expand All @@ -120,6 +125,13 @@ public abstract class ClientPlayNetworkHandlerMixin {
private void skyblocker$onEntityTrackerUpdate(EntityTrackerUpdateS2CPacket packet, CallbackInfo ci, @Local Entity entity) {
if (!(entity instanceof ArmorStandEntity armorStandEntity)) return;

if (SkyblockerConfigManager.get().slayers.highlightMinis == SlayersConfig.HighlightSlayerEntities.GLOW && SlayerEntitiesGlow.isSlayerMiniMob(armorStandEntity)
|| SkyblockerConfigManager.get().slayers.highlightBosses == SlayersConfig.HighlightSlayerEntities.GLOW && SlayerEntitiesGlow.isSlayer(armorStandEntity)) {
SlayerEntitiesGlow.setSlayerMobGlow(armorStandEntity);
}

if (SkyblockerConfigManager.get().slayers.blazeSlayer.firePillarCountdown != SlayersConfig.BlazeSlayer.FirePillar.OFF) FirePillarAnnouncer.checkFirePillar(entity);

EggFinder.checkIfEgg(armorStandEntity);
try { //Prevent packet handling fails if something goes wrong so that entity trackers still update, just without compact damage numbers
CompactDamage.compactDamage(armorStandEntity);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.hysky.skyblocker.mixins;

import de.hysky.skyblocker.skyblock.dungeon.LividColor;
import de.hysky.skyblocker.skyblock.slayers.SlayerEntitiesGlow;
import net.minecraft.entity.decoration.ArmorStandEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand Down Expand Up @@ -42,7 +44,10 @@ public class WorldRendererMixin {
boolean shouldShowBoundingBox = MobBoundingBoxes.shouldDrawMobBoundingBox(entity);

if (shouldShowBoundingBox) {
MobBoundingBoxes.submitBox2BeRendered(entity.getBoundingBox(), MobBoundingBoxes.getBoxColor(entity));
MobBoundingBoxes.submitBox2BeRendered(
entity instanceof ArmorStandEntity e ? SlayerEntitiesGlow.getSlayerMobBoundingBox(e) : entity.getBoundingBox(),
MobBoundingBoxes.getBoxColor(entity)
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package de.hysky.skyblocker.skyblock.crimson.slayer;

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.SlayerUtils;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;

import java.awt.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class AttunementColors {
private static final Pattern COLOR_PATTERN = Pattern.compile("ASHEN|SPIRIT|CRYSTAL|AURIC");

/**
* Fetches highlight colour based on the Inferno Demonlord, or its demons', Hellion Shield Attunement
*/
public static int getColor(LivingEntity e) {
if (!SkyblockerConfigManager.get().slayers.blazeSlayer.attunementHighlights) return 0xf57738;
for (Entity entity : SlayerUtils.getEntityArmorStands(e)) {
Matcher matcher = COLOR_PATTERN.matcher(entity.getDisplayName().getString());
if (matcher.find()) {
String matchedColour = matcher.group();
return switch (matchedColour) {
case "ASHEN" -> Color.DARK_GRAY.getRGB();
case "SPIRIT" -> Color.WHITE.getRGB();
case "CRYSTAL" -> Color.CYAN.getRGB();
case "AURIC" -> Color.YELLOW.getRGB();
default -> Color.RED.getRGB();
};
}
}
return Color.RED.getRGB();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package de.hysky.skyblocker.skyblock.crimson.slayer;

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.config.configs.SlayersConfig;
import de.hysky.skyblocker.utils.SlayerUtils;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.render.RenderHelper;
import de.hysky.skyblocker.utils.render.title.Title;
import de.hysky.skyblocker.utils.render.title.TitleContainer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.Entity;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.text.MutableText;
import net.minecraft.text.PlainTextContent;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class FirePillarAnnouncer {

private static final Pattern FIRE_PILLAR_PATTERN = Pattern.compile("(\\d+)s \\d+ hits");

/**
* Checks if an entity is the fire pillar when it has been updated (i.e. name change). This triggers twice on
* seven seconds remaining, so it's been reduced down to only announce the last 5 seconds until explosion.
* <p>
* There's also not a great way to detect ownership of the fire pillar, so a crude range calculation is used to try and
* prevent another player's FirePillar appearing on the HUD.
*
* @param entity The updated entity that is checked to be a fire pillar
*/
public static void checkFirePillar(Entity entity) {
if (Utils.isInCrimson() && SlayerUtils.isInSlayer() && entity instanceof ArmorStandEntity) {

String entityName = entity.getName().getString();
Matcher matcher = FIRE_PILLAR_PATTERN.matcher(entityName);

if (matcher.matches()) {
int seconds = Integer.parseInt(matcher.group(1));
if (seconds > 5) return;

// There is an edge case where the slayer has entered demon phase and temporarily despawned with
// an active fire pillar in play, So fallback to the player
Entity referenceEntity = SlayerUtils.getSlayerEntity();
if (!(referenceEntity != null ? referenceEntity : MinecraftClient.getInstance().player).getBlockPos().isWithinDistance(entity.getPos(), 22)) return;
announceFirePillarDetails(entityName);
}
}
}

private static void announceFirePillarDetails(String entityName) {
Title title = new Title(Text.literal(entityName).formatted(Formatting.BOLD, Formatting.DARK_PURPLE));

if (SkyblockerConfigManager.get().slayers.blazeSlayer.firePillarCountdown == SlayersConfig.BlazeSlayer.FirePillar.SOUND_AND_VISUAL) {
RenderHelper.displayInTitleContainerAndPlaySound(title, 15);
} else {
TitleContainer.addTitle(title, 15);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package de.hysky.skyblocker.skyblock.entity;

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.config.configs.SlayersConfig;
import de.hysky.skyblocker.skyblock.dungeon.LividColor;
import de.hysky.skyblocker.skyblock.slayers.SlayerEntitiesGlow;
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.client.MinecraftClient;
import net.minecraft.entity.Entity;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.entity.player.PlayerEntity;
Expand Down Expand Up @@ -40,6 +43,17 @@ public static boolean shouldDrawMobBoundingBox(Entity entity) {
};
}

if (SkyblockerConfigManager.get().slayers.highlightMinis == SlayersConfig.HighlightSlayerEntities.HITBOX
&& entity instanceof ArmorStandEntity le && SlayerEntitiesGlow.isSlayerMiniMob(le)) {
return true;
}

if (SkyblockerConfigManager.get().slayers.highlightBosses == SlayersConfig.HighlightSlayerEntities.HITBOX
&& entity instanceof ArmorStandEntity le) {
return le.getDisplayName().getString().contains(MinecraftClient.getInstance().getSession().getUsername()) ||
entity.getDisplayName().getString().contains("Ⓣ") || entity.getDisplayName().getString().contains("Ⓐ");
}

return false;
}

Expand Down
Loading

0 comments on commit 3830cea

Please sign in to comment.