From 072fcb25681375ce620b5046171d08ced0b4a3a6 Mon Sep 17 00:00:00 2001 From: NK Date: Sun, 5 Mar 2023 23:38:33 +0000 Subject: [PATCH] crabby render <- notgaba watch this pls --- src/main/java/me/night0721/lilase/Lilase.java | 4 +- .../night0721/lilase/gui/ImageRenderer.java | 28 +++++++ .../night0721/lilase/utils/CurrentColor.java | 76 +++++++++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 src/main/java/me/night0721/lilase/gui/ImageRenderer.java create mode 100644 src/main/java/me/night0721/lilase/utils/CurrentColor.java diff --git a/src/main/java/me/night0721/lilase/Lilase.java b/src/main/java/me/night0721/lilase/Lilase.java index 8f179b4..420d36b 100644 --- a/src/main/java/me/night0721/lilase/Lilase.java +++ b/src/main/java/me/night0721/lilase/Lilase.java @@ -6,6 +6,7 @@ import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; import me.night0721.lilase.events.SniperFlipperEvents; import me.night0721.lilase.features.ah.AHConfig; import me.night0721.lilase.features.ah.AuctionHouse; +import me.night0721.lilase.gui.ImageRenderer; import me.night0721.lilase.utils.Clock; import me.night0721.lilase.utils.ConfigUtils; import me.night0721.lilase.utils.KeyBindingManager; @@ -30,7 +31,7 @@ import static me.night0721.lilase.features.ah.AHConfig.RECONNECT_DELAY; public class Lilase { public static final String MOD_NAME = "Lilase"; public static final String MODID = "Lilase"; - public static final String VERSION = "1.0.24-beta"; + public static final String VERSION = "1.0.25"; public static final Minecraft mc = Minecraft.getMinecraft(); public static AuctionHouse auctionHouse; public static AHConfig config; @@ -43,6 +44,7 @@ public class Lilase { MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(keyBindingManager); MinecraftForge.EVENT_BUS.register(new SniperFlipperEvents()); + MinecraftForge.EVENT_BUS.register(new ImageRenderer()); EventManager.INSTANCE.register(this); ConfigUtils.register(); auctionHouse = new AuctionHouse(); diff --git a/src/main/java/me/night0721/lilase/gui/ImageRenderer.java b/src/main/java/me/night0721/lilase/gui/ImageRenderer.java new file mode 100644 index 0000000..885c320 --- /dev/null +++ b/src/main/java/me/night0721/lilase/gui/ImageRenderer.java @@ -0,0 +1,28 @@ +package me.night0721.lilase.gui; + +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import static me.night0721.lilase.Lilase.mc; + +public class ImageRenderer { + public void draw() { + ScaledResolution scaledResolution = new ScaledResolution(mc); + GlStateManager.pushMatrix(); + mc.getTextureManager().bindTexture(new ResourceLocation("lilase:images/crabby.png")); +// GlStateManager.color(CurrentColor.getFloatValue(0, 0), CurrentColor.getFloatValue(0, 1), CurrentColor.getFloatValue(0, 2)); + Gui.drawModalRectWithCustomSizedTexture(scaledResolution.getScaledWidth() / 2 + 64, scaledResolution.getScaledHeight() / 2 + 64, 0, 0, 128, 32, 128, 32); + GlStateManager.popMatrix(); + } + + @SubscribeEvent + public void onRender(RenderGameOverlayEvent e) { + if (e.type == RenderGameOverlayEvent.ElementType.ALL) { + draw(); + } + } +} diff --git a/src/main/java/me/night0721/lilase/utils/CurrentColor.java b/src/main/java/me/night0721/lilase/utils/CurrentColor.java new file mode 100644 index 0000000..07c15b2 --- /dev/null +++ b/src/main/java/me/night0721/lilase/utils/CurrentColor.java @@ -0,0 +1,76 @@ +package me.night0721.lilase.utils; + +import me.night0721.lilase.features.ah.AHConfig; + +import java.awt.*; + +/** + * @author Gabagooooooooooool (ily) + * @version 1.1 + * Basic utility for aurora theming engine. + */ + +public class CurrentColor { + public static int currentColorGet(float offset) { + switch (AHConfig.CRABBY_COLOR) { + case 0: + return getRainbow(-4000, (int) (offset * 3000)).getRGB(); + case 1: + return getGradientOffset(new Color(223, 94, 255), new Color(0, 170, 255).brighter(), Math.abs(System.currentTimeMillis() / 16L) / 100.0 + offset).getRGB(); + case 2: + return getGradientOffset(new Color(255, 0, 255), new Color(255, 255, 0), Math.abs(System.currentTimeMillis() / 16L) / 100.0 + offset).getRGB(); + case 3: + return getGradientOffset(new Color(0, 132, 99), new Color(255, 255, 99), Math.abs(System.currentTimeMillis() / 16L) / 100.0 + offset).getRGB(); + case 4: + return getGradientOffset(new Color(255, 0, 0), new Color(255, 255, 0), Math.abs(System.currentTimeMillis() / 16L) / 100.0 + offset).getRGB(); + case 5: + return getGradientOffset(new Color(0, 0, 255), new Color(0, 255, 132), Math.abs(System.currentTimeMillis() / 16L) / 100.0 + offset).getRGB(); + case 6: + return getGradientOffset(new Color(250, 250, 250), new Color(5, 5, 5), Math.abs(System.currentTimeMillis() / 16L) / 100.0 + offset).getRGB(); + case 7: + return getGradientOffset(new Color(231, 239, 239), new Color(16, 16, 24), Math.abs(System.currentTimeMillis() / 16L) / 100.0 + offset).getRGB(); + } + return Color.WHITE.getRGB(); + } + + public static float getFloatValue(float offset, int color){ + Color tempC = new Color(CurrentColor.currentColorGet(offset)); + int tempC_ = 0; + switch (color){ + case 0: + tempC_ = tempC.getRed(); + break; + case 1: + tempC_ = tempC.getGreen(); + break; + case 2: + tempC_ = tempC.getBlue(); + break; + + } + return (((float) tempC_) / 255F); + } + /** + * Following method has been circulating in Minecraft Hacking Community for a while, making it impossible to trace original author. + */ + protected static Color getGradientOffset(final Color color1, final Color color2, double offset) { + if (offset > 1.0) { + final double left = offset % 1.0; + final int off = (int)offset; + offset = ((off % 2 == 0) ? left : (1.0 - left)); + } + final double inverse_percent = 1.0 - offset; + final int redPart = (int)(color1.getRed() * inverse_percent + color2.getRed() * offset); + final int greenPart = (int)(color1.getGreen() * inverse_percent + color2.getGreen() * offset); + final int bluePart = (int)(color1.getBlue() * inverse_percent + color2.getBlue() * offset); + return new Color(redPart, greenPart, bluePart); + } + + /** + * Following method has been circulating in Minecraft Hacking Community for a while, making it impossible to trace original author. + */ + protected static Color getRainbow(final int speed, final int offset) { + float hue = (System.currentTimeMillis() + offset) % speed; + return Color.getHSBColor(hue / speed, 0.9f, 1f); + } +} \ No newline at end of file