Add registry for Binding rituals and add JEI support
This commit is contained in:
parent
a3b12cb7e2
commit
13d9cb4b5a
15 changed files with 298 additions and 93 deletions
|
@ -3,6 +3,9 @@ package WayofTime.bloodmagic.compat.jei;
|
|||
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 mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
|
@ -24,7 +27,8 @@ public class BloodMagicPlugin implements IModPlugin {
|
|||
@Nonnull
|
||||
public Iterable<? extends IRecipeCategory> getRecipeCategories() {
|
||||
return Arrays.asList(
|
||||
new AltarRecipeCategory()
|
||||
new AltarRecipeCategory(),
|
||||
new BindingRecipeCategory()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -32,7 +36,8 @@ public class BloodMagicPlugin implements IModPlugin {
|
|||
@Nonnull
|
||||
public Iterable<? extends IRecipeHandler> getRecipeHandlers() {
|
||||
return Arrays.asList(
|
||||
new AltarRecipeHandler()
|
||||
new AltarRecipeHandler(),
|
||||
new BindingRecipeHandler()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -48,7 +53,8 @@ public class BloodMagicPlugin implements IModPlugin {
|
|||
public Iterable<Object> getRecipes() {
|
||||
List<Object> recipes = new ArrayList<Object>();
|
||||
|
||||
recipes.addAll(AltarRecipeMaker.getAltarRecipes());
|
||||
recipes.addAll(AltarRecipeMaker.getRecipes());
|
||||
recipes.addAll(BindingRecipeMaker.getRecipes());
|
||||
|
||||
return recipes;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package WayofTime.bloodmagic.compat.jei.altar;
|
||||
|
||||
import WayofTime.bloodmagic.api.altar.AltarRecipe;
|
||||
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
@ -12,12 +11,12 @@ import java.util.Map;
|
|||
public class AltarRecipeMaker {
|
||||
|
||||
@Nonnull
|
||||
public static List<AltarRecipeJEI> getAltarRecipes() {
|
||||
Map<ItemStack, AltarRecipe> altarMap = AltarRecipeRegistry.getRecipes();
|
||||
public static List<AltarRecipeJEI> getRecipes() {
|
||||
Map<ItemStack, AltarRecipeRegistry.AltarRecipe> altarMap = AltarRecipeRegistry.getRecipes();
|
||||
|
||||
ArrayList<AltarRecipeJEI> recipes = new ArrayList<AltarRecipeJEI>();
|
||||
|
||||
for (Map.Entry<ItemStack, AltarRecipe> itemStackAltarRecipeEntry : altarMap.entrySet()) {
|
||||
for (Map.Entry<ItemStack, AltarRecipeRegistry.AltarRecipe> itemStackAltarRecipeEntry : altarMap.entrySet()) {
|
||||
if (itemStackAltarRecipeEntry.getValue().getOutput() != null) { // Make sure output is not null. 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();
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package WayofTime.bloodmagic.compat.jei.binding;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import mezz.jei.api.JEIManager;
|
||||
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.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BindingRecipeCategory implements IRecipeCategory {
|
||||
|
||||
private static final int INPUT_SLOT = 0;
|
||||
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);
|
||||
@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 init(@Nonnull IRecipeLayout recipeLayout) {
|
||||
recipeLayout.getItemStacks().init(INPUT_SLOT, true, 0, 5);
|
||||
recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 73, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
if (recipeWrapper instanceof BindingRecipeJEI) {
|
||||
BindingRecipeJEI bindingRecipeWrapper = (BindingRecipeJEI) recipeWrapper;
|
||||
recipeLayout.getItemStacks().set(INPUT_SLOT, bindingRecipeWrapper.getInputs());
|
||||
recipeLayout.getItemStacks().set(OUTPUT_SLOT, bindingRecipeWrapper.getOutputs());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package WayofTime.bloodmagic.compat.jei.binding;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package WayofTime.bloodmagic.compat.jei.binding;
|
||||
|
||||
import WayofTime.bloodmagic.compat.jei.BloodMagicRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BindingRecipeJEI extends BloodMagicRecipeWrapper {
|
||||
|
||||
@Nonnull
|
||||
private final ItemStack input;
|
||||
|
||||
@Nonnull
|
||||
private final ItemStack output;
|
||||
|
||||
public BindingRecipeJEI(@Nonnull ItemStack input, @Nonnull ItemStack output) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesOreDictionaryComparison() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getInputs() {
|
||||
return Collections.singletonList(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getOutputs() {
|
||||
return Collections.singletonList(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(@Nonnull Minecraft minecraft) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package WayofTime.bloodmagic.compat.jei.binding;
|
||||
|
||||
import WayofTime.bloodmagic.api.registry.BindingRecipeRegistry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BindingRecipeMaker {
|
||||
|
||||
@Nonnull
|
||||
public static List<BindingRecipeJEI> getRecipes() {
|
||||
Map<ItemStack, BindingRecipeRegistry.BindingRecipe> altarMap = BindingRecipeRegistry.getRecipes();
|
||||
|
||||
ArrayList<BindingRecipeJEI> recipes = new ArrayList<BindingRecipeJEI>();
|
||||
|
||||
for (Map.Entry<ItemStack, BindingRecipeRegistry.BindingRecipe> itemStackBindingRecipeEntry : altarMap.entrySet()) {
|
||||
ItemStack input = itemStackBindingRecipeEntry.getKey();
|
||||
ItemStack output = itemStackBindingRecipeEntry.getValue().getOutput();
|
||||
|
||||
BindingRecipeJEI recipe = new BindingRecipeJEI(input, output);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
return recipes;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue