diff --git a/odin/src/main/java/me/odin/mixin/mixins/MixinGuiIngame.java b/odin/src/main/java/me/odin/mixin/mixins/MixinGuiIngame.java new file mode 100644 index 000000000..558c37c5f --- /dev/null +++ b/odin/src/main/java/me/odin/mixin/mixins/MixinGuiIngame.java @@ -0,0 +1,16 @@ +package me.odin.mixin.mixins; + +import me.odinmain.features.impl.render.PlayerDisplay; +import net.minecraft.client.gui.GuiIngame; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@Mixin(value = GuiIngame.class) +public class MixinGuiIngame { + + @ModifyVariable(method = "setRecordPlaying(Ljava/lang/String;Z)V", at = @At("HEAD"), argsOnly = true) + private String modifyActionBar(String text) { + return PlayerDisplay.INSTANCE.modifyText(text); + } +} diff --git a/odin/src/main/resources/mixins.odin.json b/odin/src/main/resources/mixins.odin.json index 685a81f17..4264ce955 100644 --- a/odin/src/main/resources/mixins.odin.json +++ b/odin/src/main/resources/mixins.odin.json @@ -20,6 +20,7 @@ "mixins.MixinEntityRenderer", "mixins.MixinFontRenderer", "mixins.MixinGuiContainer", + "mixins.MixinGuiIngame", "mixins.MixinGuiScreen", "mixins.MixinItem", "mixins.MixinItemRenderer", diff --git a/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinGuiIngame.java b/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinGuiIngame.java new file mode 100644 index 000000000..6e5502d34 --- /dev/null +++ b/odinclient/src/main/java/me/odinclient/mixin/mixins/MixinGuiIngame.java @@ -0,0 +1,16 @@ +package me.odinclient.mixin.mixins; + +import me.odinmain.features.impl.render.PlayerDisplay; +import net.minecraft.client.gui.GuiIngame; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@Mixin(value = GuiIngame.class) +public class MixinGuiIngame { + + @ModifyVariable(method = "setRecordPlaying(Ljava/lang/String;Z)V", at = @At("HEAD"), argsOnly = true) + private String modifyActionBar(String text) { + return PlayerDisplay.INSTANCE.modifyText(text); + } +} diff --git a/odinclient/src/main/resources/mixins.odinclient.json b/odinclient/src/main/resources/mixins.odinclient.json index 8ac1d140c..cfaddf7ae 100644 --- a/odinclient/src/main/resources/mixins.odinclient.json +++ b/odinclient/src/main/resources/mixins.odinclient.json @@ -28,6 +28,7 @@ "accessors.IMinecraftAccessor", "mixins.MixinFontRenderer", "mixins.MixinGuiContainer", + "mixins.MixinGuiIngame", "mixins.MixinGuiScreen", "mixins.MixinItem", "mixins.MixinItemRenderer", diff --git a/odinmain/src/main/kotlin/me/odinmain/OdinMain.kt b/odinmain/src/main/kotlin/me/odinmain/OdinMain.kt index c6ec44d68..fa1afd1ce 100644 --- a/odinmain/src/main/kotlin/me/odinmain/OdinMain.kt +++ b/odinmain/src/main/kotlin/me/odinmain/OdinMain.kt @@ -1,28 +1,19 @@ package me.odinmain -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.* import me.odinmain.commands.impl.* import me.odinmain.config.* import me.odinmain.events.EventDispatcher import me.odinmain.features.ModuleManager -import me.odinmain.features.impl.render.ClickGUIModule -import me.odinmain.features.impl.render.DevPlayers -import me.odinmain.features.impl.render.WaypointManager +import me.odinmain.features.impl.render.* import me.odinmain.features.impl.skyblock.PartyNote import me.odinmain.font.OdinFont import me.odinmain.ui.clickgui.ClickGUI import me.odinmain.ui.util.shader.RoundedRect import me.odinmain.utils.ServerUtils import me.odinmain.utils.clock.Executor -import me.odinmain.utils.render.Color -import me.odinmain.utils.render.RenderUtils -import me.odinmain.utils.render.Renderer -import me.odinmain.utils.skyblock.KuudraUtils -import me.odinmain.utils.skyblock.LocationUtils -import me.odinmain.utils.skyblock.PlayerUtils +import me.odinmain.utils.render.* +import me.odinmain.utils.skyblock.* import me.odinmain.utils.skyblock.dungeon.DungeonUtils import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiScreen @@ -73,6 +64,7 @@ object OdinMain { WaypointManager, DevPlayers, PartyNote, + SkyblockPlayer, //HighlightRenderer, //OdinUpdater, this diff --git a/odinmain/src/main/kotlin/me/odinmain/features/ModuleManager.kt b/odinmain/src/main/kotlin/me/odinmain/features/ModuleManager.kt index 93a65e00f..c533e6bcf 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/ModuleManager.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/ModuleManager.kt @@ -117,7 +117,8 @@ object ModuleManager { HidePlayers, WarpCooldown, CopyChat, - DVD + DVD, + PlayerDisplay ) init { diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/render/DVD.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/render/DVD.kt index 674c68746..9e3a7877e 100644 --- a/odinmain/src/main/kotlin/me/odinmain/features/impl/render/DVD.kt +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/render/DVD.kt @@ -13,6 +13,8 @@ import me.odinmain.utils.skyblock.modMessage import net.minecraft.client.gui.ScaledResolution import net.minecraftforge.client.event.RenderGameOverlayEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import org.lwjgl.opengl.Display +import java.awt.Color.getHSBColor object DVD : Module( name = "DVD", @@ -27,17 +29,17 @@ object DVD : Module( private val speed: Long by NumberSetting("Speed", 10, 1, 20, 1, description = "Speed of the DVD box.") - private var x = 0 - private var y = 0 + private var x = Display.getWidth() / 2 + private var y = Display.getHeight() / 2 private var dx = 1 private var dy = 1 - var color = Color.MAGENTA + var color = Color.WHITE - private fun randomColor() { - val r = (Math.random() * 56 + 200).toInt() - val g = (Math.random() * 56 + 200).toInt() - val b = (Math.random() * 56 + 200).toInt() - color = Color(r, g, b) + private fun getDVDColor() { + val hue = (Math.random() * 360).toFloat() + + val javaColor = getHSBColor(hue, 1.0f, 0.5f) + color = Color(javaColor.red, javaColor.green, javaColor.blue) } @SubscribeEvent @@ -58,11 +60,11 @@ object DVD : Module( // Check collision with screen edges if (x <= 0 || x + boxWidth >= screenWidth) { - randomColor() + getDVDColor() dx = -dx // Reverse horizontal direction } if (y <= 0 || y + boxHeight >= screenHeight) { - randomColor() + getDVDColor() dy = -dy // Reverse vertical direction } diff --git a/odinmain/src/main/kotlin/me/odinmain/features/impl/render/PlayerDisplay.kt b/odinmain/src/main/kotlin/me/odinmain/features/impl/render/PlayerDisplay.kt new file mode 100644 index 000000000..1c80f5d57 --- /dev/null +++ b/odinmain/src/main/kotlin/me/odinmain/features/impl/render/PlayerDisplay.kt @@ -0,0 +1,73 @@ +package me.odinmain.features.impl.render + +import me.odinmain.features.Category +import me.odinmain.features.Module +import me.odinmain.features.settings.Setting.Companion.withDependency +import me.odinmain.features.settings.impl.* +import me.odinmain.ui.hud.HudElement +import me.odinmain.utils.render.* +import me.odinmain.utils.skyblock.SkyblockPlayer +import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object PlayerDisplay : Module( + name = "Player Display", + description = "Displays info about the skyblock player.", + category = Category.RENDER, +) { + private val hideElements: Boolean by DropdownSetting("Hide Elements") + private val hideArmor: Boolean by BooleanSetting("Hide Armor").withDependency { hideElements } + private val hideFood: Boolean by BooleanSetting("Hide Food").withDependency { hideElements } + private val hideHearts: Boolean by BooleanSetting("Hide Hearts").withDependency { hideElements } + private val hideXP: Boolean by BooleanSetting("Hide XP Level").withDependency { hideElements } + private val healthHud: HudElement by HudSetting("Health Hud", 10f, 10f, 1f, true) { + val text = + if (it) + "§c5000/5000❤" + else if (SkyblockPlayer.currentHealth != 0 && SkyblockPlayer.maxHealth != 0) + "§c${SkyblockPlayer.currentHealth}/${SkyblockPlayer.maxHealth}❤" + else return@HudSetting 0f to 0f + mcText(text, 2, 2, 2, Color.RED, center = false) + return@HudSetting getMCTextWidth(text) * 2f + 4f to 20f + } + private val manaHud: HudElement by HudSetting("Mana Hud", 10f, 10f, 1f, true) { + val text = + if (it) + "§b2000/2000✎" + else if (SkyblockPlayer.currentMana != 0 && SkyblockPlayer.maxMana != 0) + "§b${SkyblockPlayer.currentMana}/${SkyblockPlayer.maxMana}✎" + else return@HudSetting 0f to 0f + mcText(text, 2, 2, 2, Color.CYAN, center = false) + return@HudSetting getMCTextWidth(text) * 2f + 4f to 20f + } + private val defenseHud: HudElement by HudSetting("Defense Hud", 10f, 10f, 1f, true) { + val text = + if (it) + "§a1000❈" + else if (SkyblockPlayer.currentDefense != 0) + "§a${SkyblockPlayer.currentDefense}❈" + else return@HudSetting 0f to 0f + mcText(text, 2, 2, 2, Color.GREEN, center = false) + return@HudSetting getMCTextWidth(text) * 2f + 4f to 20f + } + + fun modifyText(text: String): String { + if (!enabled) return text + var toReturn = text + toReturn = if (healthHud.enabled) toReturn.replace("[\\d|,]+/[\\d|,]+❤".toRegex(), "") else toReturn + toReturn = if (manaHud.enabled) toReturn.replace("[\\d|,]+/[\\d|,]+✎ Mana".toRegex(), "") else toReturn + toReturn = if (defenseHud.enabled) toReturn.replace("[\\d|,]+§a❈ Defense".toRegex(), "") else toReturn + return toReturn + } + + @SubscribeEvent + fun onRenderOverlay(event: RenderGameOverlayEvent.Pre) { + event.isCanceled = when (event.type) { + RenderGameOverlayEvent.ElementType.ARMOR -> hideArmor + RenderGameOverlayEvent.ElementType.HEALTH -> hideHearts + RenderGameOverlayEvent.ElementType.FOOD -> hideFood + RenderGameOverlayEvent.ElementType.EXPERIENCE -> hideXP + else -> return + } + } +} \ No newline at end of file diff --git a/odinmain/src/main/kotlin/me/odinmain/utils/render/RenderUtils.kt b/odinmain/src/main/kotlin/me/odinmain/utils/render/RenderUtils.kt index 90e3911de..5c1b9351e 100644 --- a/odinmain/src/main/kotlin/me/odinmain/utils/render/RenderUtils.kt +++ b/odinmain/src/main/kotlin/me/odinmain/utils/render/RenderUtils.kt @@ -682,6 +682,7 @@ object RenderUtils { val xOffset = if (center) mc.fontRendererObj.getStringWidth(it) / -2f else 0f mc.fontRendererObj.drawString(it, xOffset, 0f, color.rgba, shadow) } + Color.WHITE.bind() GlStateManager.disableBlend() GlStateManager.popMatrix() } diff --git a/odinmain/src/main/kotlin/me/odinmain/utils/skyblock/SkyblockPlayer.kt b/odinmain/src/main/kotlin/me/odinmain/utils/skyblock/SkyblockPlayer.kt new file mode 100644 index 000000000..f3f856e3d --- /dev/null +++ b/odinmain/src/main/kotlin/me/odinmain/utils/skyblock/SkyblockPlayer.kt @@ -0,0 +1,49 @@ +package me.odinmain.utils.skyblock + +import me.odinmain.OdinMain.mc +import me.odinmain.events.impl.PacketReceivedEvent +import me.odinmain.utils.noControlCodes +import net.minecraft.network.play.server.S02PacketChat +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object SkyblockPlayer { + /* + in module there should be: + health display current/Max + health bar + defense display + mana display current/Max + mana bar + current speed + current ehp + */ + + val currentHealth: Int get() = (maxHealth * (mc.thePlayer?.health ?: 0f) / 40f).toInt() + var maxHealth: Int = 0 + var currentMana: Int = 0 + var maxMana: Int = 0 + var currentSpeed: Int = 0 + var currentDefense: Int = 0 + + @SubscribeEvent(priority = EventPriority.HIGHEST) + fun onPacket(event: PacketReceivedEvent) { + if (event.packet !is S02PacketChat || event.packet.type != 2.toByte()) return + val msg = event.packet.chatComponent.unformattedText.noControlCodes + val (currentHp, maxHp, middleRegion, cMana, mMana) = Regex("(.+)/(.+)❤ {5}(.+) {5}(.+)/(.+)✎ Mana").find(msg)?.destructured ?: return + + maxHealth = maxHp.replace(",", "").toIntOrNull() ?: return + currentMana = cMana.replace(",", "").toIntOrNull() ?: return + maxMana = mMana.replace(",", "").toIntOrNull() ?: return + + currentDefense = Regex("([\\d|,]+)❈ Defense").find(middleRegion)?.groupValues?.get(1)?.replace(",", "")?.toIntOrNull() ?: return + + devMessage(""" + current Health = $currentHealth + maxHealth = $maxHealth + currentMana = $currentMana + maxMana = $maxMana + currentDefense = $currentDefense + """.trimIndent()) + } +} \ No newline at end of file