aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Misc.java10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Slayer.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/EntityData.kt84
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/EntityHealthUpdateEvent.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/EntityMaxHealthUpdateEvent.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/RenderMobColoredEvent.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/ResetEntityHurtEvent.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/end/VoidlingExtremistColor.kt59
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/CorruptedMobHighlight.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/HighlightAreaMiniBoss.kt40
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/MilleniaAgedBlazeColor.kt59
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt53
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniboss.kt92
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt63
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java60
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt5
21 files changed, 251 insertions, 315 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index 02e9493ed..685dc6c9e 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -16,7 +16,6 @@ import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatModifier;
import at.hannibal2.skyhanni.features.commands.WikiCommand;
import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager;
import at.hannibal2.skyhanni.features.dungeon.*;
-import at.hannibal2.skyhanni.features.end.VoidlingExtremistColor;
import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper;
import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowHelper;
import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowParticleFinder;
@@ -29,16 +28,16 @@ import at.hannibal2.skyhanni.features.minion.MinionFeatures;
import at.hannibal2.skyhanni.features.misc.*;
import at.hannibal2.skyhanni.features.misc.tiarelay.TiaRelayHelper;
import at.hannibal2.skyhanni.features.misc.tiarelay.TiaRelayWaypoints;
-import at.hannibal2.skyhanni.features.nether.MilleniaAgedBlazeColor;
import at.hannibal2.skyhanni.features.nether.ashfang.*;
import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper;
import at.hannibal2.skyhanni.features.slayer.EndermanSlayerBeacon;
import at.hannibal2.skyhanni.features.slayer.HideMobNames;
-import at.hannibal2.skyhanni.features.slayer.HighlightSlayerMiniboss;
+import at.hannibal2.skyhanni.features.slayer.HighlightSlayerMiniBoss;
import at.hannibal2.skyhanni.features.slayer.SlayerQuestWarning;
import at.hannibal2.skyhanni.features.slayer.blaze.*;
import at.hannibal2.skyhanni.features.summonings.SummoningMobManager;
import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName;
+import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper;
import at.hannibal2.skyhanni.test.LorenzTest;
import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter;
import kotlin.coroutines.EmptyCoroutineContext;
@@ -98,6 +97,7 @@ public class SkyHanniMod {
loadModule(new MinecraftData());
loadModule(new SendTitleHelper());
loadModule(new ItemTipHelper());
+ loadModule(new RenderLivingEntityHelper());
//features
loadModule(new BazaarOrderHelper());
@@ -135,11 +135,10 @@ public class SkyHanniMod {
loadModule(new RngMeterInventory());
loadModule(new WikiCommand());
loadModule(new SummoningMobManager());
- loadModule(new VoidlingExtremistColor());
- loadModule(new MilleniaAgedBlazeColor());
+ loadModule(new HighlightAreaMiniBoss());
loadModule(new CorruptedMobHighlight());
loadModule(new MarkedPlayerManager());
- loadModule(new HighlightSlayerMiniboss());
+ loadModule(new HighlightSlayerMiniBoss());
loadModule(new PlayerDeathMessages());
loadModule(new HighlightDungeonDeathmite());
loadModule(new DungeonHideItems());
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 ff3e248be..1e7d9f07c 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
@@ -46,16 +46,10 @@ public class Misc {
public boolean highlightColor = false;
@Expose
- @ConfigOption(name = "Voidling Extremist Color", desc = "Highlight the voidling extremist in pink color")
+ @ConfigOption(name = "Area Mini Bosses", desc = "Highlight voidling extremists, millenia aged blazes.")
@ConfigEditorBoolean
@ConfigAccordionId(id = 2)
- public boolean voidlingExtremistColor = false;
-
- @Expose
- @ConfigOption(name = "Millenia Aged Blaze Color", desc = "Highlight the millenia aged blaze in red color")
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 2)
- public boolean milleniaAgedBlazeColor = false;
+ public boolean highlightAreaMinisBoss= false;
@Expose
@ConfigOption(name = "Corrupted Mob Highlight", desc = "Highlight corrupted mobs in purple color")
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Slayer.java b/src/main/java/at/hannibal2/skyhanni/config/features/Slayer.java
index 1aeaf5f33..3275304ec 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Slayer.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Slayer.java
@@ -101,7 +101,7 @@ public class Slayer {
public boolean blazeClearView = false;
@Expose
- @ConfigOption(name = "Miniboss Highlight", desc = "Highlight slayer miniboss in blue color")
+ @ConfigOption(name = "Miniboss Highlight", desc = "Highlight slayer miniboss in blue color.")
@ConfigEditorBoolean
public boolean slayerMinibossHighlight = false;
diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt
index f306bcdf8..c57119818 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt
@@ -1,46 +1,86 @@
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent
+import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent
import at.hannibal2.skyhanni.events.PacketEvent
-import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import net.minecraft.client.Minecraft
+import net.minecraft.client.entity.EntityOtherPlayerMP
+import net.minecraft.client.entity.EntityPlayerSP
import net.minecraft.entity.EntityLivingBase
+import net.minecraft.entity.boss.EntityWither
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraft.entity.item.EntityItem
+import net.minecraft.entity.item.EntityItemFrame
+import net.minecraft.entity.item.EntityXPOrb
import net.minecraft.network.play.server.S1CPacketEntityMetadata
+import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
class EntityData {
+ private val maxHealthMap = mutableMapOf<EntityLivingBase, Int>()
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (event.phase != TickEvent.Phase.START) return
+
+ val minecraft = Minecraft.getMinecraft() ?: return
+ val theWorld = minecraft.theWorld ?: return
+ for (entity in theWorld.loadedEntityList) {
+ if (entity !is EntityLivingBase) continue
+
+ val maxHealth = entity.baseMaxHealth
+ val oldMaxHealth = maxHealthMap.getOrDefault(entity, -1)
+ if (oldMaxHealth != maxHealth) {
+ maxHealthMap[entity] = maxHealth
+ EntityMaxHealthUpdateEvent(entity, maxHealth).postAndCatch()
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ maxHealthMap.clear()
+ }
+
@SubscribeEvent
fun onHealthUpdatePacket(event: PacketEvent.ReceiveEvent) {
val packet = event.packet
- if (packet !is S1CPacketEntityMetadata) return
- if (packet == null) {
- LorenzUtils.debug("packet is null in EntityData!")
- return
- }
+ if (packet !is S1CPacketEntityMetadata) return
val watchableObjects = packet.func_149376_c() ?: return
+ val entityId = packet.entityId
+
+ val theWorld = Minecraft.getMinecraft().theWorld ?: return
+ val entity = theWorld.getEntityByID(entityId) ?: return
+ if (entity is EntityArmorStand) return
+ if (entity is EntityXPOrb) return
+ if (entity is EntityItem) return
+ if (entity is EntityItemFrame) return
+
+ if (entity is EntityOtherPlayerMP) return
+ if (entity is EntityPlayerSP) return
+
for (watchableObject in watchableObjects) {
- if (watchableObject.dataValueId != 6) continue
- val theWorld = Minecraft.getMinecraft().theWorld
- if (theWorld == null) {
- LorenzUtils.debug("theWorld is null in EntityData!")
- continue
- }
- val entityId = packet.entityId
- if (entityId == null) {
- LorenzUtils.debug("entityId is null in EntityData!")
- continue
- }
+ val dataValueId = watchableObject.dataValueId
+ val any = watchableObject.`object`
+ if (dataValueId != 6) continue
- val entity = theWorld.getEntityByID(entityId) ?: continue
- if (entity !is EntityLivingBase) continue
+ val health = (any as Float).toInt()
- val health = watchableObject.`object` as Float
- EntityHealthUpdateEvent(entity, health).postAndCatch()
- return
+ if (entity is EntityWither) {
+ if (health == 300) {
+ if (entityId < 0) return
+ }
+ }
+
+ if (entity is EntityLivingBase) {
+ EntityHealthUpdateEvent(entity, health).postAndCatch()
+ }
}
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/events/EntityHealthUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/EntityHealthUpdateEvent.kt
index 3b0284cf6..5fbcfb9d7 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/EntityHealthUpdateEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/EntityHealthUpdateEvent.kt
@@ -2,4 +2,4 @@ package at.hannibal2.skyhanni.events
import net.minecraft.entity.EntityLivingBase
-class EntityHealthUpdateEvent(val entity: EntityLivingBase, val health: Float) : LorenzEvent() \ No newline at end of file
+class EntityHealthUpdateEvent(val entity: EntityLivingBase, val health: Int) : LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/events/EntityMaxHealthUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/EntityMaxHealthUpdateEvent.kt
new file mode 100644
index 000000000..116e81797
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/EntityMaxHealthUpdateEvent.kt
@@ -0,0 +1,5 @@
+package at.hannibal2.skyhanni.events
+
+import net.minecraft.entity.EntityLivingBase
+
+class EntityMaxHealthUpdateEvent(val entity: EntityLivingBase, val maxHealth: Int) : LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/events/RenderMobColoredEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RenderMobColoredEvent.kt
index 39d36643d..ef4a55563 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/RenderMobColoredEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/RenderMobColoredEvent.kt
@@ -2,4 +2,5 @@ package at.hannibal2.skyhanni.events
import net.minecraft.entity.EntityLivingBase
+//TODO remove
class RenderMobColoredEvent(val entity: EntityLivingBase, var color: Int) : LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/events/ResetEntityHurtEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ResetEntityHurtEvent.kt
index 47af03f38..2f96e4482 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/ResetEntityHurtEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/ResetEntityHurtEvent.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.events
import net.minecraft.entity.EntityLivingBase
import java.awt.Color
+//TODO remove
class ResetEntityHurtEvent(val entity: EntityLivingBase, var shouldReset: Boolean) : LorenzEvent()
fun Color.withAlpha(alpha: Int): Int = (alpha.coerceIn(0, 255) shl 24) or (this.rgb and 0x00ffffff) \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/end/VoidlingExtremistColor.kt b/src/main/java/at/hannibal2/skyhanni/features/end/VoidlingExtremistColor.kt
deleted file mode 100644
index c9b02bf5d..000000000
--- a/src/main/java/at/hannibal2/skyhanni/features/end/VoidlingExtremistColor.kt
+++ /dev/null
@@ -1,59 +0,0 @@
-package at.hannibal2.skyhanni.features.end
-
-import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.IslandType
-import at.hannibal2.skyhanni.events.RenderMobColoredEvent
-import at.hannibal2.skyhanni.events.ResetEntityHurtEvent
-import at.hannibal2.skyhanni.events.withAlpha
-import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth
-import at.hannibal2.skyhanni.utils.LorenzColor
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import net.minecraft.client.Minecraft
-import net.minecraft.entity.monster.EntityEnderman
-import net.minecraftforge.event.world.WorldEvent
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import net.minecraftforge.fml.common.gameevent.TickEvent
-
-class VoidlingExtremistColor {
-
- private var tick = 0
- private val extremists = mutableListOf<EntityEnderman>()
-
- @SubscribeEvent
- fun onTick(event: TickEvent.ClientTickEvent) {
- if (!isEnabled()) return
-
- if (tick++ % 60 == 0) {
- Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityEnderman>()
- .filter { it !in extremists && it.hasMaxHealth(8_000_000) }.forEach { extremists.add(it) }
- }
- }
-
- @SubscribeEvent
- fun onRenderMobColored(event: RenderMobColoredEvent) {
- if (!isEnabled()) return
- val entity = event.entity
-
- if (entity in extremists) {
- event.color = LorenzColor.LIGHT_PURPLE.toColor().withAlpha(127)
- }
- }
-
- @SubscribeEvent
- fun onResetEntityHurtTime(event: ResetEntityHurtEvent) {
- if (!isEnabled()) return
- val entity = event.entity
-
- if (entity in extremists) {
- event.shouldReset = true
- }
- }
-
- @SubscribeEvent
- fun onWorldChange(event: WorldEvent.Load) {
- extremists.clear()
- }
-
- private fun isEnabled(): Boolean =
- LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.THE_END && SkyHanniMod.feature.misc.voidlingExtremistColor
-} \ 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
index 0b4effca4..898a18b3d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/CorruptedMobHighlight.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CorruptedMobHighlight.kt
@@ -24,7 +24,7 @@ class CorruptedMobHighlight {
val entity = event.entity
if (entity in corruptedMobs) return
- val baseMaxHealth = entity.baseMaxHealth.toFloat()
+ val baseMaxHealth = entity.baseMaxHealth
if (event.health == baseMaxHealth * 3) {
corruptedMobs.add(entity)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HighlightAreaMiniBoss.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HighlightAreaMiniBoss.kt
new file mode 100644
index 000000000..66e6ceca3
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/HighlightAreaMiniBoss.kt
@@ -0,0 +1,40 @@
+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.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraft.entity.monster.EntityBlaze
+import net.minecraft.entity.monster.EntityEnderman
+import net.minecraft.entity.monster.EntityMob
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class HighlightAreaMiniBoss {
+
+ @SubscribeEvent
+ fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) {
+ if (!isEnabled()) return
+
+ for (bossType in AreaMiniBossType.values()) {
+ val clazz = bossType.clazz
+ val entity = event.entity
+
+ if (!clazz.isInstance(entity)) continue
+ if (event.maxHealth != bossType.health) continue
+
+ 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 EntityMob>, val health: Int, val color: Int) {
+ 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/nether/MilleniaAgedBlazeColor.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/MilleniaAgedBlazeColor.kt
deleted file mode 100644
index 8a9cad4fa..000000000
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/MilleniaAgedBlazeColor.kt
+++ /dev/null
@@ -1,59 +0,0 @@
-package at.hannibal2.skyhanni.features.nether
-
-import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.IslandType
-import at.hannibal2.skyhanni.events.RenderMobColoredEvent
-import at.hannibal2.skyhanni.events.ResetEntityHurtEvent
-import at.hannibal2.skyhanni.events.withAlpha
-import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth
-import at.hannibal2.skyhanni.utils.LorenzColor
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import net.minecraft.client.Minecraft
-import net.minecraft.entity.monster.EntityBlaze
-import net.minecraftforge.event.world.WorldEvent
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import net.minecraftforge.fml.common.gameevent.TickEvent
-
-class MilleniaAgedBlazeColor {
-
- private var tick = 0
- private val blazes = mutableListOf<EntityBlaze>()
-
- @SubscribeEvent
- fun onTick(event: TickEvent.ClientTickEvent) {
- if (!isEnabled()) return
-
- if (tick++ % 60 == 0) {
- Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityBlaze>()
- .filter { it !in blazes && it.hasMaxHealth(30_000_000) }.forEach { blazes.add(it) }
- }
- }
-
- @SubscribeEvent
- fun onRenderMobColored(event: RenderMobColoredEvent) {
- if (!isEnabled()) return
- val entity = event.entity
-
- if (entity in blazes) {
- event.color = LorenzColor.DARK_RED.toColor().withAlpha(60)
- }
- }
-
- @SubscribeEvent
- fun onResetEntityHurtTime(event: ResetEntityHurtEvent) {
- if (!isEnabled()) return
- val entity = event.entity
-
- if (entity in blazes) {
- event.shouldReset = true
- }
- }
-
- @SubscribeEvent
- fun onWorldChange(event: WorldEvent.Load) {
- blazes.clear()
- }
-
- private fun isEnabled() =
- LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.CRIMSON_ISLE && SkyHanniMod.feature.misc.milleniaAgedBlazeColor
-} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt
index ef3f965a1..4e9382d8f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt
@@ -64,7 +64,7 @@ class AshfangBlazes {
val entityId = event.entity.entityId
if (entityId !in blazeArmorStand.keys.map { it.entityId }) return
- if (event.health % 10_000_000 != 0F) {
+ if (event.health % 10_000_000 != 0) {
blazeArmorStand.keys.removeIf { it.entityId == entityId }
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt
new file mode 100644
index 000000000..9542efa93
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt
@@ -0,0 +1,53 @@
+package at.hannibal2.skyhanni.features.slayer
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent
+import at.hannibal2.skyhanni.events.withAlpha
+import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager
+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.EntityCreature
+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 HighlightSlayerMiniBoss {
+
+ @SubscribeEvent
+ fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) {
+ if (!isEnabled()) return
+
+ val entity = event.entity
+
+ if (DamageIndicatorManager.isBoss(entity)) return
+
+ val maxHealth = event.maxHealth
+
+ for (bossType in AreaMiniBossType.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)
+ }
+ }
+ }
+
+ private fun isEnabled(): Boolean {
+ return LorenzUtils.inSkyBlock && SkyHanniMod.feature.slayer.slayerMinibossHighlight && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight
+ }
+
+ enum class AreaMiniBossType(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),
+ VOIDLING(EntityEnderman::class.java, 8_400_000, 17_500_000, 52_500_000),
+ INFERNAL(EntityBlaze::class.java, 12_000_000, 25_000_000),
+ ;
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniboss.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniboss.kt
deleted file mode 100644
index abbb2a315..000000000
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniboss.kt
+++ /dev/null
@@ -1,92 +0,0 @@
-package at.hannibal2.skyhanni.features.slayer
-
-import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.RenderMobColoredEvent
-import at.hannibal2.skyhanni.events.ResetEntityHurtEvent
-import at.hannibal2.skyhanni.events.withAlpha
-import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager
-import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth
-import at.hannibal2.skyhanni.utils.LorenzColor
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import net.minecraft.client.Minecraft
-import net.minecraft.entity.EntityLivingBase
-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.event.world.WorldEvent
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import net.minecraftforge.fml.common.gameevent.TickEvent
-
-class HighlightSlayerMiniboss {
-
- private var tick = 0
- private val miniBosses = mutableListOf<EntityLivingBase>()
-
- @SubscribeEvent
- fun onTick(event: TickEvent.ClientTickEvent) {
- if (!isEnabled()) return
-
- if (tick++ % 20 == 0) {
- find()
- }
- }
-
- private fun find() {
- val entityList = Minecraft.getMinecraft().theWorld.loadedEntityList
- val list = mutableListOf<EntityLivingBase>()
-
- list.addAll(entityList.filterIsInstance<EntityZombie>().filter {
- it.hasMaxHealth(24_000) || it.hasMaxHealth(90_000) || it.hasMaxHealth(360_000) || it.hasMaxHealth(600_000) || it.hasMaxHealth(2_400_000)
- })
-
- list.addAll(entityList.filterIsInstance<EntitySpider>().filter {
- it.hasMaxHealth(54_000) || it.hasMaxHealth(144_000) || it.hasMaxHealth(576_000)
- })
-
- list.addAll(entityList.filterIsInstance<EntityWolf>().filter {
- it.hasMaxHealth(45_000) || it.hasMaxHealth(120_000) || it.hasMaxHealth(450_000)
- })
-
- list.addAll(entityList.filterIsInstance<EntityEnderman>().filter {
- it.hasMaxHealth(12_000_000) || it.hasMaxHealth(17_500_000) || it.hasMaxHealth(52_500_000)
- })
-
- list.addAll(entityList.filterIsInstance<EntityBlaze>().filter {
- it.hasMaxHealth(12_000_000) || it.hasMaxHealth(25_000_000)
- })
-
- list.filter { it !in miniBosses && !DamageIndicatorManager.isBoss(it) }.forEach(miniBosses::add)
- miniBosses.removeIf { DamageIndicatorManager.isBoss(it) }
- }
-
- @SubscribeEvent
- fun onRenderMobColored(event: RenderMobColoredEvent) {
- if (!isEnabled()) return
- val entity = event.entity
-
- if (entity in miniBosses) {
- event.color = LorenzColor.AQUA.toColor().withAlpha(127)
- }
- }
-
- @SubscribeEvent
- fun onResetEntityHurtTime(event: ResetEntityHurtEvent) {
- if (!isEnabled()) return
- val entity = event.entity
-
- if (entity in miniBosses) {
- event.shouldReset = true
- }
- }
-
- @SubscribeEvent
- fun onWorldChange(event: WorldEvent.Load) {
- miniBosses.clear()
- }
-
- private fun isEnabled(): Boolean {
- return LorenzUtils.inSkyBlock && SkyHanniMod.feature.slayer.slayerMinibossHighlight && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight
- }
-}
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt
new file mode 100644
index 000000000..371f97a68
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt
@@ -0,0 +1,63 @@
+package at.hannibal2.skyhanni.mixins.hooks
+
+import at.hannibal2.skyhanni.events.RenderMobColoredEvent
+import at.hannibal2.skyhanni.events.ResetEntityHurtEvent
+import net.minecraft.entity.EntityLivingBase
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class RenderLivingEntityHelper {
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ entityColorMap.clear()
+ entityNoHurTime.clear()
+ }
+
+ companion object {
+ private val entityColorMap = mutableMapOf<EntityLivingBase, Int>()
+ private val entityNoHurTime = mutableListOf<EntityLivingBase>()
+
+ fun <T : EntityLivingBase> setEntityColor(entity: T, color: Int) {
+ entityColorMap[entity] = color
+ }
+
+ fun <T : EntityLivingBase> setNoHurtTime(entity: T) {
+ entityNoHurTime.add(entity)
+ }
+
+ fun <T : EntityLivingBase> setColorMultiplier(entity: T, ): Int {
+ if (entityColorMap.containsKey(entity)) {
+ 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
+ }
+
+ fun <T : EntityLivingBase> changeHurtTime(entity: T): Int {
+ if (entityNoHurTime.contains(entity)) {
+ 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
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java
index 5161d55da..2ae268a63 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java
@@ -1,7 +1,6 @@
package at.hannibal2.skyhanni.mixins.transformers.renderer;
-import at.hannibal2.skyhanni.events.RenderMobColoredEvent;
-import at.hannibal2.skyhanni.events.ResetEntityHurtEvent;
+import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RendererLivingEntity;
@@ -13,75 +12,22 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import java.util.HashMap;
-import java.util.UUID;
-
//TODO make guava caches working
@Mixin(RendererLivingEntity.class)
public abstract class MixinRendererLivingEntity<T extends EntityLivingBase> extends Render<T> {
- private final HashMap<UUID, Long> lastColorCacheTime = new HashMap<>();
- private final HashMap<UUID, Integer> cachedColor = new HashMap<>();
-
- private final HashMap<UUID, Long> lastHurtCacheTime = new HashMap<>();
- private final HashMap<UUID, Boolean> cachedHurt = new HashMap<>();
-
- // private final LoadingCache<EntityLivingBase, Integer> colorMultiplier;
protected MixinRendererLivingEntity(RenderManager renderManager) {
super(renderManager);
-
-// colorMultiplier = CacheBuilder.newBuilder()
-//// .maximumSize(1000)
-// .expireAfterWrite(2, TimeUnit.SECONDS)
-// .build(
-// new CacheLoader<EntityLivingBase, Integer>() {
-// @Override
-// public Integer load(@NotNull EntityLivingBase key) {
-// RenderMobColoredEvent event = new RenderMobColoredEvent(key, 0);
-// event.postAndCatch();
-// return event.getColor();
-// }
-// }
-// );
}
@Inject(method = "getColorMultiplier", at = @At("HEAD"), cancellable = true)
private void setColorMultiplier(T entity, float lightBrightness, float partialTickTime, CallbackInfoReturnable<Integer> cir) {
- UUID uuid = entity.getUniqueID();
- if (lastColorCacheTime.getOrDefault(uuid, 0L) + 1_000 > System.currentTimeMillis()) {
- cir.setReturnValue(cachedColor.get(uuid));
- return;
- }
-
- RenderMobColoredEvent event = new RenderMobColoredEvent(entity, 0);
- event.postAndCatch();
- int color = event.getColor();
- cachedColor.put(uuid, color);
- lastColorCacheTime.put(uuid, System.currentTimeMillis());
- cir.setReturnValue(color);
-
-// try {
-// cir.setReturnValue(colorMultiplier.get(entity));
-// } catch (ExecutionException e) {
-// throw new RuntimeException(e);
-// }
+ cir.setReturnValue(RenderLivingEntityHelper.Companion.setColorMultiplier(entity));
}
@Redirect(method = "setBrightness", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/EntityLivingBase;hurtTime:I", opcode = Opcodes.GETFIELD))
private int changeHurtTime(EntityLivingBase entity) {
- UUID uuid = entity.getUniqueID();
-
- boolean shouldReset;
- if (lastHurtCacheTime.getOrDefault(uuid, 0L) + 1_000 > System.currentTimeMillis()) {
- shouldReset = cachedHurt.get(uuid);
- } else {
- ResetEntityHurtEvent event = new ResetEntityHurtEvent(entity, false);
- event.postAndCatch();
- shouldReset = event.getShouldReset();
- cachedHurt.put(uuid, shouldReset);
- lastHurtCacheTime.put(uuid, System.currentTimeMillis());
- }
+ return RenderLivingEntityHelper.Companion.changeHurtTime(entity);
- return shouldReset ? 0 : entity.hurtTime;
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt
index 8fd9a45c8..bd13a60fe 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt
@@ -61,7 +61,7 @@ object CopyNearbyEntitiesCommand {
if (entity is EntityLivingBase) {
resultList.add("EntityLivingBase:")
- val baseMaxHealth = entity.baseMaxHealth.toInt()
+ val baseMaxHealth = entity.baseMaxHealth
val health = entity.health.toInt()
resultList.add("- baseMaxHealth: $baseMaxHealth")
resultList.add("- health: $health")
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
index c91865dce..c27d464d7 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
@@ -78,18 +78,19 @@ object EntityUtils {
fun EntityLivingBase.hasBossHealth(health: Int): Boolean = this.hasMaxHealth(health, true)
- fun EntityLivingBase.hasMaxHealth(health: Int, boss: Boolean = false): Boolean {
- if (this.baseMaxHealth == health.toDouble()) return true
+ //TODO remove baseMaxHealth
+ fun EntityLivingBase.hasMaxHealth(health: Int, boss: Boolean = false, maxHealth: Int = baseMaxHealth): Boolean {
+ if (maxHealth == health) return true
//Derpy
- if (this.baseMaxHealth == health.toDouble() * 2) return true
+ if (maxHealth == health * 2) return true
if (!boss) {
//Corrupted
- if (this.baseMaxHealth == health.toDouble() * 3) return true
+ if (maxHealth == health * 3) return true
//Derpy + Corrupted
- if (this.baseMaxHealth == health.toDouble() * 2 * 3) return true
+ if (maxHealth == health * 2 * 3) return true
}
return false
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index d8e21e46f..87ae37da7 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -134,4 +134,6 @@ object ItemUtils {
set(value) {
setStackDisplayName(value)
}
+
+ fun isSkyBlockMenuItem(stack: ItemStack?): Boolean = stack?.getInternalName() == "SKYBLOCK_MENU"
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index cf557e1cb..a650e1c19 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -105,8 +105,9 @@ object LorenzUtils {
// TODO replace all calls with regex
fun String.between(start: String, end: String): String = this.split(start, end)[1]
- val EntityLivingBase.baseMaxHealth: Double
- get() = this.getEntityAttribute(SharedMonsterAttributes.maxHealth).baseValue
+ //TODO change to Int
+ val EntityLivingBase.baseMaxHealth: Int
+ get() = this.getEntityAttribute(SharedMonsterAttributes.maxHealth).baseValue.toInt()
fun formatPercentage(percentage: Double): String = formatPercentage(percentage, "0.00")