Начинающий
- Статус
- Оффлайн
- Регистрация
- 15 Фев 2024
- Сообщения
- 41
- Реакции
- 0
Рассказываю короче решил я клик гуи переписать и походу я случайно нажал сделать что то статичным хз не помню уже и у меня нахуй бац colorutil не находит я думал я класс удалил, а нет он был на месте потом чото фикшу и ПОТОМ НАХУЙ ЕЩЁ БОЛЬШЕ ТАК ЕЩЁ И КЛАСС КОТОРЫЙ Я ЗАФИКСИЛ ТОЖЕ ТЕПЕРЬ НЕ НАХОДИТ я хз нечего плохого не пишет и тд бля мне лень переделывать помогите и даже когда я просто импортировал класс и всё было ок всё ровно пишет что colorutil не найден
colorutils
colorutils
Код:
package org.excellent.client.utils.render.color;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.experimental.UtilityClass;
import net.minecraft.util.math.MathHelper;
import org.excellent.client.managers.module.impl.client.Theme;
import org.excellent.client.utils.math.Interpolator;
import org.excellent.common.impl.fastrandom.FastRandom;
import java.awt.*;
import java.util.concurrent.*;
@SuppressWarnings("unused")
@UtilityClass
public class ColorUtil {
private final FastRandom RANDOM = new FastRandom();
private final long CACHE_EXPIRATION_TIME = 60 * 1000;
private final ConcurrentHashMap<ColorKey, CacheEntry> colorCache = new ConcurrentHashMap<>();
private final ScheduledExecutorService cacheCleaner = Executors.newScheduledThreadPool(1);
private final DelayQueue<CacheEntry> cleanupQueue = new DelayQueue<>();
static {
cacheCleaner.scheduleWithFixedDelay(() -> {
CacheEntry entry = cleanupQueue.poll();
while (entry != null) {
if (entry.isExpired()) {
colorCache.remove(entry.getKey());
}
entry = cleanupQueue.poll();
}
}, 0, 1, TimeUnit.SECONDS);
}
public final int RED = getColor(255, 0, 0);
public final int GREEN = getColor(0, 255, 0);
public final int BLUE = getColor(0, 0, 255);
public final int YELLOW = getColor(255, 255, 0);
public final int WHITE = getColor(255);
public final int BLACK = getColor(0);
public int red(int c) {
return (c >> 16) & 0xFF;
}
public int green(int c) {
return (c >> 8) & 0xFF;
}
public int blue(int c) {
return c & 0xFF;
}
public int alpha(int c) {
return (c >> 24) & 0xFF;
}
public float redf(int c) {
return red(c) / 255.0f;
}
public float greenf(int c) {
return green(c) / 255.0f;
}
public float bluef(int c) {
return blue(c) / 255.0f;
}
public float alphaf(int c) {
return alpha(c) / 255.0f;
}
public int[] getRGBA(int c) {
return new int[]{red(c), green(c), blue(c), alpha(c)};
}
public int[] getRGB(int c) {
return new int[]{red(c), green(c), blue(c)};
}
public float[] getRGBAf(int c) {
return new float[]{redf(c), greenf(c), bluef(c), alphaf(c)};
}
public float[] getRGBf(int c) {
return new float[]{redf(c), greenf(c), bluef(c)};
}
public int getColor(float red, float green, float blue, float alpha) {
return getColor(Math.round(red * 255), Math.round(green * 255), Math.round(blue * 255), Math.round(alpha * 255));
}
public int getColor(int red, int green, int blue, float alpha) {
return getColor(red, green, blue, Math.round(alpha * 255));
}
public int getColor(float red, float green, float blue) {
return getColor(red, green, blue, 1.0F);
}
public int getColor(int brightness, int alpha) {
return getColor(brightness, brightness, brightness, alpha);
}
public int getColor(int brightness, float alpha) {
return getColor(brightness, Math.round(alpha * 255));
}
public int getColor(int brightness) {
return getColor(brightness, brightness, brightness);
}
public int replAlpha(int color, int alpha) {
return getColor(red(color), green(color), blue(color), alpha);
}
public int replAlpha(int color, float alpha) {
return getColor(red(color), green(color), blue(color), alpha);
}
public int multAlpha(int color, float percent01) {
return getColor(red(color), green(color), blue(color), Math.round(alpha(color) * percent01));
}
public int multDark(int color, float percent01) {
return getColor(
Math.round(red(color) * percent01),
Math.round(green(color) * percent01),
Math.round(blue(color) * percent01),
alpha(color)
);
}
public int multBright(int color, float percent01) {
return getColor(
Math.min(255, Math.round(red(color) / percent01)),
Math.min(255, Math.round(green(color) / percent01)),
Math.min(255, Math.round(blue(color) / percent01)),
alpha(color)
);
}
public int overCol(int color1, int color2, float percent01) {
final float percent = MathHelper.clamp(percent01, 0F, 1F);
return getColor(
Interpolator.lerp(red(color1), red(color2), percent),
Interpolator.lerp(green(color1), green(color2), percent),
Interpolator.lerp(blue(color1), blue(color2), percent),
Interpolator.lerp(alpha(color1), alpha(color2), percent)
);
}
public int overCol(int color1, int color2) {
return overCol(color1, color2, 0.5f);
}
public int[] genGradientForText(int color1, int color2, int length) {
int[] gradient = new int[length];
for (int i = 0; i < length; i++) {
float pc = (float) i / (length - 1);
gradient[i] = overCol(color1, color2, pc);
}
return gradient;
}
public int randomColor() {
return Color.HSBtoRGB(RANDOM.nextFloat(), 0.5F + (RANDOM.nextFloat() / 2F), 1F);
}
public int rainbow(int speed, int index, float saturation, float brightness, float opacity) {
int angle = (int) ((System.currentTimeMillis() / speed + index) % 360);
float hue = angle / 360f;
int color = Color.HSBtoRGB(hue, saturation, brightness);
return getColor(red(color), green(color), blue(color), Math.round(opacity * 255));
}
public int fade(int speed, int index, int first, int second) {
int angle = (int) ((System.currentTimeMillis() / speed + index) % 360);
angle = angle >= 180 ? 360 - angle : angle;
return overCol(first, second, angle / 180f);
}
public int fade(int index) {
Theme theme = Theme.getInstance();
return fade(theme.getSpeed(), index, theme.clientColor(), theme.darkColor());
}
public int getColor(int red, int green, int blue, int alpha) {
ColorKey key = new ColorKey(red, green, blue, alpha);
CacheEntry cacheEntry = colorCache.computeIfAbsent(key, k -> {
CacheEntry newEntry = new CacheEntry(k, computeColor(red, green, blue, alpha), CACHE_EXPIRATION_TIME);
cleanupQueue.offer(newEntry);
return newEntry;
});
return cacheEntry.getColor();
}
public int getColor(int red, int green, int blue) {
return getColor(red, green, blue, 255);
}
private int computeColor(int red, int green, int blue, int alpha) {
return ((MathHelper.clamp(alpha, 0, 255) << 24) |
(MathHelper.clamp(red, 0, 255) << 16) |
(MathHelper.clamp(green, 0, 255) << 8) |
MathHelper.clamp(blue, 0, 255));
}
private String generateKey(int red, int green, int blue, int alpha) {
return red + "," + green + "," + blue + "," + alpha;
}
@Getter
@RequiredArgsConstructor
@EqualsAndHashCode
private static class ColorKey {
final int red, green, blue, alpha;
}
@Getter
private static class CacheEntry implements Delayed {
private final ColorKey key;
private final int color;
private final long expirationTime;
CacheEntry(ColorKey key, int color, long ttl) {
this.key = key;
this.color = color;
this.expirationTime = System.currentTimeMillis() + ttl;
}
@Override
public long getDelay(TimeUnit unit) {
long delay = expirationTime - System.currentTimeMillis();
return unit.convert(delay, TimeUnit.MILLISECONDS);
}
@Override
public int compareTo(Delayed other) {
if (other instanceof CacheEntry) {
return Long.compare(this.expirationTime, ((CacheEntry) other).expirationTime);
}
return 0;
}
public boolean isExpired() {
return System.currentTimeMillis() > expirationTime;
}
}
public void shutdownCacheCleaner() {
cacheCleaner.shutdown();
}
}