aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-02-11 01:27:52 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-02-11 01:27:52 +0100
commit36f1f795ac569c712d86d02192082e233a5f17d8 (patch)
treef2cc86e4103db866271584280b8da868dc709199 /src/main/java
parent9034699b2f0cd35691b41b43ebca67ea4febb17f (diff)
downloadskyhanni-36f1f795ac569c712d86d02192082e233a5f17d8.tar.gz
skyhanni-36f1f795ac569c712d86d02192082e233a5f17d8.tar.bz2
skyhanni-36f1f795ac569c712d86d02192082e233a5f17d8.zip
Reworked entity highlight config for area mini bosses, slayer mini bosses, corrupted mobs and arachne keepers.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Features.java4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Misc.java17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Mobs.java41
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/AreaMiniBossFeatures.kt120
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/CorruptedMobHighlight.kt62
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/HighlightAreaMiniBoss.kt49
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/MobHighlight.kt47
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt40
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt7
11 files changed, 247 insertions, 160 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index 714e5b5de..2c638f67d 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -142,8 +142,8 @@ public class SkyHanniMod {
loadModule(new RngMeterInventory());
loadModule(new WikiCommand());
loadModule(new SummoningMobManager());
- loadModule(new HighlightAreaMiniBoss());
- loadModule(new CorruptedMobHighlight());
+ loadModule(new AreaMiniBossFeatures());
+ loadModule(new MobHighlight());
loadModule(new MarkedPlayerManager());
loadModule(new HighlightSlayerMiniBoss());
loadModule(new PlayerDeathMessages());
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java
index 40fce3437..11aac3fc8 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Features.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java
@@ -194,6 +194,10 @@ public class Features extends Config {
public Bingo bingo = new Bingo();
@Expose
+ @Category(name = "Mobs", desc = "Visual Help for Mobs")
+ public Mobs mobs = new Mobs();
+
+ @Expose
@Category(name = "Misc", desc = "Settings without a category.")
public Misc misc = new Misc();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
index ea51e129e..d1ae139b9 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
@@ -41,23 +41,6 @@ public class Misc {
public Position realTimePos = new Position(10, 10, false, true);
@Expose
- @ConfigOption(name = "Highlight Mobs", desc = "")
- @ConfigEditorAccordion(id = 2)
- public boolean highlightColor = false;
-
- @Expose
- @ConfigOption(name = "Area Mini Bosses", desc = "Highlight voidling extremists, millenia aged blazes.")
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 2)
- public boolean highlightAreaMinisBoss= false;
-
- @Expose
- @ConfigOption(name = "Corrupted Mob Highlight", desc = "Highlight corrupted mobs in purple color")
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 2)
- public boolean corruptedMobHighlight = false;
-
- @Expose
@ConfigOption(name = "Hide Armor", desc = "")
@ConfigEditorAccordion(id = 3)
public boolean hideArmor = false;
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Mobs.java b/src/main/java/at/hannibal2/skyhanni/config/features/Mobs.java
new file mode 100644
index 000000000..91ea4c492
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Mobs.java
@@ -0,0 +1,41 @@
+package at.hannibal2.skyhanni.config.features;
+
+import at.hannibal2.skyhanni.config.core.config.annotations.ConfigAccordionId;
+import at.hannibal2.skyhanni.config.core.config.annotations.ConfigEditorAccordion;
+import at.hannibal2.skyhanni.config.core.config.annotations.ConfigEditorBoolean;
+import at.hannibal2.skyhanni.config.core.config.annotations.ConfigOption;
+import com.google.gson.annotations.Expose;
+
+public class Mobs {
+
+ @Expose
+ @ConfigOption(
+ name = "Area Mini Bosses",
+ desc = "Special mobs in slayer regions that have way more hp than normal mobs:" +
+ "\nGolden Ghoul, Old Wolf, Voidling Extremist and Millenia-Aged Blaze"
+ )
+ @ConfigEditorAccordion(id = 0)
+ public boolean areaMiniBosses = false;
+
+ @Expose
+ @ConfigOption(name = "Highlight Mini Bosses", desc = "Highlight area mini bosses")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean areaMiniBossesHighlight = true;
+
+ @Expose
+ @ConfigOption(name = "Mini Bosses Respawn Timer", desc = "Show a timer when area mini bosses spawn.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean areaMinisBossesRespawnTimer = false;
+
+ @Expose
+ @ConfigOption(name = "Corrupted Mob Highlight", desc = "Highlight corrupted mobs in purple color")
+ @ConfigEditorBoolean
+ public boolean corruptedMobHighlight = false;
+
+ @Expose
+ @ConfigOption(name = "Arachne Keeper Highlight", desc = "Highlight corrupted mobs in purple color")
+ @ConfigEditorBoolean
+ public boolean arachneKeeperHighlight = true;
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/AreaMiniBossFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/AreaMiniBossFeatures.kt
new file mode 100644
index 000000000..6bcb168f9
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/AreaMiniBossFeatures.kt
@@ -0,0 +1,120 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent
+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.LocationUtils
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.round
+import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
+import net.minecraft.entity.EntityLiving
+import net.minecraft.entity.monster.EntityBlaze
+import net.minecraft.entity.monster.EntityEnderman
+import net.minecraft.entity.monster.EntityZombie
+import net.minecraft.entity.passive.EntityWolf
+import net.minecraftforge.client.event.RenderWorldLastEvent
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class AreaMiniBossFeatures {
+ private var lastTime = 0L
+ private var miniBossType: AreaMiniBossType? = null
+ private var respawnCooldown = 11_000L
+
+ @SubscribeEvent
+ fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+
+ val entity = event.entity
+ val maxHealth = event.maxHealth
+ for (bossType in AreaMiniBossType.values()) {
+ if (!bossType.clazz.isInstance(entity)) continue
+ if (!entity.hasMaxHealth(bossType.health, false, maxHealth)) continue
+
+ miniBossType = bossType
+ val time = System.currentTimeMillis()
+ val diff = time - lastTime
+ if (diff in 5_000..20_000) {
+ respawnCooldown = diff
+ }
+ lastTime = time
+
+ if (SkyHanniMod.feature.mobs.areaMiniBossesHighlight) {
+ val color = bossType.color.toColor().withAlpha(bossType.colorOpacity)
+ RenderLivingEntityHelper.setEntityColor(entity, color)
+ { SkyHanniMod.feature.mobs.areaMiniBossesHighlight }
+ RenderLivingEntityHelper.setNoHurtTime(entity) { SkyHanniMod.feature.mobs.areaMiniBossesHighlight }
+ }
+
+ // TODO add sound
+ }
+ }
+
+ @SubscribeEvent
+ fun onRenderWorld(event: RenderWorldLastEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (!SkyHanniMod.feature.mobs.areaMinisBossesRespawnTimer) return
+
+ miniBossType?.apply {
+ val time = getTime()
+ val playerLocation = LocationUtils.playerLocation()
+ spawnLocations.filter { it.distance(playerLocation) < 15 }
+ .forEach { event.drawDynamicText(it, time, 1.2, ignoreBlocks = false) }
+ }
+ }
+
+ private fun AreaMiniBossType.getTime(): String {
+ val duration = System.currentTimeMillis() - lastTime
+ val estimatedTime = respawnCooldown - duration % respawnCooldown
+ val double = (estimatedTime.toDouble() / 1000).round(1)
+ return color.getChatColor() + "" + LorenzUtils.formatDouble(double, "0.0") + "s"
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ miniBossType = null
+ }
+
+ enum class AreaMiniBossType(
+ val clazz: Class<out EntityLiving>,
+ val health: Int,
+ val color: LorenzColor,
+ val colorOpacity: Int,
+ vararg val spawnLocations: LorenzVec
+ ) {
+ GOLDEN_GHOUL(
+ EntityZombie::class.java, 45_000, LorenzColor.YELLOW, 127,
+ LorenzVec(-99.7, 39.0, -86.4),
+ LorenzVec(-128.5, 42.0, -138.5),
+ ),
+ OLD_WOLF(
+ EntityWolf::class.java, 15_000, LorenzColor.GOLD, 60,
+ LorenzVec(-248.0, 123.0, 54.0),
+ LorenzVec(-256.7, 105.0, 75.7),
+ LorenzVec(-268.5, 90.0, 97.7),
+ LorenzVec(-258.1, 94.0, 75.5),
+ LorenzVec(-225.7, 92.0, 127.5),
+ ),
+ VOIDLING_EXTREMIST(
+ EntityEnderman::class.java, 8_000_000, LorenzColor.LIGHT_PURPLE, 127,
+ LorenzVec(-591.1, 10.0, -304.0),
+ LorenzVec(-544.8, 21.0, -301.1),
+ LorenzVec(-593.5, 26.0, -328.7),
+ LorenzVec(-565.0, 41.0, -307.1),
+ LorenzVec(-573.2, 51.0, -353.4),
+ ),
+ MILLENIA_AGED_BLAZE(
+ EntityBlaze::class.java, 30_000_000, LorenzColor.DARK_RED, 60,
+ LorenzVec(-292.5, 97.0, -999.7),
+ LorenzVec(-232.3, 77.0, -951.1),
+ LorenzVec(-304.1, 73.0, -952.9),
+ LorenzVec(-281.6, 82.0, -1010.7),
+ LorenzVec(-342.8, 86.0, -1035.2),
+ ),
+ ;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CorruptedMobHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CorruptedMobHighlight.kt
deleted file mode 100644
index 898a18b3d..000000000
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/CorruptedMobHighlight.kt
+++ /dev/null
@@ -1,62 +0,0 @@
-package at.hannibal2.skyhanni.features.misc
-
-import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.IslandType
-import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent
-import at.hannibal2.skyhanni.events.RenderMobColoredEvent
-import at.hannibal2.skyhanni.events.ResetEntityHurtEvent
-import at.hannibal2.skyhanni.events.withAlpha
-import at.hannibal2.skyhanni.utils.LorenzColor
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
-import net.minecraft.entity.EntityLivingBase
-import net.minecraftforge.event.world.WorldEvent
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-
-class CorruptedMobHighlight {
-
- private val corruptedMobs = mutableListOf<EntityLivingBase>()
-
- @SubscribeEvent
- fun onEntityHealthUpdate(event: EntityHealthUpdateEvent) {
- if (!LorenzUtils.inSkyBlock) return
-
- val entity = event.entity
- if (entity in corruptedMobs) return
-
- val baseMaxHealth = entity.baseMaxHealth
- if (event.health == baseMaxHealth * 3) {
- corruptedMobs.add(entity)
- }
- }
-
- @SubscribeEvent
- fun onRenderMobColored(event: RenderMobColoredEvent) {
- if (!isEnabled()) return
- val entity = event.entity
-
- if (entity in corruptedMobs) {
- event.color = LorenzColor.DARK_PURPLE.toColor().withAlpha(127)
- }
- }
-
- @SubscribeEvent
- fun onResetEntityHurtTime(event: ResetEntityHurtEvent) {
- if (!isEnabled()) return
- val entity = event.entity
-
- if (entity in corruptedMobs) {
- event.shouldReset = true
- }
- }
-
- @SubscribeEvent
- fun onWorldChange(event: WorldEvent.Load) {
- corruptedMobs.clear()
- }
-
- private fun isEnabled(): Boolean {
- return LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.corruptedMobHighlight &&
- LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND
- }
-} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HighlightAreaMiniBoss.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HighlightAreaMiniBoss.kt
deleted file mode 100644
index 385b895cb..000000000
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/HighlightAreaMiniBoss.kt
+++ /dev/null
@@ -1,49 +0,0 @@
-package at.hannibal2.skyhanni.features.misc
-
-import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent
-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
-import net.minecraft.entity.EntityLiving
-import net.minecraft.entity.monster.EntityBlaze
-import net.minecraft.entity.monster.EntityEnderman
-import net.minecraft.entity.monster.EntitySpider
-import net.minecraft.entity.monster.EntityZombie
-import net.minecraft.entity.passive.EntityWolf
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-
-class HighlightAreaMiniBoss {
-
- @SubscribeEvent
- fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) {
- if (!isEnabled()) return
-
- val entity = event.entity
- val maxHealth = event.maxHealth
-
- for (bossType in AreaMiniBossType.values()) {
- if (!bossType.clazz.isInstance(entity)) continue
-
- if (entity.hasMaxHealth(bossType.health, false, maxHealth)) {
- RenderLivingEntityHelper.setEntityColor(entity, bossType.color)
- RenderLivingEntityHelper.setNoHurtTime(entity)
- }
- }
- }
-
- private fun isEnabled(): Boolean =
- LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.highlightAreaMinisBoss
-
- enum class AreaMiniBossType(val clazz: Class<out EntityLiving>, val health: Int, val color: Int) {
- GOLDEN_GHOUL(EntityZombie::class.java, 45_000, LorenzColor.YELLOW.toColor().withAlpha(127)),
-// OLD_WOLF(EntityWolf::class.java, 15_000, LorenzColor.RED.toColor().withAlpha(60)),
- OLD_WOLF(EntityWolf::class.java, 15_000, LorenzColor.GOLD.toColor().withAlpha(60)),
- KEEPER(EntitySpider::class.java, 3000, LorenzColor.GREEN.toColor().withAlpha(60)),
- ENDERMAN(EntityEnderman::class.java, 8_000_000, LorenzColor.LIGHT_PURPLE.toColor().withAlpha(127)),
- BLAZE(EntityBlaze::class.java, 30_000_000, LorenzColor.DARK_RED.toColor().withAlpha(60)),
- ;
- }
-} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MobHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MobHighlight.kt
new file mode 100644
index 000000000..ad7c64c37
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MobHighlight.kt
@@ -0,0 +1,47 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent
+import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent
+import at.hannibal2.skyhanni.events.withAlpha
+import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
+import net.minecraft.entity.monster.EntitySpider
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class MobHighlight {
+
+ @SubscribeEvent
+ fun onEntityHealthUpdate(event: EntityHealthUpdateEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+
+ val entity = event.entity
+ val baseMaxHealth = entity.baseMaxHealth
+ if (SkyHanniMod.feature.mobs.corruptedMobHighlight) {
+ if (event.health == baseMaxHealth * 3) {
+ RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.DARK_PURPLE.toColor().withAlpha(127))
+ { SkyHanniMod.feature.mobs.corruptedMobHighlight }
+ RenderLivingEntityHelper.setNoHurtTime(entity) { SkyHanniMod.feature.mobs.corruptedMobHighlight }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+
+ val entity = event.entity
+ val maxHealth = event.maxHealth
+ if (SkyHanniMod.feature.mobs.arachneKeeperHighlight) {
+ if (entity is EntitySpider) {
+ if (maxHealth == 3_000) {
+ RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.DARK_BLUE.toColor().withAlpha(127))
+ { SkyHanniMod.feature.mobs.arachneKeeperHighlight }
+ RenderLivingEntityHelper.setNoHurtTime(entity) { SkyHanniMod.feature.mobs.arachneKeeperHighlight }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt
index 9542efa93..0929bc969 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt
@@ -23,26 +23,26 @@ class HighlightSlayerMiniBoss {
if (!isEnabled()) return
val entity = event.entity
-
if (DamageIndicatorManager.isBoss(entity)) return
val maxHealth = event.maxHealth
-
- for (bossType in AreaMiniBossType.values()) {
+ for (bossType in SlayerMiniBossType.values()) {
if (!bossType.clazz.isInstance(entity)) continue
if (bossType.health.any { entity.hasMaxHealth(it, false, maxHealth) }) {
RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.AQUA.toColor().withAlpha(127))
- RenderLivingEntityHelper.setNoHurtTime(entity)
+ { SkyHanniMod.feature.slayer.slayerMinibossHighlight }
+ RenderLivingEntityHelper.setNoHurtTime(entity) { SkyHanniMod.feature.slayer.slayerMinibossHighlight }
}
}
}
- private fun isEnabled(): Boolean {
- return LorenzUtils.inSkyBlock && SkyHanniMod.feature.slayer.slayerMinibossHighlight && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight
- }
+ private fun isEnabled() = LorenzUtils.inSkyBlock &&
+ SkyHanniMod.feature.slayer.slayerMinibossHighlight &&
+ !LorenzUtils.inDungeons &&
+ !LorenzUtils.inKuudraFight
- enum class AreaMiniBossType(val clazz: Class<out EntityCreature>, vararg val health: Int) {
+ enum class SlayerMiniBossType(val clazz: Class<out EntityCreature>, vararg val health: Int) {
REVENANT(EntityZombie::class.java, 24_000, 90_000, 360_000, 600_000, 2_400_000),
TARANTULA(EntitySpider::class.java, 54_000, 144_000, 576_000),
SVEN(EntityWolf::class.java, 45_000, 120_000, 450_000),
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt
index 371f97a68..036c75627 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt
@@ -11,53 +11,55 @@ class RenderLivingEntityHelper {
@SubscribeEvent
fun onWorldChange(event: WorldEvent.Load) {
entityColorMap.clear()
+ entityColorCondition.clear()
+
entityNoHurTime.clear()
+ entityNoHurTimeCondition.clear()
}
companion object {
private val entityColorMap = mutableMapOf<EntityLivingBase, Int>()
+ private val entityColorCondition = mutableMapOf<EntityLivingBase, () -> Boolean>()
+
private val entityNoHurTime = mutableListOf<EntityLivingBase>()
+ private val entityNoHurTimeCondition = mutableMapOf<EntityLivingBase, () -> Boolean>()
- fun <T : EntityLivingBase> setEntityColor(entity: T, color: Int) {
+ fun <T : EntityLivingBase> setEntityColor(entity: T, color: Int, condition: () -> Boolean) {
entityColorMap[entity] = color
+ entityColorCondition[entity] = condition
}
- fun <T : EntityLivingBase> setNoHurtTime(entity: T) {
+ fun <T : EntityLivingBase> setNoHurtTime(entity: T, condition: () -> Boolean) {
entityNoHurTime.add(entity)
+ entityNoHurTimeCondition[entity] = condition
}
- fun <T : EntityLivingBase> setColorMultiplier(entity: T, ): Int {
+ fun <T : EntityLivingBase> setColorMultiplier(entity: T): Int {
if (entityColorMap.containsKey(entity)) {
- return entityColorMap[entity]!!
+ val condition = entityColorCondition[entity]!!
+ if (condition.invoke()) {
+ return entityColorMap[entity]!!
+ }
}
//TODO remove event
val event = RenderMobColoredEvent(entity, 0)
event.postAndCatch()
- val color = event.color
- if (color != 0) {
- //TODO remove?
- entityColorMap[entity] = color
- }
-
- return color
+ return event.color
}
fun <T : EntityLivingBase> changeHurtTime(entity: T): Int {
if (entityNoHurTime.contains(entity)) {
- return 0
+ val condition = entityNoHurTimeCondition[entity]!!
+ if (condition.invoke()) {
+ return 0
+ }
}
//TODO remove event
val event = ResetEntityHurtEvent(entity, false)
event.postAndCatch()
- val shouldReset = event.shouldReset
-
- if (shouldReset) {
- //TODO remove?
- entityNoHurTime.add(entity)
- }
- return if (shouldReset) 0 else entity.hurtTime
+ return if (event.shouldReset) 0 else entity.hurtTime
}
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
index 4df10611f..ca79b2418 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
@@ -634,7 +634,8 @@ object RenderUtils {
scaleMultiplier: Double,
yOff: Float = 0f,
hideTooCloseAt: Double = 4.5,
- smallestDistanceVew: Double = 5.0
+ smallestDistanceVew: Double = 5.0,
+ ignoreBlocks: Boolean = true,
) {
val thePlayer = Minecraft.getMinecraft().thePlayer
val x = location.x
@@ -665,7 +666,7 @@ object RenderUtils {
val renderLocation = LorenzVec(resultX, resultY, resultZ)
var scale = distRender / 12
scale *= scaleMultiplier
- render(renderLocation, "§f$text", scale, false, true, yOff)
+ render(renderLocation, "§f$text", scale, !ignoreBlocks, true, yOff)
}
private fun render(
@@ -674,7 +675,7 @@ object RenderUtils {
scale: Double,
depthTest: Boolean,
shadow: Boolean,
- yOff: Float
+ yOff: Float,
) {
if (!depthTest) {
GL11.glDisable(GL11.GL_DEPTH_TEST)