Skip to content

Commit f768a75

Browse files
amiralimollaeixCollateral
authored andcommitted
fix bugs in ModIconWidget
1 parent 7f69043 commit f768a75

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

‎src/main/java/net/vulkanmod/config/gui/widget/ModIconWidget.java‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package net.vulkanmod.config.gui.widget;
22

33
import net.minecraft.client.Minecraft;
4+
import net.minecraft.client.gui.Font;
45
import net.minecraft.client.renderer.RenderPipelines;
6+
import net.minecraft.client.sounds.SoundManager;
57
import net.minecraft.network.chat.Component;
68
import net.minecraft.network.chat.FormattedText;
79
import net.minecraft.resources.Identifier;
@@ -22,19 +24,26 @@ public ModIconWidget(FormattedText name, Identifier icon, int x0, int y0, int wi
2224
this.height = height;
2325
}
2426

27+
@Override
28+
public void playDownSound(SoundManager soundManager) {
29+
}
30+
2531
public void render(double mX, double mY) {
2632
int backgroundColor = ColorUtil.ARGB.multiplyAlpha(VGuiConstants.COLOR_BLACK, 0.6f);
2733
int width = this.width;
2834
int height = this.height;
2935
GuiRenderer.fill(this.x, this.y, this.x + width, this.y + height, backgroundColor);
3036

3137

32-
int size = this.height - 4;
38+
int iconSize = this.height - 4;
3339
int iconX = this.x + 4;
34-
int iconY = this.y + (height - size) / 2;
35-
GuiRenderer.guiGraphics.blit(RenderPipelines.GUI_TEXTURED, icon, iconX, iconY, 0f, 0f, size, size, size, size);
40+
int iconY = this.y + (height - iconSize) / 2;
41+
GuiRenderer.guiGraphics.blit(RenderPipelines.GUI_TEXTURED, icon, iconX, iconY, 0f, 0f, iconSize, iconSize, iconSize, iconSize);
42+
Font textRenderer = Minecraft.getInstance().font;
43+
44+
int size = this.height;
45+
int maxWidth = this.width - iconSize - 8;
3646

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

0 commit comments

Comments
 (0)