JEI support for Binding/Alchemy Array recipes

Needs pretty-fying
This commit is contained in:
Nick 2015-12-29 16:11:34 -08:00
parent 7b69251713
commit e16017bd56
10 changed files with 76 additions and 83 deletions

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.compat.jei;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
import WayofTime.bloodmagic.compat.jei.alchemyArray.AlchemyArrayCraftingCategory;
import WayofTime.bloodmagic.compat.jei.alchemyArray.AlchemyArrayCraftingRecipeHandler;
import WayofTime.bloodmagic.compat.jei.alchemyArray.AlchemyArrayCraftingRecipeMaker;

View file

@ -1,7 +1,10 @@
package WayofTime.bloodmagic.compat.jei.alchemyArray;
import WayofTime.bloodmagic.api.ItemStackWrapper;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry;
import com.google.common.collect.BiMap;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
@ -13,19 +16,22 @@ public class AlchemyArrayCraftingRecipeMaker {
@Nonnull
public static List<AlchemyArrayCraftingRecipeJEI> getRecipes() {
Map<ItemStack, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> altarMap = AlchemyArrayRecipeRegistry.getRecipes();
Map<ItemStackWrapper, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> alchemyArrayRecipeMap = AlchemyArrayRecipeRegistry.getRecipes();
ArrayList<AlchemyArrayCraftingRecipeJEI> recipes = new ArrayList<AlchemyArrayCraftingRecipeJEI>();
for (Map.Entry<ItemStack, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> itemStackAlchemyArrayRecipeEntry : altarMap.entrySet()) {
for (Map.Entry<ItemStackWrapper, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet()) {
ItemStack input = itemStackAlchemyArrayRecipeEntry.getValue().getInputStack();
ItemStack catalyst = itemStackAlchemyArrayRecipeEntry.getKey();
BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = itemStackAlchemyArrayRecipeEntry.getValue().catalystMap;
if (itemStackAlchemyArrayRecipeEntry.getValue().getAlchemyArrayEffectForCatalyst(catalyst) instanceof AlchemyArrayEffectCrafting) {
ItemStack output =((AlchemyArrayEffectCrafting) itemStackAlchemyArrayRecipeEntry.getValue().getAlchemyArrayEffectForCatalyst(catalyst)).getOutputStack();
for(Map.Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet()) {
ItemStack catalyst = entry.getKey().toStack();
if (AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(input, catalyst) instanceof AlchemyArrayEffectCrafting) {
ItemStack output = ((AlchemyArrayEffectCrafting) itemStackAlchemyArrayRecipeEntry.getValue().getAlchemyArrayEffectForCatalyst(catalyst)).getOutputStack();
AlchemyArrayCraftingRecipeJEI recipe = new AlchemyArrayCraftingRecipeJEI(input, catalyst, output);
recipes.add(recipe);
AlchemyArrayCraftingRecipeJEI recipe = new AlchemyArrayCraftingRecipeJEI(input, catalyst, output);
recipes.add(recipe);
}
}
}

View file

@ -3,12 +3,12 @@ package WayofTime.bloodmagic.compat.jei.binding;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin;
import WayofTime.bloodmagic.util.helper.TextHelper;
import mezz.jei.api.JEIManager;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import javax.annotation.Nonnull;
@ -16,7 +16,8 @@ import javax.annotation.Nonnull;
public class BindingRecipeCategory implements IRecipeCategory {
private static final int INPUT_SLOT = 0;
private static final int OUTPUT_SLOT = 1;
private static final int CATALYST_SLOT = 1;
private static final int OUTPUT_SLOT = 2;
@Nonnull
private final IDrawable background = BloodMagicPlugin.jeiHelper.getGuiHelper().createDrawable(new ResourceLocation(Constants.Mod.DOMAIN + "gui/jei/binding.png"), 0, 0, 100, 30);
@ -56,12 +57,14 @@ public class BindingRecipeCategory implements IRecipeCategory {
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
recipeLayout.getItemStacks().init(INPUT_SLOT, true, 0, 5);
recipeLayout.getItemStacks().init(CATALYST_SLOT, true, 50, 5);
recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 73, 5);
if (recipeWrapper instanceof BindingRecipeJEI) {
BindingRecipeJEI bindingRecipeWrapper = (BindingRecipeJEI) recipeWrapper;
recipeLayout.getItemStacks().set(INPUT_SLOT, bindingRecipeWrapper.getInputs());
recipeLayout.getItemStacks().set(OUTPUT_SLOT, bindingRecipeWrapper.getOutputs());
BindingRecipeJEI bindingRecipe = (BindingRecipeJEI) recipeWrapper;
recipeLayout.getItemStacks().set(INPUT_SLOT, (ItemStack) bindingRecipe.getInputs().get(0));
recipeLayout.getItemStacks().set(CATALYST_SLOT, (ItemStack) bindingRecipe.getInputs().get(1));
recipeLayout.getItemStacks().set(OUTPUT_SLOT, bindingRecipe.getOutputs());
}
}
}

View file

@ -3,6 +3,7 @@ package WayofTime.bloodmagic.compat.jei.binding;
import WayofTime.bloodmagic.compat.jei.BloodMagicRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import scala.actors.threadpool.Arrays;
import javax.annotation.Nonnull;
import java.util.Collections;
@ -11,19 +12,20 @@ import java.util.List;
public class BindingRecipeJEI extends BloodMagicRecipeWrapper {
@Nonnull
private final ItemStack input;
private final List<ItemStack> inputs;
@Nonnull
private final ItemStack output;
public BindingRecipeJEI(@Nonnull ItemStack input, @Nonnull ItemStack output) {
this.input = input;
@SuppressWarnings("unchecked")
public BindingRecipeJEI(@Nonnull ItemStack input, @Nonnull ItemStack catalyst, @Nonnull ItemStack output) {
this.inputs = Arrays.asList(new ItemStack[] {input, catalyst});
this.output = output;
}
@Override
public List getInputs() {
return Collections.singletonList(input);
return inputs;
}
@Override

View file

@ -1,6 +1,10 @@
package WayofTime.bloodmagic.compat.jei.binding;
import WayofTime.bloodmagic.api.registry.BindingRecipeRegistry;
import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectBinding;
import WayofTime.bloodmagic.api.ItemStackWrapper;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry;
import com.google.common.collect.BiMap;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
@ -12,16 +16,23 @@ public class BindingRecipeMaker {
@Nonnull
public static List<BindingRecipeJEI> getRecipes() {
Map<ItemStack, BindingRecipeRegistry.BindingRecipe> altarMap = BindingRecipeRegistry.getRecipes();
Map<ItemStackWrapper, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> alchemyArrayRecipeMap = AlchemyArrayRecipeRegistry.getRecipes();
ArrayList<BindingRecipeJEI> recipes = new ArrayList<BindingRecipeJEI>();
for (Map.Entry<ItemStack, BindingRecipeRegistry.BindingRecipe> itemStackBindingRecipeEntry : altarMap.entrySet()) {
ItemStack input = itemStackBindingRecipeEntry.getKey();
ItemStack output = itemStackBindingRecipeEntry.getValue().getOutput();
for (Map.Entry<ItemStackWrapper, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet()) {
ItemStack input = itemStackAlchemyArrayRecipeEntry.getValue().getInputStack();
BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = itemStackAlchemyArrayRecipeEntry.getValue().catalystMap;
BindingRecipeJEI recipe = new BindingRecipeJEI(input, output);
recipes.add(recipe);
for(Map.Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet()) {
ItemStack catalyst = entry.getKey().toStack();
if (AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(input, catalyst) instanceof AlchemyArrayEffectBinding) {
ItemStack output = ((AlchemyArrayEffectBinding) itemStackAlchemyArrayRecipeEntry.getValue().getAlchemyArrayEffectForCatalyst(catalyst)).getOutputStack();
BindingRecipeJEI recipe = new BindingRecipeJEI(input, catalyst, output);
recipes.add(recipe);
}
}
}
return recipes;