Начинающий
- Статус
- Оффлайн
- Регистрация
- 24 Ноя 2023
- Сообщения
- 64
- Реакции
- 0
- Выберите загрузчик игры
- Vanilla
пастеры уже как полгода не могут сделать кулдауны, вот им подгон
ss
Java:
package alpha.night.ui.display.impl;
import alpha.night.NightDLS;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import alpha.night.events.EventDisplay;
import alpha.night.modules.api.ModuleManager;
import alpha.night.modules.impl.render.HUD;
import alpha.night.modules.impl.render.Theme;
import alpha.night.ui.display.ElementRenderer;
import alpha.night.utils.animations.Animation;
import alpha.night.utils.animations.Direction;
import alpha.night.utils.animations.easing.CompactAnimation;
import alpha.night.utils.animations.easing.Easing;
import alpha.night.utils.animations.impl.EaseBackIn;
import alpha.night.utils.drag.Dragging;
import alpha.night.utils.render.GaussianBlur;
import alpha.night.utils.render.color.ColorUtils;
import alpha.night.utils.render.font.Fonts;
import alpha.night.utils.render.gl.Scissor;
import alpha.night.utils.render.rect.RenderUtility;
import alpha.night.utils.text.GradientUtil;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.multiplayer.PlayerController;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.text.ITextComponent;
@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class CooldownsRenderer implements ElementRenderer {
final Dragging dragging;
final CompactAnimation widthAnimation = new CompactAnimation(Easing.EASE_OUT_QUART, 100);
final CompactAnimation heightAnimation = new CompactAnimation(Easing.EASE_OUT_QUART, 100);
final Animation animation = new EaseBackIn(350, 1, 1);
float width;
float height;
@Override
public void render(EventDisplay eventDisplay) {
MatrixStack ms = eventDisplay.getMatrixStack();
float posX = dragging.getX();
float posY = dragging.getY();
float fontSize = 6.5f;
float padding = 5;
boolean shouldRender = false;
Item[] trackedItems = {
Items.ENDER_PEARL,
Items.SHIELD,
Items.CROSSBOW,
Items.DRIED_KELP,
Items.ENDER_EYE,
Items.NETHERITE_SCRAP,
Items.GOLDEN_APPLE,
Items.ENCHANTED_GOLDEN_APPLE
};
for (Item item : trackedItems) {
if (hasCooldown(item)) {
shouldRender = true;
break;
}
}
if (mc.currentScreen instanceof ChatScreen) {
shouldRender = true;
}
animation.setDirection(shouldRender ? Direction.FORWARDS : Direction.BACKWARDS);
animation.setDuration(200);
ITextComponent title = GradientUtil.gradient(" Cooldowns");
ITextComponent icon = GradientUtil.gradient(" T");
GlStateManager.pushMatrix();
sizeAnimation(posX + (width / 2), posY + (height / 2), animation.getOutput());
drawStyledRect(posX, posY, width, height, 3.5f);
Scissor.push();
Scissor.setFromComponentCoordinates(posX, posY, width, height);
// Сдвигаем заголовок чуть правее
Fonts.sfuy.drawCenteredText(ms, title, posX + width / 4.1f, posY + padding - 0.9f, 7.4f);
Fonts.icons2.drawCenteredText(ms, icon, posX + width / 1.15f, posY + padding - 0.4f, 7.5f);
// Разделительная линия
float separatorY = posY + fontSize + padding * 1.6f;
RenderUtility.drawRect(posX + 4, separatorY, posX + width - 4, separatorY + 0.7f, ColorUtils.setAlpha(Theme.RectColor(0), 60));
posY += fontSize + padding * 2.1f + 3f;
float maxWidth = Fonts.sfuy.getWidth(title, fontSize) + padding * 2;
float localHeight = fontSize + padding * 2f;
for (Item item : trackedItems) {
if (!hasCooldown(item)) continue;
float cooldown = getItemCooldown(item);
int ticksLeft = (int)(cooldown * 20);
String name = getItemDisplayName(item);
String time = String.format("%.1fs", ticksLeft / 20.0f);
float nameWidth = Fonts.sfuy.getWidth(name, fontSize);
float timeWidth = Fonts.sfuy.getWidth(time, fontSize);
float localWidth = nameWidth + timeWidth + padding * 3;
Fonts.sfuy.drawText(ms, name, posX + padding, posY - 2.6f, ColorUtils.rgba(255, 255, 255, 255), 7);
Fonts.sfuy.drawText(ms, time, posX + width - timeWidth - padding, posY - 2.2f, ColorUtils.rgba(255, 255, 255, 255), 7);
if (localWidth > maxWidth) {
maxWidth = localWidth;
}
posY += (fontSize + padding) + 1;
localHeight += (fontSize + padding) + 1;
}
GlStateManager.popMatrix();
Scissor.unset();
Scissor.pop();
widthAnimation.run(Math.max(maxWidth, 73));
width = (float) widthAnimation.getValue();
heightAnimation.run(localHeight);
height = (float) heightAnimation.getValue();
dragging.setWidth(width);
dragging.setHeight(height);
}
private boolean hasCooldown(Item item) {
if (mc.isSingleplayer()) {
return mc.player.getCooldownTracker().hasCooldown(item);
} else {
return mc.player.getCooldownTracker().hasCooldown(item);
}
}
private float getItemCooldown(Item item) {
if (mc.isSingleplayer()) {
return mc.player.getCooldownTracker().getCooldown(item, 0);
} else {
return mc.player.getCooldownTracker().getCooldown(item, 0);
}
}
private String getItemDisplayName(Item item) {
if (item == Items.GOLDEN_APPLE) {
return "Гепл";
} else if (item == Items.ENCHANTED_GOLDEN_APPLE) {
return "Чарка";
}
return new ItemStack(item).getDisplayName().getString();
}
private void drawStyledRect(float x, float y, float width, float height, float radius) {
ModuleManager moduleManager = NightDLS.getInstance().getModuleManager();
HUD hud = moduleManager.getHud();
int fillColor = hud.blur.get()
? ColorUtils.rgba(5, 5, 5, 150)
: ColorUtils.rgba(5, 5, 5, 200);
int overlayColor = ColorUtils.setAlpha(Theme.RectColor(0), 30);
if (hud.blur.get()) {
GaussianBlur.startBlur();
RenderUtility.drawRoundedRect(x, y, width, height, radius, overlayColor);
GaussianBlur.endBlur(8, 1);
RenderUtility.drawRoundedRect(x, y, width, height, radius, fillColor);
RenderUtility.drawRoundedRect(x, y, width, height, radius, overlayColor);
} else {
RenderUtility.drawRoundedRect(x, y, width, height, radius, fillColor);
RenderUtility.drawRoundedRect(x, y, width, height, radius, overlayColor);
}
RenderUtility.drawRoundedOutline(x, y, width, height, radius, 1.0f, Theme.RectColor(0));
}
public static void sizeAnimation(double width, double height, double scale) {
GlStateManager.translated(width, height, 0);
GlStateManager.scaled(scale, scale, scale);
GlStateManager.translated(-width, -height, 0);
}
}
ss