aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/dulkirmod/DulkirMod.kt32
-rw-r--r--src/main/kotlin/dulkirmod/config/Config.kt96
-rw-r--r--src/main/kotlin/dulkirmod/features/AlarmClock.kt47
-rw-r--r--src/main/kotlin/dulkirmod/features/BrokenHypeNotif.kt68
-rw-r--r--src/main/kotlin/dulkirmod/features/NametagCleaner.kt2
-rw-r--r--src/main/kotlin/dulkirmod/utils/TitleUtils.kt35
-rw-r--r--src/main/kotlin/dulkirmod/utils/Utils.kt18
7 files changed, 288 insertions, 10 deletions
diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt
index 265d121..c6aa4ab 100644
--- a/src/main/kotlin/dulkirmod/DulkirMod.kt
+++ b/src/main/kotlin/dulkirmod/DulkirMod.kt
@@ -4,6 +4,9 @@ import dulkirmod.command.*
import dulkirmod.config.Config
import dulkirmod.events.ChatEvent
import dulkirmod.features.NametagCleaner
+import dulkirmod.features.alarmClock
+import dulkirmod.features.brokenHypeNotif
+import dulkirmod.utils.TitleUtils
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -33,6 +36,7 @@ import kotlin.coroutines.EmptyCoroutineContext
)
class DulkirMod {
+ var lastLongUpdate : Long = 0
@Mod.EventHandler
fun preInit(event: FMLPreInitializationEvent) {
val directory = File(event.modConfigurationDirectory, "dulkirmod")
@@ -55,6 +59,7 @@ class DulkirMod {
MinecraftForge.EVENT_BUS.register(this)
MinecraftForge.EVENT_BUS.register(ChatEvent())
MinecraftForge.EVENT_BUS.register(NametagCleaner)
+ MinecraftForge.EVENT_BUS.register(DulkirMod.titleUtils)
keyBinds.forEach(ClientRegistry::registerKeyBinding)
}
@@ -69,9 +74,23 @@ class DulkirMod {
if (Config.noReverse3rdPerson && mc.gameSettings.thirdPersonView == 2)
mc.gameSettings.thirdPersonView = 0
- if (event.phase != TickEvent.Phase.START || display == null) return
- mc.displayGuiScreen(display)
- display = null
+ if (event.phase == TickEvent.Phase.START && display != null) {
+ mc.displayGuiScreen(display)
+ display = null
+ }
+
+ var longupdate = false
+ val currTime : Long = System.currentTimeMillis()
+ if (currTime - lastLongUpdate > 1000) {
+ longupdate = true
+ lastLongUpdate = currTime
+ }
+ if (longupdate) {
+ // EXECUTE STUFF HERE THAT DOESN'T REALLY NEED TO BE RUN EVERY TICK
+ alarmClock()
+ brokenHypeNotif()
+ longupdate = false
+ }
}
@SubscribeEvent
@@ -82,21 +101,18 @@ class DulkirMod {
companion object {
const val MOD_ID = "dulkirmod"
const val MOD_NAME = "Dulkir Mod"
- const val MOD_VERSION = "1.0.4"
+ const val MOD_VERSION = "1.0.5"
const val CHAT_PREFIX = "<DulkirMod>"
val mc: Minecraft = Minecraft.getMinecraft()
var config = Config
var display: GuiScreen? = null
val scope = CoroutineScope(EmptyCoroutineContext)
+ val titleUtils = TitleUtils()
val keyBinds = arrayOf(
KeyBinding("Open Settings", Keyboard.KEY_RSHIFT, "Dulkir Mod"),
)
}
-
- // terminal throttle code
-
-
}
diff --git a/src/main/kotlin/dulkirmod/config/Config.kt b/src/main/kotlin/dulkirmod/config/Config.kt
index da017c0..b554bbb 100644
--- a/src/main/kotlin/dulkirmod/config/Config.kt
+++ b/src/main/kotlin/dulkirmod/config/Config.kt
@@ -283,7 +283,103 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod", so
)
var bridgeColor = 6
+ @Property(
+ type = PropertyType.SWITCH,
+ name = "Ghast Notification",
+ description = "Shows a title at 9:00pm for bestiary",
+ category = "Bestiary"
+ )
+ var notifyGhast = false
+
+ @Property(
+ type = PropertyType.SWITCH,
+ name = "Zombie Villager Notification",
+ description = "Shows a title at 8:00pm for bestiary",
+ category = "Bestiary"
+ )
+ var notifyZombieVillager = false
+ @Property(
+ type = PropertyType.SWITCH,
+ name = "Broken Hype Notification",
+ description = "Tells you if you are no longer getting bestiary! Requires champion and book of stats on your item. LEAVE OFF IF FISHING.",
+ category = "Bestiary"
+ )
+ var notifyHype = false
+
+ @Property(
+ type = PropertyType.SELECTOR,
+ name = "Bestiary Notification Color",
+ description = "Changes color of title notification",
+ category = "Bestiary",
+ options = ["§0Black",
+ "§1Dark Blue",
+ "§2Dark Green",
+ "§3Dark Aqua",
+ "§4Dark Red",
+ "§5Dark Purple",
+ "§6Gold",
+ "§7Gray",
+ "§8Dark Gray",
+ "§9Blue",
+ "§aGreen",
+ "§bAqua",
+ "§cRed",
+ "§dLight Purple",
+ "§eYellow",
+ "§fWhite",
+ "§zSBA Chroma"
+ ]
+ )
+ var bestiaryNotifColor = 15
+
+ @Property(
+ type = PropertyType.SWITCH,
+ name = "Text Shadow",
+ description = "Shows text shadow for notification",
+ category = "Bestiary"
+ )
+ var bestiaryTextShadow = false
+
+ @Property(
+ type = PropertyType.DECIMAL_SLIDER,
+ name = "Scale",
+ description = "Size of notification!",
+ category = "Bestiary",
+ minF = 0f,
+ maxF = 1f,
+ decimalPlaces = 1
+ )
+ var bestiaryNotifSize = .7f
+
+ @Property(
+ type = PropertyType.SWITCH,
+ name = "Alert Noises",
+ description = "Uses relevant mob sounds, doesn't override audio/patcher settings",
+ category = "Bestiary"
+ )
+ var bestiaryAlertSounds = false
+
+ @Property(
+ type = PropertyType.DECIMAL_SLIDER,
+ name = "Alert Volume",
+ description = "Volume of notification!",
+ category = "Bestiary",
+ minF = 0f,
+ maxF = 1f,
+ decimalPlaces = 1
+ )
+ var bestiaryNotifVol = .7f
+
+ @Property(
+ type = PropertyType.BUTTON,
+ name = "Demo Volume Selection",
+ description = "Plays the Ghast Noise as Reference, Might add individual sliders later but this seems like enough",
+ category = "Bestiary"
+ )
+ fun demoVolume() {
+ DulkirMod.mc.thePlayer.playSound("mob.ghast.scream", 1f * Config.bestiaryNotifVol, 1f)
+ }
fun init() {
initialize()
addDependency("customMessage", "throttleNotifier")
diff --git a/src/main/kotlin/dulkirmod/features/AlarmClock.kt b/src/main/kotlin/dulkirmod/features/AlarmClock.kt
new file mode 100644
index 0000000..8dd0a32
--- /dev/null
+++ b/src/main/kotlin/dulkirmod/features/AlarmClock.kt
@@ -0,0 +1,47 @@
+package dulkirmod.features
+
+import dulkirmod.DulkirMod
+import dulkirmod.DulkirMod.Companion.mc
+import dulkirmod.config.Config
+import dulkirmod.utils.Utils
+import net.minecraft.scoreboard.Score
+import net.minecraft.scoreboard.ScorePlayerTeam
+
+var lastUpdate : Long = 0
+
+fun alarmClock() {
+ // CHECK IF IN SKYBLOCK
+ if (!Utils.isInSkyblock()) return
+ // CHECK TIME
+ val currTime : Long = System.currentTimeMillis()
+ val scoreboard = mc.thePlayer.worldScoreboard
+ val sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1)
+ val scores: List<Score> = ArrayList(scoreboard.getSortedScores(sidebarObjective))
+ val lines: MutableList<String> = ArrayList()
+ for (i in scores.indices.reversed()) {
+ val score = scores[i]
+ val scoreplayerteam1 = scoreboard.getPlayersTeam(score.playerName)
+ val line = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score.playerName)
+ lines.add(line)
+ }
+ for (l in lines) {
+ // ZOMBIE VILLAGER
+ if (Config.notifyZombieVillager && l.contains("8:00pm") && (currTime - lastUpdate) > 15000) {
+ lastUpdate = currTime
+ val color = Utils.getColorString(Config.bestiaryNotifColor)
+ DulkirMod.titleUtils.drawStringForTime("${color}Zombie Villager", 5000)
+ if (Config.bestiaryAlertSounds)
+ mc.thePlayer.playSound("mob.villager.yes", 1f * Config.bestiaryNotifVol, 0f)
+ }
+ // GHASTS
+ else if (Config.notifyGhast && l.contains("9:00pm") && (currTime - lastUpdate) > 15000) {
+ lastUpdate = currTime
+ val color = Utils.getColorString(Config.bestiaryNotifColor)
+ DulkirMod.titleUtils.drawStringForTime("${color}Ghast", 5000)
+ if (Config.bestiaryAlertSounds)
+ mc.thePlayer.playSound("mob.ghast.scream", 1f * Config.bestiaryNotifVol, 1f)
+ }
+
+ }
+
+} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/features/BrokenHypeNotif.kt b/src/main/kotlin/dulkirmod/features/BrokenHypeNotif.kt
new file mode 100644
index 0000000..b748f8b
--- /dev/null
+++ b/src/main/kotlin/dulkirmod/features/BrokenHypeNotif.kt
@@ -0,0 +1,68 @@
+package dulkirmod.features
+
+import dulkirmod.DulkirMod
+import dulkirmod.DulkirMod.Companion.mc
+import dulkirmod.config.Config
+import dulkirmod.utils.Utils
+import net.minecraft.item.ItemStack
+import net.minecraft.nbt.NBTTagCompound
+
+var oldKill = -1
+var oldChampionXp = -1
+var oldID = ""
+
+fun brokenHypeNotif() {
+ if (!Config.notifyHype) return;
+
+ var kill = -1
+ var championXp = -1
+ var id = ""
+
+ if (mc.thePlayer == null) return
+
+ val stack: ItemStack = mc.thePlayer.heldItem?: return
+
+ // get info about held item
+ if (stack.hasTagCompound()) {
+ val tag: NBTTagCompound = stack.tagCompound
+ if (tag.hasKey("ExtraAttributes", 10)) {
+ val ea: NBTTagCompound = tag.getCompoundTag("ExtraAttributes")
+ if (ea.hasKey("id", 8)) {
+ id = ea.getString("id")
+ }
+ if (ea.hasKey("stats_book", 99)) {
+ kill = ea.getInteger("stats_book")
+ }
+ if (ea.hasKey("champion_combat_xp", 99)) {
+ championXp = ea.getDouble("champion_combat_xp").toInt()
+ }
+ }
+ }
+
+ // check if same item as previous run
+ if (id == "") {
+ 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) {
+ 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) {
+ mc.thePlayer.playSound("random.anvil_land",1f * Config.bestiaryNotifVol,0f)
+ val color = Utils.getColorString(Config.bestiaryNotifColor)
+ DulkirMod.titleUtils.drawStringForTime("${color}Hype Broken", 5000)
+ }
+ // update item regardless of whether it is bugged or not
+ oldKill = kill
+ oldChampionXp = championXp
+}
diff --git a/src/main/kotlin/dulkirmod/features/NametagCleaner.kt b/src/main/kotlin/dulkirmod/features/NametagCleaner.kt
index 234aa6d..6d588c2 100644
--- a/src/main/kotlin/dulkirmod/features/NametagCleaner.kt
+++ b/src/main/kotlin/dulkirmod/features/NametagCleaner.kt
@@ -20,7 +20,7 @@ object NametagCleaner {
|| name.contains("Superboom TNT") || name.contains ("Blessing")) {
mc.theWorld.removeEntity(event.entity)
}
- }
+ }
}
}
}
diff --git a/src/main/kotlin/dulkirmod/utils/TitleUtils.kt b/src/main/kotlin/dulkirmod/utils/TitleUtils.kt
new file mode 100644
index 0000000..f289a8c
--- /dev/null
+++ b/src/main/kotlin/dulkirmod/utils/TitleUtils.kt
@@ -0,0 +1,35 @@
+package dulkirmod.utils
+
+import dulkirmod.DulkirMod.Companion.mc
+import dulkirmod.config.Config
+import net.minecraft.client.gui.ScaledResolution
+import net.minecraft.client.renderer.GlStateManager
+import net.minecraftforge.client.event.RenderGameOverlayEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.math.min
+
+class TitleUtils {
+ var curString = ""
+ var endTime : Long = 0
+
+ @SubscribeEvent
+ fun onRender(event: RenderGameOverlayEvent.Text) {
+ if (System.currentTimeMillis() > endTime) return
+ val width = mc.fontRendererObj.getStringWidth(curString)
+ val screenWidth = ScaledResolution(mc).scaledWidth_double
+ val screenHeight = ScaledResolution(mc).scaledHeight_double
+ var scale = ((screenWidth - 100) * Config.bestiaryNotifSize) / width
+ scale = min(scale, 10.0)
+ GlStateManager.pushMatrix()
+ GlStateManager.translate((screenWidth / 2 - width * scale / 2), screenHeight/2 - (4.5 * scale), 0.0)
+ GlStateManager.scale(scale, scale, scale)
+ mc.fontRendererObj.drawString(curString, 0f, 0f, 0, Config.bestiaryTextShadow)
+ GlStateManager.popMatrix()
+ }
+
+ fun drawStringForTime(string : String, time : Int) {
+ this.curString = string
+ this.endTime = time.toLong() + System.currentTimeMillis()
+ }
+
+} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/utils/Utils.kt b/src/main/kotlin/dulkirmod/utils/Utils.kt
index c3caa26..3aff645 100644
--- a/src/main/kotlin/dulkirmod/utils/Utils.kt
+++ b/src/main/kotlin/dulkirmod/utils/Utils.kt
@@ -9,7 +9,6 @@ import java.awt.Toolkit
import java.awt.datatransfer.Clipboard
import java.awt.datatransfer.DataFlavor
import java.awt.datatransfer.StringSelection
-import java.lang.IllegalArgumentException
import java.util.*
object Utils {
@@ -54,4 +53,21 @@ object Utils {
}
mc.displayGuiScreen(null)
}
+
+ fun isInSkyblock() : Boolean{
+ if ((mc.theWorld != null) && (mc.thePlayer != null)) {
+ if (mc.isSingleplayer || mc.thePlayer.clientBrand == null ||
+ !mc.thePlayer.clientBrand.lowercase(Locale.getDefault()).contains("hypixel")) {
+ return false
+ }
+ if (mc.thePlayer.worldScoreboard.getObjectiveInDisplaySlot(1) == null)
+ return false;
+ return stripColorCodes(mc.thePlayer.worldScoreboard.getObjectiveInDisplaySlot(1).displayName).contains("SKYBLOCK")
+ }
+ return false
+ }
+
+ fun getColorString(int : Int) : String {
+ return if (int == 16) "§z" else EnumChatFormatting.values()[int].toString()
+ }
} \ No newline at end of file