sexy ahh animations
This commit is contained in:
parent
ad5e2d32c2
commit
eee9d61bca
59661
javascript/classes.js
59661
javascript/classes.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
118
src/main/java/dev/resent/animation/Animation.java
Normal file
118
src/main/java/dev/resent/animation/Animation.java
Normal file
|
@ -0,0 +1,118 @@
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
31
src/main/java/dev/resent/animation/AnimationUtils.java
Normal file
31
src/main/java/dev/resent/animation/AnimationUtils.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
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;
|
||||
}
|
||||
}
|
12
src/main/java/dev/resent/animation/Direction.java
Normal file
12
src/main/java/dev/resent/animation/Direction.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
package dev.resent.animation;
|
||||
|
||||
public enum Direction {
|
||||
FORWARDS,
|
||||
BACKWARDS;
|
||||
|
||||
public Direction opposite() {
|
||||
if (this == Direction.FORWARDS) {
|
||||
return Direction.BACKWARDS;
|
||||
} else return Direction.FORWARDS;
|
||||
}
|
||||
}
|
40
src/main/java/dev/resent/animation/SimpleAnimation.java
Normal file
40
src/main/java/dev/resent/animation/SimpleAnimation.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
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;
|
||||
}
|
||||
}
|
31
src/main/java/dev/resent/animation/impl/EaseBackIn.java
Normal file
31
src/main/java/dev/resent/animation/impl/EaseBackIn.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
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));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ import dev.resent.module.impl.misc.Crosshair;
|
|||
import dev.resent.module.impl.misc.DynamicFOV;
|
||||
import dev.resent.module.impl.misc.FPSB;
|
||||
import dev.resent.module.impl.misc.Fullbright;
|
||||
import dev.resent.module.impl.misc.HotbarAnimation;
|
||||
import dev.resent.module.impl.misc.MinimalViewBobbing;
|
||||
import dev.resent.module.impl.misc.NoParticles;
|
||||
import dev.resent.module.impl.misc.NoRain;
|
||||
|
@ -50,6 +51,7 @@ public class ModManager {
|
|||
public static NoRain noRain = new NoRain();
|
||||
public static DynamicFOV dynamicFOV = new DynamicFOV();
|
||||
public static PotionHUD potionHud;
|
||||
public static HotbarAnimation hotbar = new HotbarAnimation();
|
||||
//public static NoHurtCam noHurtCam = new NoHurtCam();
|
||||
public static Info coordinate;
|
||||
public static FPS fps;
|
||||
|
@ -79,6 +81,7 @@ public class ModManager {
|
|||
public ModManager() {
|
||||
//Hud
|
||||
register(cosmetics);
|
||||
register(hotbar);
|
||||
register(ping = new Ping());
|
||||
register(serverInfo = new ServerInfo());
|
||||
register(watermark = new Watermark());
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package dev.resent.module.impl.misc;
|
||||
|
||||
import dev.resent.module.base.Category;
|
||||
import dev.resent.module.base.Mod;
|
||||
import dev.resent.setting.ModeSetting;
|
||||
|
||||
public class HotbarAnimation extends Mod{
|
||||
public HotbarAnimation(){
|
||||
super("Hotbar animation", Category.MISC, true);
|
||||
addSetting(speed);
|
||||
}
|
||||
|
||||
public static ModeSetting speed = new ModeSetting("Speed", "", "Slow", "Fast", "Normal");
|
||||
|
||||
public int getSpeed(){
|
||||
if(speed.getValue() == "Fast")
|
||||
return 20;
|
||||
if(speed.getValue() == "Slow")
|
||||
return 5;
|
||||
return 12;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,9 @@ 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.animation.impl.EaseBackIn;
|
||||
import dev.resent.module.base.Mod;
|
||||
import dev.resent.setting.BooleanSetting;
|
||||
import dev.resent.setting.ModeSetting;
|
||||
|
@ -22,6 +25,7 @@ import net.minecraft.util.ResourceLocation;
|
|||
|
||||
public class ClickGUI extends GuiScreen {
|
||||
|
||||
public Animation introAnimation;
|
||||
public Mod modWatching = null;
|
||||
public ScaledResolution sr;
|
||||
public int x, y, width, height;
|
||||
|
@ -95,6 +99,13 @@ public class ClickGUI extends GuiScreen {
|
|||
}
|
||||
}
|
||||
|
||||
public static void startScale(float x, float y, float scale) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(x, y, 0);
|
||||
GlStateManager.scale(scale, scale, 1);
|
||||
GlStateManager.translate(-x, -y, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float par3) {
|
||||
sr = new ScaledResolution(mc);
|
||||
|
@ -109,6 +120,8 @@ public class ClickGUI extends GuiScreen {
|
|||
y = sr.getScaledHeight() - 10 + xy;
|
||||
int off = 0;
|
||||
|
||||
startScale(((this.x) + (this.x + this.width)) / 2, ((this.y) + (this.y + this.height)) / 2, (float) introAnimation.getValue());
|
||||
|
||||
// background
|
||||
Gui.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);
|
||||
|
@ -215,6 +228,8 @@ public class ClickGUI extends GuiScreen {
|
|||
// 200,90).getRGB());
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
if (xo > width / 2) {
|
||||
xo = 0;
|
||||
off += 3;
|
||||
|
@ -234,12 +249,17 @@ public class ClickGUI extends GuiScreen {
|
|||
|
||||
public void onGuiClosed() {
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
introAnimation.setDirection(Direction.BACKWARDS);
|
||||
if(introAnimation.isDone(Direction.BACKWARDS)) {
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
mc.gameSettings.saveOptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
mc.gameSettings.loadOptions();
|
||||
introAnimation = new EaseBackIn(450, 1, 2);
|
||||
}
|
||||
|
||||
protected void keyTyped(char par1, int par2) {
|
||||
|
|
|
@ -65,4 +65,11 @@ public class RenderUtils {
|
|||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
public static void startScale(float x, float y, float scale) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(x, y, 0);
|
||||
GlStateManager.scale(scale, scale, 1);
|
||||
GlStateManager.translate(-x, -y, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
package net.minecraft.client.gui;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import dev.resent.animation.SimpleAnimation;
|
||||
import net.lax1dude.eaglercraft.v1_8.Keyboard;
|
||||
import net.lax1dude.eaglercraft.v1_8.Mouse;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||
|
@ -15,7 +20,6 @@ import net.minecraft.util.ChatComponentText;
|
|||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
|
@ -269,11 +273,14 @@ public class GuiChat extends GuiScreen {
|
|||
}
|
||||
}
|
||||
|
||||
private SimpleAnimation animation = new SimpleAnimation(0.0F);
|
||||
|
||||
/**+
|
||||
* Draws the screen and all the components in it. Args : mouseX,
|
||||
* mouseY, renderPartialTicks
|
||||
*/
|
||||
public void drawScreen(int i, int j, float f) {
|
||||
animation.setAnimation(30, 20);
|
||||
drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
|
||||
this.inputField.drawTextBox();
|
||||
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.minecraft.client.gui;
|
||||
|
||||
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.GL_ONE_MINUS_SRC_ALPHA;
|
||||
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.GL_ONE_MINUS_DST_COLOR;
|
||||
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.GL_ONE_MINUS_SRC_ALPHA;
|
||||
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.GL_ONE_MINUS_SRC_COLOR;
|
||||
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.GL_SRC_ALPHA;
|
||||
|
||||
|
@ -14,12 +14,15 @@ import com.google.common.collect.Iterables;
|
|||
import com.google.common.collect.Lists;
|
||||
|
||||
import dev.resent.Resent;
|
||||
import dev.resent.animation.SimpleAnimation;
|
||||
import dev.resent.module.base.Mod;
|
||||
import dev.resent.module.base.ModManager;
|
||||
import dev.resent.module.base.RenderModule;
|
||||
import dev.resent.module.impl.misc.Crosshair;
|
||||
import dev.resent.module.impl.misc.HotbarAnimation;
|
||||
import dev.resent.ui.HUDConfigScreen;
|
||||
import dev.resent.util.misc.W;
|
||||
import dev.resent.util.render.Color;
|
||||
import dev.resent.util.render.RenderUtils;
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
||||
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
|
||||
|
@ -27,7 +30,6 @@ import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
|||
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
|
@ -340,6 +342,8 @@ public class GuiIngame extends Gui {
|
|||
GlStateManager.enableAlpha();
|
||||
}
|
||||
|
||||
public SimpleAnimation simpleAnimation = new SimpleAnimation(0.0F);
|
||||
|
||||
protected void renderTooltip(ScaledResolution sr, float partialTicks) {
|
||||
if (this.mc.getRenderViewEntity() instanceof EntityPlayer) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
@ -348,8 +352,17 @@ public class GuiIngame extends Gui {
|
|||
int i = sr.getScaledWidth() / 2;
|
||||
float f = this.zLevel;
|
||||
this.zLevel = -90.0F;
|
||||
|
||||
simpleAnimation.setAnimation(entityplayer.inventory.currentItem * 20, ModManager.hotbar.getSpeed());
|
||||
int itemX = i - 91 + ((int) simpleAnimation.getValue());
|
||||
|
||||
if(!ModManager.hotbar.isEnabled()){
|
||||
this.drawTexturedModalRect(i - 91, sr.getScaledHeight() - 22, 0, 0, 182, 22);
|
||||
this.drawTexturedModalRect(i - 91 - 1 + entityplayer.inventory.currentItem * 20, sr.getScaledHeight() - 22 - 1, 0, 22, 24, 22);
|
||||
}else {
|
||||
drawRect(itemX, sr.getScaledHeight() - 22, itemX + 22, sr.getScaledHeight(), new Color(230, 230, 230, 180).getRGB());
|
||||
}
|
||||
|
||||
this.zLevel = f;
|
||||
GlStateManager.enableRescaleNormal();
|
||||
GlStateManager.enableBlend();
|
||||
|
|
Loading…
Reference in New Issue
Block a user