Skip to content

Commit

Permalink
File Size Reducer
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetchnoblade committed May 24, 2024
1 parent 20c412d commit 1a6fc05
Show file tree
Hide file tree
Showing 185 changed files with 134 additions and 57 deletions.
4 changes: 3 additions & 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 = "B126"
const val CLIENT_VERSION = "B127"
const val CLIENT_CHAT = "§7[§5N§di§3g§bh§6t§aX§7] [§eInfo§7] §r"

var isStarting = false
Expand Down Expand Up @@ -85,6 +85,8 @@ object Launch {
APIConnecter.checkChangelogs()
APIConnecter.checkBugs()
APIConnecter.checkStaffList()
APIConnecter.loadPictures()
APIConnecter.loadMainMenu()
APIConnecter.loadDonors()

// Init Discord RPC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package net.aspw.client.features.module.impl.visual
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.APIConnecter
import net.aspw.client.value.BoolValue
import net.aspw.client.value.ListValue
import net.minecraft.util.ResourceLocation
Expand All @@ -28,15 +29,15 @@ class Cape : Module() {
) { customCape.get() }

private val capeCache = hashMapOf<String, CapeStyle>()
fun getCapeLocation(value: String): ResourceLocation {
fun getCapeLocation(value: String): ResourceLocation? {
if (capeCache[value.uppercase(Locale.getDefault())] == null)
capeCache[value.uppercase(Locale.getDefault())] = CapeStyle.valueOf(value.uppercase(Locale.getDefault()))
return capeCache[value.uppercase(Locale.getDefault())]!!.location
}

enum class CapeStyle(val location: ResourceLocation) {
NONE(ResourceLocation("client/cape/none.png")),
NIGHTX(ResourceLocation("client/cape/nightx.png"))
enum class CapeStyle(val location: ResourceLocation?) {
NONE(APIConnecter.callImage("none", "cape")),
NIGHTX(APIConnecter.callImage("nightx", "cape"))
}

override val tag: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.aspw.client.injection.forge.mixins.gui;

import net.aspw.client.Launch;
import net.aspw.client.utils.APIConnecter;
import net.aspw.client.utils.render.RenderUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
Expand All @@ -11,7 +12,6 @@
import net.minecraft.event.HoverEvent;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -71,7 +71,7 @@ private void drawClientBackground(final CallbackInfo callbackInfo) {
GlStateManager.disableFog();

RenderUtils.drawImage(
new ResourceLocation("client/background/portal.png"), 0, 0,
APIConnecter.INSTANCE.callImage("portal", "background"), 0, 0,
width, height
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public abstract class MixinModelBiped {
public boolean isSneak;

@Inject(method = "setRotationAngles", at = @At(value = "FIELD", target = "Lnet/minecraft/client/model/ModelBiped;swingProgress:F"))
private void revertSwordAnimation(float p_setRotationAngles1, float p_setRotationAngles2, float p_setRotationAngles3, float p_setRotationAngles4, float p_setRotationAngles5, float p_setRotationAngles6, Entity p_setRotationAngles7, CallbackInfo callbackInfo) {
private void setRotationAngles(float p_setRotationAngles1, float p_setRotationAngles2, float p_setRotationAngles3, float p_setRotationAngles4, float p_setRotationAngles5, float p_setRotationAngles6, Entity p_setRotationAngles7, CallbackInfo callbackInfo) {
final KillAura killAura = Objects.requireNonNull(Launch.moduleManager.getModule(KillAura.class));
final TPAura tpAura = Objects.requireNonNull(Launch.moduleManager.getModule(TPAura.class));
final KillAuraRecode killAuraRecode = Objects.requireNonNull(Launch.moduleManager.getModule(KillAuraRecode.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.aspw.client.Launch;
import net.aspw.client.features.module.impl.visual.CustomModel;
import net.aspw.client.utils.APIConnecter;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.util.ResourceLocation;
Expand All @@ -15,13 +16,12 @@
@Mixin(RenderPlayer.class)
public class MixinRenderPlayer {

private final ResourceLocation rabbit = new ResourceLocation("client/models/rabbit.png");
private final ResourceLocation fred = new ResourceLocation("client/models/freddy.png");
private final ResourceLocation imposter = new ResourceLocation("client/models/imposter.png");

@Inject(method = {"getEntityTexture"}, at = {@At("HEAD")}, cancellable = true)
public void getEntityTexture(AbstractClientPlayer entity, CallbackInfoReturnable<ResourceLocation> ci) {
final CustomModel customModel = Objects.requireNonNull(Launch.moduleManager.getModule(CustomModel.class));
final ResourceLocation rabbit = APIConnecter.INSTANCE.callImage("rabbit", "models");
final ResourceLocation fred = APIConnecter.INSTANCE.callImage("freddy", "models");
final ResourceLocation imposter = APIConnecter.INSTANCE.callImage("imposter", "models");

if (customModel.getState()) {
if (customModel.getMode().get().contains("Rabbit")) {
Expand Down
85 changes: 85 additions & 0 deletions src/main/java/net/aspw/client/utils/APIConnecter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ object APIConnecter {
var mushstafflist = ""
var hypixelstafflist = ""

var maxTicks = 0
private var mainmenu = mutableListOf<Pair<Int, ResourceLocation>>()
private var pictures = mutableListOf<Triple<String, String, ResourceLocation>>()
private var donorCapeLocations = mutableListOf<Pair<String, ResourceLocation>>()

private val trustAllCerts = arrayOf<TrustManager>(object : X509TrustManager {
Expand All @@ -44,6 +47,88 @@ object APIConnecter {
sslContext.init(null, trustAllCerts, java.security.SecureRandom())
}

fun callImage(image: String, location: String): ResourceLocation? {
for ((i, l, s) in pictures) {
if (i == image && l == location)
return s
}
return null
}

fun callMainMenu(image: Int): ResourceLocation? {
for ((i, l) in mainmenu) {
if (i == image)
return l
}
return null
}

fun loadPictures() {
try {
if (pictures.isNotEmpty())
pictures.clear()
var gotNames: String
tlsAuthConnectionFixes()
val nameClient = OkHttpClient.Builder()
.sslSocketFactory(sslContext.socketFactory, trustAllCerts[0] as X509TrustManager)
.build()
val nameBuilder = Request.Builder().url(URLComponent.PICTURES + "locations.txt")
val nameRequest: Request = nameBuilder.build()
nameClient.newCall(nameRequest).execute().use { response ->
gotNames = response.body!!.string()
}
val details = gotNames.split("---")
for (i in details) {
var gotImage: BufferedImage
val fileName = i.split(":")[0]
val picType = i.split(":")[1]
tlsAuthConnectionFixes()
gotImage = ImageIO.read(URL(URLComponent.PICTURES + picType + "/" + fileName + ".png"))
pictures.add(
Triple(
fileName,
picType,
MinecraftInstance.mc.textureManager.getDynamicTextureLocation(
Launch.CLIENT_FOLDER,
DynamicTexture(gotImage)
)
)
)
ClientUtils.getLogger().info("Load Picture $fileName, $picType")
}
canConnect = true
ClientUtils.getLogger().info("Loaded Pictures")
} catch (e: Exception) {
canConnect = false
ClientUtils.getLogger().info("Failed to load Pictures")
}
}

fun loadMainMenu() {
try {
if (mainmenu.isNotEmpty())
mainmenu.clear()
for ((counter, i) in (0..Int.MAX_VALUE).withIndex()) {
tlsAuthConnectionFixes()
val gotImage: BufferedImage =
ImageIO.read(URL(URLComponent.PICTURES + "background/mainmenu/" + counter + ".png"))
mainmenu.add(
Pair(
i,
MinecraftInstance.mc.textureManager.getDynamicTextureLocation(
Launch.CLIENT_FOLDER,
DynamicTexture(gotImage)
)
)
)
ClientUtils.getLogger().info("Load MainMenu $counter")
maxTicks = counter
}
} catch (e: Exception) {
ClientUtils.getLogger().info("Loaded MainMenu")
}
}

fun loadCape(player: EntityPlayer): ResourceLocation? {
for ((i, l) in donorCapeLocations) {
if (i == player.uniqueID.toString())
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/aspw/client/utils/URLComponent.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package net.aspw.client.utils

object URLComponent {
var gifLoaded = false
var interval = 1_000_000_000L / 150
const val WEBSITE = "https://aspw-w.github.io/NightX"
const val STATUS = "$WEBSITE/database/data.txt"
const val STAFFS = "$WEBSITE/database/staffs.txt"
const val CHANGELOGS = "$WEBSITE/database/changelogs.txt"
const val BUGS = "$WEBSITE/database/bugs.txt"
const val DONORS = "$WEBSITE/donors/"
const val PICTURES = "$WEBSITE/pictures/"
const val CONFIGLIST = "$WEBSITE/configs/str/list.txt"
const val CONFIGS = "$WEBSITE/configs/"
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static void start() {
barBackgroundColor = new Color(200, 200, 255).getRGB();
final ResourceLocation fontLoc = new ResourceLocation(getString("fontTexture", "minecraft:textures/font/ascii.png"));
final ResourceLocation logoLoc = new ResourceLocation(getString("logoTexture", "minecraft:textures/gui/title/mojang.png"));
final ResourceLocation backgroundLoc = new ResourceLocation(getString("backgroundTexture", "client/background/splash.png"));
final ResourceLocation backgroundLoc = new ResourceLocation(getString("backgroundTexture", "client/splash.png"));
final ResourceLocation forgeLoc = new ResourceLocation(getString("forgeTexture", "fml:textures/gui/forge.gif"));
final File miscPackFile = new File(MinecraftInstance.mc.mcDataDir, getString("resourcePackPath", "resources"));
FileWriter w = null;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/aspw/client/visual/client/GuiInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import net.aspw.client.utils.misc.MiscUtils
import net.aspw.client.utils.render.RenderUtils
import net.minecraft.client.gui.GuiButton
import net.minecraft.client.gui.GuiScreen
import net.minecraft.util.ResourceLocation
import net.minecraftforge.fml.client.GuiModList
import org.lwjgl.input.Keyboard

Expand All @@ -23,7 +22,7 @@ class GuiInfo(private val prevGui: GuiScreen) : GuiScreen() {
override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {
drawBackground(0)
RenderUtils.drawImage(
ResourceLocation("client/background/portal.png"), 0, 0,
APIConnecter.callImage("portal", "background"), 0, 0,
width, height
)
super.drawScreen(mouseX, mouseY, partialTicks)
Expand Down
39 changes: 15 additions & 24 deletions src/main/java/net/aspw/client/visual/client/GuiMainMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ package net.aspw.client.visual.client

import net.aspw.client.Launch
import net.aspw.client.utils.APIConnecter
import net.aspw.client.utils.URLComponent
import net.aspw.client.utils.misc.MiscUtils
import net.aspw.client.utils.render.BlurUtils
import net.aspw.client.utils.render.RenderUtils
import net.aspw.client.visual.client.altmanager.GuiAltManager
import net.aspw.client.visual.font.smooth.FontLoaders
import net.minecraft.client.gui.*
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.util.ResourceLocation
import org.lwjgl.opengl.GL11

class GuiMainMenu : GuiScreen(), GuiYesNoCallback {

var alpha = 255
private var lastAnimTick: Long = 0L
private var previousTime = System.nanoTime()
private var interval = 1_000_000_000L / 15
private val moveMouseStrength = 200
private var alrUpdate = false
private val buttonWidth = 112
Expand Down Expand Up @@ -129,7 +128,7 @@ class GuiMainMenu : GuiScreen(), GuiYesNoCallback {
moveMouseEffect(mouseX, mouseY, moveMouseStrength - (moveMouseStrength / 2).toFloat())
loadGif()
RenderUtils.drawImage(
ResourceLocation("client/background/mainmenu/$ticks.png"),
APIConnecter.callMainMenu(ticks),
-moveMouseStrength + (moveMouseStrength / 2),
-moveMouseStrength + (moveMouseStrength / 2),
width + moveMouseStrength,
Expand All @@ -143,21 +142,16 @@ class GuiMainMenu : GuiScreen(), GuiYesNoCallback {
height.toFloat(),
5f
)
if (URLComponent.gifLoaded)
RenderUtils.drawImage2(
ResourceLocation("client/background/nightx.png"),
width / 2F - 50F,
height / 2F - 130F,
100,
100
)
RenderUtils.drawImage2(
APIConnecter.callImage("nightx", "background"),
width / 2F - 50F,
height / 2F - 130F,
100,
100
)
GlStateManager.enableAlpha()
if (URLComponent.gifLoaded) {
particles.forEach { it.update(deltaTime) }
particles.forEach { it.render() }
}
if (!URLComponent.gifLoaded)
FontLoaders.SF20.drawCenteredStringWithShadow("Loading...", width / 2f, height / 2f - 85f, -0x1111111)
particles.forEach { it.update(deltaTime) }
particles.forEach { it.render() }
val apiMessage = if (APIConnecter.canConnect) "§eOK" else "§cNo"
FontLoaders.SF20.drawStringWithShadow(
"API Connection: $apiMessage",
Expand Down Expand Up @@ -266,6 +260,8 @@ class GuiMainMenu : GuiScreen(), GuiYesNoCallback {
APIConnecter.checkChangelogs()
APIConnecter.checkBugs()
APIConnecter.checkStaffList()
APIConnecter.loadPictures()
APIConnecter.loadMainMenu()
APIConnecter.loadDonors()
}

Expand All @@ -287,15 +283,10 @@ class GuiMainMenu : GuiScreen(), GuiYesNoCallback {
val currentTime = System.nanoTime()
val deltaTime = currentTime - previousTime

if (deltaTime >= URLComponent.interval) {
if (deltaTime >= interval) {
ticks++
if (ticks > 149) {
if (!URLComponent.gifLoaded) {
URLComponent.interval = 1_000_000_000L / 15
URLComponent.gifLoaded = true
}
if (ticks > APIConnecter.maxTicks)
ticks = 0
}
previousTime = currentTime
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/aspw/client/visual/client/Particle.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package net.aspw.client.visual.client

import net.aspw.client.utils.APIConnecter
import net.aspw.client.utils.MinecraftInstance
import net.aspw.client.utils.misc.RandomUtils
import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
import net.minecraft.util.ResourceLocation
import org.lwjgl.opengl.GL11

class Particle(var x: Float, var y: Float) {
private var velocityY = (Math.random() * 100).toFloat()
private val size = 1f
private val texture = ResourceLocation("client/background/particle.png")
private val texture = APIConnecter.callImage("particle", "background")
private var delay = RandomUtils.nextInt(0, 800)

fun update(deltaTime: Float) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import net.aspw.client.auth.account.MicrosoftAccount
import net.aspw.client.auth.account.MinecraftAccount
import net.aspw.client.event.SessionEvent
import net.aspw.client.features.module.impl.visual.Interface
import net.aspw.client.utils.APIConnecter
import net.aspw.client.utils.MinecraftInstance
import net.aspw.client.utils.login.UserUtils.isValidTokenOffline
import net.aspw.client.utils.misc.RandomUtils
Expand All @@ -17,7 +18,6 @@ import net.minecraft.client.gui.GuiButton
import net.minecraft.client.gui.GuiScreen
import net.minecraft.client.gui.GuiSlot
import net.minecraft.client.gui.GuiTextField
import net.minecraft.util.ResourceLocation
import net.minecraft.util.Session
import org.lwjgl.input.Keyboard
import java.awt.Color
Expand Down Expand Up @@ -63,7 +63,7 @@ class GuiAltManager(private val prevGui: GuiScreen) : GuiScreen() {
override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {
drawBackground(0)
RenderUtils.drawImage(
ResourceLocation("client/background/portal.png"), 0, 0,
APIConnecter.callImage("portal", "background"), 0, 0,
width, height
)
altsList.drawScreen(mouseX, mouseY, partialTicks)
Expand Down
Loading

0 comments on commit 1a6fc05

Please sign in to comment.