Modify Elven Trade recipes to allow for recipes with multiple outputs

This commit is contained in:
Shadowfacts committed 2016-08-02 16:23:40 -04:00
1 parent 947a225d23
commit 6cde8299c4
6 files changed
+50 -15

No files matched your search

@@ -495,16 +495,26 @@ public final class BotaniaAPI {
/**
* Registers a Elven Trade recipe (throw an item in an Alfheim Portal).
* @param output The ItemStack to return.
* @param outputs The ItemStacks to return.
* @param inputs The items required, can be ItemStack or ore dictionary entry string.
* @return The recipe created.
*/
public static RecipeElvenTrade registerElvenTradeRecipe(ItemStack output, Object... inputs) {
RecipeElvenTrade recipe = new RecipeElvenTrade(output, inputs);
public static RecipeElvenTrade registerElvenTradeRecipe(ItemStack[] outputs, Object... inputs) {
RecipeElvenTrade recipe = new RecipeElvenTrade(outputs, inputs);
elvenTradeRecipes.add(recipe);
return recipe;
}
/**
* Registers a Elven Trade recipe (throw an item into an Alfeim Portal).
* @param output The ItemStack to return
* @param inputs The items required, can be an ItemStack or an Ore Dictionary entry string.
* @return The recipe created.
*/
public static RecipeElvenTrade registerElvenTradeRecipe(ItemStack output, Object... inputs) {
return registerElvenTradeRecipe(new ItemStack[]{ output }, inputs);
}
/**
* Registers a Brew Recipe (for the Botanical Brewery).
* @param brew The brew in to be set in this recipe.
@@ -9,11 +9,11 @@ import java.util.List;
public class RecipeElvenTrade {
private final ItemStack output;
private final ImmutableList<ItemStack> outputs;
private final ImmutableList<Object> inputs;
public RecipeElvenTrade(ItemStack output, Object... inputs) {
this.output = output;
public RecipeElvenTrade(ItemStack[] outputs, Object... inputs) {
this.outputs = ImmutableList.copyOf(outputs);
ImmutableList.Builder<Object> inputsToSet = ImmutableList.builder();
for(Object obj : inputs) {
@@ -88,8 +88,8 @@ public class RecipeElvenTrade {
return inputs;
}
public ItemStack getOutput() {
return output;
public List<ItemStack> getOutputs() {
return outputs;
}
}
@@ -22,7 +22,7 @@ import java.util.List;
public class ElvenTradeRecipeWrapper implements IRecipeWrapper {
private final List input;
private final ItemStack output;
private final List<ItemStack> outputs;
@SuppressWarnings("unchecked")
public ElvenTradeRecipeWrapper(RecipeElvenTrade recipe) {
@@ -36,7 +36,7 @@ public class ElvenTradeRecipeWrapper implements IRecipeWrapper {
}
}
input = builder.build();
output = recipe.getOutput();
outputs = ImmutableList.copyOf(recipe.getOutputs());
}
@Override
@@ -46,7 +46,7 @@ public class ElvenTradeRecipeWrapper implements IRecipeWrapper {
@Override
public List<ItemStack> getOutputs() {
return ImmutableList.of(output);
return outputs;
}
@Override
@@ -222,7 +222,8 @@ public class TileAlfPortal extends TileMod {
for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) {
if(recipe.matches(stacksIn, false)) {
recipe.matches(stacksIn, true);
spawnItem(recipe.getOutput().copy());
for(ItemStack output : recipe.getOutputs())
spawnItem(output.copy());
break;
}
}
@@ -43,7 +43,8 @@ public class PageElvenRecipe extends PageRecipe {
@Override
public void onPageAdded(LexiconEntry entry, int index) {
for(RecipeElvenTrade recipe : recipes)
LexiconRecipeMappings.map(recipe.getOutput(), entry, index);
for(ItemStack output : recipe.getOutputs())
LexiconRecipeMappings.map(output, entry, index);
}
@Override
@@ -58,7 +59,10 @@ public class PageElvenRecipe extends PageRecipe {
((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight());
GlStateManager.disableBlend();
renderItemAtGridPos(gui, 3, 1, recipe.getOutput(), false);
List<ItemStack> outputs = recipe.getOutputs();
for(int i = 0; i < outputs.size(); i++) {
renderItemAtOutputPos(gui, i % 2, i / 2, outputs.get(i));
}
List<Object> inputs = recipe.getInputs();
int i = 0;
@@ -94,6 +98,26 @@ public class PageElvenRecipe extends PageRecipe {
renderItem(gui, xPos, yPos, stack1, false);
}
@SideOnly(Side.CLIENT)
public void renderItemAtOutputPos(IGuiLexiconEntry gui, int x, int y, ItemStack stack) {
if(stack == null || stack.getItem() == null)
return;
stack = stack.copy();
if(stack.getItemDamage() == Short.MAX_VALUE)
stack.setItemDamage(0);
int xPos = gui.getLeft() + x * 20 + 94;
int yPos = gui.getTop() + y * 20 + 52;
ItemStack stack1 = stack.copy();
if (stack1.getItemDamage() == -1) {
stack1.setItemDamage(0);
}
renderItem(gui, xPos, yPos, stack1, false);
}
@Override
@SideOnly(Side.CLIENT)
@@ -114,7 +138,7 @@ public class PageElvenRecipe extends PageRecipe {
public List<ItemStack> getDisplayedRecipes() {
ArrayList<ItemStack> list = new ArrayList<>();
for(RecipeElvenTrade r : recipes)
list.add(r.getOutput());
list.addAll(r.getOutputs());
return list;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB