调整了样板供应器页码显示的位置

This commit is contained in:
GaLi 2025-08-08 23:19:41 +08:00
parent 5c58f9884c
commit 80d281de95

View File

@ -56,8 +56,9 @@ public abstract class GuiExPatternProviderMixin extends PatternProviderScreen<Co
// 获取ae通用界面样式 // 获取ae通用界面样式
int color = screenStyle.getColor(PaletteColor.DEFAULT_TEXT_COLOR).toARGB(); int color = screenStyle.getColor(PaletteColor.DEFAULT_TEXT_COLOR).toARGB();
// 调整页码显示位置"样板"文字的右边
guiGraphics.drawString(font, Component.literal("" + (currentPage + 1) + "/" + maxPage + ""), guiGraphics.drawString(font, Component.literal("" + (currentPage + 1) + "/" + maxPage + ""),
leftPos + imageWidth / 2 - 30, topPos + 5, color, false); leftPos + 8 + 50, topPos + 30, color, false);
} }
} }
@ -80,10 +81,10 @@ public abstract class GuiExPatternProviderMixin extends PatternProviderScreen<Co
fieldMaxPage.setAccessible(true); fieldMaxPage.setAccessible(true);
Integer maxPage = (Integer) fieldMaxPage.get(menu1); Integer maxPage = (Integer) fieldMaxPage.get(menu1);
// 更新按钮可见性 // 更新按钮可见性 - 始终显示支持循环翻页
if (nextPage != null && prevPage != null) { if (nextPage != null && prevPage != null) {
this.nextPage.setVisibility(page + 1 < maxPage); this.nextPage.setVisibility(true);
this.prevPage.setVisibility(page - 1 >= 0); this.prevPage.setVisibility(true);
} }
// 调整槽位位置 // 调整槽位位置
@ -191,31 +192,30 @@ public abstract class GuiExPatternProviderMixin extends PatternProviderScreen<Co
// 前进后退按钮 // 前进后退按钮
this.prevPage = new ActionEPPButton((b) -> { this.prevPage = new ActionEPPButton((b) -> {
int currentPage = getCurrentPage(); int currentPage = getCurrentPage();
if (currentPage > 0) { int maxPage = getMaxPage();
// 发送网络包更新页码 // 循环翻页第一页向前翻到最后一页
// 这里简化处理直接调用setPage方法 int newPage = (currentPage - 1 + maxPage) % maxPage;
try { try {
ContainerExPatternProvider menu1 = this.getMenu(); ContainerExPatternProvider menu1 = this.getMenu();
java.lang.reflect.Method setPageMethod = menu1.getClass().getMethod("setPage", int.class); java.lang.reflect.Method setPageMethod = menu1.getClass().getMethod("setPage", int.class);
setPageMethod.invoke(menu1, currentPage - 1); setPageMethod.invoke(menu1, newPage);
} catch (Exception e) { } catch (Exception e) {
// 忽略反射错误 // 忽略反射错误
} }
}
}, Icon.ARROW_LEFT); }, Icon.ARROW_LEFT);
this.nextPage = new ActionEPPButton((b) -> { this.nextPage = new ActionEPPButton((b) -> {
int currentPage = getCurrentPage(); int currentPage = getCurrentPage();
int maxPage = getMaxPage(); int maxPage = getMaxPage();
if (currentPage + 1 < maxPage) { // 循环翻页最后一页向后翻到第一页
int newPage = (currentPage + 1) % maxPage;
try { try {
ContainerExPatternProvider menu1 = this.getMenu(); ContainerExPatternProvider menu1 = this.getMenu();
java.lang.reflect.Method setPageMethod = menu1.getClass().getMethod("setPage", int.class); java.lang.reflect.Method setPageMethod = menu1.getClass().getMethod("setPage", int.class);
setPageMethod.invoke(menu1, currentPage + 1); setPageMethod.invoke(menu1, newPage);
} catch (Exception e) { } catch (Exception e) {
// 忽略反射错误 // 忽略反射错误
} }
}
}, Icon.ARROW_RIGHT); }, Icon.ARROW_RIGHT);
this.addToLeftToolbar(this.nextPage); this.addToLeftToolbar(this.nextPage);