Skip to content

Instantly share code, notes, and snippets.

@tehbeard
Created July 10, 2013 20:07
Show Gist options
  • Save tehbeard/5969831 to your computer and use it in GitHub Desktop.
Save tehbeard/5969831 to your computer and use it in GitHub Desktop.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.item.ItemStack;
public class EasyRecipe {
String[] rows;
ItemStack res;
Map<Character,Object> mapping = new HashMap<Character, Object>();
public EasyRecipe(ItemStack res,String... rows){
this.rows = rows;
this.res = res;
}
public EasyRecipe map(char c, ItemStack itemstack){
mapping.put(c,itemstack);
return this;
}
public EasyRecipe map(char c, String oreDict){
mapping.put(c,oreDict);
return this;
}
public void asShapedRecipe(){
List<Object> params = new ArrayList<Object>();
params.addAll(Arrays.asList(rows));
for(Entry<Character, Object> entry : mapping.entrySet()){
params.add(entry.getKey());
params.add(entry.getValue());
}
GameRegistry.addShapedRecipe(res, params.toArray());
}
public void asShapelessRecipe(){
List<Object> params = new ArrayList<Object>();
for(Entry<Character, Object> entry : mapping.entrySet()){
params.add(entry.getValue());
}
GameRegistry.addShapelessRecipe(res, params.toArray());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment