diff options
Diffstat (limited to 'src/main/java')
4 files changed, 56 insertions, 57 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt index ce9c57e97..5bf8d7c2e 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt @@ -2,4 +2,6 @@ package at.hannibal2.skyhanni.events class LorenzTickEvent(private val tick: Int) : LorenzEvent() { fun isMod(i: Int) = tick % i == 0 + + fun repeatSeconds(i: Int) = isMod(i * 20) }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt index 1a44a4bc6..6b1a4f41b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt @@ -174,7 +174,11 @@ class MobFinder { if (DungeonData.isOneOf("F5", "M5")) { if (entity is EntityOtherPlayerMP) { if (entity == DungeonLividFinder.livid) { - return EntityResult(bossType=BossType.DUNGEON_F5, ignoreBlocks = true, finalDungeonBoss = true) + return EntityResult( + bossType = BossType.DUNGEON_F5, + ignoreBlocks = true, + finalDungeonBoss = true + ) } } } @@ -521,7 +525,7 @@ class MobFinder { //F5 "§c[BOSS] Livid§r§f: This Orb you see, is Thorn, or what is left of him." -> { - floor5lividEntity = findLivid() + floor5lividEntity = DungeonLividFinder.livid floor5lividEntitySpawnTime = System.currentTimeMillis() + 13_000 } @@ -578,8 +582,4 @@ class MobFinder { } } } - - private fun findLivid(): EntityOtherPlayerMP? { - return DungeonLividFinder.livid - } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt index 4933ffd21..369d6e762 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt -import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzColor.Companion.toLorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec import net.minecraft.block.BlockStainedGlass @@ -17,43 +17,44 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color object DungeonLividFinder { - var livid : EntityOtherPlayerMP? = null + var livid: EntityOtherPlayerMP? = null private var gotBlinded = false + private val blockLocation = LorenzVec(6, 109, 43) + private val lividColor = Color(191, 0, 255).rgb @SubscribeEvent - fun onTick(tickEvent: LorenzTickEvent) { - if(!LorenzUtils.inDungeons || !DungeonData.inBossRoom) return - if(DungeonData.dungeonFloor != "F5" && DungeonData.dungeonFloor != "M5") return - if(DungeonData.dungeonFloor == "F5" && livid != null) return - if(tickEvent.isMod(100)) return - if(!gotBlinded) { + fun onTick(event: LorenzTickEvent) { + if (!LorenzUtils.inDungeons || !DungeonData.inBossRoom) return + if (DungeonData.dungeonFloor != "F5" && DungeonData.dungeonFloor != "M5") return + if (DungeonData.dungeonFloor == "F5" && livid != null) return + if (!event.repeatSeconds(2)) return + if (!gotBlinded) { gotBlinded = Minecraft.getMinecraft().thePlayer.isPotionActive(Potion.blindness) return } else if (Minecraft.getMinecraft().thePlayer.isPotionActive(Potion.blindness)) return + val dyeColor = blockLocation.getBlockStateAt().getValue(BlockStainedGlass.COLOR) + val chatColor = dyeColor.toLorenzColor()?.getChatColor() ?: return - val blockStateAt = LorenzVec(6, 109, 43).getBlockStateAt() - val color = LorenzColor.getMatchingColor(blockStateAt.getValue(BlockStainedGlass.COLOR)) ?: return + val world = Minecraft.getMinecraft().theWorld + val lividEntity = world.loadedEntityList.filterIsInstance<EntityArmorStand>() + .firstOrNull { it.name.startsWith("${chatColor}﴾ ${chatColor}§lLivid") } ?: return - for(entity in Minecraft.getMinecraft().theWorld.loadedEntityList) { - if(entity is EntityArmorStand && entity.hasCustomName()) { - if(entity.name.startsWith("${color.getChatColor()}﴾ ${color.getChatColor()}§lLivid")) { - val aabb = AxisAlignedBB( - entity.posX - 0.5, - entity.posY - 2, - entity.posZ - 0.5, - entity.posX + 0.5, - entity.posY, - entity.posZ + 0.5 - ) - val entities = Minecraft.getMinecraft().theWorld.getEntitiesWithinAABB(EntityOtherPlayerMP::class.java, aabb) - livid = entities.takeIf { it.size == 1 }?.firstOrNull() ?: return - livid?.let { - RenderLivingEntityHelper.setEntityColor(it, Color(0xBF00FF).rgb) { true } - LorenzUtils.debug("Livid found!") - } - } - } + val aabb = with(lividEntity) { + AxisAlignedBB( + posX - 0.5, + posY - 2, + posZ - 0.5, + posX + 0.5, + posY, + posZ + 0.5 + ) + } + livid = world.getEntitiesWithinAABB(EntityOtherPlayerMP::class.java, aabb) + .takeIf { it.size == 1 }?.firstOrNull() ?: return + livid?.let { + RenderLivingEntityHelper.setEntityColor(it, lividColor) { true } + LorenzUtils.debug("Livid found!") } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt index 4199dd6d3..6fdfaa2af 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt @@ -1,9 +1,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.test.command.CopyErrorCommand -import net.minecraft.client.Minecraft import net.minecraft.item.EnumDyeColor -import net.minecraft.util.ChatComponentText import java.awt.Color enum class LorenzColor(private var chatColorCode: Char, private val color: Color) { @@ -38,26 +36,24 @@ enum class LorenzColor(private var chatColorCode: Char, private val color: Color } companion object { - fun getMatchingColor(enumDyeColor: EnumDyeColor): LorenzColor? { - return when(enumDyeColor) { - EnumDyeColor.WHITE -> WHITE - EnumDyeColor.MAGENTA -> LIGHT_PURPLE - EnumDyeColor.PINK -> LIGHT_PURPLE - EnumDyeColor.RED -> RED - EnumDyeColor.SILVER -> GRAY - EnumDyeColor.GRAY -> GRAY - EnumDyeColor.GREEN -> DARK_GREEN - EnumDyeColor.LIME -> GREEN - EnumDyeColor.BLUE -> BLUE - EnumDyeColor.PURPLE -> DARK_PURPLE - EnumDyeColor.YELLOW -> YELLOW - else -> { - CopyErrorCommand.logError( - Exception("Unknown dye color: $enumDyeColor"), - "Unknown dye color: $enumDyeColor" - ) - return null - } + fun EnumDyeColor.toLorenzColor() = when (this) { + EnumDyeColor.WHITE -> WHITE + EnumDyeColor.MAGENTA -> LIGHT_PURPLE + EnumDyeColor.PINK -> LIGHT_PURPLE + EnumDyeColor.RED -> RED + EnumDyeColor.SILVER -> GRAY + EnumDyeColor.GRAY -> GRAY + EnumDyeColor.GREEN -> DARK_GREEN + EnumDyeColor.LIME -> GREEN + EnumDyeColor.BLUE -> BLUE + EnumDyeColor.PURPLE -> DARK_PURPLE + EnumDyeColor.YELLOW -> YELLOW + else -> { + CopyErrorCommand.logError( + Exception("Unknown dye color: $this"), + "Unknown dye color: $this" + ) + null } } } |