diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/Registrations.kt | 1 | ||||
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt | 4 | ||||
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/features/BrokenHyp.kt | 63 |
3 files changed, 68 insertions, 0 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt index e859c6a..650fe87 100644 --- a/src/main/kotlin/com/dulkirfabric/Registrations.kt +++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt @@ -96,6 +96,7 @@ object Registrations { EVENT_BUS.subscribe(DamageNumbers) EVENT_BUS.subscribe(Garden) EVENT_BUS.subscribe(VisitorAlert) + EVENT_BUS.subscribe(BrokenHyp) if (FabricLoader.getInstance().isDevelopmentEnvironment) EVENT_BUS.subscribe(RenderTest) diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt index a2a7d66..3118275 100644 --- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt +++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt @@ -162,6 +162,9 @@ class DulkirConfig { .setSaveConsumer { newValue -> configOptions.etherwarpPreviewColor = newValue } .build() ) + general.addEntry( + entryBuilder.mkToggle(Text.literal("Broken Hype Notification"), configOptions::brokenHypNotif) + ) val shortcuts = builder.getOrCreateCategory(Text.literal("Shortcuts")) shortcuts.addEntry( @@ -363,6 +366,7 @@ class DulkirConfig { var slayerKillTime: Boolean = false, var visitorAlert: Boolean = false, var persistentVisitorAlert: Boolean = false, + var brokenHypNotif: Boolean = false, ) @Serializable 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 |