Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
OsamaBeingLagging committed Sep 5, 2023
2 parents a33fb14 + 76c9a27 commit 196f0ee
Show file tree
Hide file tree
Showing 19 changed files with 85 additions and 151 deletions.
6 changes: 0 additions & 6 deletions src/main/kotlin/dev/macrohq/swiftslayer/SwiftSlayer.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package dev.macrohq.swiftslayer

import cc.polyfrost.oneconfig.utils.commands.CommandManager
import dev.macrohq.swiftslayer.command.BossSpawnercommand
import dev.macrohq.swiftslayer.command.PathfindTest
import dev.macrohq.swiftslayer.config.SwiftSlayerConfig
import dev.macrohq.swiftslayer.macro.BossSpawner
import dev.macrohq.swiftslayer.macro.EndermanMacro
import dev.macrohq.swiftslayer.macro.MobKiller
import dev.macrohq.swiftslayer.pathfinding.PathExecutor
Expand All @@ -26,7 +24,6 @@ class SwiftSlayer {

lateinit var pathExecutor: PathExecutor private set
lateinit var config: SwiftSlayerConfig private set
lateinit var bossSpawner: BossSpawner private set
lateinit var mobKiller: MobKiller private set
lateinit var endermanMacro: EndermanMacro private set
var removeLater: BlockPos? = null
Expand All @@ -35,15 +32,12 @@ class SwiftSlayer {
fun init(event: FMLInitializationEvent) {
config = SwiftSlayerConfig()
pathExecutor = PathExecutor()
bossSpawner = BossSpawner()
mobKiller = MobKiller()
endermanMacro = EndermanMacro()
MinecraftForge.EVENT_BUS.register(this)
MinecraftForge.EVENT_BUS.register(bossSpawner)
MinecraftForge.EVENT_BUS.register(pathExecutor)
MinecraftForge.EVENT_BUS.register(mobKiller)
CommandManager.register(PathfindTest())
CommandManager.register(BossSpawnercommand())
}

@SubscribeEvent
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.macrohq.swiftslayer.config

import cc.polyfrost.oneconfig.config.Config
import cc.polyfrost.oneconfig.config.annotations.Switch
import cc.polyfrost.oneconfig.config.data.Mod
import cc.polyfrost.oneconfig.config.data.ModType

Expand Down
59 changes: 0 additions & 59 deletions src/main/kotlin/dev/macrohq/swiftslayer/macro/BossSpawner.kt

This file was deleted.

23 changes: 21 additions & 2 deletions src/main/kotlin/dev/macrohq/swiftslayer/macro/EndermanMacro.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package dev.macrohq.swiftslayer.macro

import cc.polyfrost.oneconfig.utils.dsl.runAsync
import dev.macrohq.swiftslayer.util.*
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.monster.EntityZombie
import net.minecraft.util.Vec3
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
import java.security.Key

class EndermanMacro {

Expand All @@ -18,10 +22,25 @@ class EndermanMacro {
if(!enabled) return
when(state) {
State.HIT -> {
if(determineState() != State.HIT) state = State.DAMAGE
if(player.getDistanceSqToEntity(target) < 10.0) gameSettings.keyBindBack.setPressed(true) else gameSettings.keyBindBack.setPressed(false)
if(player.worldObj.loadedEntityList.filterIsInstance<EntityZombie>().any { it.getDistanceSqToEntity(target) > 4.0 }) return
InventoryUtil.holdItem("Reaper Scythe")
KeyBindUtil.rightClick()
}

State.DAMAGE -> {
RotationUtil.easeToEntity(target, 250, true)
if(player.getDistanceSqToEntity(target) > 3.0) gameSettings.keyBindForward.setPressed(true) else gameSettings.keyBindForward.setPressed(false)
runAsync {
while(state == State.DAMAGE) {
gameSettings.keyBindSneak.setPressed(true)
Thread.sleep(100)
KeyBindUtil.leftClick()
gameSettings.keyBindSneak.setPressed(false)
}
}
}

State.DAMAGE -> TODO()
State.LASER -> TODO()
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/main/kotlin/dev/macrohq/swiftslayer/macro/Macro.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package dev.macrohq.swiftslayer.macro

import net.minecraft.entity.monster.EntityZombie

abstract class Macro {
abstract fun run()
abstract fun onEnable()
abstract fun onDisable()
fun a() {
}
}
2 changes: 0 additions & 2 deletions src/main/kotlin/dev/macrohq/swiftslayer/macro/MacroManager.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package dev.macrohq.swiftslayer.macro

import dev.macrohq.swiftslayer.util.config

object MacroManager {
private val macros = mutableListOf<Macro>()
private val activeMacro = null
Expand Down
13 changes: 5 additions & 8 deletions src/main/kotlin/dev/macrohq/swiftslayer/macro/MobKiller.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package dev.macrohq.swiftslayer.macro

import cc.polyfrost.oneconfig.utils.dsl.tick
import dev.macrohq.swiftslayer.util.*
import dev.macrohq.swiftslayer.util.Logger.info
import kotlinx.coroutines.currentCoroutineContext
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLiving
import net.minecraft.entity.monster.EntityZombie
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
import javax.swing.text.JTextComponent.KeyBinding
import kotlin.math.abs

class MobKiller {
private var blacklist = mutableListOf<EntityLiving>()
private var mobKiller = false
private var state: State = State.NONE;
private var state: State = State.NONE
private var targetEntity: Entity? = null
private var ticks: Int = 0
private var stuckCounter: Int = 0
Expand Down Expand Up @@ -47,7 +44,7 @@ class MobKiller {
RenderUtil.entites.clear()
if(ticks>=60){
blacklist.clear()
ticks = 0;
ticks = 0
}
val targetEntityList = EntityUtil.getMobs(EntityZombie::class.java, 50000).toMutableList()
if(targetEntity!=null) targetEntityList.remove(targetEntity)
Expand Down Expand Up @@ -78,12 +75,12 @@ class MobKiller {
State.LOOKING ->{
RotationUtil.ease(RotationUtil.Rotation(AngleUtil.getAngles(targetEntity!!).yaw, 45f), 400)
state = State.LOOKING_VERIFY
return;
return
}
State.LOOKING_VERIFY -> {
val yp = RotationUtil.Rotation(AngleUtil.getAngles(targetEntity!!).yaw, 45f)
val yawDiff = abs(AngleUtil.yawTo360(player.rotationYaw)-AngleUtil.yawTo360(yp.yaw));
val pitchDiff = abs(mc.thePlayer.rotationPitch - yp.pitch);
val yawDiff = abs(AngleUtil.yawTo360(player.rotationYaw)-AngleUtil.yawTo360(yp.yaw))
val pitchDiff = abs(mc.thePlayer.rotationPitch - yp.pitch)
if(pitchDiff < 2){
RotationUtil.stop()
InventoryUtil.holdItem("Spirit")
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/dev/macrohq/swiftslayer/pathfinding/AStar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ class AStar(startPos: BlockPos, endPos: BlockPos) {
private var yaw: Float = 0f

fun getFCost(): Float {
return gCost + hCost;
return gCost + hCost
}

private fun angleCost(bp1: BlockPos, bp2: BlockPos): Float {
val dx = bp2.x - bp1.x
val dz = bp2.z - bp1.z
val yaw = -Math.toDegrees(atan2(dx.toDouble(), dz.toDouble())).toFloat()
return AngleUtil.yawTo360(yaw);
return AngleUtil.yawTo360(yaw)
}

fun calculateCost(endNode: Node) {
Expand All @@ -106,7 +106,7 @@ class AStar(startPos: BlockPos, endPos: BlockPos) {
if (this.parent!!.position.y < this.position.y
&& !BlockUtil.isStairSlab(this.position)
) {
cost += 1.4f;
cost += 1.4f
}

}
Expand Down Expand Up @@ -140,7 +140,7 @@ class AStar(startPos: BlockPos, endPos: BlockPos) {
return allowedBlocks.contains(world.getBlockState(position.up()).block)
&& allowedBlocks.contains(world.getBlockState(position.up().up()).block)
&& world.getBlockState(position).block.material.isSolid
&& !collision;
&& !collision
}

private val allowedBlocks = listOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package dev.macrohq.swiftslayer.pathfinding

import dev.macrohq.swiftslayer.util.*
import net.minecraft.block.BlockStairs
import dev.macrohq.swiftslayer.util.AngleUtil
import dev.macrohq.swiftslayer.util.BlockUtil
import dev.macrohq.swiftslayer.util.world
import net.minecraft.init.Blocks
import net.minecraft.util.BlockPos
import net.minecraft.util.MathHelper
Expand Down Expand Up @@ -86,7 +87,7 @@ class AStarPathfinder(startPos: BlockPos, endPos: BlockPos) {
val dx = bp2.x - bp1.x
val dz = bp2.z - bp1.z
val yaw = -Math.toDegrees(atan2(dx.toDouble(), dz.toDouble())).toFloat()
return AngleUtil.yawTo360(yaw);
return AngleUtil.yawTo360(yaw)
}
fun calculateCost(endNode: Node) {
var cost = 0f
Expand All @@ -98,7 +99,7 @@ class AStarPathfinder(startPos: BlockPos, endPos: BlockPos) {
if (this.parent.position.y < this.position.y
&& !BlockUtil.isStairSlab(this.position)
) {
cost += 1.5f;
cost += 1.5f
}
}
BlockUtil.neighbourGenerator(this.position.up().up().up(), 1).forEach{
Expand Down Expand Up @@ -132,7 +133,7 @@ class AStarPathfinder(startPos: BlockPos, endPos: BlockPos) {
return allowedBlocks.contains(world.getBlockState(position.up()).block)
&& allowedBlocks.contains(world.getBlockState(position.up().up()).block)
&& world.getBlockState(position).block.material.isSolid
&& !collision;
&& !collision
}

fun isIn(nodes: List<Node>): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import kotlin.math.sqrt
class PathExecutor {
private var path = listOf<BlockPos>()
private var current: BlockPos? = null
private var pathFailCounter = 0;
private var pathFailCounter = 0
private var done = false
private var aotving = false
var running = false
Expand Down Expand Up @@ -57,7 +57,7 @@ class PathExecutor {
if(aotving && sqrt(player.lastTickPosition().distanceSq(player.getStandingOnCeil()))>4){aotving = false;}
when (state) {
State.STARTING -> {
state = State.CALCULATING;
state = State.CALCULATING
}

State.CALCULATING -> {
Expand All @@ -71,15 +71,15 @@ class PathExecutor {
path[path.indexOf(path.find { it.x == player.getStandingOnCeil().x && it.z == player.getStandingOnCeil().z }) + 1]
RotationUtil.ease(RotationUtil.Rotation(AngleUtil.getAngles(current!!).yaw, 20f), 500)

RenderUtil.markers.clear();
current?.let { RenderUtil.markers.add(it) };
RenderUtil.markers.clear()
current?.let { RenderUtil.markers.add(it) }

} else if (player.onGround) pathFailCounter++
if ((pathFailCounter >= 40 && player.onGround)) {
pathFailCounter = 0
running = false
PathingUtil.goto(path[path.size - 1])
return;
return
}
state = if(sqrt(player.getDistanceSqToCenter(current)) > 12 && !aotving && path.indexOf(current) != path.size-1) {
InventoryUtil.holdItem("of the void")
Expand All @@ -91,8 +91,8 @@ class PathExecutor {
State.AOTV -> {
val yp = AngleUtil.getAngles(current!!.up().up())
RotationUtil.ease(yp, 200)
val yawDiff = abs(AngleUtil.yawTo360(player.rotationYaw)-AngleUtil.yawTo360(yp.yaw));
val pitchDiff = abs(mc.thePlayer.rotationPitch - yp.pitch);
val yawDiff = abs(AngleUtil.yawTo360(player.rotationYaw)-AngleUtil.yawTo360(yp.yaw))
val pitchDiff = abs(mc.thePlayer.rotationPitch - yp.pitch)
if(yawDiff < 5 && pitchDiff < 2){
aotving = true
KeyBindUtil.rightClick()
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/dev/macrohq/swiftslayer/util/AngleUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object AngleUtil {
}

fun getYawChange(entity: Entity): Float{
val startRot = RotationUtil.Rotation(player.rotationYaw, player.rotationPitch)
val startRot = Rotation(player.rotationYaw, player.rotationPitch)
val endRot = Rotation(getAngles(entity.positionVector).yaw, 0f)
return getNeededChange(startRot, endRot).yaw
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/kotlin/dev/macrohq/swiftslayer/util/BlockUtil.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package dev.macrohq.swiftslayer.util

import dev.macrohq.swiftslayer.pathfinding.AStar
import dev.macrohq.swiftslayer.pathfinding.AStarPathfinder
import net.minecraft.block.BlockStairs
import net.minecraft.util.BlockPos
import net.minecraft.util.EnumFacing
import net.minecraft.util.MathHelper
import net.minecraft.util.Vec3
import kotlin.math.floor

object BlockUtil {
fun neighbourGenerator(mainBlock: BlockPos, size: Int): List<BlockPos> {
Expand Down
5 changes: 1 addition & 4 deletions src/main/kotlin/dev/macrohq/swiftslayer/util/EntityUtil.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package dev.macrohq.swiftslayer.util

import dev.macrohq.swiftslayer.util.Logger.info
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLiving
import net.minecraft.entity.monster.EntityZombie
import net.minecraft.util.MathHelper
import kotlin.math.abs
import kotlin.math.sqrt
Expand All @@ -23,6 +20,6 @@ object EntityUtil {
}

fun getRevCost(entity: EntityLiving): Int{
return 1;
return 1
}
}
Loading

0 comments on commit 196f0ee

Please sign in to comment.