summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorHiZe_ <superhize@hotmail.com>2023-07-11 10:38:22 +0200
committerGitHub <noreply@github.com>2023-07-11 10:38:22 +0200
commit635d6cee39cf710286364c47d3419bd6e923a513 (patch)
tree020d820438b370f76e4249daa9485e2eae29e67c /src/main/java/at/hannibal2/skyhanni/features
parent8de1b962fe17892ad968a800d279ab78d45ff03d (diff)
downloadskyhanni-635d6cee39cf710286364c47d3419bd6e923a513.tar.gz
skyhanni-635d6cee39cf710286364c47d3419bd6e923a513.tar.bz2
skyhanni-635d6cee39cf710286364c47d3419bd6e923a513.zip
Merge pull request #302
* feature * save * changed things, fixed things * fixes * Merge branch 'beta' of https://github.com/hannibal002/skyhanni into h… * typo * changed how seeThrough work * moved function to entityutils * updated desc in config * changed value * Blood Ichor highlight * added killer spring highlight * warning for twinclaws * forgot to add config for twinclaws * renamed class * changed twinclaws title to be bold, moved it up a bit and extended ti… * always highlight co-op boss * save * config option for blood ichor beam * checking distance before processing * update * fixes * small fixes * changed detection from 20 to 15 blocs * merged beta * fixed crash with conflicting class name * moved everything in its own config, add steak title for each section * wording * Merge branch 'beta' into highlight_own_vampire * Moving vampire config into slayer category * Fixed one thing * IntelliJ auto formattings * IntelliJ auto formattings * Unnecessary check * code cleanup * parameter is already default false * moved distance check * merged beta * Fixed shouldRender
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/VampireSlayerFeatures.kt248
1 files changed, 248 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/VampireSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/VampireSlayerFeatures.kt
new file mode 100644
index 000000000..7b83e1487
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/VampireSlayerFeatures.kt
@@ -0,0 +1,248 @@
+package at.hannibal2.skyhanni.features.rift
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.ClickType
+import at.hannibal2.skyhanni.data.TitleUtils
+import at.hannibal2.skyhanni.events.EntityClickEvent
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.events.withAlpha
+import at.hannibal2.skyhanni.features.rift.everywhere.RiftAPI
+import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
+import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
+import at.hannibal2.skyhanni.utils.EntityUtils.getAllNameTagsInRadiusWith
+import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture
+import at.hannibal2.skyhanni.utils.EntityUtils.isNPC
+import at.hannibal2.skyhanni.utils.LocationUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
+import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor
+import at.hannibal2.skyhanni.utils.getLorenzVec
+import at.hannibal2.skyhanni.utils.toLorenzVec
+import net.minecraft.client.Minecraft
+import net.minecraft.client.entity.EntityOtherPlayerMP
+import net.minecraft.client.renderer.GlStateManager
+import net.minecraft.entity.EntityLivingBase
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraftforge.client.event.RenderLivingEvent
+import net.minecraftforge.client.event.RenderWorldLastEvent
+import net.minecraftforge.event.entity.living.LivingDeathEvent
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class VampireSlayerFeatures {
+
+ private val config get() = SkyHanniMod.feature.slayer.vampireSlayerConfig
+ private val entityList = mutableListOf<EntityLivingBase>()
+ private val taggedEntityList = mutableListOf<Int>()
+ private val username get() = LorenzUtils.getPlayerName()
+ private val bloodIchorTexture =
+ "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzAzNDA5MjNhNmRlNDgyNWExNzY4MTNkMTMzNTAzZWZmMTg2ZGIwODk2ZTMyYjY3MDQ5MjhjMmEyYmY2ODQyMiJ9fX0="
+ private val killerSpringTexture =
+ "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzdmN2E3YmM4YWM4NmYyM2NhN2JmOThhZmViNzY5NjAyMjdlMTgzMmZlMjA5YTMwMjZmNmNlYjhiZGU3NGY1NCJ9fX0="
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!isEnabled()) return
+ if (!event.isMod(5)) return
+ val start = LocationUtils.playerLocation()
+ if (config.ownBoss.highlight || config.othersBoss.highlight || config.coopsBossHighlight.highlight) {
+ Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityOtherPlayerMP>().forEach {
+ val vec = it.position.toLorenzVec()
+ val distance = start.distance(vec)
+ if (distance <= 15)
+ it.process()
+ }
+ }
+ if (config.bloodIchor.highlight || config.killerSpring.highlight) {
+ Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityArmorStand>().forEach { stand ->
+ val vec = stand.position.toLorenzVec()
+ val distance = start.distance(vec)
+ val isIchor = stand.hasSkullTexture(bloodIchorTexture)
+ if (isIchor || stand.hasSkullTexture(killerSpringTexture)) {
+ val color = (if (isIchor) config.bloodIchor.color else config.killerSpring.color)
+ .toChromaColor().withAlpha(config.withAlpha)
+ if (distance <= 15) {
+ RenderLivingEntityHelper.setEntityColor(
+ stand,
+ color
+ ) { isEnabled() }
+ if (isIchor)
+ entityList.add(stand)
+ }
+ }
+ }
+ }
+ }
+
+ private fun EntityOtherPlayerMP.process() {
+ if (name != "Bloodfiend ") return
+ if (config.ownBoss.twinClawsTitle || config.othersBoss.twinClawsTitle || config.coopsBossHighlight.twinClawsTitle) {
+ getAllNameTagsInRadiusWith("TWINCLAWS").forEach { stand ->
+ if (".*(?:§(?:\\d|\\w))+TWINCLAWS (?:§(?:\\w|\\d))+[0-9.,]+s.*".toRegex().matches(stand.name)) {
+ val coopList = config.coopsBossHighlight.coopMembers.split(",").toList()
+ val containUser = getAllNameTagsInRadiusWith("Spawned by").any {
+ it.name.contains(username)
+ }
+ val containCoop = getAllNameTagsInRadiusWith("Spawned by").any {
+ coopList.isNotEmpty() && config.coopsBossHighlight.highlight && coopList.any { it2 ->
+ var contain = false
+ if (".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*).*".toRegex().matches(it.name)) {
+ val name = ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*)".toRegex()
+ .find(it.name)?.groupValues?.get(1)
+ contain = it2 == name
+ }
+ contain
+ }
+ }
+ val shouldSendTitle =
+ if (containUser && config.ownBoss.twinClawsTitle) true
+ else if (containCoop && config.coopsBossHighlight.twinClawsTitle) true
+ else taggedEntityList.contains(this.entityId) && config.othersBoss.twinClawsTitle
+
+ if (shouldSendTitle) {
+ TitleUtils.sendTitle("§6§lTWINCLAWS", 300, 2.6)
+ }
+ }
+ }
+ }
+ getAllNameTagsInRadiusWith("Spawned by").forEach {
+ val coopList = config.coopsBossHighlight.coopMembers.split(",").toList()
+ val containUser = it.name.contains(username)
+ val containCoop = coopList.isNotEmpty() && coopList.any { it2 ->
+ var contain = false
+ if (".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*).*".toRegex().matches(it.name)) {
+ val name =
+ ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*)".toRegex().find(it.name)?.groupValues?.get(1)
+ contain = it2 == name
+ }
+ contain
+ }
+ val neededHealth = when (baseMaxHealth) {
+ 625 -> 125f // t1
+ 1100 -> 220f // t2
+ 1800 -> 360f // t3
+ 2400 -> 480f // t4
+ else -> 600f // t5
+ }
+ if (containUser && taggedEntityList.contains(this.entityId)) {
+ taggedEntityList.remove(this.entityId)
+ }
+ val canUseSteak = health <= neededHealth
+ val ownBoss = config.ownBoss.highlight && containUser && isNPC()
+ val otherBoss = config.othersBoss.highlight && taggedEntityList.contains(this.entityId) && isNPC()
+ val coopBoss = config.coopsBossHighlight.highlight && containCoop && isNPC()
+ val shouldRender = if (ownBoss) true else if (otherBoss) true else coopBoss
+
+ val color =
+ if (canUseSteak && config.changeColorWhenCanSteak)
+ config.steakColor.color()
+ else if (ownBoss) config.ownBoss.highlightColor.color()
+ else if (otherBoss) config.othersBoss.highlightColor.color()
+ else if (coopBoss) config.coopsBossHighlight.highlightColor.color()
+ else 0
+
+ val shouldSendSteakTitle =
+ if (canUseSteak && config.ownBoss.steakAlert && containUser) true
+ else if (canUseSteak && config.othersBoss.steakAlert && taggedEntityList.contains(this.entityId)) true
+ else canUseSteak && config.coopsBossHighlight.steakAlert && containCoop
+
+ if (shouldSendSteakTitle)
+ TitleUtils.sendTitle("§c§lSTEAK!", 300, 2.6)
+
+
+ if (shouldRender) {
+ RenderLivingEntityHelper.setEntityColor(this, color) { isEnabled() }
+ RenderLivingEntityHelper.setNoHurtTime(this) { isEnabled() }
+ entityList.add(this)
+ }
+ }
+ }
+
+ private fun String.color(): Int {
+ return toChromaColor().withAlpha(config.withAlpha)
+ }
+
+ @SubscribeEvent
+ fun onEntityHit(event: EntityClickEvent) {
+ if (!isEnabled()) return
+ if (event.clickType != ClickType.LEFT_CLICK) return
+ if (event.clickedEntity !is EntityOtherPlayerMP) return
+ if (!event.clickedEntity.isNPC()) return
+ val coopList = config.coopsBossHighlight.coopMembers.split(",").toList()
+ event.clickedEntity.getAllNameTagsInRadiusWith("Spawned by").forEach {
+ val containCoop = coopList.isNotEmpty() && coopList.any { it2 ->
+ var contain = false
+ if (".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*).*".toRegex().matches(it.name)) {
+ val name =
+ ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*)".toRegex().find(it.name)?.groupValues?.get(1)
+ contain = it2 == name
+ }
+ contain
+ }
+ if (it.name.contains(username) || containCoop) return
+ if (!taggedEntityList.contains(event.clickedEntity.entityId)) {
+ taggedEntityList.add(event.clickedEntity.entityId)
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onLivingDeath(event: LivingDeathEvent) {
+ if (!isEnabled()) return
+ val entity = event.entity
+ if (entityList.contains(entity)) {
+ entityList.remove(entity)
+ }
+ if (taggedEntityList.contains(entity.entityId)) {
+ taggedEntityList.remove(entity.entityId)
+ }
+ }
+
+ @SubscribeEvent
+ fun pre(event: RenderLivingEvent.Pre<EntityOtherPlayerMP>) {
+ if (!isEnabled()) return
+ if (!config.seeThrough) return
+ if (entityList.contains(event.entity) && LocationUtils.canSee(
+ LocationUtils.playerEyeLocation(),
+ event.entity.getLorenzVec()
+ )
+ ) {
+ GlStateManager.disableDepth()
+ }
+ }
+
+ @SubscribeEvent
+ fun pre(event: RenderLivingEvent.Post<EntityOtherPlayerMP>) {
+ if (!isEnabled()) return
+ if (!config.seeThrough) return
+ if (entityList.contains(event.entity) && LocationUtils.canSee(
+ LocationUtils.playerEyeLocation(),
+ event.entity.getLorenzVec()
+ )
+ ) {
+ GlStateManager.enableDepth()
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldRender(event: RenderWorldLastEvent) {
+ if (!isEnabled()) return
+ if (config.bloodIchor.renderBeam)
+ entityList.filterIsInstance<EntityArmorStand>().forEach {
+ if (it.isEntityAlive) {
+ event.drawWaypointFilled(
+ it.position.toLorenzVec().add(0, -2, 0), config.bloodIchor.color.toChromaColor(),
+ beacon = true
+ )
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ entityList.clear()
+ taggedEntityList.clear()
+ }
+
+ fun isEnabled() = RiftAPI.inRift()
+} \ No newline at end of file