First attempt at AlchemyArrayCrafting JEI support
Does not work currently due to broken map lookups.
This commit is contained in:
parent
03847ad6d9
commit
d9bc1105d8
|
@ -66,6 +66,7 @@ public class Constants {
|
|||
public static class Compat {
|
||||
public static final String JEI_CATEGORY_ALTAR = Mod.MODID + ":altar";
|
||||
public static final String JEI_CATEGORY_BINDING = Mod.MODID + ":binding";
|
||||
public static final String JEI_CATEGORY_ALCHEMYARRAY = Mod.MODID + ":alchemyArray";
|
||||
}
|
||||
|
||||
public static class Misc {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package WayofTime.bloodmagic.compat.jei;
|
||||
|
||||
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.altar.AltarRecipeCategory;
|
||||
import WayofTime.bloodmagic.compat.jei.altar.AltarRecipeHandler;
|
||||
import WayofTime.bloodmagic.compat.jei.altar.AltarRecipeMaker;
|
||||
|
@ -13,6 +16,8 @@ import net.minecraft.item.ItemStack;
|
|||
@JEIPlugin
|
||||
public class BloodMagicPlugin implements IModPlugin {
|
||||
|
||||
public static IJeiHelpers jeiHelper;
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded() {
|
||||
return true;
|
||||
|
@ -22,20 +27,25 @@ public class BloodMagicPlugin implements IModPlugin {
|
|||
public void register(IModRegistry registry) {
|
||||
registry.addRecipeCategories(
|
||||
new AltarRecipeCategory(),
|
||||
new BindingRecipeCategory()
|
||||
new BindingRecipeCategory(),
|
||||
new AlchemyArrayCraftingCategory()
|
||||
);
|
||||
|
||||
registry.addRecipeHandlers(
|
||||
new AltarRecipeHandler(),
|
||||
new BindingRecipeHandler()
|
||||
new BindingRecipeHandler(),
|
||||
new AlchemyArrayCraftingRecipeHandler()
|
||||
);
|
||||
|
||||
registry.addRecipes(AltarRecipeMaker.getRecipes());
|
||||
registry.addRecipes(BindingRecipeMaker.getRecipes());
|
||||
registry.addRecipes(AlchemyArrayCraftingRecipeMaker.getRecipes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJeiHelpersAvailable(IJeiHelpers jeiHelpers) {
|
||||
jeiHelper = jeiHelpers;
|
||||
|
||||
jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.bloodLight));
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package WayofTime.bloodmagic.compat.jei.altar;
|
||||
|
||||
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;
|
||||
|
@ -18,7 +19,7 @@ public class AltarRecipeCategory implements IRecipeCategory {
|
|||
private static final int OUTPUT_SLOT = 1;
|
||||
|
||||
@Nonnull
|
||||
private final IDrawable background = JEIManager.guiHelper.createDrawable(new ResourceLocation(Constants.Mod.DOMAIN + "gui/jei/altar.png"), 3, 4, 155, 65);
|
||||
private final IDrawable background = BloodMagicPlugin.jeiHelper.getGuiHelper().createDrawable(new ResourceLocation(Constants.Mod.DOMAIN + "gui/jei/altar.png"), 3, 4, 155, 65);
|
||||
@Nonnull
|
||||
private final String localizedName = TextHelper.localize("jei.BloodMagic.recipe.altar");
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
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;
|
||||
|
@ -18,7 +19,7 @@ public class BindingRecipeCategory implements IRecipeCategory {
|
|||
private static final int OUTPUT_SLOT = 1;
|
||||
|
||||
@Nonnull
|
||||
private final IDrawable background = JEIManager.guiHelper.createDrawable(new ResourceLocation(Constants.Mod.DOMAIN + "gui/jei/binding.png"), 0, 0, 100, 30);
|
||||
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.binding");
|
||||
|
||||
|
|
Loading…
Reference in a new issue