diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
3 files changed, 166 insertions, 98 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt index e0b69d21c..84d19f81e 100644 --- a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt +++ b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt @@ -4,12 +4,14 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.dungeon.DungeonData import at.hannibal2.skyhanni.events.DamageIndicatorFinalBossEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.misc.ScoreboardData import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth import net.minecraft.client.Minecraft import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.monster.EntityEnderman +import net.minecraft.entity.monster.EntityMagmaCube import net.minecraft.util.Vec3 import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.event.entity.EntityJoinWorldEvent @@ -160,105 +162,130 @@ class BossDamageIndicator { if (entityData.bossType == BossType.END_ENDERMAN_SLAYER) { - //custom prefix and health for the four different ender slayers - when (maxHealth) { - 300_000 -> { - calcMaxHealth = 100_000 - if (health > 200_000) { - calcHealth -= 200_000 - extraPrefix = "1/3" - } else if (health > 100_000) { - calcHealth -= 100_000 - extraPrefix = "2/3" - } else { - calcHealth = health - extraPrefix = "3/3" - } - } - 15_000_000 -> { - calcMaxHealth = 5_000_000 - if (health > 10_000_000) { - extraPrefix = "1/3" - calcHealth -= 10_000_000 - } else if (health > 5_000_000) { - calcHealth -= 5_000_000 - extraPrefix = "2/3" - } else { - calcHealth = health - extraPrefix = "3/3" + //Hides the damage indicator when in hit phase or in laser phase + if (entity is EntityEnderman) { + var hidden = false + if (entity.hasNameTagWith(3, " Hit")) hidden = true + if (entity.ridingEntity != null) hidden = true + entityData.hidden = hidden + } + + if (!entityData.hidden) { + //custom prefix and health for the four different ender slayers + when (maxHealth) { + 300_000 -> { + calcMaxHealth = 100_000 + if (health > 200_000) { + calcHealth -= 200_000 + extraPrefix = "1/3" + } else if (health > 100_000) { + calcHealth -= 100_000 + extraPrefix = "2/3" + } else { + calcHealth = health + extraPrefix = "3/3" + } } - } - 66_666_666 -> { - calcMaxHealth = 22_222_222 - if (health > 44_444_444) { - calcHealth -= 44_444_444 - extraPrefix = "1/3" - } else if (health > 22_222_222) { - calcHealth -= 22_222_222 - extraPrefix = "2/3" - } else { - calcHealth = health - extraPrefix = "3/3" + 15_000_000 -> { + calcMaxHealth = 5_000_000 + if (health > 10_000_000) { + extraPrefix = "1/3" + calcHealth -= 10_000_000 + } else if (health > 5_000_000) { + calcHealth -= 5_000_000 + extraPrefix = "2/3" + } else { + calcHealth = health + extraPrefix = "3/3" + } } + 66_666_666 -> { + calcMaxHealth = 22_222_222 + if (health > 44_444_444) { + calcHealth -= 44_444_444 + extraPrefix = "1/3" + } else if (health > 22_222_222) { + calcHealth -= 22_222_222 + extraPrefix = "2/3" + } else { + calcHealth = health + extraPrefix = "3/3" + } - } - 300_000_000 -> { - calcMaxHealth = 50_000_000 - if (health > 250_000_000) { - calcHealth -= 250_000_000 - extraPrefix = "1/6" - } else if (health > 200_000_000) { - calcHealth -= 200_000_000 - extraPrefix = "2/6" - } else if (health > 150_000_000) { - calcHealth -= 150_000_000 - extraPrefix = "3/6" - } else if (health > 100_000_000) { - calcHealth -= 100_000_000 - extraPrefix = "4/6" - } else if (health > 50_000_000) { - calcHealth -= 50_000_000 - extraPrefix = "5/6" - } else { - calcHealth = health - extraPrefix = "6/6" } - } - else -> { - //TODO this is a workaround, find a sweet solution pls? - if (!entityData.hidden) { + 300_000_000 -> { + calcMaxHealth = 50_000_000 + if (health > 250_000_000) { + calcHealth -= 250_000_000 + extraPrefix = "1/6" + } else if (health > 200_000_000) { + calcHealth -= 200_000_000 + extraPrefix = "2/6" + } else if (health > 150_000_000) { + calcHealth -= 150_000_000 + extraPrefix = "3/6" + } else if (health > 100_000_000) { + calcHealth -= 100_000_000 + extraPrefix = "4/6" + } else if (health > 50_000_000) { + calcHealth -= 50_000_000 + extraPrefix = "5/6" + } else { + calcHealth = health + extraPrefix = "6/6" + } + } + else -> { + //TODO this is a workaround, find a sweet solution pls? LorenzUtils.warning("§c[SkyHanni] Unknown max enderman health: $maxHealth") entityData.hidden = true - } - - } - } - //Hides the damage indicator when in hit phase or in laser phase - if (entity is EntityEnderman) { - var hidden = false - if (entity.hasNameTagWith(0, 3, 0, " Hit")) { - hidden = true - } - if (entity.ridingEntity != null) { - hidden = true + } } - entityData.hidden = hidden } } + if (entityData.bossType == BossType.NETHER_MAGMA_BOSS) { + if (entity is EntityMagmaCube) { + val slimeSize = entity.slimeSize + extraPrefix = when (slimeSize) { + 24 -> "1/6" + 22 -> "2/6" + 20 -> "3/6" + 18 -> "4/6" + 16 -> "5/6" + else -> { + calcMaxHealth = 10_000_000 + "6/6" + } + } - //See through blocks when the barbarian duke stands on the platform and the player is below - if (entityData.bossType == BossType.NETHER_BARBARIAN_DUKE) { - val location = entity.getLorenzVec() - val y = location.y - var ignoreBlocks = false - val distance = Minecraft.getMinecraft().thePlayer.getLorenzVec().distance(location) - if (distance < 10) { - if (y == 117.0) { - ignoreBlocks = true + //hide while in the middle + val position = entity.getLorenzVec() + entityData.hidden = position.x == -368.0 && position.z == -804.0 + + for (line in ScoreboardData.sidebarLinesRaw) { + if (line.contains("▎")) { + val color: String + if (line.startsWith("§7")) { + color = "§7" + } else if (line.startsWith("§e")) { + color = "§e" + } else if (line.startsWith("§6") || line.startsWith("§a") || line.startsWith("§c")) { + calcHealth = 0 + break + } else { + LorenzUtils.error("unknown magma boss health sidebar format!") + break + } + + val text = line.replace("\uD83C\uDF81" + color, "") + val max = 25.0 + val length = text.split("§e", "§7")[1].length + val missing = (health.toDouble() / max) * length + calcHealth = (health - missing).toInt() + } } } - entityData.ignoreBlocks = ignoreBlocks } val percentage = calcHealth.toDouble() / calcMaxHealth.toDouble() diff --git a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossFinder.kt b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossFinder.kt index 4576afb73..fab7890a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossFinder.kt @@ -190,7 +190,7 @@ class BossFinder { if (entity is EntityBlaze) { if (entity.name != "Dinnerbone") { - if (entity.hasNameTagWith(0, 2, 0, "§e﴾ §8[§7Lv200§8] §l§8§lAshfang§r ")) { + if (entity.hasNameTagWith(2, "§e﴾ §8[§7Lv200§8] §l§8§lAshfang§r ")) { if (entity.baseMaxHealth == 50_000_000.0) { return EntityResult(bossType = BossType.NETHER_ASHFANG) } @@ -198,7 +198,7 @@ class BossFinder { } } if (entity is EntitySkeleton) { - if (entity.hasNameTagWith(0, 5, 0, "§e﴾ §8[§7Lv200§8] §l§8§lBladesoul§r ")) { + if (entity.hasNameTagWith(5, "§e﴾ §8[§7Lv200§8] §l§8§lBladesoul§r ")) { return EntityResult(bossType = BossType.NETHER_BLADESOUL) } } @@ -213,14 +213,20 @@ class BossFinder { //TODO testing and make right and so if (entity is EntityWither) { - if (entity.hasNameTagWith(0, 4, 0, "§8[§7Lv100§8] §c§5Vanquisher§r ")) { + if (entity.hasNameTagWith(4, "§8[§7Lv100§8] §c§5Vanquisher§r ")) { return EntityResult(bossType = BossType.NETHER_VANQUISHER) } } if (entity is EntityEnderman) { - if (entity.hasNameTagWith(0, 3, 0, "§c☠ §bVoidgloom Seraph ")) { - return EntityResult(bossType = BossType.END_ENDERMAN_SLAYER) + if (entity.hasNameTagWith(3, "§c☠ §bVoidgloom Seraph ")) { + if (entity.baseMaxHealth == 300_000.0 || + entity.baseMaxHealth == 15_000_000.0 || + entity.baseMaxHealth == 66_666_666.0 || + entity.baseMaxHealth == 300_000_000.0 + ) { + return EntityResult(bossType = BossType.END_ENDERMAN_SLAYER) + } } } @@ -231,18 +237,25 @@ class BossFinder { if (entity is EntityIronGolem) { //TODO testing - if (entity.hasNameTagWith(0, 3, 0, "§e﴾ §8[§7Lv100§8] §lEndstone Protector§r ")) { + if (entity.hasNameTagWith(3, "§e﴾ §8[§7Lv100§8] §lEndstone Protector§r ")) { return EntityResult(bossType = BossType.END_ENDSTONE_PROTECTOR, ignoreBlocks = true) } } if (entity is EntityZombie) { - if (entity.hasNameTagWith(0, 2, 0, "§c☠ §fAtoned Horror ")) { + if (entity.hasNameTagWith(2, "§c☠ §fAtoned Horror ")) { if (entity.baseMaxHealth == 10_000_000.0) { return EntityResult(bossType = BossType.HUB_REVENANT_HORROR) } } } + if (entity is EntityMagmaCube) { + if (entity.baseMaxHealth == 200_000_000.0) { + if (entity.hasNameTagWith(15, "§e﴾ §8[§7Lv500§8] §l§4§lMagma Boss§r ")) { + return EntityResult(bossType = BossType.NETHER_MAGMA_BOSS, ignoreBlocks = true) + } + } + } } return null @@ -445,11 +458,36 @@ class BossFinder { } } -fun EntityLiving.hasNameTagWith(x: Int, y: Int, z: Int, contains: String): Boolean { - val center = getLorenzVec().add(x, y, z) - val a = center.add(-1.6, -1.6, -1.6).toBlocPos() +fun EntityLiving.hasNameTagWith( + y: Int, + contains: String, + debug: Boolean = false, + consumer: (EntityArmorStand) -> Unit = {}, +): Boolean { + val center = getLorenzVec().add(0, y, 0) + val a = center.add(-1.6, -1.6 - y, -1.6).toBlocPos() val b = center.add(1.6, 1.6, 1.6).toBlocPos() val alignedBB = AxisAlignedBB(a, b) val clazz = EntityArmorStand::class.java - return worldObj.getEntitiesWithinAABB(clazz, alignedBB).any { it.name.contains(contains) } + return worldObj.getEntitiesWithinAABB(clazz, alignedBB).any { + val result = it.name.contains(contains) + if (!result) { + if (debug) { + println("wrong entity in aabb: '" + it.name + "'") + } + } + if (result && debug) { + println("hasNameTagWith debug!") + val locNametag = it.getLorenzVec() + val locMob = this.getLorenzVec() + println("mob: $locMob") + println("nametag: $locNametag") + val distance = locMob.distance(locNametag) + println("distance: $distance") + + + } + if (result) consumer(it) + return result + } } diff --git a/src/main/java/at/hannibal2/skyhanni/misc/ScoreboardData.kt b/src/main/java/at/hannibal2/skyhanni/misc/ScoreboardData.kt index a10d2dcef..51bf32e56 100644 --- a/src/main/java/at/hannibal2/skyhanni/misc/ScoreboardData.kt +++ b/src/main/java/at/hannibal2/skyhanni/misc/ScoreboardData.kt @@ -12,13 +12,16 @@ class ScoreboardData { companion object { var sidebarLines: List<String> = emptyList() + var sidebarLinesRaw: List<String> = emptyList() } @SubscribeEvent(priority = EventPriority.HIGHEST) fun onTick(event: TickEvent.ClientTickEvent) { if (event.phase != TickEvent.Phase.START) return - sidebarLines = fetchScoreboardLines().map { cleanSB(it) } + val list = fetchScoreboardLines() + sidebarLines = list.map { cleanSB(it) }.reversed() + sidebarLinesRaw = list.reversed() } private fun cleanSB(scoreboard: String): String { |