diff options
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/Features.java | 2 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java (renamed from src/main/java/at/hannibal2/skyhanni/config/features/Misc.java) | 17 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt | 88 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 2 |
5 files changed, 108 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 12b607792..c43b7af5d 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -39,6 +39,7 @@ import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorTimer import at.hannibal2.skyhanni.features.inventory.* import at.hannibal2.skyhanni.features.itemabilities.FireVeilWandParticles import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbilityCooldown +import at.hannibal2.skyhanni.features.mining.HighlightMiningCommissionMobs import at.hannibal2.skyhanni.features.minion.MinionCollectLogic import at.hannibal2.skyhanni.features.minion.MinionFeatures import at.hannibal2.skyhanni.features.misc.* @@ -319,6 +320,7 @@ class SkyHanniMod { loadModule(CustomTextBox()) loadModule(RiftUpsideDownParkour()) loadModule(RiftLavaMazeParkour()) + loadModule(HighlightMiningCommissionMobs()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index 9d63c9b37..a680c806d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -125,7 +125,7 @@ public class Features extends Config { @Expose @Category(name = "Misc", desc = "Settings without a category.") - public Misc misc = new Misc(); + public MiscConfig misc = new MiscConfig(); @Expose @Category(name = "Dev", desc = "Debug and test stuff. Developers are cool.") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java index fc20fa862..43af8f090 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java @@ -10,7 +10,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class Misc { +public class MiscConfig { @Expose @ConfigOption(name = "Pet", desc = "") @@ -491,7 +491,7 @@ public class Misc { @Expose @ConfigOption(name = "Frozen Treasure Tracker", desc = "") @Accordion - public Misc.FrozenTreasureTracker frozenTreasureTracker = new Misc.FrozenTreasureTracker(); + public MiscConfig.FrozenTreasureTracker frozenTreasureTracker = new MiscConfig.FrozenTreasureTracker(); public static class FrozenTreasureTracker { @@ -576,6 +576,19 @@ public class Misc { } @Expose + @ConfigOption(name = "Mining", desc = "") + @Accordion + public MiningConfig mining = new MiningConfig(); + public static class MiningConfig { + + @Expose + @ConfigOption(name = "Highlight Commission Mobs", desc = "Highlight Mobs that are part of active commissions.") + @ConfigEditorBoolean + public boolean highlightCommissionMobs = false; + + } + + @Expose @ConfigOption(name = "Exp Bottles", desc = "Hides all the experience orbs lying on the ground.") @ConfigEditorBoolean public boolean hideExpBottles = false; diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt new file mode 100644 index 000000000..c2ae58673 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt @@ -0,0 +1,88 @@ +package at.hannibal2.skyhanni.features.mining + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.events.withAlpha +import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils.inIsland +import net.minecraft.client.Minecraft +import net.minecraft.entity.EntityLivingBase +import net.minecraft.entity.monster.EntityEndermite +import net.minecraft.entity.monster.EntityIronGolem +import net.minecraft.entity.monster.EntityMagmaCube +import net.minecraft.entity.monster.EntitySlime +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class HighlightMiningCommissionMobs { + private val config get() = SkyHanniMod.feature.misc.mining + private var active = listOf<MobType>() + + enum class MobType(val commissionName: String, val isMob: (EntityLivingBase) -> Boolean) { + + // Dwarven Mines + DWARVEN_GOBLIN_SLAYER("Goblin Slayer", { it.name == "Goblin " }), + STAR_PUNCHER("Star Sentry Puncher", { it.name == "Crystal Sentry" }), + ICE_WALKER("Ice Walker Slayer", { it.name == "Ice Walker" }), + GOLDEN_GOBLIN("Golden Goblin Slayer", { it.name.contains("Golden Goblin") }), // TODO test + + // Crystal Hollows + AUTOMATON("Automaton Slayer", { it is EntityIronGolem }), + TEAM_TREASURITE_MEMBER("Team Treasurite Member Slayer", { it.name == "Team Treasurite" }), + YOG("Yog Slayer", { it is EntityMagmaCube }), + THYST("Thyst Slayer", { it is EntityEndermite && it.hasMaxHealth(5_000) }), + CORLEONE("Corleone Slayer", { it.hasMaxHealth(1_000_000) && it.name == "Team Treasurite" }), + SLUDGE("Sludge Slayer", { + it is EntitySlime && (it.hasMaxHealth(5_000) || it.hasMaxHealth(10_000) || it.hasMaxHealth(25_000)) + }), + CH_GOBLIN_SLAYER("Goblin Slayer", { it.name == "Weakling " }), + ; + } + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!isEnabled()) return + if (!event.isMod(40)) return + + val entities = Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityLivingBase>() + for ((type, entity) in active.flatMap { type -> entities.map { type to it } }) { + if (type.isMob(entity)) { + RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.YELLOW.toColor().withAlpha(127)) + { isEnabled() && type in active } + } + } + } + + @SubscribeEvent + fun onTabListUpdate(event: TabListUpdateEvent) { + if (!isEnabled()) return + + MobType.values().filter { type -> + event.tabList.find { line -> line.contains(type.commissionName) }?.let { !it.endsWith("§aDONE") } ?: false + }.let { + if (it != active) { + active = it + } + } + } + + @SubscribeEvent + fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) { + if (!isEnabled()) return + + val entity = event.entity + for (type in active) { + if (type.isMob(entity)) { + RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.YELLOW.toColor().withAlpha(127)) + { isEnabled() && type in active } + } + } + } + + fun isEnabled() = config.highlightCommissionMobs && + (IslandType.DWARVEN_MINES.inIsland() || IslandType.CRYSTAL_HOLLOWS.inIsland()) +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index d0b970187..9f6c9cc93 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -369,6 +369,8 @@ object LorenzUtils { fun inIsland(island: IslandType) = inSkyBlock && skyBlockIsland == island + fun IslandType.inIsland() = inIsland(this) + fun <K, N : Number> MutableMap<K, N>.addOrPut(item: K, amount: N) { val old = this[item] ?: 0 val d = old.toDouble() + amount.toDouble() |