Skip to content

Commit

Permalink
Done
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetchnoblade committed May 22, 2024
1 parent bc08409 commit d497f90
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 84 deletions.
20 changes: 10 additions & 10 deletions src/main/java/net/aspw/client/Launch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ object Launch {
moduleManager = ModuleManager()
moduleManager.registerModules()

// Check update
APIConnecter.checkStatus()
APIConnecter.checkChangelogs()
APIConnecter.checkBugs()
APIConnecter.checkStaffList()
APIConnecter.loadDonors()

// Init Discord RPC
discordRPC = DiscordRPC()

// Setup default states on first launch
if (!fileManager.modulesConfig.hasConfig() || !fileManager.valuesConfig.hasConfig()) {
ClientUtils.getLogger().info("Setting up default modules...")
Expand All @@ -102,16 +112,6 @@ object Launch {

clickGui = ClickGui()

// Check update
APIConnecter.checkStatus()
APIConnecter.checkChangelogs()
APIConnecter.checkBugs()
APIConnecter.checkStaffList()
APIConnecter.loadDonors()

// Init Discord RPC
discordRPC = DiscordRPC()

ClientUtils.getLogger().info("Launched!")

isStarting = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ class Scaffold : Module() {
// Launch position
private var launchY = 0
private var placeCount = 0
private var hypixelCount = 0
private var faceBlock = false

// Rotation lock
Expand All @@ -212,7 +211,6 @@ class Scaffold : Module() {
private var lastMS = 0L
private var jumpGround = 0.0
private var verusState = 0
private var isHypixeling = false

/**
* Enable module
Expand All @@ -222,7 +220,6 @@ class Scaffold : Module() {
progress = 0f
spinYaw = 0f
placeCount = 0
hypixelCount = 0
firstPitch = mc.thePlayer.rotationPitch
firstRotate = mc.thePlayer.rotationYaw
launchY = mc.thePlayer.posY.toInt()
Expand Down Expand Up @@ -410,7 +407,7 @@ class Scaffold : Module() {
offGroundTicks = 0
} else offGroundTicks++

if (autoJumpValue.get().equals("hypixelkeepy", true) && hypixelCount != 0 && !canTower && !isHypixeling) {
if (autoJumpValue.get().equals("hypixelkeepy", true) && !canTower) {
if (mc.thePlayer.isInWater) return
if (mc.thePlayer.onGround && !mc.thePlayer.isPotionActive(Potion.moveSpeed) && MovementUtils.isMoving()) {
mc.thePlayer.motionY = 0.41999998688698
Expand All @@ -422,28 +419,8 @@ class Scaffold : Module() {
}
}

if (autoJumpValue.get().equals("hypixelkeepy", true) && !canTower) {
if (hypixelCount == 0) {
mc.thePlayer.motionX = 0.0
mc.thePlayer.motionZ = 0.0
place()
if (shouldEagle) {
KeyBinding.onTick(mc.gameSettings.keyBindUseItem.keyCode)
hypixelCount++
}
}
if (hypixelCount >= 3) {
if (mc.thePlayer.posY >= launchY + 0.4 && mc.thePlayer.posY < launchY + 1.7) {
isHypixeling = true
KeyBinding.onTick(mc.gameSettings.keyBindUseItem.keyCode)
hypixelCount++
}
if (isHypixeling && (hypixelCount >= 9 || mc.thePlayer.posY >= launchY + 1)) {
isHypixeling = false
hypixelCount = 1
}
}
}
if (autoJumpValue.get().equals("hypixelkeepy", true) && mc.thePlayer.fallDistance >= 0.00001 && mc.thePlayer.fallDistance < 1.4)
KeyBinding.onTick(mc.gameSettings.keyBindUseItem.keyCode)

if (customSpeedValue.get()) MovementUtils.strafe(customMoveSpeedValue.get())
if (sprintModeValue.get().equals("off", ignoreCase = true) || sprintModeValue.get()
Expand All @@ -460,7 +437,6 @@ class Scaffold : Module() {
) launchY = mc.thePlayer.posY.toInt()
if (GameSettings.isKeyDown(mc.gameSettings.keyBindJump) && mc.thePlayer.onGround) {
placeCount = 0
hypixelCount = 0
}

if (((autoJumpValue.get().equals(
Expand Down Expand Up @@ -638,7 +614,6 @@ class Scaffold : Module() {
else startPlaceTimer.update()
return
}
if (hypixelCount >= 3 && isHypixeling) return
if ((targetPlace) == null) {
if (placeableDelay.get()) delayTimer.reset()
return
Expand All @@ -663,7 +638,6 @@ class Scaffold : Module() {
mc.thePlayer.motionZ *= modifier.toDouble()
}
placeCount += 1
hypixelCount += 1
targetPlace = null
}

Expand All @@ -673,10 +647,8 @@ class Scaffold : Module() {
override fun onDisable() {
if (mc.thePlayer == null) return
startPlaceTimer.reset()
isHypixeling = false
faceBlock = false
placeCount = 0
hypixelCount = 0
firstPitch = 0f
firstRotate = 0f
canTower = false
Expand Down Expand Up @@ -710,7 +682,7 @@ class Scaffold : Module() {
if (autoJumpValue.get().equals(
"hypixelkeepy",
true
) && !mc.thePlayer.isPotionActive(Potion.moveSpeed) && MovementUtils.isMoving() && hypixelCount != 0 && !isHypixeling
) && !mc.thePlayer.isPotionActive(Potion.moveSpeed) && MovementUtils.isMoving()
) event.cancelEvent()
if (Launch.moduleManager.getModule(SilentRotations::class.java)?.state!! && !Launch.moduleManager.getModule(
SilentRotations::class.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,10 @@
@Mixin(AbstractClientPlayer.class)
public abstract class MixinAbstractClientPlayer extends MixinEntityPlayer {

private final Map<String, BufferedImage> donorCapeLocations = new HashMap<>();
private boolean capeInjected = false;

@Inject(method = "getLocationCape", at = @At("HEAD"), cancellable = true)
private void getCape(CallbackInfoReturnable<ResourceLocation> callbackInfoReturnable) {
final Cape cape = Objects.requireNonNull(Launch.moduleManager.getModule(Cape.class));
String playerName = getGameProfile().getName();
if (!this.capeInjected) {
for (Pair<String, BufferedImage> pair : APIConnecter.INSTANCE.getDonorCapeLocations()) {
donorCapeLocations.put(pair.getFirst(), pair.getSecond());
}
this.capeInjected = true;
}

if (donorCapeLocations.containsKey(playerName)) {
BufferedImage image = donorCapeLocations.get(playerName);
callbackInfoReturnable.setReturnValue(MinecraftInstance.mc.getTextureManager().getDynamicTextureLocation(Launch.CLIENT_FOLDER, new DynamicTexture(image)));
return;
}

if (cape.getCustomCape().get() && playerName.equalsIgnoreCase(MinecraftInstance.mc.thePlayer.getGameProfile().getName()))
if (cape.getCustomCape().get() && getGameProfile().getName().equalsIgnoreCase(MinecraftInstance.mc.thePlayer.getGameProfile().getName()))
callbackInfoReturnable.setReturnValue(cape.getCapeLocation(cape.getStyleValue().get()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.entity.player.EnumPlayerModelParts;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.struct.InjectorGroupInfo;
import scala.collection.mutable.MutableList;

import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand All @@ -41,9 +43,12 @@ public MixinLayerCape(RenderPlayer playerRenderer) {
*/
@Overwrite
public void doRenderLayer(final AbstractClientPlayer entitylivingbaseIn, final float p_177141_2_, final float p_177141_3_, final float partialTicks, final float p_177141_5_, final float p_177141_6_, final float p_177141_7_, final float scale) {
if (entitylivingbaseIn.getLocationCape() != null && !entitylivingbaseIn.isInvisible() && entitylivingbaseIn.isWearing(EnumPlayerModelParts.CAPE) && (!Objects.requireNonNull(Launch.moduleManager.getModule(Freecam.class)).getState() || entitylivingbaseIn != Objects.requireNonNull(Launch.moduleManager.getModule(Freecam.class)).getFakePlayer()) && (!Objects.requireNonNull(Launch.moduleManager.getModule(ReverseFreecam.class)).getState() || entitylivingbaseIn != Objects.requireNonNull(Launch.moduleManager.getModule(ReverseFreecam.class)).getFakePlayer())) {
ResourceLocation cape = APIConnecter.INSTANCE.loadCape(entitylivingbaseIn);
if ((entitylivingbaseIn.getLocationCape() != null || cape != null) && !entitylivingbaseIn.isInvisible() && entitylivingbaseIn.isWearing(EnumPlayerModelParts.CAPE) && (!Objects.requireNonNull(Launch.moduleManager.getModule(Freecam.class)).getState() || entitylivingbaseIn != Objects.requireNonNull(Launch.moduleManager.getModule(Freecam.class)).getFakePlayer()) && (!Objects.requireNonNull(Launch.moduleManager.getModule(ReverseFreecam.class)).getState() || entitylivingbaseIn != Objects.requireNonNull(Launch.moduleManager.getModule(ReverseFreecam.class)).getFakePlayer())) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.playerRenderer.bindTexture(entitylivingbaseIn.getLocationCape());
if (cape != null)
this.playerRenderer.bindTexture(cape);
else this.playerRenderer.bindTexture(entitylivingbaseIn.getLocationCape());
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.0F, 0.125F);
double d0 = entitylivingbaseIn.prevChasingPosX + (entitylivingbaseIn.chasingPosX - entitylivingbaseIn.prevChasingPosX) * (double) partialTicks - (entitylivingbaseIn.prevPosX + (entitylivingbaseIn.posX - entitylivingbaseIn.prevPosX) * (double) partialTicks);
Expand Down
36 changes: 14 additions & 22 deletions src/main/java/net/aspw/client/utils/APIConnecter.kt
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
package net.aspw.client.utils

import net.aspw.client.Launch
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.texture.DynamicTexture
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.util.ResourceLocation
import net.minecraftforge.fml.common.ObfuscationReflectionHelper
import okhttp3.OkHttpClient
import okhttp3.Request
import java.awt.image.BufferedImage
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
import java.net.URL
import java.nio.ByteBuffer
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.util.UUID
import javax.imageio.ImageIO
import javax.net.ssl.SSLContext
import javax.net.ssl.TrustManager
import javax.net.ssl.X509TrustManager
import kotlin.io.path.exists


object APIConnecter {
Expand All @@ -38,8 +31,7 @@ object APIConnecter {
var mushstafflist = ""
var hypixelstafflist = ""

var donorCapeLocations = mutableListOf<Pair<String, BufferedImage>>()
var donorIDs = mutableListOf<String>()
private var donorCapeLocations = mutableListOf<Pair<String, ResourceLocation>>()

private val trustAllCerts = arrayOf<TrustManager>(object : X509TrustManager {
override fun checkClientTrusted(chain: Array<java.security.cert.X509Certificate>, authType: String) {}
Expand All @@ -54,6 +46,14 @@ object APIConnecter {
sslContext.init(null, trustAllCerts, java.security.SecureRandom())
}

fun loadCape(player: EntityPlayer): ResourceLocation? {
for ((i, l) in donorCapeLocations) {
if (i == player.uniqueID.toString())
return l
}
return null
}

fun loadDonors() {
try {
var gotNames: String
Expand All @@ -69,19 +69,11 @@ object APIConnecter {
val details = gotNames.split("///")
for (i in details) {
var gotCapes: BufferedImage
val name = i.split(":")[0]
val uuid = i.split(":")[0]
val cape = i.split(":")[1]
tlsAuthConnectionFixes()
val donorClient = OkHttpClient.Builder()
.sslSocketFactory(sslContext.socketFactory, trustAllCerts[0] as X509TrustManager)
.build()
val donorBuilder = Request.Builder().url(URLComponent.DONORS + cape)
val donorRequest: Request = donorBuilder.build()
donorClient.newCall(donorRequest).execute().use { response ->
gotCapes = response.body?.byteStream().let { ImageIO.read(it) }
}
donorIDs.add(name)
donorCapeLocations.add(Pair(name, gotCapes))
gotCapes = ImageIO.read(URL(URLComponent.DONORS + cape))
donorCapeLocations.add(Pair(uuid, MinecraftInstance.mc.textureManager.getDynamicTextureLocation(Launch.CLIENT_FOLDER, DynamicTexture(gotCapes))))
}
canConnect = true
ClientUtils.getLogger().info("Loaded Donor Capes")
Expand Down

0 comments on commit d497f90

Please sign in to comment.