mirror of https://github.com/kami-blue/client
[fix] Removes FakePlayers safely
This commit is contained in:
parent
80d29cda5f
commit
c9bdd7d004
|
@ -1 +1 @@
|
|||
Subproject commit 50030f49829fdc03bb50ffd856b89785119a7902
|
||||
Subproject commit 7e7e732c02ecdfadf9e4fdef4f7bff5fb9a1a612
|
|
@ -13,9 +13,9 @@ import net.minecraft.client.gui.GuiGameOver
|
|||
import java.util.*
|
||||
|
||||
@Module.Info(
|
||||
name = "FakePlayer",
|
||||
description = "Spawns a client sided fake player",
|
||||
category = Module.Category.MISC
|
||||
name = "FakePlayer",
|
||||
description = "Spawns a client sided fake player",
|
||||
category = Module.Category.MISC
|
||||
)
|
||||
object FakePlayer : Module() {
|
||||
private val copyInventory = register(Settings.b("CopyInventory", false))
|
||||
|
@ -54,7 +54,10 @@ object FakePlayer : Module() {
|
|||
}
|
||||
|
||||
override fun onDisable() {
|
||||
if (mc.world == null || mc.player == null) return
|
||||
fakePlayer?.setDead()
|
||||
mc.addScheduledTask {
|
||||
if (mc.world == null || mc.player == null) return@addScheduledTask
|
||||
fakePlayer?.setDead()
|
||||
mc.world?.removeEntityFromWorld(-911)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ object Blink : Module() {
|
|||
private val autoReset = register(Settings.b("AutoReset", true))
|
||||
private val resetThreshold = register(Settings.integerBuilder("ResetThreshold").withValue(20).withRange(1, 100).withVisibility { autoReset.value })
|
||||
|
||||
private const val ENTITY_ID = -114514
|
||||
private val packets = LinkedList<CPacketPlayer>()
|
||||
private var clonedPlayer: EntityOtherPlayerMP? = null
|
||||
private var sending = false
|
||||
|
@ -45,8 +46,10 @@ object Blink : Module() {
|
|||
}
|
||||
|
||||
listener<ConnectionEvent.Disconnect> {
|
||||
packets.clear()
|
||||
clonedPlayer = null
|
||||
mc.addScheduledTask {
|
||||
packets.clear()
|
||||
clonedPlayer = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,22 +69,29 @@ object Blink : Module() {
|
|||
inventory.copyInventory(mc.player.inventory)
|
||||
noClip = true
|
||||
}.also {
|
||||
mc.world.addEntityToWorld(-114514, it)
|
||||
mc.world.addEntityToWorld(ENTITY_ID, it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun end() {
|
||||
if (mc.player == null) return
|
||||
if (cancelPacket.value || mc.connection == null) {
|
||||
packets.peek()?.let { mc.player.setPosition(it.x, it.y, it.z) }
|
||||
packets.clear()
|
||||
} else {
|
||||
sending = true
|
||||
while (packets.isNotEmpty()) mc.connection!!.sendPacket(packets.poll())
|
||||
sending = false
|
||||
mc.addScheduledTask {
|
||||
val player = mc.player
|
||||
val connection = mc.connection
|
||||
if (player == null || connection == null) return@addScheduledTask
|
||||
|
||||
if (cancelPacket.value || mc.connection == null) {
|
||||
packets.peek()?.let { player.setPosition(it.x, it.y, it.z) }
|
||||
packets.clear()
|
||||
} else {
|
||||
sending = true
|
||||
while (packets.isNotEmpty()) connection.sendPacket(packets.poll())
|
||||
sending = false
|
||||
}
|
||||
|
||||
clonedPlayer?.setDead()
|
||||
mc.world?.removeEntityFromWorld(ENTITY_ID)
|
||||
clonedPlayer = null
|
||||
}
|
||||
clonedPlayer?.setDead()
|
||||
clonedPlayer = null
|
||||
}
|
||||
|
||||
override fun getHudInfo(): String {
|
||||
|
|
|
@ -26,9 +26,9 @@ import kotlin.math.min
|
|||
import kotlin.math.sin
|
||||
|
||||
@Module.Info(
|
||||
name = "Freecam",
|
||||
category = Module.Category.PLAYER,
|
||||
description = "Leave your body and transcend into the realm of the gods"
|
||||
name = "Freecam",
|
||||
category = Module.Category.PLAYER,
|
||||
description = "Leave your body and transcend into the realm of the gods"
|
||||
)
|
||||
object Freecam : Module() {
|
||||
private val horizontalSpeed = register(Settings.floatBuilder("HorizontalSpeed").withValue(20f).withRange(1f, 50f).withStep(1f))
|
||||
|
@ -55,8 +55,8 @@ object Freecam : Module() {
|
|||
init {
|
||||
listener<ConnectionEvent.Disconnect> {
|
||||
prevThirdPersonViewSetting = -1
|
||||
cameraGuy = null
|
||||
if (disableOnDisconnect.value) disable()
|
||||
else cameraGuy = null
|
||||
}
|
||||
|
||||
listener<PacketEvent.Send> {
|
||||
|
@ -142,11 +142,13 @@ object Freecam : Module() {
|
|||
}
|
||||
|
||||
private fun resetCameraGuy() {
|
||||
if (mc.player == null) return
|
||||
mc.world.removeEntityFromWorld(ENTITY_ID)
|
||||
mc.renderViewEntity = mc.player
|
||||
cameraGuy = null
|
||||
if (prevThirdPersonViewSetting != -1) mc.gameSettings.thirdPersonView = prevThirdPersonViewSetting
|
||||
mc.addScheduledTask {
|
||||
if (mc.player == null) return@addScheduledTask
|
||||
mc.world?.removeEntityFromWorld(ENTITY_ID)
|
||||
mc.renderViewEntity = mc.player
|
||||
cameraGuy = null
|
||||
if (prevThirdPersonViewSetting != -1) mc.gameSettings.thirdPersonView = prevThirdPersonViewSetting
|
||||
}
|
||||
}
|
||||
|
||||
private class FakeCamera(val player: EntityPlayerSP) : EntityOtherPlayerMP(mc.world, mc.session.profile) {
|
||||
|
|
Loading…
Reference in New Issue