@@ -40,7 +40,7 @@ public class ScrollableTextWidget extends Widget<ScrollableTextWidget>
4040 private Object lastIngredient ;
4141
4242 private final ScrollArea scroll = new ScrollArea ();
43- private final TextRenderer renderer = new TextRenderer ();
43+ private final TextRenderer renderer = new ScrollingTextRenderer ();
4444
4545 public ScrollableTextWidget () {
4646 listenGuiAction ((IGuiAction .MouseReleased ) mouseButton -> {
@@ -174,17 +174,6 @@ private void drawText(ModularGuiContext context) {
174174 }
175175 this .dirty = false ;
176176 }
177- // center and bottom alignments cause issues with the text renderer
178- // when drawing in a scrolling context
179- // they draw the text higher than expected
180- if (this .text .getAlignment ().y > 0f ) { // not top
181- int type = (int ) (this .text .getAlignment ().x * 2 );
182- switch (type ) {
183- case 1 -> this .text .alignment (Alignment .TopCenter );
184- case 2 -> this .text .alignment (Alignment .TopRight );
185- default -> this .text .alignment (Alignment .TopLeft );
186- }
187- }
188177 this .text .setupRenderer (this .renderer , getArea ().getPadding ().left , getArea ().getPadding ().top - getScrollY (),
189178 getArea ().paddedWidth (), getArea ().paddedHeight (),
190179 getWidgetTheme (context .getTheme ()).getTextColor (),
@@ -240,4 +229,20 @@ public ScrollableTextWidget textBuilder(Consumer<RichText> builder) {
240229 public @ Nullable Object getIngredient () {
241230 return this .lastIngredient ;
242231 }
232+
233+ public static class ScrollingTextRenderer extends TextRenderer {
234+
235+ public int getLastY () {
236+ return (int ) lastY ;
237+ }
238+
239+ public int getLastX () {
240+ return (int ) lastX ;
241+ }
242+
243+ @ Override
244+ protected int getStartY (float height ) {
245+ return this .y ; // always draw at the top
246+ }
247+ }
243248}
0 commit comments