Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.hazuku.avox.module.modules.combat
- import com.hazuku.avox.event.EventTarget
- import com.hazuku.avox.event.events.EventPostMotionUpdate
- import com.hazuku.avox.event.events.EventPreMotionUpdate
- import com.hazuku.avox.module.internal.Module
- import com.hazuku.avox.module.internal.ModuleCategory
- import com.hazuku.avox.util.*
- import net.minecraft.entity.Entity
- import net.minecraft.entity.EntityLivingBase
- import net.minecraft.entity.monster.EntityMob
- import net.minecraft.entity.passive.EntityAnimal
- import net.minecraft.entity.passive.EntityVillager
- import net.minecraft.entity.player.EntityPlayer
- import net.minecraft.item.ItemSword
- import net.minecraft.network.play.client.C02PacketUseEntity
- import net.minecraft.network.play.client.C03PacketPlayer
- import net.minecraft.network.play.client.C0APacketAnimation
- import net.minecraft.util.MathHelper
- import net.minecraft.util.Vec3
- import penner.easing.Cubic
- import java.util.concurrent.LinkedBlockingQueue
- import kotlin.math.roundToInt
- import kotlin.random.Random
- class KillAura(name: String, description: String, category: ModuleCategory) : Module(name, description, category) {
- init {
- addSettingOf("AntiBot", "WatchDoge", listOf("OFF", "WatchDoge"))
- addSettingOf("Max Reach", 3.8, 1.0, 12.0, 0.1)
- addSettingOf("Min Reach", 3.4, 1.0, 12.0, 0.1)
- addSettingOf("Min CPS", 8.0, 1.0, 30.0)
- addSettingOf("Max CPS", 12.0, 1.0, 30.0)
- addSettingOf("Min Switch Delay", (20).toDouble(), 1.0, 200.0, 10.0)
- addSettingOf("Max Switch Delay", (40).toDouble(), 1.0, 200.0, 10.0)
- addSettingOf("Min Rotation Duration", (10).toDouble(), 1.0, 200.0, 10.0)
- addSettingOf("Max Rotation Duration", (20).toDouble(), 1.0, 200.0, 10.0)
- addSettingOf("Ticks Existed", 5.0, 0.0, 100.0, 2.0)
- addSettingOf("Crack Size", 1.0, 0.0, 20.0, 1.0)
- addSettingOf("Block Rate", 80.0, 0.0, 100.0, 1.0)
- addSettingOf("FOV", 360.0, 0.0, 360.0, 10.0)
- addSettingOf("Max Targets", 4.0, 1.0, 10.0)
- addSettingOf("Block", true)
- addSettingOf("NoSwing", false)
- addSettingOf("Legit", true)
- addSettingOf("Players", true)
- addSettingOf("Mobs", false)
- addSettingOf("Animals", false)
- addSettingOf("Villagers", false)
- addSettingOf("Invisible", false)
- addSettingOf("Teams", true)
- addSettingOf("Target Mode", "Switch", listOf("Single", "Switch"))
- addSettingOf("Priority Mode", "Angle", listOf("Health", "Distance", "Angle", "Random"))
- }
- var targets = LinkedBlockingQueue<EntityLivingBase>()
- var target: EntityLivingBase? = null
- var reach = 4.0
- var nextCPS = 1.0
- var currentSwitchDelay = 10
- var nextSwitchDelay = 10
- var rotationDuration = 0f
- var current: Long = 0
- var last: Long = 0
- var yaw = 0f
- var pitch = 0f
- var targetYaw = 0f
- var targetPitch = 0f
- var count = 0f
- var canAttack = false
- override fun onEnable() {
- super.onEnable()
- targets = LinkedBlockingQueue<EntityLivingBase>()
- target = null
- reach = 4.0
- nextCPS = 1.0
- currentSwitchDelay = 10
- nextSwitchDelay = 10
- rotationDuration = 0f
- current = 0
- last = 0
- yaw = 0f
- pitch = 0f
- targetYaw = 0f
- targetPitch = 0f
- count = 0f
- canAttack = false
- }
- override fun onDisable() {
- super.onDisable()
- targets = LinkedBlockingQueue<EntityLivingBase>()
- target = null
- reach = 4.0
- nextCPS = 1.0
- currentSwitchDelay = 10
- nextSwitchDelay = 10
- rotationDuration = 0f
- current = 0
- last = 0
- yaw = 0f
- pitch = 0f
- targetYaw = 0f
- targetPitch = 0f
- count = 0f
- canAttack = false
- }
- //えいむ
- @EventTarget
- fun onPre(event: EventPreMotionUpdate) {
- reach = getRandom(getNumberSetting("Min Reach") ?: 0.0, getNumberSetting("Max Reach") ?: 0.0)
- var entities = getAroundEntities(reach).filter { it.isEntityAlive && it.canAttack() && !it.isBot() }
- if (entities.isEmpty()) return
- entities = entities.applyPriority()
- targets.addAll(entities.filter { !targets.contains(it) })
- targets = LinkedBlockingQueue(targets.toList().filter { it.isEntityAlive && it.canAttack() && !it.isBot() }.applyPriority())
- when (getOptionableSetting("Target Mode").toLowerCase()) {
- "switch" -> {
- currentSwitchDelay++
- if (currentSwitchDelay > nextSwitchDelay) {
- nextSwitchDelay = getRandom(getNumberSetting("Min Switch Delay")
- ?: 0.0, getNumberSetting("Max Switch Delay") ?: 0.0).toInt()
- try {
- targets.add(targets.poll())
- } catch (e: Exception) {
- }
- currentSwitchDelay = 0
- }
- }
- }
- if (targets.firstOrNull()?.uniqueID ?: "HOGE" != target?.uniqueID ?: "PIYO") {
- count = 0f
- rotationDuration = getRandom(
- getNumberSetting("Min Rotation Duration") ?: 0.0,
- getNumberSetting("Max Rotation Duration") ?: 0.0
- ).toFloat()
- target = targets.firstOrNull()
- }
- val t = target ?: return
- val rotation = t.getRotations()
- targetYaw = try {
- rotation.first()
- } catch (e: Exception) {
- return
- }
- targetPitch = try {
- rotation[1]
- } catch (e: Exception) {
- return
- }
- if (count > rotationDuration)
- count = 0f
- yaw = (yaw % 360)
- val a = when {
- targetYaw - yaw <= 180 -> targetYaw - yaw
- else -> {
- if (targetYaw >= 0) {
- (targetYaw - (-180)) + (180 - yaw)
- } else {
- -1 * ((yaw - (-180)) + (180 - targetYaw))
- }
- }
- }
- yaw = Cubic.easeOut(count, yaw, a, rotationDuration)
- pitch = Cubic.easeOut(count, pitch, targetPitch - pitch, rotationDuration)
- yaw %= 360
- count++
- if (getBooleanSetting("Legit")) {
- getPlayer().rotationYaw = yaw
- getPlayer().rotationPitch = pitch
- }
- canAttack = diff(yaw, targetYaw) < 10f && diff(pitch, targetPitch) < 10f
- sendPacket(C03PacketPlayer.C05PacketPlayerLook(yaw, pitch, getPlayer().onGround))
- }
- private fun diff(x: Float, y: Float) = when {
- x > y -> x - y
- y > x -> y - x
- else -> 0f
- }
- var ezAttack = false
- //あたっく
- @EventTarget
- fun onPost(event: EventPostMotionUpdate) {
- ezAttack = canAttack && target != null && targets.isNotEmpty() && target?.isEntityAlive == true && target?.canAttack() == true && target?.isBot() == false
- if (ezAttack)
- target?.attack()
- }
- private fun EntityLivingBase.attack() {
- updateTime()
- if (current - last > 1000 / nextCPS) {
- resetTime()
- nextCPS = getRandom(getNumberSetting("Min CPS") ?: 0.0, getNumberSetting("Max CPS") ?: 0.0)
- for (i in 0..(getNumberSetting("Crack Size") ?: 0.0).roundToInt()) getPlayer().onCriticalHit(this)
- sendPacket(C02PacketUseEntity(this, C02PacketUseEntity.Action.ATTACK))
- if (getBooleanSetting("Block")
- && getPlayer().heldItem?.item != null
- && getPlayer().heldItem?.item is ItemSword
- && this.getDistanceToEntity(getPlayer()) < 8F
- && getNumberSetting("Block Rate") ?: 80.0 >= Math.random() * 100)
- getMinecraft().playerController.sendUseItem(getPlayer(), getWorld(), com.hazuku.avox.util.getInventory().getCurrentItem())
- if (!getBooleanSetting("NoSwing"))
- getPlayer().swingItem()
- else
- sendPacket(C0APacketAnimation())
- }
- }
- private fun getAroundEntities(range: Double) = getLoadedEntities()
- .filter { it.inRange(range, getPlayer()) }
- .filter { it is EntityLivingBase }
- .map { it as EntityLivingBase }
- private fun List<EntityLivingBase>.applyPriority() = when (getOptionableSetting("Priority Mode").toLowerCase()) {
- "health" -> sortedBy { it.health }
- "distance" -> sortedBy { getPlayer().getDistanceToEntity(it) }
- "angle" -> sortedBy { getAngleDifference(getPlayer().rotationYaw, getRotations(it.posX, it.posY, it.posZ)[0]) }
- "random" -> {
- random()
- this
- }
- else -> this
- }
- private fun Entity.getRotations(): FloatArray {
- val diffX = posX - getPlayer().posX
- val diffZ = posZ - getPlayer().posZ
- var bestPos = Vec3(posX, posY, posZ)
- val eyePos = Vec3(getPlayer().posX, getPlayer().posY + getPlayer().eyeHeight, getPlayer().posZ)
- var i = entityBoundingBox.minY + 0.7
- while (i < entityBoundingBox.maxY - 0.1) {
- if (eyePos.distanceTo(Vec3(posX, i, posZ)) < eyePos.distanceTo(bestPos)) {
- bestPos = Vec3(posX, i, posZ)
- }
- i += 0.1
- }
- val diffY = bestPos.yCoord - (getPlayer().posY + getPlayer().eyeHeight)
- val dist = MathHelper.sqrt_double(diffX * diffX + diffZ * diffZ).toDouble()
- val yaw = (Math.atan2(diffZ, diffX) * 180.0 / 3.141592653589793).toFloat() - 90.0f
- val pitch = (-(Math.atan2(diffY, dist) * 180.0 / 3.141592653589793)).toFloat()
- return floatArrayOf(yaw, pitch)
- }
- private fun updateTime() {
- current = System.nanoTime() / 1000000L
- }
- private fun resetTime() {
- last = System.nanoTime() / 1000000L
- }
- private fun getRandom(min: Double, max: Double) = Random(1919810).nextDouble(min, max)
- private fun Entity.inRange(range: Double, target: Entity) = getDistanceToEntity(target) <= range
- private fun Entity.isBot() = when (getOptionableSetting("AntiBot")) {
- "WatchDoge" -> (getMinecraft().netHandler.getPlayerInfo(uniqueID)?.responseTime ?: 0) <= 5
- else -> false
- }
- private fun EntityLivingBase.canAttack(): Boolean {
- if (this is EntityPlayer || this is EntityAnimal || this is EntityMob || this is EntityVillager) {
- if (this is EntityPlayer && !getBooleanSetting("Players"))
- return false
- if (this is EntityAnimal && !getBooleanSetting("Animals"))
- return false
- if (this is EntityMob && !getBooleanSetting("Mobs"))
- return false
- if (this is EntityVillager && !getBooleanSetting("Villagers"))
- return false
- }
- if (this.isOnSameTeam(getPlayer()) && getBooleanSetting("Teams"))
- return false
- if (this.isInvisible && !getBooleanSetting("Invisible"))
- return false
- return if (!this.isInFOV(getNumberSetting("FOV") ?: 0.0))
- false
- else this !== getPlayer()
- && this.isEntityAlive && getPlayer().getDistanceToEntity(this) <= getMinecraft().playerController.blockReachDistance
- && this.ticksExisted > getNumberSetting("Ticks Existed") ?: 0.0
- }
- private fun Entity.isInFOV(angle: Double): Boolean {
- var an = angle
- an *= .5
- val angleDiff = getAngleDifference(getPlayer().rotationYaw, getRotations(posX, posY, posZ)[0])
- return angleDiff > 0 && angleDiff < an || -an < angleDiff && angleDiff < 0
- }
- private fun getRotations(x: Double, y: Double, z: Double): FloatArray {
- val diffX = x + .5 - getPlayer().posX
- val diffY = (y + .5) / 2.0 - (getPlayer().posY + getPlayer().eyeHeight)
- val diffZ = z + .5 - getPlayer().posZ
- val dist = MathHelper.sqrt_double(diffX * diffX + diffZ * diffZ).toDouble()
- val yaw = (Math.atan2(diffZ, diffX) * 180.0 / Math.PI).toFloat() - 90f
- val pitch = (-(Math.atan2(diffY, dist) * 180.0 / Math.PI)).toFloat()
- return floatArrayOf(yaw, pitch)
- }
- private fun getAngleDifference(dir: Float, yaw: Float): Float {
- val f = Math.abs(yaw - dir) % 360f
- return if (f > 180f) 360f - f else f
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement