Skip to content

Commit

Permalink
chore: improve performance when checking dungeon floor number
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Jan 21, 2024
1 parent 50a94c5 commit d86709e
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import gg.essential.universal.UMatrixStack
import gg.skytils.skytilsmod.Skytils
import gg.skytils.skytilsmod.Skytils.Companion.mc
import gg.skytils.skytilsmod.core.structure.GuiElement
import gg.skytils.skytilsmod.features.impl.dungeons.DungeonFeatures.dungeonFloorNumber
import gg.skytils.skytilsmod.utils.RenderUtil
import gg.skytils.skytilsmod.utils.Utils
import gg.skytils.skytilsmod.utils.graphics.ScreenRenderer
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer.TextAlignment
import gg.skytils.skytilsmod.utils.graphics.colors.CommonColors
import gg.skytils.skytilsmod.utils.stripControlCodes
Expand Down Expand Up @@ -86,12 +86,7 @@ object BossHPDisplays {
val hasSadanPlayer = mc.theWorld.getPlayerEntityByName("Sadan ") != null
giantNames = mc.theWorld.loadedEntityList.filterIsInstance<EntityArmorStand>().filter {
val name = it.displayName.formattedText
name.contains("") && (!hasSadanPlayer && name.contains("§e﴾ §c§lSadan§r") || (name.contains("Giant") && Utils.equalsOneOf(
DungeonFeatures.dungeonFloor,
"F7",
"M6",
"M7"
)) || GiantHPElement.GIANT_NAMES.any {
name.contains("") && (!hasSadanPlayer && name.contains("§e﴾ §c§lSadan§r") || (name.contains("Giant") && dungeonFloorNumber?.let { it >= 6 } == true) || GiantHPElement.GIANT_NAMES.any {
name.contains(
it
)
Expand All @@ -100,12 +95,7 @@ object BossHPDisplays {
Pair(it.displayName.formattedText, it.positionVector.addVector(0.0, -10.0, 0.0))
}
} else giantNames = emptyList()
if (Skytils.config.showGuardianRespawnTimer && DungeonFeatures.hasBossSpawned && Utils.equalsOneOf(
DungeonFeatures.dungeonFloor,
"M3",
"F3"
) && mc.theWorld != null
) {
if (Skytils.config.showGuardianRespawnTimer && DungeonFeatures.hasBossSpawned && dungeonFloorNumber == 3 && mc.theWorld != null) {
guardianRespawnTimers = mutableListOf<String>().apply {
for (entity in mc.theWorld.loadedEntityList) {
if (size >= 4) break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import gg.skytils.skytilsmod.mixins.transformers.accessors.AccessorEnumDyeColor
import gg.skytils.skytilsmod.utils.*
import gg.skytils.skytilsmod.utils.Utils.equalsOneOf
import gg.skytils.skytilsmod.utils.graphics.ScreenRenderer
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer.TextAlignment
import gg.skytils.skytilsmod.utils.graphics.colors.CommonColors
import kotlinx.coroutines.Job
Expand Down Expand Up @@ -88,6 +87,12 @@ object DungeonFeatures {
"aim"
)
var dungeonFloor: String? = null
set(value) {
field = value
dungeonFloorNumber = value?.drop(1)?.ifEmpty { "0" }?.toIntOrNull()
}
var dungeonFloorNumber: Int? = null
private set
var hasBossSpawned = false
private var isInTerracottaPhase = false
private var terracottaEndTime = -1.0
Expand Down Expand Up @@ -176,15 +181,14 @@ object DungeonFeatures {
if (event.phase != TickEvent.Phase.START || mc.thePlayer == null || mc.theWorld == null) return
if (Utils.inDungeons) {
if (dungeonFloor == null) {
for (line in ScoreboardUtil.sidebarLines) {
if (line.contains("The Catacombs (")) {
dungeonFloor = line.substringAfter("(").substringBefore(")")
ScoreCalculation.floorReq.set(
ScoreCalculation.floorRequirements[dungeonFloor]
?: ScoreCalculation.floorRequirements["default"]!!
)
break
}
ScoreboardUtil.sidebarLines.find {
it.contains("The Catacombs (")
}?.let {
dungeonFloor = it.substringAfter("(").substringBefore(")")
ScoreCalculation.floorReq.set(
ScoreCalculation.floorRequirements[dungeonFloor]
?: ScoreCalculation.floorRequirements["default"]!!
)
}
}
if (!hasClearedText) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import gg.essential.universal.UChat
import gg.skytils.skytilsmod.Skytils
import gg.skytils.skytilsmod.core.structure.GuiElement
import gg.skytils.skytilsmod.core.tickTimer
import gg.skytils.skytilsmod.features.impl.dungeons.DungeonFeatures.dungeonFloorNumber
import gg.skytils.skytilsmod.listeners.DungeonListener
import gg.skytils.skytilsmod.utils.NumberUtil
import gg.skytils.skytilsmod.utils.NumberUtil.roundToPrecision
import gg.skytils.skytilsmod.utils.RenderUtil
import gg.skytils.skytilsmod.utils.Utils
import gg.skytils.skytilsmod.utils.graphics.ScreenRenderer
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer
import gg.skytils.skytilsmod.utils.stripControlCodes
import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.event.world.WorldEvent
Expand Down Expand Up @@ -125,21 +125,11 @@ object DungeonTimer {
}
add("§9Boss entry §bwas ${dungeonTimeFormat((bossEntryTime - dungeonStartTime) / 1000.0)}.")
}
if (Skytils.config.sadanPhaseTimer && Utils.equalsOneOf(
DungeonFeatures.dungeonFloor,
"F6",
"M6"
)
) {
if (Skytils.config.sadanPhaseTimer && dungeonFloorNumber == 6) {
add("§dTerracotta §btook ${diff(terraClearTime, bossEntryTime)} seconds.")
add("§aGiants §btook ${diff(giantsClearTime, terraClearTime)} seconds.")
add("§cSadan §btook ${diff(bossClearTime, giantsClearTime)} seconds.")
} else if (Skytils.config.necronPhaseTimer && Utils.equalsOneOf(
DungeonFeatures.dungeonFloor,
"F7",
"M7"
)
) {
} else if (Skytils.config.necronPhaseTimer && dungeonFloorNumber == 7) {
add("§bMaxor took ${diff(phase1ClearTime, bossEntryTime)} seconds.")
add("§cStorm §btook ${diff(phase2ClearTime, phase1ClearTime)} seconds.")
add("§eTerminals §btook ${diff(terminalClearTime, phase2ClearTime)} seconds.")
Expand All @@ -157,7 +147,7 @@ object DungeonTimer {
}
}

Utils.equalsOneOf(DungeonFeatures.dungeonFloor, "F7", "M7") && (message.startsWith("§r§4[BOSS] ") || message.startsWith("§r§aThe Core entrance ")) -> {
dungeonFloorNumber == 7 && (message.startsWith("§r§4[BOSS] ") || message.startsWith("§r§aThe Core entrance ")) -> {
when {
message.endsWith("§r§cPathetic Maxor, just like expected.§r") && phase1ClearTime == -1L -> {
phase1ClearTime = System.currentTimeMillis()
Expand Down Expand Up @@ -196,7 +186,7 @@ object DungeonTimer {
}
}

Utils.equalsOneOf(DungeonFeatures.dungeonFloor, "F6", "M6") && message.startsWith("§r§c[BOSS] Sadan") -> {
dungeonFloorNumber == 6 && message.startsWith("§r§c[BOSS] Sadan") -> {
when {
(message.endsWith("§r§f: ENOUGH!§r") && terraClearTime == -1L) -> {
terraClearTime = System.currentTimeMillis()
Expand Down Expand Up @@ -297,12 +287,7 @@ object DungeonTimer {

class NecronPhaseTimerElement : GuiElement("Necron Phase Timer", x = 200, y = 120) {
override fun render() {
if (toggled && Utils.inDungeons && bossEntryTime != -1L && Utils.equalsOneOf(
DungeonFeatures.dungeonFloor,
"F7",
"M7"
)
) {
if (toggled && Utils.inDungeons && bossEntryTime != -1L && dungeonFloorNumber == 7) {
val lines = arrayListOf(
"§bMaxor: ${dungeonTimeFormat(((if (phase1ClearTime == -1L) if (scoreShownAt == -1L) System.currentTimeMillis() else scoreShownAt else phase1ClearTime) - bossEntryTime) / 1000.0)}"
).apply {
Expand Down Expand Up @@ -349,12 +334,7 @@ object DungeonTimer {

class SadanPhaseTimerElement : GuiElement("Sadan Phase Timer", x = 200, y = 120) {
override fun render() {
if (toggled && Utils.inDungeons && bossEntryTime != -1L && Utils.equalsOneOf(
DungeonFeatures.dungeonFloor,
"F6",
"M6"
)
) {
if (toggled && Utils.inDungeons && bossEntryTime != -1L && dungeonFloorNumber == 6) {
val lines = arrayListOf(
"§dTerracotta: ${dungeonTimeFormat(((if (terraClearTime == -1L) if (scoreShownAt == -1L) System.currentTimeMillis() else scoreShownAt else terraClearTime) - bossEntryTime) / 1000.0)}"
).apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import gg.skytils.skytilsmod.core.GuiManager
import gg.skytils.skytilsmod.core.structure.GuiElement
import gg.skytils.skytilsmod.core.tickTimer
import gg.skytils.skytilsmod.events.impl.MainReceivePacketEvent
import gg.skytils.skytilsmod.features.impl.dungeons.DungeonFeatures.dungeonFloorNumber
import gg.skytils.skytilsmod.features.impl.handlers.MayorInfo
import gg.skytils.skytilsmod.listeners.DungeonListener
import gg.skytils.skytilsmod.mixins.transformers.accessors.AccessorChatComponentText
import gg.skytils.skytilsmod.utils.*
import gg.skytils.skytilsmod.utils.graphics.ScreenRenderer
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer.TextAlignment
import gg.skytils.skytilsmod.utils.graphics.colors.CommonColors
import net.minecraft.entity.monster.EntityZombie
Expand Down Expand Up @@ -279,7 +279,7 @@ object ScoreCalculation {
if (floorReq.get().secretPercentage != 1.0) "§7(§6Total: ${totalSecrets.get()}§7)" else ""
)
ScoreCalculationElement.text.add("§f• §eCrypts:§a ${crypts.get()}")
if (Utils.equalsOneOf(DungeonFeatures.dungeonFloor, "F6", "F7", "M6", "M7")) {
if (dungeonFloorNumber?.let { it >= 6 } == true) {
ScoreCalculationElement.text.add("§f• §eMimic:§l${if (mimicKilled.get()) "§a ✔" else "§c ✘"}")
}
ScoreCalculationElement.text.add("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import gg.skytils.skytilsmod.Skytils.Companion.mc
import gg.skytils.skytilsmod.core.tickTimer
import gg.skytils.skytilsmod.events.impl.MainReceivePacketEvent
import gg.skytils.skytilsmod.events.impl.PacketEvent
import gg.skytils.skytilsmod.features.impl.dungeons.DungeonFeatures
import gg.skytils.skytilsmod.utils.*
import net.minecraft.entity.item.EntityItemFrame
import net.minecraft.init.Blocks
Expand Down Expand Up @@ -68,7 +67,8 @@ object AlignmentTaskSolver {
}
}

fun isSolverActive() = Skytils.config.alignmentTerminalSolver && Utils.inDungeons && mc.thePlayer != null && TerminalFeatures.isInPhase3() && Utils.equalsOneOf(DungeonFeatures.dungeonFloor, "F7", "M7")
fun isSolverActive() =
Skytils.config.alignmentTerminalSolver && Utils.inDungeons && mc.thePlayer != null && TerminalFeatures.isInPhase3()

fun computeLayout() {
if (!isSolverActive()) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@
*/
package gg.skytils.skytilsmod.features.impl.dungeons.solvers.terminals

import gg.essential.universal.UChat
import gg.essential.universal.UMatrixStack
import gg.skytils.skytilsmod.Skytils
import gg.skytils.skytilsmod.Skytils.Companion.mc
import gg.skytils.skytilsmod.events.impl.BlockChangeEvent
import gg.skytils.skytilsmod.events.impl.PacketEvent
import gg.skytils.skytilsmod.features.impl.dungeons.DungeonFeatures
import gg.skytils.skytilsmod.features.impl.dungeons.DungeonTimer
import gg.skytils.skytilsmod.features.impl.misc.Funny
import gg.skytils.skytilsmod.utils.RenderUtil
import gg.skytils.skytilsmod.utils.SuperSecretSettings
Expand Down Expand Up @@ -89,12 +86,7 @@ object SimonSaysSolver {
val pos = event.pos
val old = event.old
val state = event.update
if (Utils.inDungeons && Skytils.config.simonSaysSolver && TerminalFeatures.isInPhase3() && Utils.equalsOneOf(
DungeonFeatures.dungeonFloor,
"F7",
"M7"
)
) {
if (Utils.inDungeons && Skytils.config.simonSaysSolver && TerminalFeatures.isInPhase3()) {
if ((pos.y in 120..123) && pos.z in 92..95) {
if (pos.x == 111) {
//println("Block at $pos changed to ${state.block.localizedName} from ${old.block.localizedName}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package gg.skytils.skytilsmod.features.impl.dungeons.solvers.terminals
import gg.skytils.skytilsmod.Skytils
import gg.skytils.skytilsmod.Skytils.Companion.mc
import gg.skytils.skytilsmod.events.impl.GuiContainerEvent.SlotClickEvent
import gg.skytils.skytilsmod.features.impl.dungeons.DungeonFeatures.dungeonFloorNumber
import gg.skytils.skytilsmod.features.impl.dungeons.DungeonTimer
import gg.skytils.skytilsmod.utils.SuperSecretSettings
import gg.skytils.skytilsmod.utils.Utils
Expand All @@ -33,7 +34,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object TerminalFeatures {

fun isInPhase3(): Boolean {
return (SuperSecretSettings.azooPuzzoo || DungeonTimer.phase2ClearTime != -1L) && DungeonTimer.phase3ClearTime == -1L
return (SuperSecretSettings.azooPuzzoo || DungeonTimer.phase2ClearTime != -1L) && DungeonTimer.terminalClearTime == -1L && dungeonFloorNumber == 7
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import gg.skytils.skytilsmod.events.impl.GuiRenderItemEvent
import gg.skytils.skytilsmod.events.impl.MainReceivePacketEvent
import gg.skytils.skytilsmod.events.impl.PacketEvent
import gg.skytils.skytilsmod.features.impl.dungeons.DungeonFeatures
import gg.skytils.skytilsmod.features.impl.dungeons.DungeonFeatures.dungeonFloorNumber
import gg.skytils.skytilsmod.features.impl.handlers.AuctionData
import gg.skytils.skytilsmod.mixins.transformers.accessors.AccessorGuiContainer
import gg.skytils.skytilsmod.utils.*
Expand All @@ -43,7 +44,6 @@ import gg.skytils.skytilsmod.utils.RenderUtil.highlight
import gg.skytils.skytilsmod.utils.RenderUtil.renderRarity
import gg.skytils.skytilsmod.utils.Utils.equalsOneOf
import gg.skytils.skytilsmod.utils.graphics.ScreenRenderer
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer.TextAlignment
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer.TextShadow
import gg.skytils.skytilsmod.utils.graphics.colors.CommonColors
Expand Down Expand Up @@ -426,12 +426,7 @@ object ItemFeatures {
if (this is S2APacketParticles) {
if (type == EnumParticleTypes.EXPLOSION_LARGE && Skytils.config.hideImplosionParticles) {
if (isLongDistance && count == 8 && speed == 8f && xOffset == 0f && yOffset == 0f && zOffset == 0f) {
val dist = (if (DungeonFeatures.hasBossSpawned && equalsOneOf(
DungeonFeatures.dungeonFloor,
"F7",
"M7"
)
) 4f else 11f).pow(2f)
val dist = (if (DungeonFeatures.hasBossSpawned && dungeonFloorNumber == 7) 4f else 11f).pow(2f)

if (mc.theWorld.playerEntities.any {
it.heldItem != null && it.uniqueID.version() == 4 && it.getDistanceSq(
Expand Down

0 comments on commit d86709e

Please sign in to comment.