mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-10-26 14:24:07 +00:00
Fix Permutations for Information Handler (#804)
This commit is contained in:
1 parent
7f555f7a7f
commit
bcef287e71
4 files changed
+21
-20
No files matched your search
@@ -70,8 +70,8 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
|
||||
}
|
||||
|
||||
public void setActiveStack(ItemStack activeStack) {
|
||||
final ItemStack realStack = items.stream()
|
||||
.filter(stack -> NEIClientUtils.areStacksSameTypeWithNBT(stack, activeStack)).findFirst().orElse(null);
|
||||
final ItemStack realStack = items.stream().filter(stack -> NEIClientUtils.areStacksSameType(stack, activeStack))
|
||||
.findFirst().orElse(null);
|
||||
this.activeStackIndex = items.indexOf(realStack);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ public class PositionedStack {
|
||||
public int getPermutationIndex(ItemStack stack) {
|
||||
|
||||
for (int index = 0; index < this.items.length; index++) {
|
||||
if (NEIServerUtils.areStacksSameTypeCraftingWithNBT(items[index], stack)) {
|
||||
if (NEIServerUtils.areStacksSameType(items[index], stack)) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,13 +134,6 @@ public class GuiRecipeCatalyst extends ScrollContainer {
|
||||
int index = 0;
|
||||
|
||||
for (PositionedStack pStack : this.items) {
|
||||
|
||||
if (pStack.items.length > 1) {
|
||||
final int stackIndex = (pStack.items.length + pStack.getPermutationIndex(pStack.item) + 1)
|
||||
% pStack.items.length;
|
||||
pStack.setPermutationToRender(stackIndex);
|
||||
}
|
||||
|
||||
pStack.relx = visibleWidth - SLOT_SIZE - (index / rows) * SLOT_SIZE;
|
||||
pStack.rely = (index % rows) * SLOT_SIZE;
|
||||
index++;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user