Skip to content

Commit

Permalink
Button
Browse files Browse the repository at this point in the history
  • Loading branch information
Aspw-w committed May 25, 2024
1 parent 3e38f98 commit 4641325
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/aspw/client/Launch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object Launch {
// Client information
const val CLIENT_BEST = "NightX"
const val CLIENT_FOLDER = "NightX-Client"
const val CLIENT_VERSION = "B128-Beta"
const val CLIENT_VERSION = "B128"
const val CLIENT_CHAT = "§7[§5N§di§3g§bh§6t§aX§7] [§eInfo§7] §r"

var isStarting = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package net.aspw.client.features.module.impl.movement
import net.aspw.client.event.EventTarget
import net.aspw.client.event.PacketEvent
import net.aspw.client.event.Render3DEvent
import net.aspw.client.event.TeleportEvent
import net.aspw.client.features.module.Module
import net.aspw.client.features.module.ModuleCategory
import net.aspw.client.features.module.ModuleInfo
import net.aspw.client.utils.PredictUtils
import net.aspw.client.utils.timer.TickTimer
import net.minecraft.block.BlockAir
import net.minecraft.network.Packet
import net.minecraft.network.play.client.C03PacketPlayer
import net.minecraft.util.BlockPos
import java.util.concurrent.LinkedBlockingQueue
import kotlin.math.abs

Expand All @@ -32,41 +35,60 @@ class BlinkAntiVoid : Module() {

@EventTarget
fun onRender3D(event: Render3DEvent) {
togglePrevent = PredictUtils.checkVoid(5)
togglePrevent = PredictUtils.checkVoid(7)
if (togglePrevent) {
if (abs(mc.thePlayer.posY - preY!!) > 8) {
mc.thePlayer.setPositionAndRotation(preX!!, preY!!, preZ!!, preYaw!!, prePitch!!)
mc.thePlayer.motionX = 0.0
mc.thePlayer.motionY = 0.0
mc.thePlayer.motionZ = 0.0
reset()
} else if (safeTimer.hasTimePassed(60) || mc.thePlayer.onGround) {
} else if (safeTimer.hasTimePassed(20) || shouldSync(0.8f) || shouldSync(1.8f))
sync()
}
} else sync()
}

@EventTarget
fun onPacket(event: PacketEvent) {
val packet = event.packet
if (mc.thePlayer == null || disableLogger) return
if (packet is C03PacketPlayer && togglePrevent) {
if (mc.thePlayer == null || disableLogger || !togglePrevent) return
if (packet is C03PacketPlayer) {
if (preX == null)
preX = mc.thePlayer.posX
preX = packet.x
if (preY == null)
preY = mc.thePlayer.posY
preY = packet.y
if (preZ == null)
preZ = mc.thePlayer.posZ
preZ = packet.z
if (preYaw == null)
preYaw = mc.thePlayer.rotationYaw
preYaw = packet.yaw
if (prePitch == null)
prePitch = mc.thePlayer.rotationPitch
prePitch = packet.pitch
packets.add(packet)
safeTimer.update()
event.cancelEvent()
}
}

@EventTarget
fun onTeleport(event: TeleportEvent) {
if (togglePrevent) {
if (preX == null)
preX = event.posX
if (preY == null)
preY = event.posY
if (preZ == null)
preZ = event.posZ
if (preYaw == null)
preYaw = event.yaw
if (prePitch == null)
prePitch = event.pitch
}
}

private fun shouldSync(y: Float): Boolean {
return mc.theWorld.getBlockState(BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - y, mc.thePlayer.posZ)).block !is BlockAir || mc.theWorld.getBlockState(BlockPos(mc.thePlayer.posX + 0.2, mc.thePlayer.posY - y, mc.thePlayer.posZ + 0.2)).block !is BlockAir || mc.theWorld.getBlockState(BlockPos(mc.thePlayer.posX + 0.2, mc.thePlayer.posY - y, mc.thePlayer.posZ - 0.2)).block !is BlockAir || mc.theWorld.getBlockState(BlockPos(mc.thePlayer.posX - 0.2, mc.thePlayer.posY - y, mc.thePlayer.posZ + 0.2)).block !is BlockAir || mc.theWorld.getBlockState(BlockPos(mc.thePlayer.posX - 0.2, mc.thePlayer.posY - y, mc.thePlayer.posZ - 0.2)).block !is BlockAir
}

private fun sync() {
try {
disableLogger = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class NoSlow : Module() {
private val debugValue =
BoolValue("Debug", false) { modeValue.get().equals("watchdog", true) || modeValue.get().equals("blink", true) }

// Soulsand
val soulsandValue = BoolValue("Soulsand", true)
val liquidPushValue = BoolValue("LiquidPush", true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,11 @@ public void renderItemInFirstPerson(final float partialTicks) {
GlStateManager.rotate(this.delay, 0.0F, 0.0F, -0.1F);
if (Animations.cancelEquip.get())
this.transformFirstPersonItem(0.0F, 0.0F);
else this.transformFirstPersonItem(f / 1.2F, 0.0F);
else this.transformFirstPersonItem(f / 1.1F, 0.0F);
long currentTime = System.currentTimeMillis();
long elapsedTime = currentTime - lastUpdateTime;
if (this.rotateTimer.hasReached(1L)) {
this.delay += elapsedTime * 360.0 / 1000.0;
this.delay += elapsedTime * 360.0 / 850.0;
this.rotateTimer.reset();
}
lastUpdateTime = currentTime;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/aspw/client/utils/PredictUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public static boolean checkVoid(int tick) {
mc.getNetHandler(),
new StatFileWriter()
);
sp.setPositionAndRotation(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch);
sp.onGround = mc.thePlayer.onGround;
sp.setPositionAndRotation(mc.thePlayer.posX, mc.thePlayer.posY + 1, mc.thePlayer.posZ, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch);
sp.onGround = false;
sp.setSneaking(mc.thePlayer.isSneaking());
sp.motionX = mc.thePlayer.motionX;
sp.motionY = mc.thePlayer.motionY;
Expand Down Expand Up @@ -98,6 +98,6 @@ private static boolean detectVoid(EntityPlayerSP sp) {
break;
}
}
return doing && sp.fallDistance != 0 && mc.thePlayer != null && mc.theWorld != null;
return doing && sp.fallDistance != 0 && mc.thePlayer != null && mc.theWorld != null && !mc.thePlayer.isSneaking() && !mc.thePlayer.capabilities.isFlying;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ class GuiAltManager(private val prevGui: GuiScreen) : GuiScreen() {

val startPositionY = 22
buttonList.add(GuiButton(1, width - 80, startPositionY + 24, 70, 20, "Add"))
buttonList.add(GuiButton(2, width - 80, startPositionY + 24 * 2, 70, 20, "Delete"))
buttonList.add(GuiButton(9, width - 80, startPositionY + 24 * 3, 70, 20, "Reload"))
buttonList.add(GuiButton(6, width - 80, startPositionY + 24 * 2, 70, 20, "Direct"))
buttonList.add(GuiButton(2, width - 80, startPositionY + 24 * 3, 70, 20, "Delete"))
buttonList.add(GuiButton(9, width - 80, startPositionY + 24 * 4, 70, 20, "Reload"))
buttonList.add(GuiButton(0, width - 80, height - 65, 70, 20, "Done"))
buttonList.add(GuiButton(3, 5, startPositionY + 24, 90, 20, "Login").also { loginButton = it })
buttonList.add(GuiButton(4, 5, startPositionY + 24 * 2, 90, 20, "Random Alt").also { randomButton = it })
Expand Down Expand Up @@ -107,7 +108,7 @@ class GuiAltManager(private val prevGui: GuiScreen) : GuiScreen() {

when (button.id) {
0 -> mc.displayGuiScreen(prevGui)
1 -> mc.displayGuiScreen(GuiAddAccount(this))
1 -> mc.displayGuiScreen(GuiAddAccount(this, false))
2 -> {
status = if (altsList.selectedSlot != -1 && altsList.selectedSlot < altsList.size) {
fileManager.accountsConfig.removeAccount(altsList.accounts[altsList.selectedSlot])
Expand Down Expand Up @@ -182,6 +183,8 @@ class GuiAltManager(private val prevGui: GuiScreen) : GuiScreen() {
} ?: "§cYou do not have any accounts."
}

6 -> mc.displayGuiScreen(GuiAddAccount(this, true))

9 -> {
fileManager.loadConfig(fileManager.accountsConfig)
if (Launch.moduleManager.getModule(Interface::class.java)?.flagSoundValue!!.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import net.aspw.client.visual.client.altmanager.GuiAltManager
import net.minecraft.client.gui.GuiButton
import net.minecraft.client.gui.GuiScreen
import net.minecraft.client.gui.GuiTextField
import net.minecraft.util.Session
import org.lwjgl.input.Keyboard
import java.io.IOException
import kotlin.concurrent.thread

class GuiAddAccount(private val prevGui: GuiAltManager) : GuiScreen() {
class GuiAddAccount(private val prevGui: GuiAltManager, private val directLogin: Boolean) : GuiScreen() {

private lateinit var addButton: GuiButton
private lateinit var username: GuiTextField
Expand All @@ -24,7 +25,8 @@ class GuiAddAccount(private val prevGui: GuiAltManager) : GuiScreen() {
Keyboard.enableRepeatEvents(true)

// Login via Microsoft account
buttonList.add(GuiButton(3, width / 2 - 100, 133, "Microsoft Login"))
if (!directLogin)
buttonList.add(GuiButton(3, width / 2 - 100, 133, "Microsoft Login"))

// Add and back button
buttonList.add(
Expand All @@ -34,7 +36,7 @@ class GuiAddAccount(private val prevGui: GuiAltManager) : GuiScreen() {
height - 54,
98,
20,
"Add"
if (directLogin) "Login" else "Add"
).also { addButton = it })
buttonList.add(GuiButton(0, width / 2 + 2, height - 54, 98, 20, "Done"))

Expand All @@ -51,7 +53,7 @@ class GuiAddAccount(private val prevGui: GuiAltManager) : GuiScreen() {
)
RenderUtils.drawRect(30F, 30F, width - 30F, height - 30F, Int.MIN_VALUE)
this.drawCenteredString(
mc.fontRendererObj, "Add Account",
mc.fontRendererObj, if (directLogin) "Direct Login" else "Add Account",
width / 2,
34,
0xffffff
Expand Down Expand Up @@ -129,12 +131,20 @@ class GuiAddAccount(private val prevGui: GuiAltManager) : GuiScreen() {
addButton.enabled = false

thread(name = "Account-Checking-Task") {
Launch.fileManager.accountsConfig.addAccount(account)
Launch.fileManager.saveConfig(Launch.fileManager.accountsConfig)
if (directLogin) {
mc.session = Session(
account.session.username,
account.session.uuid, account.session.token, "mojang"
)
status = "§aLogged successfully to ${mc.session.username}."
} else {
Launch.fileManager.accountsConfig.addAccount(account)
Launch.fileManager.saveConfig(Launch.fileManager.accountsConfig)
status = "§aThe account has been added."
}
if (Launch.moduleManager.getModule(Interface::class.java)?.flagSoundValue!!.get()) {
Launch.tipSoundManager.popSound.asyncPlay(Launch.moduleManager.popSoundPower)
}
status = "§aThe account has been added."
prevGui.status = status
mc.displayGuiScreen(prevGui)
}
Expand Down

0 comments on commit 4641325

Please sign in to comment.