Optimize some code and delete unnecessary files, replace checkmark

This commit is contained in:
ThisIsALegitUsername 2023-02-11 00:42:14 +00:00
parent 40a74ee84b
commit 762bb3bec1
18 changed files with 25688 additions and 26015 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,118 +0,0 @@
package dev.resent.animation;
public abstract class Animation {
public AnimationTimer timer = new AnimationTimer();
protected int duration;
protected double endPoint;
protected Direction direction;
public Animation(int ms, double endPoint) {
this.duration = ms;
this.endPoint = endPoint;
this.direction = Direction.FORWARDS;
}
public Animation(int ms, double endPoint, Direction direction) {
this.duration = ms;
this.endPoint = endPoint;
this.direction = direction;
}
public boolean isDone(Direction direction) {
return isDone() && this.direction.equals(direction);
}
public double getLinearOutput() {
return 1 - ((timer.getTime() / (double) duration) * endPoint);
}
public void reset() {
timer.reset();
}
public boolean isDone() {
return timer.hasTimeElapsed(duration);
}
public void changeDirection() {
setDirection(direction.opposite());
}
public void setDirection(Direction direction) {
if (this.direction != direction) {
this.direction = direction;
timer.setTime(System.currentTimeMillis() - (duration - Math.min(duration, timer.getTime())));
}
}
protected boolean correctOutput() {
return false;
}
public double getValue() {
if (direction == Direction.FORWARDS) {
if (isDone())
return endPoint;
return (getEquation(timer.getTime()) * endPoint);
} else {
if (isDone()) return 0;
if (correctOutput()) {
double revTime = Math.min(duration, Math.max(0, duration - timer.getTime()));
return getEquation(revTime) * endPoint;
} else return (1 - getEquation(timer.getTime())) * endPoint;
}
}
protected abstract double getEquation(double x);
public double getEndPoint() {
return endPoint;
}
public void setEndPoint(double endPoint) {
this.endPoint = endPoint;
}
public int getDuration() {
return duration;
}
public Direction getDirection() {
return direction;
}
}
class AnimationTimer {
public long lastMS = System.currentTimeMillis();
public void reset() {
lastMS = System.currentTimeMillis();
}
public boolean hasTimeElapsed(long time, boolean reset) {
if (System.currentTimeMillis() - lastMS > time) {
if (reset) reset();
return true;
}
return false;
}
public boolean hasTimeElapsed(long time) {
return System.currentTimeMillis() - lastMS > time;
}
public long getTime() {
return System.currentTimeMillis() - lastMS;
}
public void setTime(long time) {
lastMS = time;
}
}

View File

@ -1,31 +0,0 @@
package dev.resent.animation;
public class AnimationUtils {
public static float calculateCompensation(final float target, float current, final double speed, long delta) {
final float diff = current - target;
double add = (delta * (speed / 50));
if (diff > speed){
if(current - add > target) {
current -= add;
}else {
current = target;
}
}
else if (diff < -speed) {
if(current + add < target) {
current += add;
}else {
current = target;
}
}
else{
current = target;
}
return current;
}
}

View File

@ -1,12 +0,0 @@
package dev.resent.animation;
public enum Direction {
FORWARDS,
BACKWARDS;
public Direction opposite() {
if (this == Direction.FORWARDS) {
return Direction.BACKWARDS;
} else return Direction.FORWARDS;
}
}

View File

@ -1,40 +0,0 @@
package dev.resent.animation;
public class SimpleAnimation {
private float value;
private long lastMS;
public SimpleAnimation(final float value){
this.value = value;
this.lastMS = System.currentTimeMillis();
}
public void setAnimation(final float value, double speed){
final long currentMS = System.currentTimeMillis();
final long delta = currentMS - this.lastMS;
this.lastMS = currentMS;
double deltaValue = 0.0;
if(speed > 28) {
speed = 28;
}
if (speed != 0.0)
{
deltaValue = Math.abs(value - this.value) * 0.35f / (10.0 / speed);
}
this.value = AnimationUtils.calculateCompensation(value, this.value, deltaValue, delta);
}
public float getValue() {
return value;
}
public void setValue(float value) {
this.value = value;
}
}

View File

@ -1,20 +0,0 @@
package dev.resent.animation.impl;
import dev.resent.animation.Animation;
import dev.resent.animation.Direction;
public class DecelerateAnimation extends Animation {
public DecelerateAnimation(int ms, double endPoint) {
super(ms, endPoint);
}
public DecelerateAnimation(int ms, double endPoint, Direction direction) {
super(ms, endPoint, direction);
}
protected double getEquation(double x) {
double x1 = x / duration;
return 1 - ((x1 - 1) * (x1 - 1));
}
}

View File

@ -1,31 +0,0 @@
package dev.resent.animation.impl;
import dev.resent.animation.Animation;
import dev.resent.animation.Direction;
public class EaseBackIn extends Animation {
private final float easeAmount;
public EaseBackIn(int ms, double endPoint, float easeAmount) {
super(ms, endPoint);
this.easeAmount = easeAmount;
}
public EaseBackIn(int ms, double endPoint, float easeAmount, Direction direction) {
super(ms, endPoint, direction);
this.easeAmount = easeAmount;
}
@Override
protected boolean correctOutput() {
return true;
}
@Override
protected double getEquation(double x) {
double x1 = x / duration;
float shrink = easeAmount + 1;
return Math.max(0, 1 + shrink * Math.pow(x1 - 1, 3) + easeAmount * Math.pow(x1 - 1, 2));
}
}

View File

@ -1,21 +0,0 @@
package dev.resent.animation.impl;
import dev.resent.animation.Animation;
import dev.resent.animation.Direction;
public class EaseInOutQuad extends Animation {
public EaseInOutQuad(int ms, double endPoint) {
super(ms, endPoint);
}
public EaseInOutQuad(int ms, double endPoint, Direction direction) {
super(ms, endPoint, direction);
}
protected double getEquation(double x1) {
double x = x1 / duration;
return x < 0.5 ? 2 * Math.pow(x, 2) : 1 - Math.pow(-2 * x + 2, 2) / 2;
}
}

View File

@ -1,32 +0,0 @@
package dev.resent.animation.impl;
import dev.resent.animation.Animation;
import dev.resent.animation.Direction;
public class ElasticAnimation extends Animation {
float easeAmount;
float smooth;
boolean reallyElastic;
public ElasticAnimation(int ms, double endPoint, float elasticity, float smooth, boolean moreElasticity) {
super(ms, endPoint);
this.easeAmount = elasticity;
this.smooth = smooth;
this.reallyElastic = moreElasticity;
}
public ElasticAnimation(int ms, double endPoint, float elasticity, float smooth, boolean moreElasticity, Direction direction) {
super(ms, endPoint, direction);
this.easeAmount = elasticity;
this.smooth = smooth;
this.reallyElastic = moreElasticity;
}
@Override
protected double getEquation(double x) {
double x1 = Math.pow(x / duration, smooth);
double elasticity = easeAmount * .1f;
return Math.pow(2, -10 * (reallyElastic ? Math.sqrt(x1) : x1)) * Math.sin((x1 - (elasticity / 4)) * ((2 * Math.PI) / elasticity)) + 1;
}
}

View File

@ -1,21 +0,0 @@
package dev.resent.animation.impl;
import dev.resent.animation.Animation;
import dev.resent.animation.Direction;
public class SmoothStepAnimation extends Animation {
public SmoothStepAnimation(int ms, double endPoint) {
super(ms, endPoint);
}
public SmoothStepAnimation(int ms, double endPoint, Direction direction) {
super(ms, endPoint, direction);
}
protected double getEquation(double x) {
double x1 = x / (double) duration; //Used to force input to range from 0 - 1
return -2 * Math.pow(x1, 3) + (3 * Math.pow(x1, 2));
}
}

View File

@ -3,8 +3,8 @@ package dev.resent.ui;
import java.io.IOException;
import dev.resent.Resent;
import dev.resent.animation.Animation;
import dev.resent.animation.Direction;
import dev.resent.ui.animation.Animation;
import dev.resent.ui.animation.Direction;
import dev.resent.module.base.Mod;
import dev.resent.module.setting.BooleanSetting;
import dev.resent.module.setting.ModeSetting;
@ -48,12 +48,12 @@ public class ClickGUI extends GuiScreen {
int off = 0;
for (Mod m : Resent.INSTANCE.modManager.modules) {
int fh = fr.FONT_HEIGHT;
int fh = 9;
if (isMouseInside(mouseX, mouseY, this.x + 90 + xo - 1 + 10, height - 2 - fh * -(off) + 51 - 1 - offset, this.x + 90 + xo - 1 + 21, height + 30 - fh * (-off) + 30 - 1 + 2 - 1 - offset) && m.hasSetting && modWatching == null) {
// Open settings
this.modWatching = m;
} else if (isMouseInside(mouseX, mouseY, x - fr.FONT_HEIGHT + 2, height + 27 + fr.FONT_HEIGHT + 2, x - fr.FONT_HEIGHT + 6 + fr.getStringWidth("<"), height + 33 + fr.FONT_HEIGHT + 2 + fr.getStringWidth("<")) && mouseButton == 0) {
} else if (isMouseInside(mouseX, mouseY, x - 9 + 2, height + 27 + 9 + 2, x - 9 + 6 + fr.getStringWidth("<"), height + 33 + 9 + 2 + fr.getStringWidth("<")) && mouseButton == 0) {
// Close settings
this.modWatching = null;
} else if (isMouseInside(mouseX, mouseY, width + 15, height - 10, width + 25, height + 7)) {
@ -63,7 +63,7 @@ public class ClickGUI extends GuiScreen {
} else if (isMouseInside(mouseX, mouseY, this.x + 10 + xo - 2 + 10, height - 2 - fh * -(off) + 50 - 2 - offset, this.x + 90 + xo + 22, height + 30 - fh * (-off) + 30 + 2 - offset) && mouseButton == 0 && modWatching == null) {
// Toggle mod
m.toggle();
} else if (isMouseInside(mouseX, mouseY, GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 - 5, GuiScreen.height - y - fr.FONT_HEIGHT, GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 + 5 + fr.getStringWidth("Edit Layout"), GuiScreen.height - y + 5) && mouseButton == 0) {
} else if (isMouseInside(mouseX, mouseY, GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 - 5, GuiScreen.height - y - 9, GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 + 5 + fr.getStringWidth("Edit Layout"), GuiScreen.height - y + 5) && mouseButton == 0) {
mc.displayGuiScreen(new HUDConfigScreen());
this.modWatching = null;
}
@ -84,17 +84,17 @@ public class ClickGUI extends GuiScreen {
if (s instanceof BooleanSetting) {
b = (BooleanSetting) s;
if (isMouseInside(mouseX, mouseY, this.x + 6 + 1 + 6, height - fr.FONT_HEIGHT + 50 - offset + var + 1, this.x + 15 - 1 + 6, height - fr.FONT_HEIGHT + 50 + fr.FONT_HEIGHT - offset + var - 1) && mouseButton == 0) {
if (isMouseInside(mouseX, mouseY, this.x + 6 + 1 + 6, height - 9 + 50 - offset + var + 1, this.x + 15 - 1 + 6, height - 9 + 50 + 9 - offset + var - 1) && mouseButton == 0) {
b.toggle();
}
}
if (s instanceof ModeSetting) {
m = (ModeSetting) s;
if (isMouseInside(mouseX, mouseY, this.x + 24, height - fr.FONT_HEIGHT + 50 + var, this.x + 24 + fr.getStringWidth(s.name + ": " + m.getValue()), height - fr.FONT_HEIGHT + 50 + var + fr.FONT_HEIGHT) && mouseButton == 0) m.next();
if (isMouseInside(mouseX, mouseY, this.x + 24, height - 9 + 50 + var, this.x + 24 + fr.getStringWidth(s.name + ": " + m.getValue()), height - 9 + 50 + var + 9) && mouseButton == 0) m.next();
}
var += fr.FONT_HEIGHT + 2;
var += 9 + 2;
}
}
}
@ -125,16 +125,16 @@ public class ClickGUI extends GuiScreen {
// background
drawRect(x - 10, y + 20, width + 35, height - 10, new Color(35, 39, 42, 200).getRGB());
fr.drawString(Resent.NAME + " Client " + Resent.VERSION, x + 8, height - 2, -1);
RenderUtils.drawRectOutline(GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 - 5, GuiScreen.height - y - fr.FONT_HEIGHT, GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 + 5 + fr.getStringWidth("Edit Layout"), GuiScreen.height - y + 5, -1);
RenderUtils.drawRectOutline(GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 - 5, GuiScreen.height - y - 9, GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 + 5 + fr.getStringWidth("Edit Layout"), GuiScreen.height - y + 5, -1);
drawRect(
GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 - 4,
GuiScreen.height - y - fr.FONT_HEIGHT + 1,
GuiScreen.height - y - 9 + 1,
GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 + 5 + fr.getStringWidth("Edit Layout") - 1,
GuiScreen.height - y + 4,
isMouseInside(mouseX, mouseY, GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 - 4, GuiScreen.height - y - fr.FONT_HEIGHT + 1, GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 + 5 + fr.getStringWidth("Edit Layout") - 1, GuiScreen.height - y + 4) ? new Color(105, 105, 105, 65).getRGB() : new Color(211, 211, 211, 65).getRGB()
isMouseInside(mouseX, mouseY, GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 - 4, GuiScreen.height - y - 9 + 1, GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 + 5 + fr.getStringWidth("Edit Layout") - 1, GuiScreen.height - y + 4) ? new Color(105, 105, 105, 65).getRGB() : new Color(211, 211, 211, 65).getRGB()
);
fr.drawStringWithShadow("Edit Layout", GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 + 1, GuiScreen.height - y - fr.FONT_HEIGHT + fr.FONT_HEIGHT / 2 - 1, -1);
fr.drawStringWithShadow("Edit Layout", GuiScreen.width / 2 - fr.getStringWidth("Edit Layout") / 2 + 1, GuiScreen.height - y - 9 + 9 / 2 - 1, -1);
// close
// RenderUtils.drawRectOutline(width+15, height-5, width+26, height+8, new Color(200, 200, 200, 90).getRGB());
@ -145,7 +145,7 @@ public class ClickGUI extends GuiScreen {
GlUtils.stopScale();
for (Mod m : Resent.INSTANCE.modManager.modules) {
if (this.modWatching == null) {
int fh = fr.FONT_HEIGHT;
int fh = 9;
if (height - 2 - fh * -(off) + 50 - 2 - offset > height + 29 && height + 30 - fh * (-off) + 30 + 2 - offset < y + 20 && introAnimation.isDone()) {
// Enabled outline
RenderUtils.drawRectOutline(this.x + 10 + xo - 2 + 10, height - 2 - fh * -(off) + 50 - 2 - offset, this.x + 90 + xo + 22, height + 30 - fh * (-off) + 30 + 2 - offset, m.isEnabled() ? Color.GREEN.getRGB() : Color.RED.getRGB());
@ -158,9 +158,9 @@ public class ClickGUI extends GuiScreen {
);
if (m.hasSetting) {
//fr.drawString("o", this.x+99+xo, height - 2 - fh * -(off) + 51 + 1 - offset, isMouseInside(mouseX, mouseY, this.x + 90 + xo - 1 + 10, height - 2 - fh * -(off) + 51 + 1 - offset, this.x + 90 + xo - 1 + 10 + fr.getStringWidth("o"), height - 2 - fh * -(off) + 51 + 1 - offset + fr.FONT_HEIGHT) ? new Color(105, 105, 105, 65).getRGB() : -1);
//fr.drawString("o", this.x+99+xo, height - 2 - fh * -(off) + 51 + 1 - offset, isMouseInside(mouseX, mouseY, this.x + 90 + xo - 1 + 10, height - 2 - fh * -(off) + 51 + 1 - offset, this.x + 90 + xo - 1 + 10 + fr.getStringWidth("o"), height - 2 - fh * -(off) + 51 + 1 - offset + 9) ? new Color(105, 105, 105, 65).getRGB() : -1);
GlStateManager.enableBlend();
if(isMouseInside(mouseX, mouseY, this.x + 90 + xo - 1 + 10, height - 2 - fh * -(off) + 51 + 1 - offset, this.x + 90 + xo - 1 + 10 + fr.getStringWidth("o"), height - 2 - fh * -(off) + 51 + 1 - offset + fr.FONT_HEIGHT))
if(isMouseInside(mouseX, mouseY, this.x + 90 + xo - 1 + 10, height - 2 - fh * -(off) + 51 + 1 - offset, this.x + 90 + xo - 1 + 10 + fr.getStringWidth("o"), height - 2 - fh * -(off) + 51 + 1 - offset + 9))
GlStateManager.color(1,1,1,0.5f);
this.mc.getTextureManager().bindTexture(new ResourceLocation("eagler:gui/gear.png"));
Gui.drawModalRectWithCustomSizedTexture(this.x+99+xo, height - 2 - fh * -(off) + 51 + 1 - offset, 0, 0, 8, 8, 8, 8);
@ -172,8 +172,8 @@ public class ClickGUI extends GuiScreen {
}
} else if (this.modWatching != null) {
int var = 0;
fr.drawString("<", x - fr.FONT_HEIGHT + 4, height + 29 + fr.FONT_HEIGHT + 2, -1);
fr.drawStringWithShadow("Resent - " + modWatching.name, GuiScreen.width / 2 - (fr.getStringWidth("Resent - " + modWatching.name) / 2), height + 29 - fr.FONT_HEIGHT - 2, -1);
fr.drawString("<", x - 9 + 4, height + 29 + 9 + 2, -1);
fr.drawStringWithShadow("Resent - " + modWatching.name, GuiScreen.width / 2 - (fr.getStringWidth("Resent - " + modWatching.name) / 2), height + 29 - 9 - 2, -1);
for (int amogus = 0; amogus < this.modWatching.settings.size(); amogus++) {
ModeSetting mo;
@ -183,30 +183,30 @@ public class ClickGUI extends GuiScreen {
b = (BooleanSetting) s;
drawRect(
this.x + 11,
height - fr.FONT_HEIGHT + 50 + var,
height - 9 + 50 + var,
this.x + 19,
height - fr.FONT_HEIGHT + 50 + fr.FONT_HEIGHT + var-1,
height - 9 + 50 + 9 + var-1,
isMouseInside(
mouseX, mouseY,
this.x + 11,
height - fr.FONT_HEIGHT + 50 + var,
height - 9 + 50 + var,
this.x + 19,
height - fr.FONT_HEIGHT + 50 + fr.FONT_HEIGHT + var-1) ? new Color(211, 211, 211, 65).getRGB() : new Color(105, 105, 105, 65).getRGB());
height - 9 + 50 + 9 + var-1) ? new Color(211, 211, 211, 65).getRGB() : new Color(105, 105, 105, 65).getRGB());
if(b.getValue()){
mc.getTextureManager().bindTexture(new ResourceLocation("eagler:gui/check.png"));
Gui.drawModalRectWithCustomSizedTexture(this.x+11, height-fr.FONT_HEIGHT+50+var, 0, 0, 8, 8, 8, 8);
Gui.drawModalRectWithCustomSizedTexture(this.x+11, height-9+50+var, 0, 0, 8, 8, 8, 8);
}
}
if (s instanceof ModeSetting) {
mo = (ModeSetting) s;
fr.drawStringWithShadow(s.name + ": " + mo.getValue(), this.x + 18 + 6, height - fr.FONT_HEIGHT + 50 + var, -1);
fr.drawStringWithShadow(s.name + ": " + mo.getValue(), this.x + 18 + 6, height - 9 + 50 + var, -1);
} else {
fr.drawStringWithShadow(s.name, this.x + 18 + 6, height - fr.FONT_HEIGHT + 50 + var, -1);
fr.drawStringWithShadow(s.name, this.x + 18 + 6, height - 9 + 50 + var, -1);
}
var += fr.FONT_HEIGHT + 2;
var += 9 + 2;
}
}

View File

@ -1,12 +1,12 @@
package dev.resent.ui;
import dev.resent.animation.Animation;
import dev.resent.animation.impl.DecelerateAnimation;
import dev.resent.animation.impl.EaseBackIn;
import dev.resent.animation.impl.EaseInOutQuad;
import dev.resent.animation.impl.ElasticAnimation;
import dev.resent.animation.impl.SmoothStepAnimation;
import dev.resent.module.impl.misc.HUD;
import dev.resent.ui.animation.Animation;
import dev.resent.ui.animation.impl.DecelerateAnimation;
import dev.resent.ui.animation.impl.EaseBackIn;
import dev.resent.ui.animation.impl.EaseInOutQuad;
import dev.resent.ui.animation.impl.ElasticAnimation;
import dev.resent.ui.animation.impl.SmoothStepAnimation;
import dev.resent.util.render.RenderUtils;
public class Theme {

View File

@ -7,7 +7,7 @@ import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Lists;
import dev.resent.animation.SimpleAnimation;
import dev.resent.ui.animation.SimpleAnimation;
import dev.resent.util.misc.GlUtils;
import net.lax1dude.eaglercraft.v1_8.Keyboard;
import net.lax1dude.eaglercraft.v1_8.Mouse;

View File

@ -14,7 +14,7 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import dev.resent.Resent;
import dev.resent.animation.SimpleAnimation;
import dev.resent.ui.animation.SimpleAnimation;
import dev.resent.module.base.Mod;
import dev.resent.module.base.ModManager;
import dev.resent.module.base.RenderMod;

View File

@ -1,6 +1,6 @@
package net.minecraft.client.gui.inventory;
import dev.resent.animation.Animation;
import dev.resent.ui.animation.Animation;
import dev.resent.ui.Theme;
import dev.resent.util.misc.GlUtils;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;