1
mirror of https://github.com/Shiewk/Widgets.git synced 2026-04-28 11:34:17 +02:00

Support latest changes for 1.21.4 (2.3.0) (#4)

This commit is contained in:
Shy
2026-01-05 17:35:24 +01:00
parent 13bad05776
commit a93d8ee398
52 changed files with 1875 additions and 353 deletions
@@ -3,6 +3,7 @@ package de.shiewk.widgets.utils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.tick.TickManager;
import java.util.function.BooleanSupplier;
@@ -35,4 +36,25 @@ public class WidgetUtils {
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(ev, 1f, 1f));
}
public static int fadeColor(int color1, int color2, double delta) {
int alpha = (int) MathHelper.lerp(delta, (color1 >> 24) & 0xff, (color2 >> 24) & 0xff);
int red = (int) MathHelper.lerp(delta, (color1 >> 16) & 0xff, (color2 >> 16) & 0xff);
int green = (int) MathHelper.lerp(delta, (color1 >> 8) & 0xff, (color2 >> 8) & 0xff);
int blue = (int) MathHelper.lerp(delta, color1 & 0xff, color2 & 0xff);
return (alpha << 24) | (red << 16) | (green << 8) | blue;
}
public static String colorARGBToHexRGBA(int color) {
int a = color >> 24 & 0xff;
int r = color >> 16 & 0xff;
int g = color >> 8 & 0xff;
int b = color & 0xff;
return toHexSingle(r) + toHexSingle(g) + toHexSingle(b) + toHexSingle(a);
}
private static String toHexSingle(int comp){
String s = Integer.toHexString(comp);
return "0".repeat(2 - s.length()) + s;
}
}