-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #888 from BigloBot/new-slayer-highlighting-pr
[Slayer Helpers] Slayer Highlights, Blaze Helpers and Glow Caching
- Loading branch information
Showing
12 changed files
with
518 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/de/hysky/skyblocker/skyblock/crimson/slayer/AttunementColors.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/main/java/de/hysky/skyblocker/skyblock/crimson/slayer/FirePillarAnnouncer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.