Skip to content

Commit

Permalink
fix 6709 (ldtteam#6729)
Browse files Browse the repository at this point in the history
Fixes visual bug of overflowing recipes
Also fixes tooltip rendering of stacks in recipes
  • Loading branch information
Raycoms authored Mar 12, 2021
1 parent d6e42cd commit 75b8748
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ public class WindowListRecipes extends Window implements ButtonHandler
/**
* The item icon of the resource.
*/
private static final String RESOURCE = "resource%d";

/**
* The item icon of the 3x3 resource.
*/
private static final String RES = "res%d";
private static final String RESOURCE = "res%d";

/**
* Contains all the recipes.
Expand Down Expand Up @@ -140,22 +135,39 @@ public void updateElement(final int index, @NotNull final Pane rowPane)
}
}

final String name;
if (recipe.getInput().size() <= 4)
// Some special recipes might not include all necessary air blocks.
if (recipe.getInput().size() < 4)
{
name = RESOURCE;
for (int i = 0; i < 9; i++)
{
if (i < recipe.getInput().size())
{
rowPane.findPaneOfTypeByID(String.format(RESOURCE, i + 1), ItemIcon.class).setItem(recipe.getInput().get(i));
}
else
{
rowPane.findPaneOfTypeByID(String.format(RESOURCE, i + 1), ItemIcon.class).setItem(ItemStack.EMPTY);
}
}
}
else
else if (recipe.getInput().size() == 4)
{
name = RES;
rowPane.findPaneOfTypeByID("3x3", Box.class).setVisible(true);
rowPane.findPaneOfTypeByID("2x2", Box.class).setVisible(false);
icon.setPosition(80, 17);
rowPane.findPaneOfTypeByID(String.format(RESOURCE, 1), ItemIcon.class).setItem(recipe.getInput().get(0));
rowPane.findPaneOfTypeByID(String.format(RESOURCE, 2), ItemIcon.class).setItem(recipe.getInput().get(1));
rowPane.findPaneOfTypeByID(String.format(RESOURCE, 3), ItemIcon.class).setItem(ItemStack.EMPTY);
rowPane.findPaneOfTypeByID(String.format(RESOURCE, 4), ItemIcon.class).setItem(recipe.getInput().get(2));
rowPane.findPaneOfTypeByID(String.format(RESOURCE, 5), ItemIcon.class).setItem(recipe.getInput().get(3));
for (int i = 6; i < 9; i++)
{
rowPane.findPaneOfTypeByID(String.format(RESOURCE, i + 1), ItemIcon.class).setItem(ItemStack.EMPTY);
}
}

for (int i = 0; i < recipe.getInput().size(); i++)
else
{
rowPane.findPaneOfTypeByID(String.format(name, i + 1), ItemIcon.class).setItem(recipe.getInput().get(i));
for (int i = 0; i < 9; i++)
{
rowPane.findPaneOfTypeByID(String.format(RESOURCE, i + 1), ItemIcon.class).setItem(recipe.getInput().get(i));
}
}
}
});
Expand All @@ -164,6 +176,7 @@ public void updateElement(final int index, @NotNull final Pane rowPane)
@Override
public void onUpdate()
{
super.onUpdate();
updateRecipes();
if (!Screen.hasShiftDown())
{
Expand Down
10 changes: 2 additions & 8 deletions src/main/resources/assets/minecolonies/gui/windowlistrecipes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
<label size="100% 11" pos="0 70" textalign="TOP_MIDDLE" color="white" id="recipestatus" />
<list id="recipes" size="70% 100" pos="60 90" align="TOP_MIDDLE">
<view size="70% 50">
<itemicon id="output" size="16 16" pos="80 5"/>
<box id="2x2" size="100% 30" linewidth="2">
<itemicon id="resource1" size="16 16" pos="20 1"/>
<itemicon id="resource2" size="16 16" pos="20 15"/>
<itemicon id="resource3" size="16 16" pos="34 15"/>
<itemicon id="resource4" size="16 16" pos="34 1"/>
</box>
<box id="3x3" size="100% 50" linewidth="2" visible="false">
<itemicon id="output" size="16 16" pos="80 17"/>
<box id="3x3" size="100% 50" linewidth="2">
<itemicon id="res1" size="16 16" pos="20 1"/>
<itemicon id="res2" size="16 16" pos="34 1"/>
<itemicon id="res3" size="16 16" pos="48 1"/>
Expand Down

0 comments on commit 75b8748

Please sign in to comment.