Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Cezqr committed Apr 27, 2024
2 parents dc9517f + afdb041 commit b90e6a9
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 24 deletions.
16 changes: 16 additions & 0 deletions odin/src/main/java/me/odin/mixin/mixins/MixinGuiIngame.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
1 change: 1 addition & 0 deletions odin/src/main/resources/mixins.odin.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"mixins.MixinEntityRenderer",
"mixins.MixinFontRenderer",
"mixins.MixinGuiContainer",
"mixins.MixinGuiIngame",
"mixins.MixinGuiScreen",
"mixins.MixinItem",
"mixins.MixinItemRenderer",
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
1 change: 1 addition & 0 deletions odinclient/src/main/resources/mixins.odinclient.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"accessors.IMinecraftAccessor",
"mixins.MixinFontRenderer",
"mixins.MixinGuiContainer",
"mixins.MixinGuiIngame",
"mixins.MixinGuiScreen",
"mixins.MixinItem",
"mixins.MixinItemRenderer",
Expand Down
18 changes: 5 additions & 13 deletions odinmain/src/main/kotlin/me/odinmain/OdinMain.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -73,6 +64,7 @@ object OdinMain {
WaypointManager,
DevPlayers,
PartyNote,
SkyblockPlayer,
//HighlightRenderer,
//OdinUpdater,
this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ object ModuleManager {
HidePlayers,
WarpCooldown,
CopyChat,
DVD
DVD,
PlayerDisplay
)

init {
Expand Down
22 changes: 12 additions & 10 deletions odinmain/src/main/kotlin/me/odinmain/features/impl/render/DVD.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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())
}
}

0 comments on commit b90e6a9

Please sign in to comment.