Hardcoded Recipes aren't my style

This commit is contained in:
oitsjustjose 2015-12-16 17:16:24 -06:00
commit 867d179a28
4 changed files with 72 additions and 33 deletions

View file

@ -2,10 +2,10 @@
-Changed: Pouches are now made differently; they no longer store color in Metadata, instead they use NBT, and can be any hex color! -Changed: Pouches are now made differently; they no longer store color in Metadata, instead they use NBT, and can be any hex color!
Note: Pouches can be dyed via Ore Dictionary Dyes! Unlike leather armor and sheep (might make a fix for that in V-Tweaks...) Note: Pouches can be dyed via Ore Dictionary Dyes! Unlike leather armor and sheep (might make a fix for that in V-Tweaks...)
-Added Crafting Handler to address new changes to pouches. -Added: Crafting Handler to address new changes to pouches.
Take your "broken" pouch and put it in your crafting grid, you'll get a new one back, keeping all stored items Take your "broken" pouch and put it in your crafting grid, you'll get a new one back, keeping all stored items
-Added ability to clear pouch of color like vanilla armor; use a cauldron with water -Added: ability to clear pouch of color like vanilla armor; use a cauldron with water
-Added the Scribe: new Tile Entity for crafting enchanted books. Only crafts Level I enchanted books; recipes and process times are non-configurable. -Added: the Scribe: new Tile Entity for crafting enchanted books. Only crafts Level I enchanted books; recipes and process times are non-configurable.
The Scribe only crafts enchanted books at Level I. This is for balance, since it does not require XP any other ways. The Scribe only crafts enchanted books at Level I. This is for balance, since it does not require XP any other ways.

View file

@ -17,6 +17,7 @@ import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@Mod(modid = Lib.modid, name = Lib.name, version = Lib.version, guiFactory = Lib.guifactory) @Mod(modid = Lib.modid, name = Lib.name, version = Lib.version, guiFactory = Lib.guifactory)
@ -40,12 +41,13 @@ public class CrissCross
LibBlocks.init(); LibBlocks.init();
LibItems.init(); LibItems.init();
VanillaRecipes.init(); VanillaRecipes.init();
CCMachineRecipes.init();
} }
@EventHandler @EventHandler
public static void init(FMLInitializationEvent event) public static void postInit(FMLPostInitializationEvent event)
{ {
CCMachineRecipes.init();
if (event.getSide().isClient()) if (event.getSide().isClient())
ClientProxy.init(); ClientProxy.init();
} }

View file

@ -31,7 +31,10 @@ public class ConfigHandler
public static int woodchipperOutput; public static int woodchipperOutput;
public static String woodchipperRecipeItem; public static String woodchipperRecipeItem;
public static String[] woodchipperFuels; public static String[] woodchipperFuels;
public static String[] defaultWoodchipperFuels = new String[] { "minecraft:water_bucket", "minecraft:potion:0", "CrissCross:magicBucket:0" }; public static String[] defaultWoodchipperFuels = new String[] { "minecraft:water_bucket", "minecraft:potion:0", "crisscross:special_bucket:0" };
public static String[] scribeRecipes;
public static String[] defaultScribeRecipes = new String[] { "minecraft:fish:3*16=6", "minecraft:spider_eye:0*8=18", "minecraft:obsidian:0*8=3", "minecraft:prismarine_shard:0*16=8", "minecraft:feather:0*32=2", "minecraft:blaze_rod:0*8=20", "minecraft:blaze_powder:0*16=50", "minecraft:piston:0*4=19", "minecraft:prismarine_crystals:0*16=61", "minecraft:fish:0*16=62", "minecraft:potion:8269*1=5", "minecraft:slime:0*8=33", "minecraft:rotten_flesh:0*48=17", "minecraft:double_plant:4*64=7", "ingotIron*24=34", "ingotGold*12=49", "gemQuartz*16=48", "gemDiamond*8=51", "gemEmerald*3=21", "logWood*16=4", "blockIron*4=0", "blockQuartz*16=16", "blockLapis*12=35", "blockRedstone*8=32" };
public static int blockGeneratorProcessTimes; public static int blockGeneratorProcessTimes;
@ -78,6 +81,8 @@ public class ConfigHandler
woodchipperRecipeItem = config.getString("Woodchipper Crafting Item", config.CATEGORY_GENERAL, "minecraft:diamond_block", "This is the item located in the center of the crafting recipe for the Woodchipper. Formatted as: <modid>:<item>:<meta> or <modid>:<item>."); woodchipperRecipeItem = config.getString("Woodchipper Crafting Item", config.CATEGORY_GENERAL, "minecraft:diamond_block", "This is the item located in the center of the crafting recipe for the Woodchipper. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.");
scribeRecipes = config.get(config.CATEGORY_GENERAL, "Custom Scribe Recipes", defaultScribeRecipes, "Formatted as <modid>:<item>:<metadata>*<qty>=<enchantment ID>" + "\n" + "Also can be <oreDict>*qty=<enchantment ID>" + "\n" + "A list of custom additional recipes for the Scribe. Default ones cannot be disabled").getStringList();
// Autosmith's Configs // Autosmith's Configs
blockGeneratorProcessTimes = config.getInt("Stone Generators' Process Times", config.CATEGORY_GENERAL, 20, 0, Short.MAX_VALUE, "Control how many ticks it takes a stone generator to process an item. Default is 20; furnaces are 200."); blockGeneratorProcessTimes = config.getInt("Stone Generators' Process Times", config.CATEGORY_GENERAL, 20, 0, Short.MAX_VALUE, "Control how many ticks it takes a stone generator to process an item. Default is 20; furnaces are 200.");

View file

@ -67,30 +67,54 @@ public class CCMachineRecipes
public static void initScribeRecipes() public static void initScribeRecipes()
{ {
ScribeRecipes.getInstance().addRecipe(new ItemStack(Items.fish, 16, 3), getEnchantedBook(Enchantment.aquaAffinity)); for (int i = 0; i < ConfigHandler.scribeRecipes.length; i++)
ScribeRecipes.getInstance().addRecipe(new ItemStack(Items.spider_eye, 8), getEnchantedBook(Enchantment.baneOfArthropods)); {
ScribeRecipes.getInstance().addRecipe(new ItemStack(Blocks.obsidian, 8), getEnchantedBook(Enchantment.blastProtection)); try
ScribeRecipes.getInstance().addRecipe(new ItemStack(Items.prismarine_shard, 16), getEnchantedBook(Enchantment.depthStrider)); {
ScribeRecipes.getInstance().addRecipe(new ItemStack(Items.feather, 32), getEnchantedBook(Enchantment.featherFalling)); String[] parts = ConfigHandler.scribeRecipes[i].split("[\\W]");
ScribeRecipes.getInstance().addRecipe(new ItemStack(Items.blaze_rod, 8), getEnchantedBook(Enchantment.fireAspect)); if (parts.length == 5)
ScribeRecipes.getInstance().addRecipe(new ItemStack(Items.blaze_powder, 16), getEnchantedBook(Enchantment.flame)); {
ScribeRecipes.getInstance().addRecipe(new ItemStack(Blocks.piston, 4), getEnchantedBook(Enchantment.knockback)); String modid = parts[0];
ScribeRecipes.getInstance().addRecipe(new ItemStack(Items.prismarine_crystals, 16), getEnchantedBook(Enchantment.luckOfTheSea)); String object = parts[1];
ScribeRecipes.getInstance().addRecipe(new ItemStack(Items.fish, 16, 0), getEnchantedBook(Enchantment.lure)); int metadata = Integer.parseInt(parts[2]);
ScribeRecipes.getInstance().addRecipe(new ItemStack(Items.potionitem, 1, 8269), getEnchantedBook(Enchantment.respiration)); int qty = Integer.parseInt(parts[3]);
ScribeRecipes.getInstance().addRecipe(new ItemStack(Blocks.slime_block, 8), getEnchantedBook(Enchantment.silkTouch)); int enchID = Integer.parseInt(parts[4]);
ScribeRecipes.getInstance().addRecipe(new ItemStack(Items.rotten_flesh, 48), getEnchantedBook(Enchantment.smite));
ScribeRecipes.getInstance().addRecipe(new ItemStack(Blocks.double_plant, 64, 4), getEnchantedBook(Enchantment.thorns)); if (ConfigHandler.findItemStack(modid, object) != null && Enchantment.getEnchantmentById(enchID) != null)
ScribeRecipes.getInstance().addRecipe("ingotIron", 24, getEnchantedBook(Enchantment.unbreaking)); {
ScribeRecipes.getInstance().addRecipe("ingotGold", 12, getEnchantedBook(Enchantment.punch)); ItemStack newStack = ConfigHandler.findItemStack(modid, object);
ScribeRecipes.getInstance().addRecipe("gemQuartz", 16, getEnchantedBook(Enchantment.power)); ScribeRecipes.getInstance().addRecipe(new ItemStack(newStack.getItem(), qty, metadata), getEnchantedBook(enchID));
ScribeRecipes.getInstance().addRecipe("gemDiamond", 8, getEnchantedBook(Enchantment.infinity)); }
ScribeRecipes.getInstance().addRecipe("gemEmerald", 3, getEnchantedBook(Enchantment.looting)); else
ScribeRecipes.getInstance().addRecipe("logWood", 16, getEnchantedBook(Enchantment.projectileProtection)); {
ScribeRecipes.getInstance().addRecipe("blockIron", 4, getEnchantedBook(Enchantment.protection)); CCLog.warn("Item " + ConfigHandler.scribeRecipes[i] + " could not be added to the Scribe's recipe list.");
ScribeRecipes.getInstance().addRecipe("blockQuartz", 16, getEnchantedBook(Enchantment.sharpness)); CCLog.warn("Please confirm you have the name and formatting and ID's correct.");
ScribeRecipes.getInstance().addRecipe("blockLapis", 12, getEnchantedBook(Enchantment.fortune)); }
ScribeRecipes.getInstance().addRecipe("blockRedstone", 8, getEnchantedBook(Enchantment.efficiency)); }
else if (parts.length == 3)
{
String oreDict = parts[0];
int qty = Integer.parseInt(parts[1]);
int enchID = Integer.parseInt(parts[2]);
if (OreDictionary.getOres(oreDict).size() > 0)
{
if (Enchantment.getEnchantmentById(enchID) != null)
ScribeRecipes.getInstance().addRecipe(oreDict, qty, getEnchantedBook(enchID));
else
CCLog.warn("Enchantment ID " + enchID + " does not appear to be valid. Skipping Scribe recipe addition.");
}
else
CCLog.warn("Ore Dictionary Name " + oreDict + " does not appear to be valid. Skipping Scribe recipe addition.");
}
else
CCLog.warn("Your formatting for entry " + (i + 1) + " does not appear to be correct.");
}
catch (Exception e)
{
CCLog.warn("Error reading itemstack for Scribe from input file at item: " + (i + 1));
}
}
} }
public static void initCropomatorRecipes() public static void initCropomatorRecipes()
@ -131,7 +155,7 @@ public class CCMachineRecipes
} }
catch (Exception e) catch (Exception e)
{ {
CCLog.warn("Error reading itemstack for inputs from input file at item: " + (i + 1)); CCLog.warn("Error reading itemstack for Cropomator from input file at item: " + (i + 1));
} }
} }
@ -171,7 +195,7 @@ public class CCMachineRecipes
} }
catch (Exception e) catch (Exception e)
{ {
CCLog.warn("Error reading itemstack for catalysts from input file at item: " + (i + 1)); CCLog.warn("Error reading itemstack for Cropomator Cataylsts from input file at item: " + (i + 1));
} }
} }
} }
@ -343,6 +367,14 @@ public class CCMachineRecipes
} }
} }
static ItemStack getEnchantedBook(int id)
{
ItemStack retBook = new ItemStack(Items.enchanted_book);
Items.enchanted_book.addEnchantment(retBook, new EnchantmentData(Enchantment.getEnchantmentById(id), 1));
return retBook;
}
static ItemStack getEnchantedBook(Enchantment enchantment) static ItemStack getEnchantedBook(Enchantment enchantment)
{ {
ItemStack retBook = new ItemStack(Items.enchanted_book); ItemStack retBook = new ItemStack(Items.enchanted_book);