Начинающий
Начинающий
- Статус
- Оффлайн
- Регистрация
- 13 Фев 2024
- Сообщения
- 56
- Реакции
- 2
- Выберите загрузчик игры
- Fabric
ребята гпт код фулл, мне было скучно, есть кривоватость
мб кому то зайдет, сорян если хуйня
targethud gpt code:
package sweetie.evaware.client.ui.widget.overlay;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.math.MathHelper;
import sweetie.evaware.api.event.events.render.Render2DEvent;
import sweetie.evaware.api.utils.animation.AnimationUtil;
import sweetie.evaware.api.utils.color.ColorUtil;
import sweetie.evaware.api.utils.color.UIColors;
import sweetie.evaware.api.utils.math.MathUtil;
import sweetie.evaware.api.utils.render.RenderUtil;
import sweetie.evaware.client.features.modules.combat.AuraModule;
import sweetie.evaware.client.ui.widget.Widget;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class TargetInfoWidget extends Widget {
public TargetInfoWidget() {
super(30f, 30f);
}
@Override
public String getName() {
return "Target info";
}
private final AnimationUtil showAnimation = new AnimationUtil();
private float healthAnimation = 0f;
private LivingEntity target;
private DrawContext drawContext;
@Override
public void render(Render2DEvent.Render2DEventData event) {
this.drawContext = event.context();
render(event.matrixStack());
}
@Override
public void render(MatrixStack ms) {
update();
LivingEntity pretendTarget = getTarget();
if (pretendTarget != null) target = pretendTarget;
if (showAnimation.getValue() <= 0.0 || target == null) return;
float anim = (float) showAnimation.getValue();
int fullAlpha = (int) (anim * 255f);
healthAnimation = MathHelper.clamp(
MathUtil.interpolate(healthAnimation, target.getHealth() / target.getMaxHealth(), 0.3f),
0f, 1f
);
float x = getDraggable().getX();
float y = getDraggable().getY();
float pad = scaled(3f);
float headSize = scaled(16f);
float fontSize = scaled(5.5f);
float hpFont = scaled(5f);
float barH = scaled(2.5f);
float itemSize = scaled(10f);
float itemGap = scaled(1.5f);
float gap = scaled(1.5f);
// items
List<ItemStack> items = new ArrayList<>();
if (target instanceof PlayerEntity player) {
items.add(player.getMainHandStack().copy());
items.add(player.getOffHandStack().copy());
List<ItemStack> armor = player.getInventory().armor;
for (int i = armor.size() - 1; i >= 0; i--) {
ItemStack s = armor.get(i);
if (!s.isEmpty() && s.getItem() != Items.AIR) items.add(s.copy());
}
}
items.removeIf(s -> s.isEmpty() || s.getItem() == Items.AIR);
String name = target.getName().getString();
String hpText = String.format("%.1f", target.getHealth() + target.getAbsorptionAmount()) + "hp";
float nameW = getMediumFont().getWidth(name, fontSize);
float hpW = getMediumFont().getWidth(hpText, hpFont);
// contentW must fit: name + gap + hp
float minContentW = nameW + scaled(4f) + hpW;
// also fit items row
float itemsRowW = items.isEmpty() ? 0f : items.size() * (itemSize + itemGap) - itemGap;
float contentW = Math.max(minContentW, Math.max(itemsRowW, scaled(40f)));
float itemsRowH = items.isEmpty() ? 0f : itemSize + itemGap;
float nameRowH = fontSize + gap;
float contentH = nameRowH + barH + (items.isEmpty() ? 0f : gap + itemsRowH);
float height = Math.max(headSize, contentH) + pad * 2f;
float width = pad + headSize + pad + contentW + pad;
Color bg = ColorUtil.setAlpha(new Color(12, 12, 18), fullAlpha);
RenderUtil.RECT.draw(ms, x, y, width, height, scaled(3f), bg);
// head
float headX = x + pad;
float headY = y + (height - headSize) / 2f;
if (target instanceof PlayerEntity player) {
RenderUtil.TEXTURE_RECT.drawHead(ms, player, headX, headY, headSize, headSize, scaled(0.5f), scaled(2f),
ColorUtil.setAlpha(Color.WHITE, fullAlpha));
} else {
getSemiBoldFont().drawCenteredText(ms, "?",
headX + headSize / 2f, headY + headSize / 2f - fontSize / 2f,
fontSize, UIColors.textColor(fullAlpha));
}
float cx = headX + headSize + pad;
float cy = y + (height - contentH) / 2f;
// name + hp on same row
getMediumFont().drawGradientText(ms, name, cx, cy, fontSize,
UIColors.primary(fullAlpha), UIColors.secondary(fullAlpha), nameW);
getMediumFont().drawText(ms, hpText,
x + width - pad - hpW,
cy + fontSize / 2f - hpFont / 2f,
hpFont, UIColors.inactiveTextColor(fullAlpha), 0f);
// health bar
float barY = cy + nameRowH;
float barW = contentW;
RenderUtil.RECT.draw(ms, cx, barY, barW, barH, barH * 0.4f,
ColorUtil.setAlpha(new Color(30, 30, 40), fullAlpha));
Color c1 = UIColors.primary(fullAlpha);
Color c2 = UIColors.secondary(fullAlpha);
RenderUtil.GRADIENT_RECT.draw(ms, cx, barY, barW * healthAnimation, barH, barH * 0.4f,
c1, c2, c1, c2);
// items
if (!items.isEmpty() && drawContext != null) {
float itemY = barY + barH + gap;
float scale = itemSize / 16f;
for (int i = 0; i < items.size(); i++) {
float itemX = cx + i * (itemSize + itemGap);
ms.push();
ms.translate(itemX, itemY, 150f);
ms.scale(scale, scale, 1f);
DiffuseLighting.disableGuiDepthLighting();
RenderSystem.setShaderColor(1f, 1f, 1f, anim);
drawContext.drawItem(items.get(i), 0, 0);
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
ms.pop();
}
}
getDraggable().setWidth(width);
getDraggable().setHeight(height);
}
private void update() {
showAnimation.update();
showAnimation.run(getTarget() != null ? 1.0 : 0.0, getDuration(), getEasing());
}
private LivingEntity getTarget() {
AuraModule aura = AuraModule.getInstance();
if (aura.isEnabled() && aura.target != null) return aura.target;
if (mc.currentScreen instanceof ChatScreen) return mc.player;
return null;
}
}
мб кому то зайдет, сорян если хуйня