Skip to content

Commit

Permalink
Improved Hypixel detection
Browse files Browse the repository at this point in the history
Improved ArrowAlign click detection
  • Loading branch information
odtheking committed Nov 6, 2024
1 parent 583be52 commit 56ad1c6
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ object GhostBlocks : Module(
private fun BlockData.reset() = mc.theWorld?.setBlockState(pos, state)

fun breakBlock(pos: BlockPos) {
if (!stonkDelayToggle || (sdOnlySB && !LocationUtils.inSkyblock)) return
if (!stonkDelayToggle || (sdOnlySB && !LocationUtils.isInSkyblock)) return
sdBlocks.add(BlockData(pos, mc.theWorld.getBlockState(pos), System.currentTimeMillis(), false))
}

@SubscribeEvent
fun onBlockChange(event: BlockChangeEvent) {
if (event.update == Blocks.air.defaultState || !stonkDelayToggle || (sdOnlySB && !LocationUtils.inSkyblock)) return
if (event.update == Blocks.air.defaultState || !stonkDelayToggle || (sdOnlySB && !LocationUtils.isInSkyblock)) return
sdBlocks.find { event.pos == it.pos }?.let {
it.state = event.update
it.serverReplaced = true
Expand All @@ -145,13 +145,13 @@ object GhostBlocks : Module(

@SubscribeEvent
fun onPlayerInteract(event: PlayerInteractEvent) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK || !stonkDelayToggle || (sdOnlySB && !LocationUtils.inSkyblock)) return
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK || !stonkDelayToggle || (sdOnlySB && !LocationUtils.isInSkyblock)) return
sdBlocks.removeIf { it.pos == (event.pos.offset(event.face) ?: return@removeIf false) }
}

@SubscribeEvent
fun tick(event: TickEvent.ClientTickEvent) {
if (event.phase != TickEvent.Phase.START || !stonkDelayToggle || (sdOnlySB && !LocationUtils.inSkyblock)) return
if (event.phase != TickEvent.Phase.START || !stonkDelayToggle || (sdOnlySB && !LocationUtils.isInSkyblock)) return
val currentMillis = System.currentTimeMillis()
val blocksToReset = mutableListOf<BlockData>()
sdBlocks.removeAll {
Expand All @@ -164,7 +164,7 @@ object GhostBlocks : Module(
}

fun postChunkData(packet: S21PacketChunkData) {
if (!enabled || !stonkDelayToggle || (sdOnlySB && !LocationUtils.inSkyblock)) return
if (!enabled || !stonkDelayToggle || (sdOnlySB && !LocationUtils.isInSkyblock)) return
sdBlocks.forEach {
if (it.pos.x in (packet.chunkX shl 4).rangeAdd(15) && it.pos.z in (packet.chunkZ shl 4).rangeAdd(15)) {
mc.theWorld?.setBlockState(it.pos, Blocks.air.defaultState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package me.odinclient.features.impl.skyblock
import me.odinmain.features.Category
import me.odinmain.features.Module
import me.odinmain.utils.name
import me.odinmain.utils.skyblock.LocationUtils.inSkyblock
import me.odinmain.utils.skyblock.LocationUtils.isInSkyblock
import me.odinmain.utils.skyblock.PlayerUtils
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.init.Blocks
Expand All @@ -30,7 +30,7 @@ object AutoHarp : Module(

@SubscribeEvent
fun onGuiOpen(event: GuiOpenEvent) {
if (!inSkyblock) return
if (!isInSkyblock) return
val inventorySlots = (event.gui as? GuiChest)?.inventorySlots ?: return
inHarp = inventorySlots.name.startsWith("Harp -")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ object NoBlock : Module(

@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
if (event.phase != TickEvent.Phase.START || !LocationUtils.inSkyblock) return
if (event.phase != TickEvent.Phase.START || !LocationUtils.isInSkyblock) return
isRightClickKeyDown = mc.gameSettings.keyBindUseItem.isKeyDown
}

@SubscribeEvent
fun onInteract(event: PlayerInteractEvent) {
if (!LocationUtils.inSkyblock || event.action != PlayerInteractEvent.Action.RIGHT_CLICK_AIR || (onlyBoss && !DungeonUtils.inBoss)) return
if (!LocationUtils.isInSkyblock || event.action != PlayerInteractEvent.Action.RIGHT_CLICK_AIR || (onlyBoss && !DungeonUtils.inBoss)) return

if (mc.thePlayer?.heldItem?.hasAbility == false || mc.thePlayer?.heldItem?.item !is ItemSword) return
event.isCanceled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ object Triggerbot : Module(
val frameGridCorner = Vec3(-2.0, 120.0, 75.0)

private fun arrowAlignTriggerbot() {
if ((sneakToDisableTriggerbot && mc.thePlayer.isSneaking)) return
if ((sneakToDisableTriggerbot && mc.thePlayer.isSneaking) || clicksRemaining.isEmpty()) return
val targetFrame = mc.objectMouseOver?.entityHit as? EntityItemFrame ?: return

val targetFramePosition = targetFrame.positionVector.flooredVec()
Expand Down
18 changes: 10 additions & 8 deletions src/main/kotlin/me/odinmain/features/impl/floor7/p3/ArrowAlign.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.odinmain.features.impl.floor7.p3

import me.odinmain.events.impl.ClickEvent
import me.odinmain.events.impl.PacketSentEvent
import me.odinmain.features.Category
import me.odinmain.features.Module
import me.odinmain.features.settings.impl.BooleanSetting
Expand All @@ -11,6 +11,7 @@ import me.odinmain.utils.skyblock.dungeon.DungeonUtils
import me.odinmain.utils.skyblock.dungeon.M7Phases
import net.minecraft.entity.item.EntityItemFrame
import net.minecraft.init.Items
import net.minecraft.network.play.client.C02PacketUseEntity
import net.minecraft.util.Vec3
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
Expand Down Expand Up @@ -56,13 +57,14 @@ object ArrowAlign : Module(
}

@SubscribeEvent
fun onRightClick(event: ClickEvent.RightClickEvent) {
if (DungeonUtils.getF7Phase() != M7Phases.P3) return
val targetFrame = mc.objectMouseOver?.entityHit as? EntityItemFrame ?: return
val targetFramePosition = targetFrame.positionVector.flooredVec()

val frameIndex = ((targetFramePosition.yCoord - frameGridCorner.yCoord) + (targetFramePosition.zCoord - frameGridCorner.zCoord) * 5).toInt()
if (targetFramePosition.xCoord != frameGridCorner.xCoord || currentFrameRotations?.get(frameIndex) == -1 || frameIndex !in 0..24) return
fun onPacket(event: PacketSentEvent) {
val packet = event.packet as? C02PacketUseEntity ?: return
if (DungeonUtils.getF7Phase() != M7Phases.P3 || clicksRemaining.isEmpty() || packet.action != C02PacketUseEntity.Action.INTERACT) return
val entity = packet.getEntityFromWorld(mc.theWorld) ?: return
val entityPosition = entity.positionVector.flooredVec()
if (entity !is EntityItemFrame || entity.displayedItem?.item != Items.arrow) return
val frameIndex = ((entityPosition.yCoord - frameGridCorner.yCoord) + (entityPosition.zCoord - frameGridCorner.zCoord) * 5).toInt()
if (entityPosition.xCoord != frameGridCorner.xCoord || currentFrameRotations?.get(frameIndex) == -1 || frameIndex !in 0..24) return

if (!clicksRemaining.containsKey(frameIndex) && !mc.thePlayer.isSneaking && blockWrong) {
event.isCanceled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object ClickGUIModule: Module(
init {
execute(250) {
if (joined) destroyExecutor()
if (!LocationUtils.inSkyblock) return@execute
if (!LocationUtils.isInSkyblock) return@execute
joined = true
Config.save()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ object RenderOptimizer : Module(

@SubscribeEvent
fun onPacket(event: PacketReceivedEvent) {
if (!LocationUtils.inSkyblock) return
if (!LocationUtils.isInSkyblock) return
if (event.packet is S1CPacketEntityMetadata && hide0HealthNames) {
mc.theWorld?.getEntityByID(event.packet.entityId)?.let { entity ->
event.packet.func_149376_c()?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object AbilityTimers : Module(
private val compact: Boolean by BooleanSetting("Compact Mode", default = true, description = "Compacts the Hud to just one character wide.").withDependency { witherImpact }
private val hideWhenDone: Boolean by BooleanSetting("Hide When Ready", default = true, description = "Hides the hud when the cooldown is over.").withDependency { witherImpact }
private val witherHud: HudElement by HudSetting("Wither Impact Hud", 10f, 10f, 1f, true) {
if (witherImpactTicks == 0 && (hideWhenDone || !LocationUtils.inSkyblock) && !it) return@HudSetting 0f to 0f
if (witherImpactTicks == 0 && (hideWhenDone || !LocationUtils.isInSkyblock) && !it) return@HudSetting 0f to 0f
val width = if (compact) 6f else 65f
mcText(witherImpactText, width/2f, 0f, 1f, Color.WHITE, shadow = true)
width to 10f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ object InvincibilityTimer : Module(

@SubscribeEvent
fun onRenderSlotOverlay(event: DrawSlotOverlayEvent) {
if (!LocationUtils.inSkyblock || !showCooldown) return
if (!LocationUtils.isInSkyblock || !showCooldown) return
val durability = when (event.stack.skyblockID) {
"BONZO_MASK", "STARRED_BONZO_MASK" -> (System.currentTimeMillis() - bonzoMaskProc) / 180_000.0
"SPIRIT_MASK", "STARRED_SPIRIT_MASK" -> (System.currentTimeMillis() - spiritMaskProc) / 30_000.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object PlayerDisplay : Module(
val text =
if (example)
generateText(5000, 5000, "")
else if(!LocationUtils.inSkyblock) return@HudSetting 0f to 0f
else if(!LocationUtils.isInSkyblock) return@HudSetting 0f to 0f
else if (SkyblockPlayer.currentHealth != 0 && SkyblockPlayer.maxHealth != 0)
generateText(SkyblockPlayer.currentHealth, SkyblockPlayer.maxHealth, "")
else return@HudSetting 0f to 0f
Expand All @@ -52,7 +52,7 @@ object PlayerDisplay : Module(
private val manaHud by HudSetting("Mana Hud", 10f, 10f, 1f, true) { example ->
val text = if (example)
generateText(2000, 20000, "") + (if(!separateOverflow) " ${generateText(SkyblockPlayer.overflowMana, "ʬ", hideZeroSF)}" else "")
else if(!LocationUtils.inSkyblock) return@HudSetting 0f to 0f
else if(!LocationUtils.isInSkyblock) return@HudSetting 0f to 0f
else if (SkyblockPlayer.maxMana != 0)
if(SkyblockPlayer.currentMana == 0 && separateOverflow) return@HudSetting 0f to 0f
else generateText(SkyblockPlayer.currentMana, SkyblockPlayer.maxMana, "") + (if(!separateOverflow && overflowManaHud.enabled) " ${generateText(SkyblockPlayer.overflowMana, "ʬ", hideZeroSF)}" else "")
Expand All @@ -65,7 +65,7 @@ object PlayerDisplay : Module(
private val overflowManaHud by HudSetting("Overflow Mana Hud", 10f, 10f, 1f, true) { example ->
val text = if (example)
generateText(333, "ʬ", hideZeroSF)
else if(!LocationUtils.inSkyblock) return@HudSetting 0f to 0f
else if(!LocationUtils.isInSkyblock) return@HudSetting 0f to 0f
else if (separateOverflow)
generateText(SkyblockPlayer.overflowMana, "ʬ", hideZeroSF)
else return@HudSetting 0f to 0f
Expand All @@ -77,7 +77,7 @@ object PlayerDisplay : Module(
private val defenseHud by HudSetting("Defense Hud", 10f, 10f, 1f, true) { example ->
val text = if (example)
generateText(1000, "", true)
else if(!LocationUtils.inSkyblock) return@HudSetting 0f to 0f
else if(!LocationUtils.isInSkyblock) return@HudSetting 0f to 0f
else if (SkyblockPlayer.currentDefense != 0)
generateText(SkyblockPlayer.currentDefense, "", true)
else return@HudSetting 0f to 0f
Expand All @@ -90,7 +90,7 @@ object PlayerDisplay : Module(
private val eHPHud by HudSetting("EffectiveHealth Hud", 10f, 10f, 1f, true) { example ->
val text = if (example)
generateText(1000000, "", true)
else if(!LocationUtils.inSkyblock) return@HudSetting 0f to 0f
else if(!LocationUtils.isInSkyblock) return@HudSetting 0f to 0f
else if (SkyblockPlayer.effectiveHP != 0) generateText(SkyblockPlayer.effectiveHP, "", true)
else return@HudSetting 0f to 0f

Expand Down Expand Up @@ -129,7 +129,7 @@ object PlayerDisplay : Module(
@SubscribeEvent
fun onRenderOverlay(event: RenderGameOverlayEvent.Pre) {
if (event.isCanceled) return // don't override other mods cancelling the event.
if(!LocationUtils.inSkyblock) return
if(!LocationUtils.isInSkyblock) return
event.isCanceled = when (event.type) {
RenderGameOverlayEvent.ElementType.ARMOR -> hideArmor
RenderGameOverlayEvent.ElementType.HEALTH -> hideHearts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ object SpringBoots : Module(

init {
onPacket(S29PacketSoundEffect::class.java) {
if (!LocationUtils.inSkyblock) return@onPacket
if (!LocationUtils.isInSkyblock) return@onPacket
when (it.soundName) {
"random.eat", "fireworks.launch" -> if (it.pitch.equalsOneOf(0.0952381f, 1.6984127f)) pitchCounts.fill(0)
"note.pling" -> if (mc.thePlayer?.isSneaking == true && mc.thePlayer?.getCurrentArmor(0)?.skyblockID == "SPRING_BOOTS") {
Expand All @@ -70,14 +70,14 @@ object SpringBoots : Module(

@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
if (event.phase != TickEvent.Phase.END || !LocationUtils.inSkyblock) return
if (event.phase != TickEvent.Phase.END || !LocationUtils.isInSkyblock) return
if (mc.thePlayer?.getCurrentArmor(0)?.skyblockID != "SPRING_BOOTS" || mc.thePlayer?.isSneaking == false) pitchCounts.fill(0)
blocksList.getSafe(pitchCounts.sum())?.let { blockPos = if (it != 0.0) mc.thePlayer?.positionVector?.addVec(x = -0.5 + offset, y = it, z = -0.5) else null }
}

@SubscribeEvent
fun onRenderWorld(event: RenderWorldLastEvent) {
if (!renderGoal || !LocationUtils.inSkyblock) return
if (!renderGoal || !LocationUtils.isInSkyblock) return
blockPos?.let { Renderer.drawBox(it.toAABB(), goalColor, fillAlpha = 0f) }
}
}
26 changes: 17 additions & 9 deletions src/main/kotlin/me/odinmain/utils/skyblock/LocationUtils.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.odinmain.utils.skyblock

import me.odinmain.OdinMain.mc
import me.odinmain.events.impl.PacketReceivedEvent
import me.odinmain.events.impl.SkyblockJoinIslandEvent
import me.odinmain.features.impl.render.ClickGUIModule
import me.odinmain.utils.*
Expand All @@ -10,23 +11,24 @@ import me.odinmain.utils.skyblock.dungeon.Dungeon
import me.odinmain.utils.skyblock.dungeon.DungeonUtils
import me.odinmain.utils.skyblock.dungeon.Floor
import net.minecraft.client.network.NetHandlerPlayClient
import net.minecraft.network.play.server.S3FPacketCustomPayload
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.network.FMLNetworkEvent

object LocationUtils {

private var onHypixel: Boolean = false
var inSkyblock: Boolean = false
private var isOnHypixel: Boolean = false
var isInSkyblock: Boolean = false

var currentDungeon: Dungeon? = null
var currentArea: Island = Island.Unknown
var kuudraTier: Int = 0

init {
Executor(500, "LocationUtils") {
if (!inSkyblock)
inSkyblock = onHypixel && mc.theWorld?.scoreboard?.getObjectiveInDisplaySlot(1)?.let { cleanSB(it.displayName).contains("SKYBLOCK") } == true
if (!isInSkyblock)
isInSkyblock = isOnHypixel && mc.theWorld?.scoreboard?.getObjectiveInDisplaySlot(1)?.let { cleanSB(it.displayName).contains("SKYBLOCK") } == true

if (currentArea.isArea(Island.Kuudra) && kuudraTier == 0)
sidebarLines.find { cleanLine(it).contains("Kuudra's Hollow (") }?.let {
Expand All @@ -45,8 +47,8 @@ object LocationUtils {

@SubscribeEvent
fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) {
onHypixel = false
inSkyblock = false
isOnHypixel = false
isInSkyblock = false
currentArea = Island.Unknown
kuudraTier = 0
SkyblockJoinIslandEvent(currentArea).postAndCatch()
Expand All @@ -56,7 +58,7 @@ object LocationUtils {
@SubscribeEvent
fun onWorldChange(event: WorldEvent.Unload) {
currentDungeon = null
inSkyblock = false
isInSkyblock = false
kuudraTier = 0
currentArea = Island.Unknown
}
Expand All @@ -68,11 +70,17 @@ object LocationUtils {
*/
@SubscribeEvent
fun onConnect(event: FMLNetworkEvent.ClientConnectedToServerEvent) {
onHypixel = if (ClickGUIModule.forceHypixel) true else mc.runCatching {
isOnHypixel = if (ClickGUIModule.forceHypixel) true else mc.runCatching {
!event.isLocal && ((thePlayer?.clientBrand?.contains("hypixel", true) ?: currentServerData?.serverIP?.contains("hypixel", true)) == true)
}.getOrDefault(false)
}

@SubscribeEvent
fun onPacket(event: PacketReceivedEvent) {
if (isOnHypixel || event.packet !is S3FPacketCustomPayload || event.packet.channelName != "MC|Brand") return
if (event.packet.bufferData?.readStringFromBuffer(Short.MAX_VALUE.toInt())?.contains("hypixel", true) == true) isOnHypixel = true
}

/**
* Returns the current area from the tab list info.
* If no info can be found, return Island.Unknown.
Expand All @@ -81,7 +89,7 @@ object LocationUtils {
*/
private fun getArea(): Island {
if (mc.isSingleplayer) return Island.SinglePlayer
if (!inSkyblock) return Island.Unknown
if (!isInSkyblock) return Island.Unknown
val netHandlerPlayClient: NetHandlerPlayClient = mc.thePlayer?.sendQueue ?: return Island.Unknown
val list = netHandlerPlayClient.playerInfoMap ?: return Island.Unknown

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ object DungeonUtils {
* @return The current phase of floor 7 boss, or `null` if the player is not in the boss room.
*/
fun getF7Phase(): M7Phases {
if (!isFloor(7) || !inBoss) return M7Phases.Unknown
// if (!isFloor(7) || !inBoss) return M7Phases.Unknown

return when {
posY > 210 -> M7Phases.P1
Expand Down

0 comments on commit 56ad1c6

Please sign in to comment.