-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
- Loading branch information
Showing
10 changed files
with
176 additions
and
24 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
odin/src/main/java/me/odin/mixin/mixins/MixinGuiIngame.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
odinclient/src/main/java/me/odinclient/mixin/mixins/MixinGuiIngame.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,7 +117,8 @@ object ModuleManager { | |
HidePlayers, | ||
WarpCooldown, | ||
CopyChat, | ||
DVD | ||
DVD, | ||
PlayerDisplay | ||
) | ||
|
||
init { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
odinmain/src/main/kotlin/me/odinmain/features/impl/render/PlayerDisplay.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
odinmain/src/main/kotlin/me/odinmain/utils/skyblock/SkyblockPlayer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} | ||
} |