From f974f44aeb343a222074b26d7c615e118cfdd9f6 Mon Sep 17 00:00:00 2001 From: Nicholas Ignoffo Date: Sun, 11 Feb 2018 11:53:45 -0800 Subject: [PATCH] Fixup Alchemy Array JEI compat --- .../compat/jei/BloodMagicJEIPlugin.java | 11 +++--- .../AlchemyArrayCraftingCategory.java | 2 +- .../AlchemyArrayCraftingRecipeHandler.java | 31 --------------- .../AlchemyArrayCraftingRecipeJEI.java | 21 +++++----- .../AlchemyArrayCraftingRecipeMaker.java | 39 ------------------- 5 files changed, 16 insertions(+), 88 deletions(-) delete mode 100644 src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeHandler.java delete mode 100644 src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeMaker.java diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicJEIPlugin.java b/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicJEIPlugin.java index 8a0ed800..e6c26b9a 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicJEIPlugin.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicJEIPlugin.java @@ -1,6 +1,7 @@ package WayofTime.bloodmagic.compat.jei; import WayofTime.bloodmagic.api.impl.BloodMagicAPI; +import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyArray; import WayofTime.bloodmagic.api.impl.recipe.RecipeBloodAltar; import WayofTime.bloodmagic.api.impl.recipe.RecipeTartaricForge; import WayofTime.bloodmagic.apibutnotreally.Constants; @@ -8,11 +9,9 @@ import WayofTime.bloodmagic.apibutnotreally.livingArmour.LivingArmourHandler; import WayofTime.bloodmagic.apibutnotreally.util.helper.ItemHelper.LivingUpgrades; import WayofTime.bloodmagic.client.gui.GuiSoulForge; import WayofTime.bloodmagic.compat.jei.alchemyArray.AlchemyArrayCraftingCategory; -import WayofTime.bloodmagic.compat.jei.alchemyArray.AlchemyArrayCraftingRecipeHandler; -import WayofTime.bloodmagic.compat.jei.alchemyArray.AlchemyArrayCraftingRecipeMaker; +import WayofTime.bloodmagic.compat.jei.alchemyArray.AlchemyArrayCraftingRecipeJEI; import WayofTime.bloodmagic.compat.jei.alchemyTable.AlchemyTableRecipeCategory; import WayofTime.bloodmagic.compat.jei.alchemyTable.AlchemyTableRecipeHandler; -import WayofTime.bloodmagic.compat.jei.alchemyTable.AlchemyTableRecipeJEI; import WayofTime.bloodmagic.compat.jei.alchemyTable.AlchemyTableRecipeMaker; import WayofTime.bloodmagic.compat.jei.altar.AltarRecipeCategory; import WayofTime.bloodmagic.compat.jei.altar.AltarRecipeJEI; @@ -34,7 +33,7 @@ import javax.annotation.Nonnull; import java.util.Map; @JEIPlugin -public class BloodMagicJEIPlugin extends BlankModPlugin { +public class BloodMagicJEIPlugin implements IModPlugin { public static IJeiHelpers jeiHelper; @Override @@ -43,19 +42,19 @@ public class BloodMagicJEIPlugin extends BlankModPlugin { registry.addRecipeHandlers( new BindingRecipeHandler(), - new AlchemyArrayCraftingRecipeHandler(), new AlchemyTableRecipeHandler(), new ArmourDowngradeRecipeHandler() ); registry.addRecipes(BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAltarRecipes(), Constants.Compat.JEI_CATEGORY_ALTAR); registry.addRecipes(BloodMagicAPI.INSTANCE.getRecipeRegistrar().getTartaricForgeRecipes(), Constants.Compat.JEI_CATEGORY_SOULFORGE); + registry.addRecipes(BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAlchemyArrayRecipes(), Constants.Compat.JEI_CATEGORY_ALCHEMYARRAY); registry.handleRecipes(RecipeBloodAltar.class, AltarRecipeJEI::new, Constants.Compat.JEI_CATEGORY_ALTAR); registry.handleRecipes(RecipeTartaricForge.class, TartaricForgeRecipeJEI::new, Constants.Compat.JEI_CATEGORY_SOULFORGE); + registry.handleRecipes(RecipeAlchemyArray.class, AlchemyArrayCraftingRecipeJEI::new, Constants.Compat.JEI_CATEGORY_ALCHEMYARRAY); registry.addRecipes(BindingRecipeMaker.getRecipes()); - registry.addRecipes(AlchemyArrayCraftingRecipeMaker.getRecipes()); registry.addRecipes(AlchemyTableRecipeMaker.getRecipes()); registry.addRecipes(ArmourDowngradeRecipeMaker.getRecipes()); diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingCategory.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingCategory.java index dbb41825..c026c81f 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingCategory.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingCategory.java @@ -63,7 +63,7 @@ public class AlchemyArrayCraftingCategory implements IRecipeCategory { if (recipeWrapper instanceof AlchemyArrayCraftingRecipeJEI) { recipeLayout.getItemStacks().set(INPUT_SLOT, ingredients.getInputs(ItemStack.class).get(0)); - recipeLayout.getItemStacks().set(CATALYST_SLOT, ingredients.getInputs(ItemStack.class).get(ingredients.getInputs(ItemStack.class).size() - 1)); + recipeLayout.getItemStacks().set(CATALYST_SLOT, ingredients.getInputs(ItemStack.class).get(1)); recipeLayout.getItemStacks().set(OUTPUT_SLOT, ingredients.getOutputs(ItemStack.class).get(0)); } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeHandler.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeHandler.java deleted file mode 100644 index f05a4cbd..00000000 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeHandler.java +++ /dev/null @@ -1,31 +0,0 @@ -package WayofTime.bloodmagic.compat.jei.alchemyArray; - -import WayofTime.bloodmagic.apibutnotreally.Constants; -import mezz.jei.api.recipe.IRecipeHandler; -import mezz.jei.api.recipe.IRecipeWrapper; - -import javax.annotation.Nonnull; - -public class AlchemyArrayCraftingRecipeHandler implements IRecipeHandler { - @Nonnull - @Override - public Class getRecipeClass() { - return AlchemyArrayCraftingRecipeJEI.class; - } - - @Override - public String getRecipeCategoryUid(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) { - return Constants.Compat.JEI_CATEGORY_ALCHEMYARRAY; - } - - @Nonnull - @Override - public IRecipeWrapper getRecipeWrapper(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) { - return recipe; - } - - @Override - public boolean isRecipeValid(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) { - return true; - } -} diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeJEI.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeJEI.java index 9cd323b9..fe451eb0 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeJEI.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeJEI.java @@ -1,35 +1,34 @@ package WayofTime.bloodmagic.compat.jei.alchemyArray; +import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyArray; import com.google.common.collect.Lists; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeWrapper; +import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.List; -public class AlchemyArrayCraftingRecipeJEI extends BlankRecipeWrapper { +public class AlchemyArrayCraftingRecipeJEI implements IRecipeWrapper { @Nonnull private final List inputs; @Nullable - private final ItemStack catalyst; + private final List catalyst; @Nonnull private final ItemStack output; - public AlchemyArrayCraftingRecipeJEI(@Nonnull List input, @Nullable ItemStack catalyst, @Nonnull ItemStack output) { - this.inputs = input; - this.catalyst = catalyst; - this.output = output; - } - - public ItemStack getCatalyst() { - return catalyst; + public AlchemyArrayCraftingRecipeJEI(RecipeAlchemyArray array) { + this.inputs = NonNullList.from(ItemStack.EMPTY, array.getInput().getMatchingStacks()); + this.catalyst = NonNullList.from(ItemStack.EMPTY, array.getCatalyst().getMatchingStacks()); + this.output = array.getOutput(); } @Override public void getIngredients(IIngredients ingredients) { - ingredients.setInputLists(ItemStack.class, Lists.newArrayList(inputs, Lists.newArrayList(catalyst))); + ingredients.setInputLists(ItemStack.class, Lists.newArrayList(inputs, catalyst)); ingredients.setOutput(ItemStack.class, output); } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeMaker.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeMaker.java deleted file mode 100644 index 3d95e801..00000000 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeMaker.java +++ /dev/null @@ -1,39 +0,0 @@ -package WayofTime.bloodmagic.compat.jei.alchemyArray; - -import WayofTime.bloodmagic.apibutnotreally.ItemStackWrapper; -import WayofTime.bloodmagic.apibutnotreally.alchemyCrafting.AlchemyArrayEffect; -import WayofTime.bloodmagic.apibutnotreally.alchemyCrafting.AlchemyArrayEffectCrafting; -import WayofTime.bloodmagic.apibutnotreally.registry.AlchemyArrayRecipeRegistry; -import com.google.common.collect.BiMap; -import net.minecraft.item.ItemStack; - -import javax.annotation.Nonnull; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class AlchemyArrayCraftingRecipeMaker { - @Nonnull - public static List getRecipes() { - Map, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> alchemyArrayRecipeMap = AlchemyArrayRecipeRegistry.getRecipes(); - - ArrayList recipes = new ArrayList(); - - for (Map.Entry, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet()) { - List input = itemStackAlchemyArrayRecipeEntry.getValue().getInput(); - BiMap catalystMap = itemStackAlchemyArrayRecipeEntry.getValue().catalystMap; - - for (Map.Entry entry : catalystMap.entrySet()) { - ItemStack catalyst = entry.getKey().toStack(); - if (AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(input, catalyst) instanceof AlchemyArrayEffectCrafting) { - ItemStack output = ((AlchemyArrayEffectCrafting) itemStackAlchemyArrayRecipeEntry.getValue().getAlchemyArrayEffectForCatalyst(catalyst)).outputStack; - - AlchemyArrayCraftingRecipeJEI recipe = new AlchemyArrayCraftingRecipeJEI(input, catalyst, output); - recipes.add(recipe); - } - } - } - - return recipes; - } -}