aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/misc
diff options
context:
space:
mode:
authorLorenz <ESs95s3P5z8Pheb>2022-07-14 12:06:07 +0200
committerLorenz <ESs95s3P5z8Pheb>2022-07-14 12:06:07 +0200
commita5c540d977a3510812cac7fac340fe17e7d10983 (patch)
treedbbe5b208e6871378a10868d1206d1d78beeb950 /src/main/java/at/hannibal2/skyhanni/misc
parentd6c99ed30a2b1cb228b2fdc3d3178cf1f369dc53 (diff)
downloadskyhanni-a5c540d977a3510812cac7fac340fe17e7d10983.tar.gz
skyhanni-a5c540d977a3510812cac7fac340fe17e7d10983.tar.bz2
skyhanni-a5c540d977a3510812cac7fac340fe17e7d10983.zip
renamed mod to SkyHanni
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/misc')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/misc/ButtonOnPause.kt51
-rw-r--r--src/main/java/at/hannibal2/skyhanni/misc/CurrentPetDisplay.kt53
-rw-r--r--src/main/java/at/hannibal2/skyhanni/misc/ExpBottleOnGroundHider.kt19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/misc/HypixelData.kt63
-rw-r--r--src/main/java/at/hannibal2/skyhanni/misc/ScoreboardData.kt45
5 files changed, 231 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/misc/ButtonOnPause.kt b/src/main/java/at/hannibal2/skyhanni/misc/ButtonOnPause.kt
new file mode 100644
index 000000000..c42c304db
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/misc/ButtonOnPause.kt
@@ -0,0 +1,51 @@
+package at.hannibal2.skyhanni.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.config.config.ConfigEditor
+import at.hannibal2.skyhanni.config.core.GuiScreenElementWrapper
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraft.client.gui.GuiButton
+import net.minecraft.client.gui.GuiIngameMenu
+import net.minecraftforge.client.event.GuiScreenEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class ButtonOnPause {
+ private val buttonId = System.nanoTime().toInt()
+
+ @SubscribeEvent
+ fun onGuiAction(event: GuiScreenEvent.ActionPerformedEvent.Post) {
+ if (!LorenzUtils.isOnHypixel) return
+
+ if (SkyHanniMod.feature.misc.configButtonOnPause && event.gui is GuiIngameMenu && event.button.id == buttonId) {
+ SkyHanniMod.screenToOpen = GuiScreenElementWrapper(
+ ConfigEditor(
+ SkyHanniMod.feature
+ )
+ )
+ }
+ }
+
+ @SubscribeEvent
+ fun onGuiInitPost(event: GuiScreenEvent.InitGuiEvent.Post) {
+ if (!LorenzUtils.isOnHypixel) return
+
+ if (SkyHanniMod.feature.misc.configButtonOnPause && event.gui is GuiIngameMenu) {
+ val x = event.gui.width - 105
+ val x2 = x + 100
+ var y = event.gui.height - 22
+ var y2 = y + 20
+ val sorted = event.buttonList.sortedWith { a, b -> b.yPosition + b.height - a.yPosition + a.height }
+ for (button in sorted) {
+ val otherX = button.xPosition
+ val otherX2 = button.xPosition + button.width
+ val otherY = button.yPosition
+ val otherY2 = button.yPosition + button.height
+ if (otherX2 > x && otherX < x2 && otherY2 > y && otherY < y2) {
+ y = otherY - 20 - 2
+ y2 = y + 20
+ }
+ }
+ event.buttonList.add(GuiButton(buttonId, x, 0.coerceAtLeast(y), 100, 20, "SkyHanni"))
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/misc/CurrentPetDisplay.kt b/src/main/java/at/hannibal2/skyhanni/misc/CurrentPetDisplay.kt
new file mode 100644
index 000000000..5adf570b5
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/misc/CurrentPetDisplay.kt
@@ -0,0 +1,53 @@
+package at.hannibal2.skyhanni.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.utils.GuiRender.renderString
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.between
+import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex
+import net.minecraftforge.client.event.RenderGameOverlayEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class CurrentPetDisplay {
+
+ companion object {
+ var currentPet: String = ""
+ }
+
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ if (!LorenzUtils.inSkyblock) return
+
+ var blocked = false
+
+ val message = event.message
+ if (message.matchRegex("§aYou summoned your §r(.*)§r§a!")) {
+ currentPet = message.between("your §r", "§r§a")
+ blocked = true
+ }
+ if (message.matchRegex("§cAutopet §eequipped your §7(.*)§e! §a§lVIEW RULE")) {
+ currentPet = message.between("] ", "§e!")
+ blocked = true
+ }
+ if (message.matchRegex("§aYou despawned your §r(.*)§r§a!")) {
+ currentPet = ""
+ blocked = true
+ }
+
+ if (blocked && SkyHanniMod.feature.misc.petDisplay) {
+ event.blockedReason = "pets"
+ }
+ }
+
+
+ @SubscribeEvent
+ fun renderOverlay(event: RenderGameOverlayEvent.Post) {
+ if (!LorenzUtils.inSkyblock) return
+
+ if (!SkyHanniMod.feature.misc.petDisplay) return
+ if (currentPet == "") return
+
+ SkyHanniMod.feature.misc.petDisplayPos.renderString(currentPet)
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/misc/ExpBottleOnGroundHider.kt b/src/main/java/at/hannibal2/skyhanni/misc/ExpBottleOnGroundHider.kt
new file mode 100644
index 000000000..119160c4f
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/misc/ExpBottleOnGroundHider.kt
@@ -0,0 +1,19 @@
+package at.hannibal2.skyhanni.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.CheckRenderEntityEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraft.entity.item.EntityXPOrb
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class ExpBottleOnGroundHider {
+ @SubscribeEvent
+ fun onCheckRender(event: CheckRenderEntityEvent<*>) {
+ if (!LorenzUtils.inSkyblock) return
+ if (!SkyHanniMod.feature.misc.hideExpBottles) return
+
+ if (event.entity is EntityXPOrb) {
+ event.isCanceled = true
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/misc/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/misc/HypixelData.kt
new file mode 100644
index 000000000..29fa2a242
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/misc/HypixelData.kt
@@ -0,0 +1,63 @@
+package at.hannibal2.skyhanni.misc
+
+import at.hannibal2.skyhanni.events.PacketEvent
+import net.minecraft.client.Minecraft
+import net.minecraft.network.play.server.S38PacketPlayerListItem
+import net.minecraft.network.play.server.S3DPacketDisplayScoreboard
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.network.FMLNetworkEvent
+
+class HypixelData {
+
+ companion object {
+ var hypixel = false
+ var skyblock = false
+ var dungeon = false
+}
+
+ @SubscribeEvent
+ fun onConnect(event: FMLNetworkEvent.ClientConnectedToServerEvent) {
+ hypixel = Minecraft.getMinecraft().runCatching {
+ !event.isLocal && (thePlayer?.clientBrand?.lowercase()?.contains("hypixel")
+ ?: currentServerData?.serverIP?.lowercase()?.contains("hypixel") ?: false)
+ }.onFailure { it.printStackTrace() }.getOrDefault(false)
+ }
+
+ @SubscribeEvent
+ fun onScoreboardChange(event: PacketEvent.ReceiveEvent) {
+ if (!hypixel || skyblock || event.packet !is S3DPacketDisplayScoreboard) return
+ if (event.packet.func_149371_c() != 1) return
+ skyblock = event.packet.func_149370_d() == "SBScoreboard"
+ }
+
+ val areaRegex = Regex("§r§b§l(?<area>[\\w]+): §r§7(?<loc>[\\w ]+)§r")
+
+ @SubscribeEvent
+ fun onTabUpdate(event: PacketEvent.ReceiveEvent) {
+ if (dungeon || !hypixel || event.packet !is S38PacketPlayerListItem ||
+ (event.packet.action != S38PacketPlayerListItem.Action.UPDATE_DISPLAY_NAME &&
+ event.packet.action != S38PacketPlayerListItem.Action.ADD_PLAYER)
+ ) return
+ event.packet.entries.forEach { playerData ->
+ val name = playerData?.displayName?.formattedText ?: playerData?.profile?.name ?: return@forEach
+ areaRegex.matchEntire(name)?.let { result ->
+ dungeon = skyblock && result.groups["area"]?.value == "Dungeon"
+ return@forEach
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ skyblock = false
+ dungeon = false
+ }
+
+ @SubscribeEvent
+ fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) {
+ hypixel = false
+ skyblock = false
+ dungeon = false
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/misc/ScoreboardData.kt b/src/main/java/at/hannibal2/skyhanni/misc/ScoreboardData.kt
new file mode 100644
index 000000000..166b6ce17
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/misc/ScoreboardData.kt
@@ -0,0 +1,45 @@
+package at.hannibal2.skyhanni.misc
+
+import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes
+import net.minecraft.client.Minecraft
+import net.minecraft.scoreboard.Score
+import net.minecraft.scoreboard.ScorePlayerTeam
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+
+class ScoreboardData {
+
+ companion object {
+ var sidebarLines: List<String> = emptyList()
+ }
+
+ @SubscribeEvent(priority = EventPriority.HIGHEST)
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (event.phase != TickEvent.Phase.START) return
+
+ sidebarLines = fetchScoreboardLines().map { cleanSB(it) }
+ }
+
+ private fun cleanSB(scoreboard: String): String {
+ return scoreboard.removeColorCodes().toCharArray().filter { it.code in 21..126 }.joinToString(separator = "")
+ }
+
+ fun fetchScoreboardLines(): List<String> {
+ val scoreboard = Minecraft.getMinecraft().theWorld?.scoreboard ?: return emptyList()
+ val objective = scoreboard.getObjectiveInDisplaySlot(1) ?: return emptyList()
+ var scores = scoreboard.getSortedScores(objective)
+ val list = scores.filter { input: Score? ->
+ input != null && input.playerName != null && !input.playerName
+ .startsWith("#")
+ }
+ scores = if (list.size > 15) {
+ list.drop(15)
+ } else {
+ list
+ }
+ return scores.map {
+ ScorePlayerTeam.formatPlayerName(scoreboard.getPlayersTeam(it.playerName), it.playerName)
+ }
+ }
+} \ No newline at end of file