generated from nea89o/Forge1.8.9Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
useless shit that will be deleted soon
- Loading branch information
1 parent
94df423
commit 23c6cf7
Showing
43 changed files
with
3,178 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/main/java/com/github/floor2java/corrupted_macro/utils/gui/ImageProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.github.floor2java.corrupted_macro.utils.gui; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.renderer.texture.DynamicTexture; | ||
import net.minecraft.util.ResourceLocation; | ||
import org.lwjgl.opengl.GL11; | ||
|
||
import javax.imageio.ImageIO; | ||
import java.awt.*; | ||
import java.awt.image.BufferedImage; | ||
import java.io.IOException; | ||
|
||
public class ImageProcessor { | ||
public static ResourceLocation resizeAndLoadTexture(ResourceLocation originalTexture, int targetWidth, int targetHeight) { | ||
try { | ||
// Charger l'image originale | ||
BufferedImage originalImage = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(originalTexture).getInputStream()); | ||
|
||
// Redimensionner l'image | ||
BufferedImage resizedImage = resizeImage(originalImage, targetWidth, targetHeight); | ||
|
||
// Créer une nouvelle texture dynamique | ||
DynamicTexture dynamicTexture = new DynamicTexture(resizedImage); | ||
|
||
// Créer une nouvelle ResourceLocation pour la texture redimensionnée | ||
return Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("resized_" + originalTexture.getResourcePath(), dynamicTexture); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
return originalTexture; // Retourner la texture originale en cas d'erreur | ||
} | ||
} | ||
|
||
// La méthode resizeImage reste la même que dans votre code original | ||
public static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) { | ||
BufferedImage resizedImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_ARGB); | ||
Graphics2D g2d = resizedImage.createGraphics(); | ||
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); | ||
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); | ||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); | ||
g2d.drawImage(originalImage, 0, 0, targetWidth, targetHeight, null); | ||
g2d.dispose(); | ||
return resizedImage; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/github/floor2java/corrupted_macro/utils/gui/SettingsArrow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.github.floor2java.corrupted_macro.utils.gui; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.Gui; | ||
import net.minecraft.client.gui.ScaledResolution; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.client.renderer.OpenGlHelper; | ||
import net.minecraft.client.renderer.Tessellator; | ||
import net.minecraft.client.renderer.WorldRenderer; | ||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; | ||
import net.minecraft.util.ResourceLocation; | ||
import org.lwjgl.opengl.GL11; | ||
|
||
public class SettingsArrow { | ||
|
||
private float currentRotation2 = 0.0f; | ||
private float currentScale = 1.0f; // Variable to track the current scale | ||
|
||
public void drawComboArrow(float x, float y, float width, float height, ResourceLocation image, boolean isExpanded, float partialTicks, float alpha) { | ||
Minecraft.getMinecraft().getTextureManager().bindTexture(image); | ||
|
||
GlStateManager.enableBlend(); | ||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); | ||
GlStateManager.color(1.0f, 1.0f, 1.0f, alpha); | ||
|
||
GlStateManager.pushMatrix(); | ||
|
||
// Determine target rotation based on expanded state | ||
float targetRotation = isExpanded ? 180.0f : 0.0f; | ||
|
||
// Interpolate rotation using partialTicks | ||
float interpolatedRotation = currentRotation2 + (targetRotation - currentRotation2) * partialTicks; | ||
|
||
// Determine target scale based on hover state | ||
float targetScale = isExpanded ? 1f : 0.9f; | ||
|
||
// Interpolate scale using partialTicks | ||
float interpolatedScale = currentScale + (targetScale - currentScale) * partialTicks; | ||
|
||
// Translate to the center of the image before rotating and scaling | ||
GlStateManager.translate(x + width / 2, y + height / 2, 0); | ||
GlStateManager.rotate(interpolatedRotation, 0, 0, 1); | ||
GlStateManager.scale(interpolatedScale, interpolatedScale, interpolatedScale); | ||
GlStateManager.translate(-(x + width / 2), -(y + height / 2), 0); | ||
|
||
Tessellator tessellator = Tessellator.getInstance(); | ||
WorldRenderer worldrenderer = tessellator.getWorldRenderer(); | ||
|
||
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); | ||
worldrenderer.pos(x, y + height, 0).tex(0, 1).endVertex(); | ||
worldrenderer.pos(x + width, y + height, 0).tex(1, 1).endVertex(); | ||
worldrenderer.pos(x + width, y, 0).tex(1, 0).endVertex(); | ||
worldrenderer.pos(x, y, 0).tex(0, 0).endVertex(); | ||
tessellator.draw(); | ||
|
||
// Update currentRotation and currentScale for next frame | ||
currentRotation2 = interpolatedRotation; | ||
currentScale = interpolatedScale; | ||
|
||
GlStateManager.popMatrix(); | ||
GlStateManager.disableBlend(); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/com/github/floor2java/corrupted_macro/utils/gui/animations/AnimatedColor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.github.floor2java.corrupted_macro.utils.gui.animations; | ||
|
||
|
||
import com.github.floor2java.corrupted_macro.utils.ColorUtils; | ||
|
||
import java.awt.Color; | ||
|
||
public class AnimatedColor { | ||
private boolean isActive = false; | ||
private LinearAnimation animation; | ||
private final Color baseColor; | ||
private final Color activeColor; | ||
private final int animationDuration; | ||
private boolean guiColor; | ||
|
||
public AnimatedColor(Color baseColor, Color activeColor, int animationDuration, boolean guiColor) { | ||
this.baseColor = baseColor; | ||
if(guiColor){ | ||
this.activeColor = ColorUtils.getClickGUIColor().darker(); | ||
}else{ | ||
this.activeColor = activeColor; | ||
} | ||
this.animationDuration = animationDuration; | ||
this.guiColor = guiColor; | ||
} | ||
|
||
public Color update(boolean shouldBeActive) { | ||
if (shouldBeActive != isActive) { | ||
isActive = shouldBeActive; | ||
animation = new LinearAnimation(isActive ? 0 : 1, isActive ? 1 : 0, animationDuration, true); | ||
} | ||
|
||
if (animation != null) { | ||
if (animation.isAnimationDone()) { | ||
if(guiColor){ | ||
return isActive ? ColorUtils.getClickGUIColor().darker() : baseColor; | ||
}else{ | ||
return isActive ? activeColor : baseColor; | ||
} | ||
} else { | ||
float progress = animation.getAnimationValue(); | ||
if(guiColor){ | ||
return ColorUtils.lerpColor(baseColor, ColorUtils.getClickGUIColor().darker(), progress); | ||
}else{ | ||
return ColorUtils.lerpColor(baseColor, activeColor, progress); | ||
} | ||
} | ||
} | ||
|
||
return baseColor; | ||
} | ||
} |
171 changes: 171 additions & 0 deletions
171
...main/java/com/github/floor2java/corrupted_macro/utils/gui/animations/LinearAnimation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
package com.github.floor2java.corrupted_macro.utils.gui.animations; | ||
|
||
public class LinearAnimation { | ||
|
||
private long prevTime; | ||
|
||
private float animationValue; | ||
|
||
public float startValue; | ||
|
||
public float endValue; | ||
|
||
private boolean isIncreasing; | ||
|
||
private float changeValuePms; | ||
|
||
private boolean isDrawAnimation = false; | ||
|
||
private boolean resetUsingBackWardsAnimation = false; | ||
|
||
|
||
public LinearAnimation(float startValue, float endValue, long time) { | ||
this.prevTime = System.currentTimeMillis(); | ||
this.startValue = startValue; | ||
this.endValue = (startValue == endValue ? endValue+1 : endValue); | ||
this.animationValue = startValue; | ||
this.isIncreasing = endValue > startValue; | ||
float animationDistance = Math.abs(startValue - endValue); | ||
this.changeValuePms = animationDistance / time; | ||
|
||
|
||
} | ||
|
||
|
||
public LinearAnimation(float startValue, float endValue, long time, boolean instaIsDrawAnimation) { | ||
this.prevTime = System.currentTimeMillis(); | ||
this.startValue = startValue; | ||
this.endValue = (startValue == endValue ? endValue+1 : endValue); | ||
this.animationValue = startValue; | ||
this.isIncreasing = endValue > startValue; | ||
float animationDistance = Math.abs(startValue - endValue); | ||
this.changeValuePms = animationDistance / time; | ||
|
||
this.isDrawAnimation = instaIsDrawAnimation; | ||
|
||
} | ||
|
||
public LinearAnimation() { | ||
} | ||
|
||
|
||
public float getAnimationValue() { | ||
updateAnimationValue(); | ||
return animationValue; | ||
} | ||
|
||
public boolean isAnimationDone() { | ||
return animationValue == endValue; | ||
} | ||
|
||
|
||
private void updateAnimationValue() { | ||
if(isDrawAnimation) { | ||
resetUsingBackWardsAnimation = false; | ||
if (animationValue == endValue) return; | ||
|
||
if (isIncreasing) { | ||
if (animationValue >= endValue) { | ||
animationValue = endValue; | ||
return; | ||
} | ||
|
||
|
||
animationValue += (changeValuePms) * (System.currentTimeMillis() - prevTime); | ||
//animationValue += resetUsingBackWardsAnimation ? -1 *((changeValuePms) * (System.currentTimeMillis() - prevTime)) : ((changeValuePms) * (System.currentTimeMillis() - prevTime)); | ||
|
||
if (animationValue > endValue) | ||
animationValue = endValue; | ||
this.prevTime = System.currentTimeMillis(); | ||
return; | ||
} else { | ||
if (animationValue <= endValue) { | ||
animationValue = endValue; | ||
return; | ||
} | ||
animationValue -= (changeValuePms) * (System.currentTimeMillis() - prevTime); | ||
|
||
//animationValue -= resetUsingBackWardsAnimation ? -1 *((changeValuePms) * (System.currentTimeMillis() - prevTime)) : ((changeValuePms) * (System.currentTimeMillis() - prevTime)); | ||
|
||
if (animationValue < endValue) | ||
animationValue = endValue; | ||
this.prevTime = System.currentTimeMillis(); | ||
return; | ||
} | ||
} | ||
else if (resetUsingBackWardsAnimation) { | ||
setIsDrawAnimation(false); | ||
if (animationValue == startValue) { | ||
reset(); | ||
resetUsingBackWardsAnimation = false; | ||
return; | ||
} | ||
if(isIncreasing) { | ||
if(animationValue <= startValue) { | ||
reset(); | ||
return; | ||
} | ||
} | ||
animationValue -= (changeValuePms) * (System.currentTimeMillis() - prevTime); | ||
if (animationValue < startValue) | ||
reset(); | ||
this.prevTime = System.currentTimeMillis(); | ||
return; | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
|
||
public void reset() { | ||
animationValue = startValue; | ||
prevTime = System.currentTimeMillis(); | ||
} | ||
|
||
|
||
|
||
public void AnimationUpdateValue(float startValue, float endValue, long time) { | ||
reset(); | ||
this.prevTime = System.currentTimeMillis(); | ||
this.startValue = startValue; | ||
this.endValue = (startValue == endValue ? endValue+1 : endValue); | ||
this.animationValue = startValue; | ||
this.isIncreasing = endValue > startValue; | ||
float animationDistance = Math.abs(startValue - endValue); | ||
this.changeValuePms = animationDistance / time; | ||
} | ||
|
||
public void AnimationUpdateValue(float startValue, float endValue, long time, boolean instaDrawAnimation) { | ||
this.prevTime = System.currentTimeMillis(); | ||
this.startValue = startValue; | ||
this.endValue = (startValue == endValue ? endValue+1 : endValue); | ||
this.animationValue = startValue; | ||
this.isIncreasing = endValue > startValue; | ||
float animationDistance = Math.abs(startValue - endValue); | ||
this.changeValuePms = animationDistance / time; | ||
|
||
this.isDrawAnimation = instaDrawAnimation; | ||
|
||
} | ||
|
||
|
||
public void setIsDrawAnimation(boolean drawAnimation) { | ||
this.isDrawAnimation = drawAnimation; | ||
|
||
} | ||
|
||
public boolean getIsDrawAnimation() { | ||
return isDrawAnimation; | ||
|
||
} | ||
|
||
public void resetUsingBackWardsAnimation() { | ||
prevTime = System.currentTimeMillis(); | ||
setIsDrawAnimation(false); | ||
this.resetUsingBackWardsAnimation = true; | ||
|
||
} | ||
|
||
|
||
} |
Oops, something went wrong.