Skip to content

Commit

Permalink
MainMenu Particles, Visual Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aspw-w committed May 23, 2024
1 parent 9d88059 commit 95d3d94
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 41 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 = "B125-Beta"
const val CLIENT_VERSION = "B125"
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 @@ -60,8 +60,7 @@ class Animations : Module() {
"Tap1",
"Tap2",
"Sigma3",
"Sigma4",
"Spin"
"Sigma4"
), "Swing"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Objects;
Expand Down Expand Up @@ -160,4 +158,9 @@ private void resolveScreenState(CallbackInfo ci) {
private char resolveForeignKeyboards() {
return (char) (Keyboard.getEventCharacter() + 256);
}

@ModifyConstant(method = "getLimitFramerate", constant = @Constant(intValue = 30))
public int getLimitFramerate(int constant) {
return MinecraftInstance.mc.gameSettings.limitFramerate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public abstract class MixinItemRenderer {
private Minecraft mc;
@Shadow
private ItemStack itemToRender;

private float delay = 0;
private long lastUpdateTime = System.currentTimeMillis();

@Shadow
protected abstract void rotateArroundXAndY(float angle, float angleY);
Expand Down Expand Up @@ -245,7 +247,7 @@ public void renderItemInFirstPerson(final float partialTicks) {
transformFirstPersonItem(0.0F, 0.0f);
else transformFirstPersonItem(f / 1.4F, 0.0f);
doBlockTransformations();
GlStateManager.rotate(-var * 42.5F, 1.1F, 0.8F, -0.3F);
GlStateManager.rotate(-var * 41F, 1.1F, 0.8F, -0.3F);
GlStateManager.scale(Animations.scale.get() + 1, Animations.scale.get() + 1, Animations.scale.get() + 1);
break;
}
Expand All @@ -272,16 +274,16 @@ 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.3F, 0.0F);
else this.transformFirstPersonItem(f / 1.2F, 0.0F);
long currentTime = System.currentTimeMillis();
long elapsedTime = currentTime - lastUpdateTime;
if (this.rotateTimer.hasReached(1L)) {
for (int i = 0; i < 1; i++) {
++this.delay;
}
this.delay += elapsedTime * 360.0 / 1000.0;
this.rotateTimer.reset();
}
if (this.delay > 360.0F) {
lastUpdateTime = currentTime;
if (this.delay > 360.0F)
this.delay = 0.0F;
}
doBlockTransformations();
GlStateManager.scale(Animations.scale.get() + 1, Animations.scale.get() + 1, Animations.scale.get() + 1);
break;
Expand Down Expand Up @@ -337,28 +339,14 @@ public void renderItemInFirstPerson(final float partialTicks) {
GlStateManager.scale(Animations.scale.get() + 1, Animations.scale.get() + 1, Animations.scale.get() + 1);
break;
}
case "Spin": {
GL11.glTranslated(Animations.blockPosX.get().doubleValue(), Animations.blockPosY.get().doubleValue(), Animations.blockPosZ.get().doubleValue());
if (Animations.cancelEquip.get())
transformFirstPersonItem(0.0f, 0.0f);
else transformFirstPersonItem(f / 1.4F, 0.0F);
GlStateManager.translate(0, 0.2F, -1);
GlStateManager.rotate(-59, -1, 0, 3);
GlStateManager.rotate(-(System.currentTimeMillis() / 2 % 360), 1, 0, 0.0F);
GlStateManager.rotate(60.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.scale(Animations.scale.get() + 1, Animations.scale.get() + 1, Animations.scale.get() + 1);
}
case "Slash": {
GL11.glTranslated(Animations.blockPosX.get().doubleValue(), Animations.blockPosY.get().doubleValue(), Animations.blockPosZ.get().doubleValue());
GL11.glTranslated(Animations.blockPosX.get().doubleValue() + 0.08, Animations.blockPosY.get().doubleValue() + 0.08, Animations.blockPosZ.get().doubleValue());
final float var = MathHelper.sin((float) (MathHelper.sqrt_float(f1) * Math.PI));
if (Animations.cancelEquip.get())
transformFirstPersonItem(0.0f, 0.0f);
else transformFirstPersonItem(f / 1.8f, 0.0f);
transformFirstPersonItem(0.0F, 0.0f);
else transformFirstPersonItem(f / 1.4F, 0.0f);
doBlockTransformations();
final float var16 = MathHelper.sin((float) (f1 * f1 * Math.PI));
GlStateManager.rotate(-var16 * 0f, 0.0f, 1.0f, 0.0f);
GlStateManager.rotate(-var * 50f, 0.0f, 0.0f, 1.0f);
GlStateManager.rotate(-var * 0f, 1.5f, 0.0f, 0.0f);
GlStateManager.rotate(-var * 70F, 5F, 13F, 50F);
GlStateManager.scale(Animations.scale.get() + 1, Animations.scale.get() + 1, Animations.scale.get() + 1);
break;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/aspw/client/utils/URLComponent.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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"
Expand Down
75 changes: 65 additions & 10 deletions src/main/java/net/aspw/client/visual/client/GuiMainMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ 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
Expand All @@ -15,13 +17,21 @@ class GuiMainMenu : GuiScreen(), GuiYesNoCallback {

var alpha = 255
private var lastAnimTick: Long = 0L
private var previousTime = System.nanoTime()
private val moveMouseStrength = 200
private var alrUpdate = false
private val buttonWidth = 112
private val buttonHeight = 20
private var level = 0
private var ticks = 0
private val particles = mutableListOf<Particle>()
private var lastUpdateTime = System.currentTimeMillis()

override fun initGui() {
if (particles.isNotEmpty())
particles.clear()
for (i in 0 until 600) {
particles.add(Particle((Math.random() * width).toFloat(), (Math.random() * height).toFloat()))
}
this.buttonList.add(
GuiButton(
0,
Expand Down Expand Up @@ -110,16 +120,44 @@ class GuiMainMenu : GuiScreen(), GuiYesNoCallback {
lastAnimTick = System.currentTimeMillis()
alrUpdate = true
}
val currentTime = System.currentTimeMillis()
val deltaTime = (currentTime - lastUpdateTime) / 1000.0f
lastUpdateTime = currentTime
GL11.glPushMatrix()
GlStateManager.disableAlpha()
drawBackground(0)
moveMouseEffect(mouseX, mouseY, moveMouseStrength - (moveMouseStrength / 2).toFloat())
loadGif()
RenderUtils.drawImage(
ResourceLocation("client/background/mainmenu/$ticks.png"), 0, 0,
width, height
ResourceLocation("client/background/mainmenu/$ticks.png"),
-moveMouseStrength + (moveMouseStrength / 2),
-moveMouseStrength + (moveMouseStrength / 2),
width + moveMouseStrength,
height + moveMouseStrength
)
moveMouseEffect(mouseX, mouseY, -moveMouseStrength + (moveMouseStrength / 2).toFloat())
BlurUtils.blurArea(
0f,
0f,
width.toFloat(),
height.toFloat(),
5f
)
RenderUtils.drawGradientRect(0, 0, width, height, -13158600, -804253680)
if (URLComponent.gifLoaded)
RenderUtils.drawImage2(
ResourceLocation("client/background/nightx.png"),
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)
val apiMessage = if (APIConnecter.canConnect) "§eOK" else "§cNo"
FontLoaders.SF20.drawStringWithShadow(
"API Connection: $apiMessage",
Expand Down Expand Up @@ -236,20 +274,37 @@ class GuiMainMenu : GuiScreen(), GuiYesNoCallback {
}
}

private fun moveMouseEffect(mouseX: Int, mouseY: Int, strength: Float) {
val mX = mouseX - width / 2
val mY = mouseY - height / 2
val xDelta = mX.toFloat() / (width / 2).toFloat()
val yDelta = mY.toFloat() / (height / 2).toFloat()

GL11.glTranslatef(xDelta * strength, yDelta * strength, 0F)
}

private fun loadGif() {
level++
if (level >= 2) {
val currentTime = System.nanoTime()
val deltaTime = currentTime - previousTime

if (deltaTime >= URLComponent.interval) {
ticks++
level = 0
if (ticks > 149) {
if (!URLComponent.gifLoaded) {
URLComponent.interval = 1_000_000_000L / 15
URLComponent.gifLoaded = true
}
ticks = 0
}
previousTime = currentTime
}
if (ticks > 149)
ticks = 0
}

override fun keyTyped(typedChar: Char, keyCode: Int) {}

override fun onGuiClosed() {
level = 0
if (particles.isNotEmpty())
particles.clear()
ticks = 0
}
}
52 changes: 52 additions & 0 deletions src/main/java/net/aspw/client/visual/client/Particle.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package net.aspw.client.visual.client

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 var delay = RandomUtils.nextInt(0, 800)

fun update(deltaTime: Float) {
if (delay > 0) {
delay--
return
}

velocityY += 700f * deltaTime
y += velocityY * deltaTime

if (y >= MinecraftInstance.mc.displayHeight) {
reset()
}
}

fun render() {
if (delay > 0) return

MinecraftInstance.mc.textureManager.bindTexture(texture)
GL11.glColor4f(1f, 1f, 1f, 1f)
val tessellator = Tessellator.getInstance()
val worldrenderer = tessellator.worldRenderer

worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX)
worldrenderer.pos((x - size).toDouble(), (y + size).toDouble(), 0.0).tex(0.0, 1.0).endVertex()
worldrenderer.pos((x + size).toDouble(), (y + size).toDouble(), 0.0).tex(1.0, 1.0).endVertex()
worldrenderer.pos((x + size).toDouble(), (y - size).toDouble(), 0.0).tex(1.0, 0.0).endVertex()
worldrenderer.pos((x - size).toDouble(), (y - size).toDouble(), 0.0).tex(0.0, 0.0).endVertex()
tessellator.draw()
}

private fun reset() {
x = (Math.random() * MinecraftInstance.mc.displayWidth).toFloat()
y = (Math.random() * -20).toFloat()
velocityY = (Math.random() * 100).toFloat()
delay = RandomUtils.nextInt(0, 800)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 95d3d94

Please sign in to comment.