欢迎光临散文网 会员登陆 & 注册

花雨庭AutoReport

2023-08-16 14:50 作者:bili_40057106161  | 我要投稿

以下代码来自ChatGPT
package net.ccbluex.liquidbounce.features.module.modules.player

import net.ccbluex.liquidbounce.event.EventTarget
import net.ccbluex.liquidbounce.event.PacketEvent
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.ModuleCategory
import net.ccbluex.liquidbounce.features.module.ModuleInfo
import net.minecraft.network.play.server.S08PacketPlayerPosLook
import net.minecraft.network.play.server.S12PacketEntityVelocity
import net.minecraft.network.play.server.S27PacketExplosion
import net.minecraft.client.Minecraft

@ModuleInfo(name = "AutoReport", category = ModuleCategory.RENDER)
class AutoReport : Module() {

   private var prevX: Double = 0.0
   private var prevY: Double = 0.0
   private var prevZ: Double = 0.0

   @EventTarget
   fun onPacket(event: PacketEvent) {
       val packet = event.packet

       if (packet is S08PacketPlayerPosLook) {
           val playerName = Minecraft.getMinecraft().thePlayer.name
           val player = Minecraft.getMinecraft().thePlayer
           val yaw = packet.yaw
           val pitch = packet.pitch

           // 判断玩家是否开启了 KillAura
           val hasKillAura = Minecraft.getMinecraft().thePlayer.isSwingInProgress && Minecraft.getMinecraft().objectMouseOver.entityHit != null
           // 判断玩家是否开启了 Speed
           val hasSpeed =
                   player.motionX > 0.2 || player.motionZ > 0.2
           // 判断玩家是否开启了 Blink
           val hasBlink =
                   Math.abs(player.posX - prevX) < 0.1 && Math.abs(player.posY - prevY) < 0.1 && Math.abs(player.posZ - prevZ) < 0.1

           if (hasKillAura) {
               val reportReason = "使用了 KillAura"
               reportPlayer(playerName, reportReason)
           }

           if (hasSpeed) {
               val reportReason = "使用了 Speed"
               reportPlayer(playerName, reportReason)
           }

           if (hasBlink) {
               val reportReason = "使用了 Blink"
               reportPlayer(playerName, reportReason)
           }

           prevX = player.posX
           prevY = player.posY
           prevZ = player.posZ
       } else if (packet is S12PacketEntityVelocity) {
           val playerName = Minecraft.getMinecraft().thePlayer.name
           val player = Minecraft.getMinecraft().thePlayer
           val entityID = packet.entityID
           val velocityX = packet.motionX
           val velocityY = packet.motionY
           val velocityZ = packet.motionZ

           // 判断玩家是否开启了 KillAura
           val hasKillAura = Minecraft.getMinecraft().thePlayer.isSwingInProgress && Minecraft.getMinecraft().objectMouseOver.entityHit != null
           // 判断玩家是否开启了 Speed
           val hasSpeed =
                   player.motionX > 0.2 || player.motionZ > 0.2
           // 判断玩家是否开启了 Blink
           val hasBlink =
                   player.motionX == 0.0 && player.motionZ == 0.0

           // 判断玩家是否受到了 Velocity,并且没有其他已知的功能开启
           val hasVelocity = entityID == Minecraft.getMinecraft().thePlayer.entityId && !hasKillAura && !hasSpeed && !hasBlink

           if (hasVelocity) {
               val reportReason = "受到了 Velocity"
               reportPlayer(playerName, reportReason)
           }
       }
   }
}

// 定义一个举报玩家的函数
fun reportPlayer(playerId: String, reason: String) {
   val selfName = Minecraft.getMinecraft().thePlayer.name

   if (playerId != selfName) {
       val reportCommand = "/report $playerId $reason"
       // 这里可以添加代码来发送举报命令给游戏服务器
       println("已自动向游戏服务器提交举报:$reportCommand")
   }
}

花雨庭AutoReport的评论 (共 条)

分享到微博请遵守国家法律