Fix Permutations for Information Handler (#804)

This commit is contained in:
slprime authored and GitHub committed 2025-11-08 09:32:47 +02:00
1 parent 7f555f7a7f
commit bcef287e71
4 files changed
+21 -20

No files matched your search

@@ -34,13 +34,12 @@ public class InformationHandler extends TemplateRecipeHandler {
@Override
public void drawExtras(int recipe) {
CachedInfoPage page = (CachedInfoPage) this.arecipes.get(recipe);
drawWrappedText(StatCollector.translateToLocal(page.getPage().info).replace("\\n", "\n"), 4, 24);
final CachedInfoPage page = (CachedInfoPage) this.arecipes.get(recipe);
drawWrappedText(page.getLines(), 4, 24);
}
private void drawWrappedText(String text, int x, int y) {
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
List<String> lines = font.listFormattedStringToWidth(text, 156);
private void drawWrappedText(List<String> lines, int x, int y) {
final FontRenderer font = Minecraft.getMinecraft().fontRenderer;
for (String line : lines) {
font.drawString(line, x, y, 0);
y += 10;
@@ -82,14 +81,23 @@ public class InformationHandler extends TemplateRecipeHandler {
return "nei:textures/gui/recipebg.png";
}
@Override
public int getRecipeHeight(int recipe) {
final CachedInfoPage page = (CachedInfoPage) this.arecipes.get(recipe);
return 24 + page.getLines().size() * 10;
}
private class CachedInfoPage extends CachedRecipe {
private final InformationPage page;
private final PositionedStack stack;
private final List<String> lines;
public CachedInfoPage(InformationPage page) {
this.page = page;
stack = new PositionedStack(page.items, 75, 2);
final FontRenderer font = Minecraft.getMinecraft().fontRenderer;
final String info = StatCollector.translateToLocal(page.info).replace("\\n", "\n");
this.lines = font.listFormattedStringToWidth(info, 156);
this.stack = new PositionedStack(page.items, 75, 2);
}
@Override
@@ -102,8 +110,8 @@ public class InformationHandler extends TemplateRecipeHandler {
return Collections.singletonList(this.stack);
}
public InformationPage getPage() {
return page;
public List<String> getLines() {
return lines;
}
}