First attempt at AlchemyArrayCrafting JEI support

Does not work currently due to broken map lookups.
This commit is contained in:
Nick 2015-12-26 16:50:22 -08:00
parent 03847ad6d9
commit d9bc1105d8
8 changed files with 201 additions and 4 deletions

View file

@ -0,0 +1,71 @@
package WayofTime.bloodmagic.compat.jei.alchemyArray;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin;
import WayofTime.bloodmagic.util.helper.TextHelper;
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;
public class AlchemyArrayCraftingCategory implements IRecipeCategory {
private static final int INPUT_SLOT = 0;
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);
@Nonnull
private final String localizedName = TextHelper.localize("jei.BloodMagic.recipe.alchemyArrayCrafting");
@Nonnull
@Override
public String getUid() {
return Constants.Compat.JEI_CATEGORY_ALCHEMYARRAY;
}
@Nonnull
@Override
public String getTitle() {
return localizedName;
}
@Nonnull
@Override
public IDrawable getBackground() {
return background;
}
@Override
public void drawExtras(Minecraft minecraft) {
}
@Override
public void drawAnimations(Minecraft minecraft) {
}
@Override
@SuppressWarnings("unchecked")
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 AlchemyArrayCraftingRecipeJEI) {
AlchemyArrayCraftingRecipeJEI alchemyArrayWrapper = (AlchemyArrayCraftingRecipeJEI) recipeWrapper;
recipeLayout.getItemStacks().set(INPUT_SLOT, (ItemStack) alchemyArrayWrapper.getInputs().get(0));
recipeLayout.getItemStacks().set(CATALYST_SLOT, (ItemStack) alchemyArrayWrapper.getInputs().get(1));
recipeLayout.getItemStacks().set(OUTPUT_SLOT, alchemyArrayWrapper.getOutputs());
}
}
}

View file

@ -0,0 +1,33 @@
package WayofTime.bloodmagic.compat.jei.alchemyArray;
import WayofTime.bloodmagic.api.Constants;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import javax.annotation.Nonnull;
public class AlchemyArrayCraftingRecipeHandler implements IRecipeHandler<AlchemyArrayCraftingRecipeJEI> {
@Nonnull
@Override
public Class<AlchemyArrayCraftingRecipeJEI> getRecipeClass() {
return AlchemyArrayCraftingRecipeJEI.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
return Constants.Compat.JEI_CATEGORY_ALCHEMYARRAY;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) {
return recipe;
}
@Override
public boolean isRecipeValid(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) {
return recipe.getInputs().size() > 0 && recipe.getOutputs().size() > 0;
}
}

View file

@ -0,0 +1,46 @@
package WayofTime.bloodmagic.compat.jei.alchemyArray;
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 javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
public class AlchemyArrayCraftingRecipeJEI extends BloodMagicRecipeWrapper {
@Nonnull
private final List<ItemStack> inputs;
@Nonnull
private final ItemStack output;
@SuppressWarnings("unchecked")
public AlchemyArrayCraftingRecipeJEI(@Nonnull ItemStack input, @Nullable ItemStack catalyst, @Nonnull ItemStack output) {
this.inputs = Arrays.asList(new ItemStack[] {input, catalyst});
this.output = output;
}
@Override
public List getInputs() {
return inputs;
}
@Override
public List getOutputs() {
return Collections.singletonList(output);
}
@Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
}
}

View file

@ -0,0 +1,34 @@
package WayofTime.bloodmagic.compat.jei.alchemyArray;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry;
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<AlchemyArrayCraftingRecipeJEI> getRecipes() {
Map<ItemStack, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> altarMap = AlchemyArrayRecipeRegistry.getRecipes();
ArrayList<AlchemyArrayCraftingRecipeJEI> recipes = new ArrayList<AlchemyArrayCraftingRecipeJEI>();
for (Map.Entry<ItemStack, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> itemStackAlchemyArrayRecipeEntry : altarMap.entrySet()) {
ItemStack input = itemStackAlchemyArrayRecipeEntry.getValue().getInputStack();
ItemStack catalyst = itemStackAlchemyArrayRecipeEntry.getKey();
if (itemStackAlchemyArrayRecipeEntry.getValue().getAlchemyArrayEffectForCatalyst(catalyst) instanceof AlchemyArrayEffectCrafting) {
ItemStack output =((AlchemyArrayEffectCrafting) itemStackAlchemyArrayRecipeEntry.getValue().getAlchemyArrayEffectForCatalyst(catalyst)).getOutputStack();
AlchemyArrayCraftingRecipeJEI recipe = new AlchemyArrayCraftingRecipeJEI(input, catalyst, output);
recipes.add(recipe);
}
}
return recipes;
}
}