Skip to content

Instantly share code, notes, and snippets.

@skyboy
Last active June 13, 2018 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyboy/9ca22f7eee539ec67446773717207458 to your computer and use it in GitHub Desktop.
Save skyboy/9ca22f7eee539ec67446773717207458 to your computer and use it in GitHub Desktop.
package powercrystals.minefactoryreloaded.api;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import java.io.File;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
public interface IMFRRecipeSet {
/**
* Apply this annotation to your RecipeSet if it depends on other mods,
* they will be checked to see if they are loaded before creating your RecipeSet
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface DependsOn {
String[] value();
}
/**
* Register oredictionary entries for MFR's (or your) items that are not otherwise registered by default
*/
default void registerOredict() {
}
/**
* Read configuration options for your recipe set from the provided config
* <p>
* You are handed a {@link File} instead of a {@link net.minecraftforge.common.config.Configuration Configuration}
* so that you may either use a different format, or ignore this entirely if you have no settings without creating an empty file.
*/
default void readConfig(File config) {
}
/**
* Register your recipes for MFR's items
*/
void registerRecipes();
/**
* The name of your recipe set, by default the Class's name is used
*
* @return String The name of this set used in MFR's config for enabling/disabling sets
*/
default String getSetName() {
return this.getClass().getSimpleName();
}
/**
* TODO: docs: auto-populated fields, lists
*/
interface IRecipeHolder {
/**
* The name of this Recipe
* @return The name of this Recipe
*/
ResourceLocation getName();
/**
* Test whether or not this RecipeHolder is enabled.
* <p>
* This is only needed if you want to test for special conditions, and is automatically handled otherwise.
* @return true if this recipe is enabled
*/
boolean isEnabled();
/**
* Get the ItemStack for this RecipeHolder.
* <p>
* This is only needed for special conditions within your own code.
* @return The ItemStack for this RecipeHolder
*/
ItemStack getItemStack();
/**
* Add a shaped crafting recipe for this.
* @param input The Shape of this recipe followed by the list of ingredients
*/
void addShapedRecipe(Object... input);
/**
* Add a shapeless crafting recipe for this.
* @param input The list of ingredients
*/
void addShapelessRecipe(Object... input);
/**
* This is just a dummy object, so that you may populate your fields with it
* if your IDE is complaining about nulls
*/
IRecipeHolder EMPTY = new IRecipeHolder() {
@Override
public ResourceLocation getName() {
return null;
}
@Override
public boolean isEnabled() {
return false;
}
@Override
public ItemStack getItemStack() {
return null;
}
@Override
public void addShapedRecipe(Object... input) {
}
@Override
public void addShapelessRecipe(Object... input) {
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment