Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/main/java/net/vulkanmod/config/gui/widget/ModIconWidget.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package net.vulkanmod.config.gui.widget;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.renderer.RenderPipelines;
import net.minecraft.client.sounds.SoundManager;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.resources.Identifier;
Expand All @@ -22,19 +24,26 @@ public ModIconWidget(FormattedText name, Identifier icon, int x0, int y0, int wi
this.height = height;
}

@Override
public void playDownSound(SoundManager soundManager) {
}

public void render(double mX, double mY) {
int backgroundColor = ColorUtil.ARGB.multiplyAlpha(VGuiConstants.COLOR_BLACK, 0.6f);
int width = this.width;
int height = this.height;
GuiRenderer.fill(this.x, this.y, this.x + width, this.y + height, backgroundColor);


int size = this.height - 4;
int iconSize = this.height - 4;
int iconX = this.x + 4;
int iconY = this.y + (height - size) / 2;
GuiRenderer.guiGraphics.blit(RenderPipelines.GUI_TEXTURED, icon, iconX, iconY, 0f, 0f, size, size, size, size);
int iconY = this.y + (height - iconSize) / 2;
GuiRenderer.guiGraphics.blit(RenderPipelines.GUI_TEXTURED, icon, iconX, iconY, 0f, 0f, iconSize, iconSize, iconSize, iconSize);
Font textRenderer = Minecraft.getInstance().font;

int size = this.height;
int maxWidth = this.width - iconSize - 8;

size = this.height;
GuiRenderer.drawString(Minecraft.getInstance().font, (Component) this.name, this.x + 6 + size, this.y + this.height / 2 - 4, 0xffffffff);
GuiRenderer.drawScrollingString(textRenderer, (Component) this.name, this.x + size + maxWidth / 2 + 3, this.y + this.height / 2 - 4, maxWidth - 4, 0xffffffff);
}
}