Начинающий
- Статус
- Оффлайн
- Регистрация
- 6 Окт 2024
- Сообщения
- 142
- Реакции
- 0
- Выберите загрузчик игры
- Прочие моды
Ну кароче это просто выводит то что в шалкере находиться когда он в руке работает и в левой и в правой ( через худ )
SS
Пастим:
package yume.fun.ui.display.impl;
import yume.fun.events.EventDisplay;
import yume.fun.events.EventUpdate;
import yume.fun.ui.display.ElementRenderer;
import yume.fun.utils.drag.Dragging;
import yume.fun.utils.render.ColorUtils;
import yume.fun.utils.render.DisplayUtils;
import yume.fun.utils.render.font.Fonts;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.util.text.TextFormatting;
import java.util.Arrays;
import java.util.List;
@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class ShulkerRenderer implements ElementRenderer {
final Dragging drag;
boolean shouldRender = false;
ItemStack currentShulker = ItemStack.EMPTY;
final ItemStack[] shulkerContents = new ItemStack[27];
final List<Item> shulkerBoxes = Arrays.asList(
Items.SHULKER_BOX,
Items.WHITE_SHULKER_BOX,
Items.ORANGE_SHULKER_BOX,
Items.MAGENTA_SHULKER_BOX,
Items.LIGHT_BLUE_SHULKER_BOX,
Items.YELLOW_SHULKER_BOX,
Items.LIME_SHULKER_BOX,
Items.PINK_SHULKER_BOX,
Items.GRAY_SHULKER_BOX,
Items.LIGHT_GRAY_SHULKER_BOX,
Items.CYAN_SHULKER_BOX,
Items.PURPLE_SHULKER_BOX,
Items.BLUE_SHULKER_BOX,
Items.BROWN_SHULKER_BOX,
Items.GREEN_SHULKER_BOX,
Items.RED_SHULKER_BOX,
Items.BLACK_SHULKER_BOX
);
@Override
public void render(EventDisplay eventDisplay) {
updateShulkerState();
if (!shouldRender) return;
float x = drag.getX();
float y = drag.getY();
float padding = 5;
float slotSize = 16;
float panelWidth = 9 * slotSize + padding * 2;
float panelHeight = 3 * slotSize + padding * 2;
drag.setWidth(panelWidth);
drag.setHeight(panelHeight);
DisplayUtils.drawRoundedRect(x - 1.3f, y - 1.3f, panelWidth + 2.8f, panelHeight + 2.8f, 5, ColorUtils.rgb(46, 45, 58));
DisplayUtils.drawRoundedRect(x - 0.5f, y - 0.5f, panelWidth + 1f, panelHeight + 1f, 4, ColorUtils.rgb(9, 8, 23));
DisplayUtils.drawRoundedRect(x, y, panelWidth, panelHeight, 3, ColorUtils.rgba(20, 19, 30, 240));
// Если хочешь заголовок шалкера вруби это
// renderShulkerTitle(eventDisplay, x, y, panelWidth);
renderShulkerItems(eventDisplay, x + padding, y + padding);
}
private void updateShulkerState() {
shouldRender = false;
ItemStack mainHand = mc.player.getHeldItemMainhand();
if (isShulkerBox(mainHand)) {
currentShulker = mainHand;
shouldRender = true;
}
if (!shouldRender) {
ItemStack offHand = mc.player.getHeldItemOffhand();
if (isShulkerBox(offHand)) {
currentShulker = offHand;
shouldRender = true;
}
}
if (shouldRender) {
loadShulkerContents();
} else {
currentShulker = ItemStack.EMPTY;
}
}
private boolean isShulkerBox(ItemStack stack) {
if (stack.isEmpty()) return false;
return shulkerBoxes.contains(stack.getItem());
}
private void loadShulkerContents() {
for (int i = 0; i < 27; i++) {
shulkerContents[i] = ItemStack.EMPTY;
}
if (currentShulker.isEmpty() || !currentShulker.hasTag()) return;
CompoundNBT tag = currentShulker.getTag();
if (tag.contains("BlockEntityTag", 10)) {
CompoundNBT blockEntityTag = tag.getCompound("BlockEntityTag");
if (blockEntityTag.contains("Items", 9)) {
ListNBT items = blockEntityTag.getList("Items", 10);
for (int i = 0; i < items.size(); i++) {
CompoundNBT itemTag = items.getCompound(i);
int slot = itemTag.getByte("Slot") & 255;
if (slot >= 0 && slot < 27) {
shulkerContents[slot] = ItemStack.read(itemTag);
}
}
}
}
}
private void renderShulkerTitle(EventDisplay eventDisplay, float x, float y, float width) {
String shulkerName = getShulkerDisplayName();
float titleWidth = Fonts.sfui.getWidth(shulkerName, 8);
float titleX = x + (width - titleWidth) / 2;
float titleY = y - 10;
DisplayUtils.drawRoundedRect(titleX - 3, titleY - 1, titleWidth + 6, 9, 2, ColorUtils.rgb(9, 8, 23));
DisplayUtils.drawRoundedRect(titleX - 2, titleY, titleWidth + 4, 7, 1, ColorUtils.rgb(46, 45, 58));
Fonts.sfui.drawText(eventDisplay.getMatrixStack(), shulkerName, titleX, titleY, ColorUtils.rgb(255, 255, 255), 8);
}
private String getShulkerDisplayName() {
if (currentShulker.hasDisplayName()) {
return currentShulker.getDisplayName().getString();
}
Item shulkerItem = currentShulker.getItem();
TextFormatting color = getShulkerColor(shulkerItem);
return color + "Shulker Box";
}
private TextFormatting getShulkerColor(Item shulkerItem) {
if (shulkerItem == Items.WHITE_SHULKER_BOX) return TextFormatting.WHITE;
if (shulkerItem == Items.ORANGE_SHULKER_BOX) return TextFormatting.GOLD;
if (shulkerItem == Items.MAGENTA_SHULKER_BOX) return TextFormatting.LIGHT_PURPLE;
if (shulkerItem == Items.LIGHT_BLUE_SHULKER_BOX) return TextFormatting.AQUA;
if (shulkerItem == Items.YELLOW_SHULKER_BOX) return TextFormatting.YELLOW;
if (shulkerItem == Items.LIME_SHULKER_BOX) return TextFormatting.GREEN;
if (shulkerItem == Items.PINK_SHULKER_BOX) return TextFormatting.LIGHT_PURPLE;
if (shulkerItem == Items.GRAY_SHULKER_BOX) return TextFormatting.DARK_GRAY;
if (shulkerItem == Items.LIGHT_GRAY_SHULKER_BOX) return TextFormatting.GRAY;
if (shulkerItem == Items.CYAN_SHULKER_BOX) return TextFormatting.DARK_AQUA;
if (shulkerItem == Items.PURPLE_SHULKER_BOX) return TextFormatting.DARK_PURPLE;
if (shulkerItem == Items.BLUE_SHULKER_BOX) return TextFormatting.BLUE;
if (shulkerItem == Items.BROWN_SHULKER_BOX) return TextFormatting.GOLD;
if (shulkerItem == Items.GREEN_SHULKER_BOX) return TextFormatting.DARK_GREEN;
if (shulkerItem == Items.RED_SHULKER_BOX) return TextFormatting.RED;
if (shulkerItem == Items.BLACK_SHULKER_BOX) return TextFormatting.BLACK;
return TextFormatting.LIGHT_PURPLE;
}
private void renderShulkerItems(EventDisplay eventDisplay, float baseX, float baseY) {
float slotSize = 16;
int slot = 0;
for (int row = 0; row < 3; row++) {
for (int col = 0; col < 9; col++) {
ItemStack item = shulkerContents[slot];
if (!item.isEmpty()) {
renderItemStack(eventDisplay, item, baseX + col * slotSize, baseY + row * slotSize);
}
slot++;
}
}
}
private void renderItemStack(EventDisplay eventDisplay, ItemStack stack, float x, float y) {
mc.getItemRenderer().renderItemAndEffectIntoGUI(stack, (int) x, (int) y);
mc.getItemRenderer().renderItemOverlays(mc.fontRenderer, stack, (int) x, (int) y);
if (stack.getCount() > 1) {
String countText = String.valueOf(stack.getCount());
float countX = x + 16 - Fonts.sfui.getWidth(countText, 7);
float countY = y + 8;
Fonts.sfui.drawText(eventDisplay.getMatrixStack(), countText, countX, countY, ColorUtils.rgb(255, 255, 255), 7);
}
if (stack.isDamageable() && stack.isDamaged()) {
float damagePercent = (float) (stack.getMaxDamage() - stack.getDamage()) / stack.getMaxDamage();
float barWidth = 14 * damagePercent;
int color = getDurabilityColor(damagePercent);
DisplayUtils.drawRect(x + 1, y + 15, barWidth, 1, color);
}
}
private int getDurabilityColor(float percent) {
if (percent > 0.6) return ColorUtils.rgb(0, 255, 0);
if (percent > 0.3) return ColorUtils.rgb(255, 255, 0);
return ColorUtils.rgb(255, 0, 0);
}
public void update(EventUpdate e) {
}
}

