Backported to 1.21(.1)

This commit is contained in:
maloryware
2025-01-27 09:11:43 +00:00
parent 2c92bf30a0
commit 6aa053665f
3 changed files with 14 additions and 11 deletions

View File

@@ -37,11 +37,14 @@ public abstract class MixinOptionsScreen extends Screen {
}
}
@Inject(at = @At("TAIL"), method = "refreshWidgetPositions")
@Inject(at = @At("TAIL"), method = "initTabNavigation")
public void midnightlib$onResize(CallbackInfo ci) {
if (shouldShowButton()) this.midnightlib$setButtonPos();
}
@Unique
public void midnightlib$setButtonPos() {
midnightlib$button.setPosition(layout.getWidth() / 2 + 158, layout.getY() + layout.getFooterHeight() - 4);

View File

@@ -251,9 +251,9 @@ public abstract class MidnightConfig {
if (prevTab != null && prevTab != tabManager.getCurrentTab()) {
prevTab = tabManager.getCurrentTab();
this.list.clear(); fillList();
list.setScrollY(0);
list.setScrollAmount(0);
}
scrollProgress = list.getScrollY();
scrollProgress = list.getScrollAmount();
for (EntryInfo info : entries) try {info.field.set(null, info.value);} catch (IllegalAccessException ignored) {}
updateButtons();
}
@@ -395,7 +395,7 @@ public abstract class MidnightConfig {
}
this.list.addButton(widgets, name, info);
} else this.list.addButton(List.of(), name, info);
} list.setScrollY(scrollProgress);
} list.setScrollAmount(scrollProgress);
updateButtons();
}
}
@@ -423,7 +423,7 @@ public abstract class MidnightConfig {
protected void drawHeaderAndFooterSeparators(DrawContext context) {
if (renderHeaderSeparator) super.drawHeaderAndFooterSeparators(context);
else { RenderSystem.enableBlend();
context.drawTexture(RenderLayer::getGuiTextured, this.client.world == null ? Screen.FOOTER_SEPARATOR_TEXTURE : Screen.INWORLD_FOOTER_SEPARATOR_TEXTURE, this.getX(), this.getBottom(), 0.0F, 0.0F, this.getWidth(), 2, 32, 2);
context.drawTexture(this.client.world == null ? Screen.FOOTER_SEPARATOR_TEXTURE : Screen.INWORLD_FOOTER_SEPARATOR_TEXTURE, this.getX(), this.getBottom(), 0.0F, 0.0F, this.getWidth(), 2, 32, 2);
RenderSystem.disableBlend(); }
}
public void addButton(List<ClickableWidget> buttons, Text text, EntryInfo info) { this.addEntry(new ButtonEntry(buttons, text, info)); }