From d6faaa1f987b8766637fbc1e20a97112dfce164a Mon Sep 17 00:00:00 2001 From: ronald Date: Sun, 30 Jul 2023 14:55:30 -0500 Subject: BROKEN HYP! --- .../kotlin/com/dulkirfabric/features/BrokenHyp.kt | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/main/kotlin/com/dulkirfabric/features/BrokenHyp.kt (limited to 'src/main/kotlin/com/dulkirfabric/features/BrokenHyp.kt') diff --git a/src/main/kotlin/com/dulkirfabric/features/BrokenHyp.kt b/src/main/kotlin/com/dulkirfabric/features/BrokenHyp.kt new file mode 100644 index 0000000..dfae99b --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/features/BrokenHyp.kt @@ -0,0 +1,63 @@ +package com.dulkirfabric.features + +import com.dulkirfabric.DulkirModFabric.mc +import com.dulkirfabric.config.DulkirConfig +import com.dulkirfabric.events.LongUpdateEvent +import com.dulkirfabric.util.TablistUtils +import com.dulkirfabric.util.render.HudRenderUtil +import meteordevelopment.orbit.EventHandler +import net.minecraft.item.ItemStack +import net.minecraft.text.Style +import net.minecraft.text.Text +import net.minecraft.util.Formatting +import java.time.Duration + + +object BrokenHyp { + + private var oldKill = -1 + private var oldChampionXp = -1.0 + private var oldID = "" + + private var kill = -1 + private var championXp = -1.0 + private var id = "" + + @EventHandler + fun onLong(event: LongUpdateEvent) { + if (!DulkirConfig.configOptions.brokenHypNotif) return + val stack: ItemStack = mc.player?.mainHandStack ?: return + + // get info about held item + val tag = stack.nbt ?: return + id = tag.getCompound("ExtraAttributes")?.getString("id") ?: "" + kill = tag.getCompound("ExtraAttributes")?.getInt("stats_book") ?: -1 + championXp = tag.getCompound("ExtraAttributes")?.getDouble("champion_combat_xp") ?: -1.0 + + // check if a wither blade, then check if same id + if (!(id matches "(HYPERION|ASTRAEA|SCYLLA|VALKYRIE)".toRegex())) { + return + } else if (id != oldID) { + // Check if this is a valid item for testing whether bestiary is broken. + // That is, to be specific, check that it has champion and book of stats. + // If it doesn't, don't reset because it can't be used anyway. + if (kill == -1 || championXp == -1.0) { + return + } + // If we get here this is a new item that is legitimate for testing bugged xp, in theory. + oldID = id + oldKill = kill + oldChampionXp = championXp + return + } + + // If this section of the code is reached, then we have the same item, and we can check for updated stats + if (oldKill != kill && oldChampionXp == championXp && TablistUtils.persistentInfo.area != "Private Island") { + HudRenderUtil.drawTitle(Text.literal("Hype Broken").setStyle(Style.EMPTY.withColor(Formatting.RED)), + Duration.ofSeconds(2)) + } + // update item regardless of whether it is bugged or not + oldKill = kill + oldChampionXp = championXp + } +} \ No newline at end of file -- cgit