diff --git a/build.gradle.kts b/build.gradle.kts index 43766fe..c852b68 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -43,7 +43,7 @@ loom { launchConfigs { getByName("client") { arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker") - property("devauth.enabled", "false") + property("devauth.enabled", "true") property("fml.coreMods.load", "dev.macrohq.swiftslayer.DevMixinLoader") } } diff --git a/src/main/kotlin/dev/macrohq/swiftslayer/SwiftSlayer.kt b/src/main/kotlin/dev/macrohq/swiftslayer/SwiftSlayer.kt index 715b0f4..4dda06d 100644 --- a/src/main/kotlin/dev/macrohq/swiftslayer/SwiftSlayer.kt +++ b/src/main/kotlin/dev/macrohq/swiftslayer/SwiftSlayer.kt @@ -87,7 +87,6 @@ object SwiftSlayer { @Subscribe fun onRenderWorldLast(event: RenderWorldLastEvent) { - // this is here because im not sure if objects can have events cuz they are kinda static RotationUtil.onRenderWorldLast() RenderUtil.onRenderWorldLast(event) KeyBindUtil.onRenderWorldLast() diff --git a/src/main/kotlin/dev/macrohq/swiftslayer/config/SwiftSlayerConfig.kt b/src/main/kotlin/dev/macrohq/swiftslayer/config/SwiftSlayerConfig.kt index 29e0193..eb3acfb 100644 --- a/src/main/kotlin/dev/macrohq/swiftslayer/config/SwiftSlayerConfig.kt +++ b/src/main/kotlin/dev/macrohq/swiftslayer/config/SwiftSlayerConfig.kt @@ -7,7 +7,6 @@ import cc.polyfrost.oneconfig.config.data.Mod import cc.polyfrost.oneconfig.config.data.ModType import cc.polyfrost.oneconfig.libs.universal.UKeyboard import dev.macrohq.swiftslayer.util.macroManager -import kotlin.math.* class SwiftSlayerConfig : Config(Mod("SwiftSlayer", ModType.SKYBLOCK), "swiftslayer.json") { @@ -32,10 +31,30 @@ class SwiftSlayerConfig : Config(Mod("SwiftSlayer", ModType.SKYBLOCK), "swiftsla name = "Weapon type for mobs", category = "General", subcategory = "Slayer", - options = ["Spirit Sceptre", "Melee", "Fire Veil Wand", "Right click Melee"] + options = ["Hyperion", "Ranged", "Melee"] ) var mobKillerWeapon = 0 + @Slider( + name = "'Ranged' range", + category = "General", + subcategory = "Slayer", + min = 1f, + max = 15f, + step = 1 + ) + var rangedRange = 1 + + @Slider( + name = "'Ranged' cooldown (in seconds)", + category = "General", + subcategory = "Slayer", + min = 0f, + max = 25f, + step = 1 + ) + var rangedCooldown = 1 + @Dropdown( name = "Weapon type for boss", category = "General", @@ -116,7 +135,6 @@ class SwiftSlayerConfig : Config(Mod("SwiftSlayer", ModType.SKYBLOCK), "swiftsla var useHealingAt = 70 - @Slider( name = "Gui delay", category = "General", @@ -138,36 +156,7 @@ class SwiftSlayerConfig : Config(Mod("SwiftSlayer", ModType.SKYBLOCK), "swiftsla return (macroGuiDelay + Math.random().toFloat() * macroGuiDelayRandomness).toLong() } - @Slider( - name = "Rotation time", - category = "General", - subcategory = "Advanced", - min = 100f, - max = 500f, - ) - var macroRotationTime: Float = 250f - @Slider( - name = "Rotation time randomness", - category = "General", - subcategory = "Advanced", - min = 100f, - max = 1000f, - ) - var macroRotationTimeRandomness: Float = 300f - fun getRandomRotationTime(): Long { - val ran = (macroRotationTime + Math.random().toFloat() * macroRotationTimeRandomness).toLong() - return ran - } - - @Slider( - name = "Lock rotation smoothness", - category = "General", - subcategory = "Advanced", - min = 2f, - max = 10f, - ) - var macroLockSmoothness: Float = 4f @Dropdown( name = "Boss killer movement", @@ -187,41 +176,6 @@ class SwiftSlayerConfig : Config(Mod("SwiftSlayer", ModType.SKYBLOCK), "swiftsla @HUD(name = "HUD", category = "HUD") var hud = SwiftSlayerHud() - fun calculateRotationTime(degrees: Double): Int { - val proportion = degrees / 180.0 - return (getRandomRotationTime() * proportion).toInt() - } - - fun calculateDegreeDistance( - initialYaw: Double, - initialPitch: Double, - targetYaw: Double, - targetPitch: Double - ): Double { - // Calculate angular difference in yaw - val deltaYaw = Math.toDegrees( - atan2( - sin(Math.toRadians(targetYaw - initialYaw)), cos( - Math.toRadians(targetYaw - initialYaw) - ) - ) - ) - - - val deltaPitch = Math.toDegrees( - atan2( - sin(Math.toRadians(targetPitch - initialPitch)), cos( - Math.toRadians(targetPitch - initialPitch) - ) - ) - ) - - val degreeDistance = sqrt(deltaYaw.pow(2.0) + deltaPitch.pow(2.0)) - - return degreeDistance - } - - init { initialize() @@ -232,10 +186,10 @@ class SwiftSlayerConfig : Config(Mod("SwiftSlayer", ModType.SKYBLOCK), "swiftsla hideIf("useHealingAt") { !showAdvanced } hideIf("macroGuiDelay") { !showAdvanced } hideIf("macroGuiDelayRandomness") { !showAdvanced } - hideIf("macroRotationTime") { !showAdvanced } - hideIf("macroRotationTimeRandomness") { !showAdvanced } - hideIf("macroLockSmoothness") { !showAdvanced } hideIf("movementType") { !showAdvanced } hideIf("debugMode") { !showAdvanced } + + hideIf("rangedRange") { mobKillerWeapon != 1} + hideIf("rangedCooldown") { mobKillerWeapon != 1} } } \ No newline at end of file diff --git a/src/main/kotlin/dev/macrohq/swiftslayer/macro/AbstractMobKiller.kt b/src/main/kotlin/dev/macrohq/swiftslayer/macro/AbstractMobKiller.kt index 26da7ca..68c4b78 100644 --- a/src/main/kotlin/dev/macrohq/swiftslayer/macro/AbstractMobKiller.kt +++ b/src/main/kotlin/dev/macrohq/swiftslayer/macro/AbstractMobKiller.kt @@ -3,11 +3,12 @@ package dev.macrohq.swiftslayer.macro import dev.macrohq.swiftslayer.feature.helper.Angle import dev.macrohq.swiftslayer.feature.helper.Target import dev.macrohq.swiftslayer.util.* +import dev.macrohq.swiftslayer.util.rotation.Rotation import dev.macrohq.swiftslayer.util.rotation.RotationManager import net.minecraft.entity.EntityLiving import kotlin.math.abs -abstract class AbstractMobKiller:IMobKiller { +abstract class AbstractMobKiller: IMobKiller { override var enabled: Boolean = false override var paused: Boolean = false @@ -36,22 +37,16 @@ abstract class AbstractMobKiller:IMobKiller { override fun lookAtEntity(entity: EntityLiving) { when (config.mobKillerWeapon) { - - 0 -> RotationManager.getInstance().rotateTo(entity) - 1 -> RotationManager.getInstance().rotateTo(entity) - 2 -> {} - 3 -> RotationManager.getInstance().rotateTo(entity, 1f) + 0 -> RotationManager.getInstance().rotateTo(Rotation(AngleUtil.getAngles(entity).pitch, 90f), 1f) + else -> { + RotationManager.getInstance().rotateTo(entity) + } } - // Logger.info(time) + } override fun angleForWeapon(entity: EntityLiving): Angle { - return when (config.mobKillerWeapon) { - 0 -> AngleUtil.getAngle(entity.position.add(0, (entity.height*0.6).toInt(), 0)) - 1 -> AngleUtil.getAngle(entity.position.add(0, (entity.height*0.6).toInt(), 0)) - 3 -> AngleUtil.getAngle(entity.position.add(0, (entity.height*0.6).toInt(), 0)) - else -> Angle(0f,0f) - } + return Angle(0f, 0f) } override fun useWeapon() { when (config.mobKillerWeapon) { @@ -71,11 +66,12 @@ abstract class AbstractMobKiller:IMobKiller { override fun attackDistance(): Int { return when (config.mobKillerWeapon) { - 0 -> 6 - 1 -> 3 + 0 -> 3 + 1 -> config.rangedRange 2 -> 4 - 3 -> 3 - else -> 6 + else -> { + 4 + } } } @@ -100,12 +96,16 @@ abstract class AbstractMobKiller:IMobKiller { override fun lookDone(): Boolean { val yawDiff = abs(AngleUtil.yawTo360(player.rotationYaw) - AngleUtil.yawTo360(Target(currentTarget!!).getAngle().yaw)) val pitchDiff = abs(mc.thePlayer.rotationPitch - Target(currentTarget!!).getAngle().pitch) - return when (config.mobKillerWeapon) { - 0 -> pitchDiff < 2 - 1 -> yawDiff < 10 && pitchDiff < 5 - 2 -> true - 3 -> yawDiff < 10 && pitchDiff < 5 - else -> true + when(config.mobKillerWeapon) { + 1 -> { + return pitchDiff < 2 && yawDiff < 5 + } + 2 -> { + return pitchDiff < 4 && yawDiff < 10 + } + else -> { + return true + } } } diff --git a/src/main/kotlin/dev/macrohq/swiftslayer/macro/MacroManager.kt b/src/main/kotlin/dev/macrohq/swiftslayer/macro/MacroManager.kt index f7d8569..a7ddcf4 100644 --- a/src/main/kotlin/dev/macrohq/swiftslayer/macro/MacroManager.kt +++ b/src/main/kotlin/dev/macrohq/swiftslayer/macro/MacroManager.kt @@ -16,7 +16,7 @@ class MacroManager { fun onTick(event: ClientTickEvent) { if (!enabled || mobKiller.getInstance().enabled || RevBossKiller.getInstance().enabled) return - if(!InventoryUtil.holdItem("Maddox Batphone")) state = State.KILL_MOBS + //if(!InventoryUtil.holdItem("Maddox Batphone")) state = State.KILL_MOBS when (state) { State.ACTIVATE_QUEST -> { @@ -30,9 +30,7 @@ class MacroManager { } } State.KILL_MOBS -> mobKiller.getInstance().enable() - State.KILL_BOSS -> { - //if (config.slayer == 3) endermanBossKiller.enable() - /* else*/ RevBossKiller.getInstance().enable() + State.KILL_BOSS -> { RevBossKiller.getInstance().enable() } } state = State.entries[(state.ordinal + 1) % State.entries.size] // tf is this for? diff --git a/src/main/kotlin/dev/macrohq/swiftslayer/macro/bossKiller/RevBossKiller.kt b/src/main/kotlin/dev/macrohq/swiftslayer/macro/bossKiller/RevBossKiller.kt index d2c7942..c1448d2 100644 --- a/src/main/kotlin/dev/macrohq/swiftslayer/macro/bossKiller/RevBossKiller.kt +++ b/src/main/kotlin/dev/macrohq/swiftslayer/macro/bossKiller/RevBossKiller.kt @@ -70,7 +70,7 @@ class RevBossKiller:AbstractBossKiller() { 1 -> { // move back if(chosenBlock == null || findNewBlock) { findBlock@ - for (block: BlockPos in BlockUtil.getBlocks(BlockPos(mc.thePlayer.posX + mc.thePlayer.getLookVec().xCoord * -25, mc.thePlayer.posY, mc.thePlayer.posZ + mc.thePlayer.getLookVec().zCoord * -25), 15, 5, 15)) { + for (block: BlockPos in BlockUtil.getBlocks(BlockPos(mc.thePlayer.posX + mc.thePlayer.getLookVec().xCoord * -10, mc.thePlayer.posY, mc.thePlayer.posZ + mc.thePlayer.getLookVec().zCoord * -10), 6, 4, 6)) { if (BlockUtil.getXZDistance(player.getStandingOnCeil(), block) > 6 && BlockUtil.blocksBetweenValid(CalculationContext(SwiftSlayer), player.getStandingOnCeil(), block) && !BlockUtil.isSingleCorner(block)) { chosenBlock = block break@findBlock @@ -85,7 +85,6 @@ class RevBossKiller:AbstractBossKiller() { } MovementState.GOTO_BLOCK -> { - // AutoRotation.disable() if(chosenBlock == null) { movState = MovementState.FIND_BLOCK Logger.info("null block") @@ -100,9 +99,8 @@ class RevBossKiller:AbstractBossKiller() { MovementState.VERIFY_PATHFINDIG -> { - if(blockTimer.isDone) { + if(blockTimer.isDone && SwiftSlayer.config.movementType == 1) { movState = MovementState.FIND_BLOCK - return } //movement type = walking back @@ -134,13 +132,8 @@ class RevBossKiller:AbstractBossKiller() { //movement type = find corner if(BlockUtil.getXZDistance(player.getStandingOnCeil(), chosenBlock!!) < 1 && SwiftSlayer.config.movementType == 0) { - if(BlockUtil.blocksBetweenValid(CalculationContext(SwiftSlayer), player.getStandingOnCeil(), chosenBlock!!)) { movState = MovementState.GOTO_BLOCK - } else { - findNewBlock = true - movState = MovementState.FIND_BLOCK - chosenBlock = null - } + return } } @@ -179,9 +172,14 @@ class RevBossKiller:AbstractBossKiller() { when (rotState) { RotationState.LOOK_AT_TARGET -> { if(!currentTarget!!.onGround) return + if(mc.objectMouseOver.entityHit == null && !rotTimer.isDone) return + lookAtEntity(currentTarget!!) + if(mc.objectMouseOver.entityHit != null) { + rotTimer = Timer(50) + } } RotationState.VERIFY_LOOKING -> { @@ -200,10 +198,10 @@ class RevBossKiller:AbstractBossKiller() { } override fun enable() { - if(SlayerUtil.getBoss() != null) { - currentTarget = SlayerUtil.getBoss()!!.first + if(SlayerUtil.getFakeBoss() != null) { + currentTarget = SlayerUtil.getFakeBoss() } - if(SlayerUtil.getBoss() == null) return + if(SlayerUtil.getFakeBoss() == null) return if(currentTarget == null) { Logger.info("null entity!?") diff --git a/src/main/kotlin/dev/macrohq/swiftslayer/macro/mobKillers/RevMobKiller.kt b/src/main/kotlin/dev/macrohq/swiftslayer/macro/mobKillers/RevMobKiller.kt index cf8c64b..c7fe76b 100644 --- a/src/main/kotlin/dev/macrohq/swiftslayer/macro/mobKillers/RevMobKiller.kt +++ b/src/main/kotlin/dev/macrohq/swiftslayer/macro/mobKillers/RevMobKiller.kt @@ -4,7 +4,6 @@ import dev.macrohq.swiftslayer.SwiftSlayer import dev.macrohq.swiftslayer.macro.AbstractMobKiller import dev.macrohq.swiftslayer.util.* import dev.macrohq.swiftslayer.util.InventoryUtil.getHotbarSlotForItem -import dev.macrohq.swiftslayer.util.rotation.RotationManager import me.kbrewster.eventbus.Subscribe import net.minecraft.entity.EntityLiving import net.minecraft.entity.monster.EntityZombie @@ -21,6 +20,7 @@ class RevMobKiller: AbstractMobKiller() { override val targetEntityClass: Class = EntityZombie::class.java override var blacklist = mutableListOf() var waitTimer: Timer = Timer(0) + var rotTimer: Timer = Timer(0) override var tickCounter: Int = 0 override var ticksSinceLastClick: Int = 0 override var ticksSinceLastMovement: Int = 0 @@ -79,7 +79,12 @@ class RevMobKiller: AbstractMobKiller() { } } - // Logger.log(state.name) + + if(state != State.KILL_TARGET) { + KeyBindUtil.stopClicking() + } + + Logger.info(state.name) when (state) { State.CHOOSE_TARGET -> { RenderUtil.entites.clear() @@ -100,11 +105,12 @@ class RevMobKiller: AbstractMobKiller() { State.GOTO_TARGET -> { //AutoRotation.disable() + if(!currentTarget!!.onGround || !player.onGround) return thread = Thread { PathingUtil.stop() //AutoRotation.disable() if (player.canEntityBeSeen(currentTarget!!)) { - PathingUtil.goto(currentTarget!!.getStandingOnCeil()) + PathingUtil.goto(currentTarget!!.getStandingOnCeil(), currentTarget!!) looking = true } else { PathingUtil.goto(currentTarget!!.getStandingOnCeil()) @@ -120,7 +126,7 @@ class RevMobKiller: AbstractMobKiller() { } State.VERIFY_PATHFINDING -> { - if (player.getDistanceToEntity(currentTarget) < attackDistance()) { + if (player.getDistanceToEntity(currentTarget) < attackDistance() && player.canEntityBeSeen(currentTarget)) { stopWalking() state = State.LOOK_AT_TARGET return @@ -141,9 +147,11 @@ class RevMobKiller: AbstractMobKiller() { } State.LOOK_AT_TARGET -> { - //AutoRotation.disable() + if(!rotTimer.isDone) return + PathingUtil.stop() if(currentTarget != null) { lookAtEntity(currentTarget!!) + rotTimer = Timer(100) } else { Logger.info("failed to look at target!") state = State.CHOOSE_TARGET @@ -154,37 +162,79 @@ class RevMobKiller: AbstractMobKiller() { } State.VERIFY_LOOKING -> { - // if(AutoRotation.enabled) return - if(mc.objectMouseOver.entityHit != null && player.getDistanceToEntity(currentTarget) <= attackDistance() && player.canEntityBeSeen(currentTarget)) { - holdWeapon() - state = State.KILL_TARGET - return - } - if(mc.objectMouseOver.entityHit == null && player.getDistanceToEntity(currentTarget) < attackDistance() && !RotationManager.getInstance().currentThread.isAlive) { - if(!currentTarget!!.onGround) return - state = State.LOOK_AT_TARGET - return + if(player.getDistanceToEntity(currentTarget) > attackDistance() || !player.canEntityBeSeen(currentTarget)) { + state = State.GOTO_TARGET + return + } + when(config.mobKillerWeapon) { + 0 -> { + state = State.KILL_TARGET + } + + 1 -> { + state = if(lookDone()) { + State.KILL_TARGET + + } else { + State.LOOK_AT_TARGET + } + } + + 2 -> { + if(mc.objectMouseOver.entityHit != null) { + state = State.KILL_TARGET + } else { + state = State.LOOK_AT_TARGET + return + } + } } - if(player.getDistanceToEntity(currentTarget) > attackDistance()) { - state = State.GOTO_TARGET - return - } + + } State.KILL_TARGET -> { - if(ticksSinceLastClick > 3) { - useWeapon() - ticksSinceLastClick = 0 - } + + when(config.mobKillerWeapon) { + //hyperion + 0 -> { + if(ticksSinceLastClick > 4) + KeyBindUtil.rightClick(1) + } + + //ranged + 1 -> { + if(ticksSinceLastClick > 4 && lookDone() && waitTimer.isDone) { + KeyBindUtil.rightClick(1) + waitTimer = Timer((config.rangedCooldown * 1000).toLong()) } + else if(!lookDone()) { + state = State.LOOK_AT_TARGET + return + } + + } + + //melee + 2 -> { + + if(mc.objectMouseOver.entityHit != null && lookDone()) { + KeyBindUtil.leftClick(5) } + else if(mc.objectMouseOver.entityHit == null || !lookDone()){ + state = State.LOOK_AT_TARGET + return + } + + } + } + ticksSinceLastClick = 0 if (currentTarget!!.isDead || currentTarget!!.health < 1) { blacklist.add(currentTarget!!) state = State.CHOOSE_TARGET return } - state = State.VERIFY_LOOKING return } @@ -198,6 +248,15 @@ class RevMobKiller: AbstractMobKiller() { override fun enable() { + var scoreBoard = ScoreboardUtil + /* if(!scoreBoard.getScoreboardLines().contains("Coal Mine")) { + Logger.info("You must enter the crypt ghoul cave to activate this macro.") + macroManager.toggle() + return + } */ + + + if(!enabled) SwiftEventBus.register(this) enabled = true diff --git a/src/main/kotlin/dev/macrohq/swiftslayer/pathfinding/PathExecutor.kt b/src/main/kotlin/dev/macrohq/swiftslayer/pathfinding/PathExecutor.kt index dabcb4e..deda364 100644 --- a/src/main/kotlin/dev/macrohq/swiftslayer/pathfinding/PathExecutor.kt +++ b/src/main/kotlin/dev/macrohq/swiftslayer/pathfinding/PathExecutor.kt @@ -28,14 +28,8 @@ class PathExecutor { if (!enabled) return if(RotationManager.getInstance().currentThread.isAlive) { gameSettings.keyBindSprint.setPressed(false) - gameSettings.keyBindForward.setPressed(false) - gameSettings.keyBindJump.setPressed(false) - return } - - - if (!isOnPath()) { if (pathFailCounter >= 100) { Logger.error("Path execution failed, retrying.") @@ -54,7 +48,7 @@ class PathExecutor { if (isOnPath()) { next = path[path.indexOf(getStandingOn()!!) + 1] - if(rotate && !shouldJump()) { + if(rotate) { if (goal != null) { RotationManager.getInstance().rotateTo(goal!!.toVec3Top(), 2f) } else { @@ -84,7 +78,7 @@ class PathExecutor { } // val rotation = RotationUtil.Rotation(AngleUtil.getAngles(next!!.toVec3Top()).yaw, 20f) - val rotation = Angle(AngleUtil.getAngle(next!!.toVec3Top()).yaw, 20f) + val rotation = Angle(AngleUtil.getAngle(next!!).yaw,AngleUtil.getAngle(next!!).pitch ) directionYaw = rotation.yaw gameSettings.keyBindSprint.setPressed(AngleUtil.yawTo360(player.rotationYaw) in AngleUtil.yawTo360(player.rotationYaw) - 45..AngleUtil.yawTo360(player.rotationYaw) + 45) gameSettings.keyBindForward.setPressed(true) diff --git a/src/main/kotlin/dev/macrohq/swiftslayer/util/SlayerUtil.kt b/src/main/kotlin/dev/macrohq/swiftslayer/util/SlayerUtil.kt index ee21a2f..c8a276b 100644 --- a/src/main/kotlin/dev/macrohq/swiftslayer/util/SlayerUtil.kt +++ b/src/main/kotlin/dev/macrohq/swiftslayer/util/SlayerUtil.kt @@ -1,16 +1,10 @@ package dev.macrohq.swiftslayer.util -import dev.macrohq.swiftslayer.SwiftSlayer -import dev.macrohq.swiftslayer.feature.helper.Target -import dev.macrohq.swiftslayer.macro.bossKiller.RevBossKiller -import dev.macrohq.swiftslayer.macro.mobKillers.RevMobKiller -import me.kbrewster.eventbus.Subscribe import net.minecraft.entity.EntityLiving import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.monster.* import net.minecraft.entity.passive.EntityWolf import net.minecraft.util.StringUtils -import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent object SlayerUtil { @@ -151,24 +145,5 @@ object SlayerUtil { BOSS_ALIVE, BOSS_DEAD, } - - @Subscribe - fun onTick(event: ClientTickEvent) { - if(!macroManager.enabled || RevBossKiller.getInstance().enabled) return - - - - if(getState() == SlayerState.BOSS_ALIVE) { - PathingUtil.stop() - if(RevMobKiller.getInstance().lastTargetPos != null) { - val target = RevMobKiller.getInstance().lastTargetPos!!.add(0, 1, 0) - val time = SwiftSlayer.config.calculateRotationTime( - SwiftSlayer.config.calculateDegreeDistance(AngleUtil.yawTo360(mc.thePlayer.rotationYaw).toDouble(), mc.thePlayer.rotationPitch.toDouble(), AngleUtil.yawTo360( - Target(target).getAngle().yaw).toDouble(), Target(target).getAngle().pitch.toDouble())) - } - - RevMobKiller.getInstance().disable() - RevBossKiller.getInstance().enable() - } - } + } \ No newline at end of file