Added JEI compat for the Alchemy Table
This commit is contained in:
parent
f9fc33d1ee
commit
ce385bd9a6
9 changed files with 234 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue