Add support for JustEnoughItems
Will build on as we add more recipe types.
This commit is contained in:
parent
6f96e200d2
commit
91f88b846f
|
@ -65,6 +65,7 @@ public class BloodMagic {
|
|||
ModRecipes.init();
|
||||
ModRituals.initRituals();
|
||||
ModRituals.initImperfectRituals();
|
||||
ModCompatibility.registerModCompat();
|
||||
ConfigHandler.checkRituals();
|
||||
|
||||
proxy.init();
|
||||
|
|
|
@ -132,4 +132,8 @@ public enum EnumAltarTier {
|
|||
public void buildComponents() {
|
||||
|
||||
}
|
||||
|
||||
public int toInt() {
|
||||
return ordinal() + 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package WayofTime.bloodmagic.compat;
|
||||
|
||||
/**
|
||||
* Implement on all primary compatibility classes.
|
||||
*/
|
||||
public interface ICompatibility {
|
||||
|
||||
/**
|
||||
* Called after the given {@code modid} has been verified as loaded.
|
||||
*/
|
||||
void loadCompatibility();
|
||||
|
||||
/**
|
||||
* The {@code modid} of the mod we are adding compatibility for.
|
||||
*/
|
||||
String getModId();
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
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 mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BloodMagicPlugin implements IModPlugin {
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends IRecipeCategory> getRecipeCategories() {
|
||||
return Arrays.asList(
|
||||
new AltarRecipeCategory()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends IRecipeHandler> getRecipeHandlers() {
|
||||
return Arrays.asList(
|
||||
new AltarRecipeHandler()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Object> getRecipes() {
|
||||
List<Object> recipes = new ArrayList<Object>();
|
||||
|
||||
recipes.addAll(AltarRecipeMaker.getAltarRecipes());
|
||||
|
||||
return recipes;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package WayofTime.bloodmagic.compat.jei;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BloodMagicRecipeWrapper implements IRecipeWrapper {
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidInputs() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidOutputs() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package WayofTime.bloodmagic.compat.jei;
|
||||
|
||||
import WayofTime.bloodmagic.compat.ICompatibility;
|
||||
import mezz.jei.api.JEIManager;
|
||||
|
||||
public class CompatibilityJustEnoughItems implements ICompatibility {
|
||||
|
||||
@Override
|
||||
public void loadCompatibility() {
|
||||
JEIManager.pluginRegistry.registerPlugin(new BloodMagicPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModId() {
|
||||
return "JEI";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package WayofTime.bloodmagic.compat.jei.altar;
|
||||
|
||||
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.IGuiFluidTanks;
|
||||
import mezz.jei.api.gui.IGuiItemStacks;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class AltarRecipeCategory 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/altar.png"), 3, 4, 155, 65);
|
||||
@Nonnull
|
||||
private final String localizedName = TextHelper.localize("jei.BloodMagic.recipe.altar");
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return localizedName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(@Nonnull IGuiItemStacks guiItemStacks, @Nonnull IGuiFluidTanks guiFluidTanks) {
|
||||
guiItemStacks.init(INPUT_SLOT, 31, 0);
|
||||
guiItemStacks.init(OUTPUT_SLOT, 125, 30);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setRecipe(@Nonnull IGuiItemStacks guiItemStacks, @Nonnull IGuiFluidTanks guiFluidTanks, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
if (recipeWrapper instanceof AltarRecipeJEI) {
|
||||
AltarRecipeJEI altarRecipeWrapper = (AltarRecipeJEI) recipeWrapper;
|
||||
guiItemStacks.set(INPUT_SLOT, altarRecipeWrapper.getInputs());
|
||||
guiItemStacks.set(OUTPUT_SLOT, altarRecipeWrapper.getOutputs());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package WayofTime.bloodmagic.compat.jei.altar;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class AltarRecipeHandler implements IRecipeHandler<AltarRecipeJEI> {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<AltarRecipeJEI> getRecipeClass() {
|
||||
return AltarRecipeJEI.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<? extends IRecipeCategory> getRecipeCategoryClass() {
|
||||
return AltarRecipeCategory.class;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package WayofTime.bloodmagic.compat.jei.altar;
|
||||
|
||||
import WayofTime.bloodmagic.compat.jei.BloodMagicRecipeWrapper;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AltarRecipeJEI extends BloodMagicRecipeWrapper {
|
||||
|
||||
@Nonnull
|
||||
private final ItemStack input;
|
||||
|
||||
@Nonnull
|
||||
private final ItemStack output;
|
||||
|
||||
private final String[] infoString;
|
||||
|
||||
public AltarRecipeJEI(@Nonnull ItemStack input, @Nonnull ItemStack output, int tier, int requiredLP) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
|
||||
this.infoString = new String[]{ TextHelper.localize("jei.BloodMagic.recipe.requiredTier", tier), TextHelper.localize("jei.BloodMagic.recipe.requiredLP", requiredLP) };
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getInputs() {
|
||||
return Collections.singletonList(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getOutputs() {
|
||||
return Collections.singletonList(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(@Nonnull Minecraft minecraft) {
|
||||
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());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package WayofTime.bloodmagic.compat.jei.altar;
|
||||
|
||||
import WayofTime.bloodmagic.api.altar.AltarRecipe;
|
||||
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.*;
|
||||
|
||||
public class AltarRecipeMaker {
|
||||
|
||||
@Nonnull
|
||||
public static List<AltarRecipeJEI> getAltarRecipes() {
|
||||
Map<ItemStack, AltarRecipe> altarMap = AltarRecipeRegistry.getRecipes();
|
||||
|
||||
ArrayList<AltarRecipeJEI> recipes = new ArrayList<AltarRecipeJEI>();
|
||||
|
||||
for (Map.Entry<ItemStack, 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();
|
||||
int requiredTier = itemStackAltarRecipeEntry.getValue().getMinTier().toInt();
|
||||
int requiredLP = itemStackAltarRecipeEntry.getValue().getSyphon();
|
||||
|
||||
AltarRecipeJEI recipe = new AltarRecipeJEI(input, output, requiredTier, requiredLP);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
return recipes;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package WayofTime.bloodmagic.registry;
|
||||
|
||||
import WayofTime.bloodmagic.compat.ICompatibility;
|
||||
import WayofTime.bloodmagic.compat.jei.CompatibilityJustEnoughItems;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ModCompatibility {
|
||||
|
||||
private static ArrayList<ICompatibility> compatibilities = new ArrayList<ICompatibility>();
|
||||
|
||||
public static void registerModCompat() {
|
||||
compatibilities.add(new CompatibilityJustEnoughItems());
|
||||
|
||||
for (ICompatibility compat : compatibilities) {
|
||||
if (Loader.isModLoaded(compat.getModId()))
|
||||
compat.loadCompatibility();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -110,3 +110,8 @@ tooltip.BloodMagic.pack.stored=Stored: %d LP
|
|||
tooltip.BloodMagic.activationCrystal.weak=Activates low-level rituals
|
||||
tooltip.BloodMagic.activationCrystal.awakened=Activates more powerful rituals
|
||||
tooltip.BloodMagic.activationCrystal.creative=Creative Only - Activates any ritual
|
||||
|
||||
# JustEnoughItems
|
||||
jei.BloodMagic.recipe.altar=Blood Altar
|
||||
jei.BloodMagic.recipe.requiredLP=LP: %d
|
||||
jei.BloodMagic.recipe.requiredTier=Tier: %d
|
||||
|
|
Loading…
Reference in a new issue