Added JEI compat for the Alchemy Table

This commit is contained in:
WayofTime 2016-05-02 13:45:52 -04:00
parent f9fc33d1ee
commit ce385bd9a6
9 changed files with 234 additions and 5 deletions

View file

@ -1,7 +1,7 @@
------------------------------------------------------
Version 2.0.0-36
------------------------------------------------------
- Added JEI compat for the Alchemy Table
------------------------------------------------------
Version 2.0.0-35

View file

@ -137,6 +137,7 @@ public class Constants
public static final String JEI_CATEGORY_BINDING = Mod.MODID + ":binding";
public static final String JEI_CATEGORY_ALCHEMYARRAY = Mod.MODID + ":alchemyArray";
public static final String JEI_CATEGORY_SOULFORGE = Mod.MODID + ":soulForge";
public static final String JEI_CATEGORY_ALCHEMYTABLE = Mod.MODID + ":salchemyTable";
public static final String WAILA_CONFIG_BYPASS_SNEAK = Mod.MODID + ".bypassSneak";
public static final String WAILA_CONFIG_ALTAR = Mod.MODID + ".bloodAltar";

View file

@ -4,8 +4,6 @@ import java.util.Map;
import javax.annotation.Nonnull;
import WayofTime.bloodmagic.client.gui.GuiSoulForge;
import WayofTime.bloodmagic.item.ItemComponent;
import mezz.jei.api.BlankModPlugin;
import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.IModRegistry;
@ -15,9 +13,13 @@ import net.minecraftforge.oredict.OreDictionary;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler;
import WayofTime.bloodmagic.api.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.alchemyTable.AlchemyTableRecipeCategory;
import WayofTime.bloodmagic.compat.jei.alchemyTable.AlchemyTableRecipeHandler;
import WayofTime.bloodmagic.compat.jei.alchemyTable.AlchemyTableRecipeMaker;
import WayofTime.bloodmagic.compat.jei.altar.AltarRecipeCategory;
import WayofTime.bloodmagic.compat.jei.altar.AltarRecipeHandler;
import WayofTime.bloodmagic.compat.jei.altar.AltarRecipeMaker;
@ -42,14 +44,15 @@ public class BloodMagicPlugin extends BlankModPlugin
{
jeiHelper = registry.getJeiHelpers();
registry.addRecipeCategories(new AltarRecipeCategory(), new BindingRecipeCategory(), new AlchemyArrayCraftingCategory(), new TartaricForgeRecipeCategory());
registry.addRecipeCategories(new AltarRecipeCategory(), new BindingRecipeCategory(), new AlchemyArrayCraftingCategory(), new TartaricForgeRecipeCategory(), new AlchemyTableRecipeCategory());
registry.addRecipeHandlers(new AltarRecipeHandler(), new BindingRecipeHandler(), new AlchemyArrayCraftingRecipeHandler(), new TartaricForgeRecipeHandler(), new ShapedOrbRecipeHandler(), new ShapelessOrbRecipeHandler());
registry.addRecipeHandlers(new AltarRecipeHandler(), new BindingRecipeHandler(), new AlchemyArrayCraftingRecipeHandler(), new TartaricForgeRecipeHandler(), new AlchemyTableRecipeHandler(), new ShapedOrbRecipeHandler(), new ShapelessOrbRecipeHandler());
registry.addRecipes(AltarRecipeMaker.getRecipes());
registry.addRecipes(BindingRecipeMaker.getRecipes());
registry.addRecipes(AlchemyArrayCraftingRecipeMaker.getRecipes());
registry.addRecipes(TartaricForgeRecipeMaker.getRecipes());
registry.addRecipes(AlchemyTableRecipeMaker.getRecipes());
registry.addDescription(new ItemStack(ModItems.altarMaker), "jei.BloodMagic.desc.altarBuilder");
registry.addDescription(new ItemStack(ModItems.monsterSoul), "jei.BloodMagic.desc.demonicWill");
@ -79,6 +82,7 @@ public class BloodMagicPlugin extends BlankModPlugin
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.soulForge), Constants.Compat.JEI_CATEGORY_SOULFORGE);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModItems.arcaneAshes), Constants.Compat.JEI_CATEGORY_ALCHEMYARRAY);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModItems.arcaneAshes), Constants.Compat.JEI_CATEGORY_BINDING);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.alchemyTable), Constants.Compat.JEI_CATEGORY_ALCHEMYTABLE);
jeiHelper.getNbtIgnoreList().ignoreNbtTagNames(Constants.NBT.OWNER_UUID);
jeiHelper.getNbtIgnoreList().ignoreNbtTagNames(Constants.NBT.OWNER_NAME);

View file

@ -0,0 +1,98 @@
package WayofTime.bloodmagic.compat.jei.alchemyTable;
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 AlchemyTableRecipeCategory implements IRecipeCategory
{
private static final int OUTPUT_SLOT = 0;
private static final int ORB_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/alchemyTable.png"), 0, 0, 118, 40);
@Nonnull
private final String localizedName = TextHelper.localize("jei.BloodMagic.recipe.alchemyTable");
@Nonnull
private final ICraftingGridHelper craftingGridHelper;
public AlchemyTableRecipeCategory()
{
craftingGridHelper = BloodMagicPlugin.jeiHelper.getGuiHelper().createCraftingGridHelper(INPUT_SLOT, OUTPUT_SLOT);
}
@Nonnull
@Override
public String getUid()
{
return Constants.Compat.JEI_CATEGORY_ALCHEMYTABLE;
}
@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, 91, 13);
guiItemStacks.init(ORB_SLOT, true, 60, 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 AlchemyTableRecipeJEI)
{
AlchemyTableRecipeJEI recipe = (AlchemyTableRecipeJEI) recipeWrapper;
guiItemStacks.set(ORB_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.alchemyTable;
import javax.annotation.Nonnull;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import WayofTime.bloodmagic.api.Constants;
public class AlchemyTableRecipeHandler implements IRecipeHandler<AlchemyTableRecipeJEI>
{
@Nonnull
@Override
public Class<AlchemyTableRecipeJEI> getRecipeClass()
{
return AlchemyTableRecipeJEI.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid()
{
return Constants.Compat.JEI_CATEGORY_ALCHEMYTABLE;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull AlchemyTableRecipeJEI recipe)
{
return recipe;
}
@Override
public boolean isRecipeValid(@Nonnull AlchemyTableRecipeJEI recipe)
{
return recipe.getInputs().get(0).size() > 0 && recipe.getOutputs().size() > 0;
}
}

View file

@ -0,0 +1,61 @@
package WayofTime.bloodmagic.compat.jei.alchemyTable;
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.AlchemyTableRecipe;
import WayofTime.bloodmagic.api.registry.OrbRegistry;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class AlchemyTableRecipeJEI extends BlankRecipeWrapper
{
@Getter
private AlchemyTableRecipe recipe;
// @Getter
// private ArrayList<ItemStack> validGems = new ArrayList<ItemStack>();
public AlchemyTableRecipeJEI(AlchemyTableRecipe recipe)
{
this.recipe = recipe;
}
@Override
@Nonnull
public List<Collection> getInputs()
{
ArrayList<Collection> ret = new ArrayList<Collection>();
ret.add(recipe.getInput());
ret.add(OrbRegistry.getOrbsDownToTier(recipe.getTierRequired()));
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 >= 58 && mouseX <= 78 && mouseY >= 21 && mouseY <= 34)
{
ret.add(TextHelper.localize("jei.BloodMagic.recipe.lpDrained", recipe.getLpDrained()));
ret.add(TextHelper.localize("jei.BloodMagic.recipe.ticksRequired", recipe.getTicksRequired()));
return ret;
}
return null;
}
}

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 B

View file

@ -195,6 +195,7 @@ tile.BloodMagic.incenseAltar.name=Incense Altar
tile.BloodMagic.teleposer.name=Teleposer
tile.BloodMagic.soulForge.name=Hellfire Forge
tile.BloodMagic.alchemyTable.name=Alchemy Table
tile.BloodMagic.demonCrucible.name=Demon Crucible
tile.BloodMagic.demonPylon.name=Demon Pylon
tile.BloodMagic.demonCrystallizer.name=Demon Crystallizer
@ -560,12 +561,15 @@ jei.BloodMagic.recipe.altar=Blood Altar
jei.BloodMagic.recipe.binding=Alchemy Array (Binding)
jei.BloodMagic.recipe.alchemyArrayCrafting=Alchemy Array
jei.BloodMagic.recipe.soulForge=Hellfire Forge
jei.BloodMagic.recipe.alchemyTable=Alchemy Table
jei.BloodMagic.recipe.requiredLP=LP: %d
jei.BloodMagic.recipe.requiredTier=Tier: %d
jei.BloodMagic.recipe.consumptionRate=Consumption: %d LP/t
jei.BloodMagic.recipe.drainRate=Drain: %d LP/t
jei.BloodMagic.recipe.minimumSouls=Minimum: %1$,.2f Will
jei.BloodMagic.recipe.soulsDrained=Drained: %1$,.2f Will
jei.BloodMagic.recipe.lpDrained=Drained: %,d LP
jei.BloodMagic.recipe.ticksRequired=Time: %,d Ticks
jei.BloodMagic.desc.altarBuilder=A creative-only item for use in debugging and testing.\n\nShift + Right click to change the tier to build. Right click an Altar to initiate the build.\n\nBreak an Altar while holding to dismantle it.
jei.BloodMagic.desc.demonicWill=An imprint of a demonic entity attached to a creature.\n\nCan be obtained by killing a mob with a sentient weapon or by throwing a snare at a mob and killing it while it has white particles.