Re-add JEI compat

This commit is contained in:
Nick 2016-03-18 04:07:49 -07:00
parent 4e580adee1
commit 252a4559f0
24 changed files with 1271 additions and 2 deletions

View file

@ -59,7 +59,7 @@ repositories {
}
dependencies {
// deobfCompile "mezz.jei:jei_${mc_version}:${jei_version}"
deobfCompile "mezz.jei:jei_${mc_version}:${jei_version}"
// deobfCompile "info.amerifrance.guideapi:Guide-API:${mc_version}-${guideapi_version}"
// compile "mcp.mobius.waila:Waila:${waila_version}_1.8.8:dev"

View file

@ -7,7 +7,7 @@ curse_id=224791
mappings_version=snapshot_20160312
jei_version=2.27.0.157
jei_version=3.0.0.158
waila_version=1.6.0-B3
thaumcraft_version=5.1.5
baubles_version=1.1.3.0

View file

@ -0,0 +1,84 @@
package WayofTime.bloodmagic.compat.jei;
import java.util.Map;
import javax.annotation.Nonnull;
import mezz.jei.api.BlankModPlugin;
import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.JEIPlugin;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler;
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;
import WayofTime.bloodmagic.compat.jei.binding.BindingRecipeCategory;
import WayofTime.bloodmagic.compat.jei.binding.BindingRecipeHandler;
import WayofTime.bloodmagic.compat.jei.binding.BindingRecipeMaker;
import WayofTime.bloodmagic.compat.jei.forge.TartaricForgeRecipeCategory;
import WayofTime.bloodmagic.compat.jei.forge.TartaricForgeRecipeHandler;
import WayofTime.bloodmagic.compat.jei.forge.TartaricForgeRecipeMaker;
import WayofTime.bloodmagic.compat.jei.orb.ShapedOrbRecipeHandler;
import WayofTime.bloodmagic.compat.jei.orb.ShapelessOrbRecipeHandler;
import WayofTime.bloodmagic.item.ItemUpgradeTome;
import WayofTime.bloodmagic.registry.ModBlocks;
import WayofTime.bloodmagic.registry.ModItems;
@JEIPlugin
public class BloodMagicPlugin extends BlankModPlugin
{
public static IJeiHelpers jeiHelper;
@Override
public void register(@Nonnull IModRegistry registry)
{
jeiHelper = registry.getJeiHelpers();
registry.addRecipeCategories(new AltarRecipeCategory(), new BindingRecipeCategory(), new AlchemyArrayCraftingCategory(), new TartaricForgeRecipeCategory());
registry.addRecipeHandlers(new AltarRecipeHandler(), new BindingRecipeHandler(), new AlchemyArrayCraftingRecipeHandler(), new TartaricForgeRecipeHandler(), new ShapedOrbRecipeHandler(), new ShapelessOrbRecipeHandler());
registry.addRecipes(AltarRecipeMaker.getRecipes());
registry.addRecipes(BindingRecipeMaker.getRecipes());
registry.addRecipes(AlchemyArrayCraftingRecipeMaker.getRecipes());
registry.addRecipes(TartaricForgeRecipeMaker.getRecipes());
registry.addDescription(new ItemStack(ModItems.altarMaker), "jei.BloodMagic.desc.altarBuilder");
registry.addDescription(new ItemStack(ModItems.monsterSoul), "jei.BloodMagic.desc.demonicWill");
jeiHelper.getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.bloodLight));
jeiHelper.getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.spectralBlock));
jeiHelper.getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.phantomBlock));
jeiHelper.getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.alchemyArray));
jeiHelper.getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.dimensionalPortal, 1, OreDictionary.WILDCARD_VALUE));
for (Map.Entry<String, Integer> entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet())
{
String key = entry.getKey();
int maxLevel = entry.getValue();
for (int i = 0; i < maxLevel - 1; i++)
{
ItemStack stack = new ItemStack(ModItems.upgradeTome);
ItemUpgradeTome.setKey(stack, key);
ItemUpgradeTome.setLevel(stack, i);
jeiHelper.getItemBlacklist().addItemToBlacklist(stack);
}
}
jeiHelper.getNbtIgnoreList().ignoreNbtTagNames(Constants.NBT.OWNER_UUID);
jeiHelper.getNbtIgnoreList().ignoreNbtTagNames(Constants.NBT.OWNER_NAME);
jeiHelper.getNbtIgnoreList().ignoreNbtTagNames(Constants.NBT.USES);
jeiHelper.getNbtIgnoreList().ignoreNbtTagNames(Constants.NBT.SOULS);
jeiHelper.getNbtIgnoreList().ignoreNbtTagNames(Constants.NBT.X_COORD);
jeiHelper.getNbtIgnoreList().ignoreNbtTagNames(Constants.NBT.Y_COORD);
jeiHelper.getNbtIgnoreList().ignoreNbtTagNames(Constants.NBT.Z_COORD);
jeiHelper.getNbtIgnoreList().ignoreNbtTagNames(Constants.NBT.DIMENSION_ID);
jeiHelper.getNbtIgnoreList().ignoreNbtTagNames(Constants.NBT.ITEM_INVENTORY);
}
}

View file

@ -0,0 +1,24 @@
package WayofTime.bloodmagic.compat.jei;
import WayofTime.bloodmagic.compat.ICompatibility;
public class CompatibilityJustEnoughItems implements ICompatibility
{
@Override
public void loadCompatibility(InitializationPhase phase)
{
}
@Override
public String getModId()
{
return "JEI";
}
@Override
public boolean enableCompat()
{
return true;
}
}

View file

@ -0,0 +1,77 @@
package WayofTime.bloodmagic.compat.jei.alchemyArray;
import javax.annotation.Nonnull;
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 WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin;
import WayofTime.bloodmagic.util.helper.TextHelper;
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,37 @@
package WayofTime.bloodmagic.compat.jei.alchemyArray;
import javax.annotation.Nonnull;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import WayofTime.bloodmagic.api.Constants;
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,39 @@
package WayofTime.bloodmagic.compat.jei.alchemyArray;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import net.minecraft.item.ItemStack;
public class AlchemyArrayCraftingRecipeJEI extends BlankRecipeWrapper
{
@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(input, catalyst);
this.output = output;
}
@Override
public List getInputs()
{
return inputs;
}
@Override
public List getOutputs()
{
return Collections.singletonList(output);
}
}

View file

@ -0,0 +1,46 @@
package WayofTime.bloodmagic.compat.jei.alchemyArray;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
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;
public class AlchemyArrayCraftingRecipeMaker
{
@Nonnull
public static List<AlchemyArrayCraftingRecipeJEI> getRecipes()
{
Map<ItemStackWrapper, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> alchemyArrayRecipeMap = AlchemyArrayRecipeRegistry.getRecipes();
ArrayList<AlchemyArrayCraftingRecipeJEI> recipes = new ArrayList<AlchemyArrayCraftingRecipeJEI>();
for (Map.Entry<ItemStackWrapper, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet())
{
ItemStack input = itemStackAlchemyArrayRecipeEntry.getValue().getInputStack();
BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = itemStackAlchemyArrayRecipeEntry.getValue().catalystMap;
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);
}
}
}
return recipes;
}
}

View file

@ -0,0 +1,72 @@
package WayofTime.bloodmagic.compat.jei.altar;
import javax.annotation.Nonnull;
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.util.ResourceLocation;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class AltarRecipeCategory implements IRecipeCategory
{
private static final int INPUT_SLOT = 0;
private static final int OUTPUT_SLOT = 1;
@Nonnull
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");
@Nonnull
@Override
public String getUid()
{
return Constants.Compat.JEI_CATEGORY_ALTAR;
}
@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, 31, 0);
recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 125, 30);
if (recipeWrapper instanceof AltarRecipeJEI)
{
AltarRecipeJEI altarRecipeWrapper = (AltarRecipeJEI) recipeWrapper;
recipeLayout.getItemStacks().set(INPUT_SLOT, altarRecipeWrapper.getInputs());
recipeLayout.getItemStacks().set(OUTPUT_SLOT, altarRecipeWrapper.getOutputs());
}
}
}

View file

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

View file

@ -0,0 +1,70 @@
package WayofTime.bloodmagic.compat.jei.altar;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class AltarRecipeJEI extends BlankRecipeWrapper
{
@Nonnull
private final ItemStack input;
@Nonnull
private final ItemStack output;
private final String[] infoString;
private final int consumptionRate;
private final int drainRate;
public AltarRecipeJEI(@Nonnull ItemStack input, @Nonnull ItemStack output, int tier, int requiredLP, int consumptionRate, int drainRate)
{
this.input = input;
this.output = output;
this.infoString = new String[] { TextHelper.localize("jei.BloodMagic.recipe.requiredTier", tier), TextHelper.localize("jei.BloodMagic.recipe.requiredLP", requiredLP) };
this.consumptionRate = consumptionRate;
this.drainRate = drainRate;
}
@Override
public List getInputs()
{
return Collections.singletonList(input);
}
@Override
public List getOutputs()
{
return Collections.singletonList(output);
}
@Nullable
@Override
public List<String> getTooltipStrings(int mouseX, int mouseY)
{
ArrayList<String> ret = new ArrayList<String>();
if (mouseX >= 13 && mouseX <= 64 && mouseY >= 27 && mouseY <= 58)
{
ret.add(TextHelper.localize("jei.BloodMagic.recipe.consumptionRate", consumptionRate));
ret.add(TextHelper.localize("jei.BloodMagic.recipe.drainRate", drainRate));
return ret;
}
return null;
}
@Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY)
{
minecraft.fontRendererObj.drawString(infoString[0], 90 - minecraft.fontRendererObj.getStringWidth(infoString[0]) / 2, 0, Color.gray.getRGB());
minecraft.fontRendererObj.drawString(infoString[1], 90 - minecraft.fontRendererObj.getStringWidth(infoString[1]) / 2, 10, Color.gray.getRGB());
}
}

View file

@ -0,0 +1,41 @@
package WayofTime.bloodmagic.compat.jei.altar;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import WayofTime.bloodmagic.api.orb.IBloodOrb;
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
public class AltarRecipeMaker
{
@Nonnull
public static List<AltarRecipeJEI> getRecipes()
{
Map<ItemStack, AltarRecipeRegistry.AltarRecipe> altarMap = AltarRecipeRegistry.getRecipes();
ArrayList<AltarRecipeJEI> recipes = new ArrayList<AltarRecipeJEI>();
for (Map.Entry<ItemStack, AltarRecipeRegistry.AltarRecipe> itemStackAltarRecipeEntry : altarMap.entrySet())
{
if (!(itemStackAltarRecipeEntry.getKey().getItem() instanceof IBloodOrb))
{
// Make sure input is not a Blood Orb. If it is, the recipe is for a filling orb, and we don't want that.
ItemStack input = itemStackAltarRecipeEntry.getKey();
ItemStack output = itemStackAltarRecipeEntry.getValue().getOutput();
int requiredTier = itemStackAltarRecipeEntry.getValue().getMinTier().toInt();
int requiredLP = itemStackAltarRecipeEntry.getValue().getSyphon();
int consumptionRate = itemStackAltarRecipeEntry.getValue().getConsumeRate();
int drainRate = itemStackAltarRecipeEntry.getValue().getDrainRate();
AltarRecipeJEI recipe = new AltarRecipeJEI(input, output, requiredTier, requiredLP, consumptionRate, drainRate);
recipes.add(recipe);
}
}
return recipes;
}
}

View file

@ -0,0 +1,77 @@
package WayofTime.bloodmagic.compat.jei.binding;
import javax.annotation.Nonnull;
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 WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class BindingRecipeCategory 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.binding");
@Nonnull
@Override
public String getUid()
{
return Constants.Compat.JEI_CATEGORY_BINDING;
}
@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 BindingRecipeJEI)
{
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

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

View file

@ -0,0 +1,38 @@
package WayofTime.bloodmagic.compat.jei.binding;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import net.minecraft.item.ItemStack;
public class BindingRecipeJEI extends BlankRecipeWrapper
{
@Nonnull
private final List<ItemStack> inputs;
@Nonnull
private final ItemStack output;
@SuppressWarnings("unchecked")
public BindingRecipeJEI(@Nonnull ItemStack input, @Nonnull ItemStack catalyst, @Nonnull ItemStack output)
{
this.inputs = Arrays.asList(input, catalyst);
this.output = output;
}
@Override
public List getInputs()
{
return inputs;
}
@Override
public List getOutputs()
{
return Collections.singletonList(output);
}
}

View file

@ -0,0 +1,46 @@
package WayofTime.bloodmagic.compat.jei.binding;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
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;
public class BindingRecipeMaker
{
@Nonnull
public static List<BindingRecipeJEI> getRecipes()
{
Map<ItemStackWrapper, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> alchemyArrayRecipeMap = AlchemyArrayRecipeRegistry.getRecipes();
ArrayList<BindingRecipeJEI> recipes = new ArrayList<BindingRecipeJEI>();
for (Map.Entry<ItemStackWrapper, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet())
{
ItemStack input = itemStackAlchemyArrayRecipeEntry.getValue().getInputStack();
BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = itemStackAlchemyArrayRecipeEntry.getValue().catalystMap;
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;
}
}

View file

@ -0,0 +1,98 @@
package WayofTime.bloodmagic.compat.jei.forge;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
import mezz.jei.api.gui.ICraftingGridHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiItemStackGroup;
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 WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class TartaricForgeRecipeCategory implements IRecipeCategory
{
private static final int OUTPUT_SLOT = 0;
private static final int GEM_SLOT = 1;
private static final int INPUT_SLOT = 2;
@Nonnull
private final IDrawable background = BloodMagicPlugin.jeiHelper.getGuiHelper().createDrawable(new ResourceLocation(Constants.Mod.DOMAIN + "gui/jei/soulForge.png"), 0, 0, 100, 40);
@Nonnull
private final String localizedName = TextHelper.localize("jei.BloodMagic.recipe.soulForge");
@Nonnull
private final ICraftingGridHelper craftingGridHelper;
public TartaricForgeRecipeCategory()
{
craftingGridHelper = BloodMagicPlugin.jeiHelper.getGuiHelper().createCraftingGridHelper(INPUT_SLOT, OUTPUT_SLOT);
}
@Nonnull
@Override
public String getUid()
{
return Constants.Compat.JEI_CATEGORY_SOULFORGE;
}
@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)
{
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.init(OUTPUT_SLOT, false, 73, 13);
guiItemStacks.init(GEM_SLOT, true, 42, 0);
for (int y = 0; y < 3; ++y)
{
for (int x = 0; x < 3; ++x)
{
int index = INPUT_SLOT + x + (y * 3);
guiItemStacks.init(index, true, x * 18, y * 18);
}
}
if (recipeWrapper instanceof TartaricForgeRecipeJEI)
{
TartaricForgeRecipeJEI recipe = (TartaricForgeRecipeJEI) recipeWrapper;
guiItemStacks.set(GEM_SLOT, (ArrayList<ItemStack>) recipe.getInputs().get(1));
craftingGridHelper.setOutput(guiItemStacks, recipe.getOutputs());
craftingGridHelper.setInput(guiItemStacks, (List) recipe.getInputs().get(0), 2, 3);
}
}
}

View file

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

View file

@ -0,0 +1,83 @@
package WayofTime.bloodmagic.compat.jei.forge;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import lombok.Getter;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import net.minecraft.item.ItemStack;
import WayofTime.bloodmagic.api.recipe.TartaricForgeRecipe;
import WayofTime.bloodmagic.registry.ModItems;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class TartaricForgeRecipeJEI extends BlankRecipeWrapper
{
@Getter
private TartaricForgeRecipe recipe;
@Getter
private ArrayList<ItemStack> validGems = new ArrayList<ItemStack>();
public TartaricForgeRecipeJEI(TartaricForgeRecipe recipe)
{
this.recipe = recipe;
for (DefaultWill will : DefaultWill.values())
if (will.minSouls >= recipe.getMinimumSouls())
this.validGems.add(will.willStack);
}
@Override
@Nonnull
public List<Collection> getInputs()
{
ArrayList<Collection> ret = new ArrayList<Collection>();
ret.add(recipe.getInput());
ret.add(validGems);
return ret;
}
@Override
@Nonnull
public List<ItemStack> getOutputs()
{
return Collections.singletonList(recipe.getRecipeOutput());
}
@Nullable
@Override
public List<String> getTooltipStrings(int mouseX, int mouseY)
{
ArrayList<String> ret = new ArrayList<String>();
if (mouseX >= 40 && mouseX <= 60 && mouseY >= 21 && mouseY <= 34)
{
ret.add(TextHelper.localize("jei.BloodMagic.recipe.minimumSouls", recipe.getMinimumSouls()));
ret.add(TextHelper.localize("jei.BloodMagic.recipe.soulsDrained", recipe.getSoulsDrained()));
return ret;
}
return null;
}
public enum DefaultWill
{
SOUL(new ItemStack(ModItems.monsterSoul, 1, 0), 64),
PETTY(new ItemStack(ModItems.soulGem, 1, 0), 64),
LESSER(new ItemStack(ModItems.soulGem, 1, 1), 256),
COMMON(new ItemStack(ModItems.soulGem, 1, 2), 1024),
GREATER(new ItemStack(ModItems.soulGem, 1, 3), 4096),
GRAND(new ItemStack(ModItems.soulGem, 1, 4), 16384);
public final ItemStack willStack;
public final double minSouls;
DefaultWill(ItemStack willStack, double minSouls)
{
this.willStack = willStack;
this.minSouls = minSouls;
}
}
}

View file

@ -0,0 +1,24 @@
package WayofTime.bloodmagic.compat.jei.forge;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
import WayofTime.bloodmagic.api.recipe.TartaricForgeRecipe;
import WayofTime.bloodmagic.api.registry.TartaricForgeRecipeRegistry;
public class TartaricForgeRecipeMaker
{
@Nonnull
public static List<TartaricForgeRecipeJEI> getRecipes()
{
List<TartaricForgeRecipe> recipeList = TartaricForgeRecipeRegistry.getRecipeList();
ArrayList<TartaricForgeRecipeJEI> recipes = new ArrayList<TartaricForgeRecipeJEI>();
for (TartaricForgeRecipe recipe : recipeList)
recipes.add(new TartaricForgeRecipeJEI(recipe));
return recipes;
}
}

View file

@ -0,0 +1,41 @@
package WayofTime.bloodmagic.compat.jei.orb;
import java.util.Arrays;
import javax.annotation.Nonnull;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import WayofTime.bloodmagic.api.recipe.ShapedBloodOrbRecipe;
public class ShapedOrbRecipeHandler implements IRecipeHandler<ShapedBloodOrbRecipe>
{
@Nonnull
@Override
public Class<ShapedBloodOrbRecipe> getRecipeClass()
{
return ShapedBloodOrbRecipe.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid()
{
return VanillaRecipeCategoryUid.CRAFTING;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull ShapedBloodOrbRecipe recipe)
{
return new ShapedOrbRecipeJEI(Arrays.asList(recipe.getInput()), recipe.getTier(), recipe.getRecipeOutput());
}
@Override
public boolean isRecipeValid(@Nonnull ShapedBloodOrbRecipe recipe)
{
return recipe.getInput().length > 0;
}
}

View file

@ -0,0 +1,117 @@
package WayofTime.bloodmagic.compat.jei.orb;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import WayofTime.bloodmagic.api.registry.OrbRegistry;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class ShapedOrbRecipeJEI implements IShapedCraftingRecipeWrapper
{
@Nonnull
private final List inputs;
private final int tier;
@Nonnull
private final ItemStack output;
@SuppressWarnings("unchecked")
public ShapedOrbRecipeJEI(@Nonnull List input, int tier, @Nonnull ItemStack output)
{
ArrayList inputList = new ArrayList(input);
int replaceIndex = 0;
Object toReplace = null;
for (Object object : inputList)
{
if (object instanceof Integer)
{
replaceIndex = inputList.indexOf(object);
toReplace = object;
}
}
if (toReplace != null)
{
inputList.remove(replaceIndex);
inputList.add(replaceIndex, OrbRegistry.getOrbsDownToTier((Integer) toReplace));
}
this.inputs = inputList;
this.tier = tier;
this.output = output;
}
@Override
public int getWidth()
{
return 3;
}
@Override
public int getHeight()
{
return 3;
}
@Override
public List getInputs()
{
return inputs;
}
@Override
public List<ItemStack> getOutputs()
{
return Collections.singletonList(output);
}
@Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY)
{
String draw = TextHelper.localize("jei.BloodMagic.recipe.requiredTier", tier);
minecraft.fontRendererObj.drawString(draw, 72 - minecraft.fontRendererObj.getStringWidth(draw) / 2, 10, Color.gray.getRGB());
}
@Override
public List<FluidStack> getFluidInputs()
{
return null;
}
@Override
public List<FluidStack> getFluidOutputs()
{
return null;
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight)
{
}
@Nullable
@Override
public List<String> getTooltipStrings(int mouseX, int mouseY)
{
return null;
}
@Override
public boolean handleClick(@Nonnull Minecraft minecraft, int mouseX, int mouseY, int mouseButton)
{
return false;
}
}

View file

@ -0,0 +1,39 @@
package WayofTime.bloodmagic.compat.jei.orb;
import javax.annotation.Nonnull;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import WayofTime.bloodmagic.api.recipe.ShapelessBloodOrbRecipe;
public class ShapelessOrbRecipeHandler implements IRecipeHandler<ShapelessBloodOrbRecipe>
{
@Nonnull
@Override
public Class<ShapelessBloodOrbRecipe> getRecipeClass()
{
return ShapelessBloodOrbRecipe.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid()
{
return VanillaRecipeCategoryUid.CRAFTING;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull ShapelessBloodOrbRecipe recipe)
{
return new ShapelessOrbRecipeJEI(recipe.getInput(), recipe.getTier(), recipe.getRecipeOutput());
}
@Override
public boolean isRecipeValid(@Nonnull ShapelessBloodOrbRecipe recipe)
{
return recipe.getInput().size() > 0;
}
}

View file

@ -0,0 +1,105 @@
package WayofTime.bloodmagic.compat.jei.orb;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import mezz.jei.api.recipe.wrapper.ICraftingRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import WayofTime.bloodmagic.api.registry.OrbRegistry;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class ShapelessOrbRecipeJEI implements ICraftingRecipeWrapper
{
@Nonnull
private final List inputs;
private final int tier;
@Nonnull
private final ItemStack output;
@SuppressWarnings("unchecked")
public ShapelessOrbRecipeJEI(@Nonnull List input, int tier, @Nonnull ItemStack output)
{
ArrayList inputList = new ArrayList(input);
int replaceIndex = 0;
Object toReplace = null;
for (Object object : inputList)
{
if (object instanceof Integer)
{
replaceIndex = inputList.indexOf(object);
toReplace = object;
}
}
if (toReplace != null)
{
inputList.remove(replaceIndex);
inputList.add(replaceIndex, OrbRegistry.getOrbsDownToTier((Integer) toReplace));
}
this.inputs = inputList;
this.tier = tier;
this.output = output;
}
@Override
public List getInputs()
{
return inputs;
}
@Override
public List<ItemStack> getOutputs()
{
return Collections.singletonList(output);
}
@Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY)
{
String draw = TextHelper.localize("jei.BloodMagic.recipe.requiredTier", tier);
minecraft.fontRendererObj.drawString(draw, 72 - minecraft.fontRendererObj.getStringWidth(draw) / 2, 10, Color.gray.getRGB());
}
@Override
public List<FluidStack> getFluidInputs()
{
return null;
}
@Override
public List<FluidStack> getFluidOutputs()
{
return null;
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight)
{
}
@Nullable
@Override
public List<String> getTooltipStrings(int mouseX, int mouseY)
{
return null;
}
@Override
public boolean handleClick(@Nonnull Minecraft minecraft, int mouseX, int mouseY, int mouseButton)
{
return false;
}
}