Fixing Recipe stuff. Custom Recipes should now work **right**

This commit is contained in:
oitsjustjose 2015-12-20 23:13:01 -06:00
commit 49a6450c3f
14 changed files with 88 additions and 77 deletions

View file

@ -5,10 +5,11 @@ import com.oitsjustjose.criss_cross.lib.CreativeTab;
import com.oitsjustjose.criss_cross.lib.Lib;
import com.oitsjustjose.criss_cross.lib.LibBlocks;
import com.oitsjustjose.criss_cross.lib.LibItems;
import com.oitsjustjose.criss_cross.recipes.CCMachineRecipes;
import com.oitsjustjose.criss_cross.recipes.VanillaRecipes;
import com.oitsjustjose.criss_cross.recipes.MachineRecipes;
import com.oitsjustjose.criss_cross.recipes.CraftingRecipes;
import com.oitsjustjose.criss_cross.util.ClientProxy;
import com.oitsjustjose.criss_cross.util.CommonProxy;
import com.oitsjustjose.criss_cross.util.LogHelper;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraftforge.common.MinecraftForge;
@ -40,15 +41,17 @@ public class CrissCross
LibBlocks.init();
LibItems.init();
VanillaRecipes.init();
CraftingRecipes.init();
}
@EventHandler
public static void postInit(FMLPostInitializationEvent event)
{
CCMachineRecipes.init();
MachineRecipes.init();
if (event.getSide().isClient())
ClientProxy.init();
LogHelper.info("Successfully loaded!");
}
}

View file

@ -2,6 +2,9 @@ package com.oitsjustjose.criss_cross.lib;
import java.io.File;
import com.oitsjustjose.criss_cross.util.LogHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
@ -101,9 +104,11 @@ public class ConfigHandler
public static ItemStack findItemStack(String modid, String name)
{
if (GameRegistry.findItem(modid, name) != null)
return new ItemStack(GameRegistry.findItem(modid, name));
return new ItemStack(GameRegistry.findItem(modid, name), 1);
else if (GameRegistry.findBlock(modid, name) != null)
return new ItemStack(GameRegistry.findBlock(modid, name));
if (Item.getItemFromBlock(GameRegistry.findBlock(modid, name)) != null)
return new ItemStack(Item.getItemFromBlock(GameRegistry.findBlock(modid, name)), 1);
return null;
}
}

View file

@ -3,7 +3,7 @@ package com.oitsjustjose.criss_cross.recipes;
import com.oitsjustjose.criss_cross.lib.ConfigHandler;
import com.oitsjustjose.criss_cross.lib.LibBlocks;
import com.oitsjustjose.criss_cross.lib.LibItems;
import com.oitsjustjose.criss_cross.util.CCLog;
import com.oitsjustjose.criss_cross.util.LogHelper;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@ -14,21 +14,19 @@ import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.RecipeSorter.Category;
import net.minecraftforge.oredict.ShapedOreRecipe;
public class VanillaRecipes
public class CraftingRecipes
{
public static void init()
{
cropomatorRecipe();
electroextractorRecipe();
woodChipperRecipe();
initOthers();
initStaticRecipes();
intUserRecipes();
CraftingManager.getInstance().getRecipeList().add(new PouchColorRecipes());
CraftingManager.getInstance().getRecipeList().add(new PouchRollbackRecipes());
RecipeSorter.register("CrissCross:PouchColorRecipes", PouchColorRecipes.class, Category.SHAPELESS, "");
RecipeSorter.register("CrissCross:PouchRollbackRecipes", PouchRollbackRecipes.class, Category.SHAPELESS, "");
}
static void initOthers()
static void initStaticRecipes()
{
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(LibBlocks.cobblegen), "CPC", "#$#", "CPC", '$', "blockIron", 'C', "cobblestone", 'P', Blocks.piston, '#', Items.stone_pickaxe));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(LibBlocks.stonegen), "CPC", "#$#", "CPC", '$', "blockIron", 'C', "stone", 'P', Blocks.piston, '#', Items.stone_pickaxe));
@ -40,9 +38,10 @@ public class VanillaRecipes
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(LibItems.mantleSmasherMkII), "## ", "#PI", " IN", '#', "blockDiamond", 'I', "blockGold", 'P', LibItems.mantleSmasherMkI, 'N', Items.nether_star));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(LibItems.pouch), "SDS", "LCL", "LLL", 'S', Items.string, 'D', "gemDiamond", 'L', Items.leather, 'C', Blocks.chest));
}
static void woodChipperRecipe()
static void intUserRecipes()
{
//Woodchipper Recipe
String[] unlocItem = ConfigHandler.woodchipperRecipeItem.split(":");
ItemStack centerItem = new ItemStack(Blocks.diamond_block);
@ -56,17 +55,17 @@ public class VanillaRecipes
}
else
{
CCLog.warn("Item " + ConfigHandler.woodchipperRecipeItem + "could not be added as part of the recipe of the Woodchipper.");
CCLog.warn("Please confirm you have the name and formatting correct.");
LogHelper.warn(ConfigHandler.woodchipperRecipeItem + " could not be implemented into the Woodchipper's Crafting Recipe.");
LogHelper.warn("The fallback, " + centerItem.getDisplayName() + ", has been used instead");
LogHelper.warn("Please confirm you have the name and formatting correct.");
System.out.println();
}
GameRegistry.addRecipe(new ItemStack(LibBlocks.woodchipper), new Object[] { "I#I", "SCS", "I#I", '#', Items.diamond_axe, 'I', Blocks.iron_bars, 'S', Items.golden_axe, 'C', centerItem });
}
static void electroextractorRecipe()
{
String[] unlocItem = ConfigHandler.electroextractorRecipeItem.split(":");
ItemStack centerItem = new ItemStack(Blocks.diamond_block);
//Electroextractor Recipe
unlocItem = ConfigHandler.electroextractorRecipeItem.split(":");
centerItem = new ItemStack(Blocks.diamond_block);
if (ConfigHandler.findItemStack(unlocItem[0], unlocItem[1]) != null)
{
@ -78,18 +77,17 @@ public class VanillaRecipes
}
else
{
CCLog.warn("Item " + ConfigHandler.electroextractorRecipeItem + " could not be added as part of the recipe of the electroextractor.");
CCLog.warn("Please confirm you have the name and formatting correct.");
LogHelper.warn(ConfigHandler.electroextractorRecipeItem + " could not be implemented into the Electroextractor's Crafting Recipe.");
LogHelper.warn("The fallback, " + centerItem.getDisplayName() + ", has been used instead");
LogHelper.warn("Please confirm you have the name and formatting correct.");
System.out.println();
}
GameRegistry.addRecipe(new ItemStack(LibBlocks.electroextractor), new Object[] { "I#I", "SCS", "I#I", '#', Blocks.piston, 'I', Blocks.iron_bars, 'S', Items.golden_pickaxe, 'C', centerItem });
}
static void cropomatorRecipe()
{
String[] unlocItem = ConfigHandler.cropomatorRecipeItem.split(":");
ItemStack centerItem = new ItemStack(Blocks.diamond_block);
//Cropomator Recipe
unlocItem = ConfigHandler.cropomatorRecipeItem.split(":");
centerItem = new ItemStack(Blocks.diamond_block);
if (ConfigHandler.findItemStack(unlocItem[0], unlocItem[1]) != null)
{
@ -101,11 +99,12 @@ public class VanillaRecipes
}
else
{
CCLog.warn("Item " + ConfigHandler.cropomatorRecipeItem + " could not be added as part of the recipe of the cropomator.");
CCLog.warn("Please confirm you have the name and formatting correct.");
LogHelper.warn(ConfigHandler.cropomatorRecipeItem + " could not be implemented into the Cropomator's Crafting Recipe.");
LogHelper.warn("The fallback, " + centerItem.getDisplayName() + ", has been used instead");
LogHelper.warn("Please confirm you have the name and formatting correct.");
System.out.println();
}
GameRegistry.addRecipe(new ItemStack(LibBlocks.cropomator), new Object[] { "I#I", "SCS", "I#I", '#', Blocks.hay_block, 'I', Items.iron_ingot, 'S', Items.golden_hoe, 'C', centerItem });
}
}

View file

@ -6,12 +6,16 @@ import java.util.List;
import com.oitsjustjose.criss_cross.items.ItemDust;
import com.oitsjustjose.criss_cross.lib.ConfigHandler;
import com.oitsjustjose.criss_cross.lib.LibItems;
import com.oitsjustjose.criss_cross.recipes.machine.CropomatorRecipes;
import com.oitsjustjose.criss_cross.recipes.machine.ElectroextractorRecipes;
import com.oitsjustjose.criss_cross.recipes.machine.ScribeRecipes;
import com.oitsjustjose.criss_cross.recipes.machine.WoodchipperRecipes;
import com.oitsjustjose.criss_cross.tileentity.TileCobblegen;
import com.oitsjustjose.criss_cross.tileentity.TileCropomator;
import com.oitsjustjose.criss_cross.tileentity.TileElectroextractor;
import com.oitsjustjose.criss_cross.tileentity.TileStonegen;
import com.oitsjustjose.criss_cross.tileentity.TileWoodchipper;
import com.oitsjustjose.criss_cross.util.CCLog;
import com.oitsjustjose.criss_cross.util.LogHelper;
import com.oitsjustjose.criss_cross.util.ItemHelper;
import net.minecraft.enchantment.Enchantment;
@ -26,7 +30,7 @@ import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
public class CCMachineRecipes
public class MachineRecipes
{
public static void init()
{
@ -85,11 +89,11 @@ public class CCMachineRecipes
ScribeRecipes.getInstance().addRecipe(new ItemStack(newStack.getItem(), qty, metadata), getEnchantedBook(enchID));
}
else
CCLog.warn("Enchantment ID " + enchID + " does not appear to be valid. Skipping Scribe recipe addition.");
LogHelper.warn("Enchantment ID " + enchID + " does not appear to be valid. Skipping Scribe recipe addition.");
}
else
{
CCLog.warn("Item " + (modid + " " + object) + " does not appear to be valid. Skipping Scribe recipe addition.");
LogHelper.warn("Item " + (modid + " " + object) + " does not appear to be valid. Skipping Scribe recipe addition.");
}
}
else if (parts.length == 3)
@ -103,17 +107,17 @@ public class CCMachineRecipes
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.");
LogHelper.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.");
LogHelper.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.");
LogHelper.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));
LogHelper.warn("Error reading itemstack for Scribe from input file at item: " + (i + 1));
}
}
}
@ -134,8 +138,8 @@ public class CCMachineRecipes
}
else
{
CCLog.warn("Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's recipe list.");
CCLog.warn("Please confirm you have the name and formatting correct.");
LogHelper.warn("Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's recipe list.");
LogHelper.warn("Please confirm you have the name and formatting correct.");
}
}
@ -149,14 +153,14 @@ public class CCMachineRecipes
}
else
{
CCLog.warn("Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's recipe list.");
CCLog.warn("Please confirm you have the name and formatting correct.");
LogHelper.warn("Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's recipe list.");
LogHelper.warn("Please confirm you have the name and formatting correct.");
}
}
}
catch (Exception e)
{
CCLog.warn("Error reading itemstack for Cropomator from input file at item: " + (i + 1));
LogHelper.warn("Error reading itemstack for Cropomator from input file at item: " + (i + 1));
}
}
@ -175,8 +179,8 @@ public class CCMachineRecipes
TileCropomator.addFuel(ConfigHandler.findItemStack(parts[0], parts[1]));
else
{
CCLog.warn("Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's catalyst list.");
CCLog.warn("Please confirm you have the name and formatting correct.");
LogHelper.warn("Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's catalyst list.");
LogHelper.warn("Please confirm you have the name and formatting correct.");
}
}
@ -189,14 +193,14 @@ public class CCMachineRecipes
}
else
{
CCLog.warn("Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's catalyst list.");
CCLog.warn("Please confirm you have the name and formatting correct.");
LogHelper.warn("Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's catalyst list.");
LogHelper.warn("Please confirm you have the name and formatting correct.");
}
}
}
catch (Exception e)
{
CCLog.warn("Error reading itemstack for Cropomator Cataylsts from input file at item: " + (i + 1));
LogHelper.warn("Error reading itemstack for Cropomator Cataylsts from input file at item: " + (i + 1));
}
}
}
@ -270,8 +274,8 @@ public class CCMachineRecipes
TileWoodchipper.addFuel(ConfigHandler.findItemStack(parts[0], parts[1]));
else
{
CCLog.warn("Item " + ConfigHandler.woodchipperFuels[i] + " could not be added to the Woodchipper's fuel list.");
CCLog.warn("Please confirm you have the name and formatting correct.");
LogHelper.warn("Item " + ConfigHandler.woodchipperFuels[i] + " could not be added to the Woodchipper's fuel list.");
LogHelper.warn("Please confirm you have the name and formatting correct.");
}
}
@ -284,14 +288,14 @@ public class CCMachineRecipes
}
else
{
CCLog.warn("Item " + ConfigHandler.woodchipperFuels[i] + " could not be added to the Woodchipper's fuel list.");
CCLog.warn("Please confirm you have the name and formatting correct.");
LogHelper.warn("Item " + ConfigHandler.woodchipperFuels[i] + " could not be added to the Woodchipper's fuel list.");
LogHelper.warn("Please confirm you have the name and formatting correct.");
}
}
}
catch (Exception e)
{
CCLog.warn("Error reading itemstack for Woodchipper's energy sources at item: " + (i + 1));
LogHelper.warn("Error reading itemstack for Woodchipper's energy sources at item: " + (i + 1));
}
}
}
@ -309,8 +313,8 @@ public class CCMachineRecipes
TileElectroextractor.addFuel(ConfigHandler.findItemStack(parts[0], parts[1]));
else
{
CCLog.warn("Item " + ConfigHandler.electroextractorEnergySources[i] + " could not be added to the Electroextractor's fuel list.");
CCLog.warn("Please confirm you have the name and formatting correct.");
LogHelper.warn("Item " + ConfigHandler.electroextractorEnergySources[i] + " could not be added to the Electroextractor's fuel list.");
LogHelper.warn("Please confirm you have the name and formatting correct.");
}
}
@ -323,14 +327,14 @@ public class CCMachineRecipes
}
else
{
CCLog.warn("Item " + ConfigHandler.electroextractorEnergySources[i] + " could not be added to the Electroextractor's fuel list.");
CCLog.warn("Please confirm you have the name and formatting correct.");
LogHelper.warn("Item " + ConfigHandler.electroextractorEnergySources[i] + " could not be added to the Electroextractor's fuel list.");
LogHelper.warn("Please confirm you have the name and formatting correct.");
}
}
}
catch (Exception e)
{
CCLog.warn("Error reading itemstack for electroextractor's energy sources at item: " + (i + 1));
LogHelper.warn("Error reading itemstack for electroextractor's energy sources at item: " + (i + 1));
}
}
}
@ -350,11 +354,11 @@ public class CCMachineRecipes
}
else
{
CCLog.warn("Your oreDictionary Entry " + ConfigHandler.electroextractorOreDictInputs[i] + " could not be registered.");
LogHelper.warn("Your oreDictionary Entry " + ConfigHandler.electroextractorOreDictInputs[i] + " could not be registered.");
if (!doesOreNameExist("ore" + entry[0]))
CCLog.warn("This is because your oreDictionary Entry was not valid or registered as " + entry[0] + ".");
LogHelper.warn("This is because your oreDictionary Entry was not valid or registered as " + entry[0] + ".");
else if (!doesOreNameExist("ingot" + entry[0]))
CCLog.warn("This is because your oreDictionary Entry does not have an ingot for " + entry[0] + ".");
LogHelper.warn("This is because your oreDictionary Entry does not have an ingot for " + entry[0] + ".");
}
}

View file

@ -1,4 +1,4 @@
package com.oitsjustjose.criss_cross.recipes;
package com.oitsjustjose.criss_cross.recipes.machine;
import java.util.ArrayList;
import java.util.Iterator;

View file

@ -1,4 +1,4 @@
package com.oitsjustjose.criss_cross.recipes;
package com.oitsjustjose.criss_cross.recipes.machine;
import java.util.HashMap;
import java.util.Iterator;

View file

@ -1,4 +1,4 @@
package com.oitsjustjose.criss_cross.recipes;
package com.oitsjustjose.criss_cross.recipes.machine;
import java.util.Iterator;
import java.util.List;

View file

@ -1,4 +1,4 @@
package com.oitsjustjose.criss_cross.recipes;
package com.oitsjustjose.criss_cross.recipes.machine;
import java.util.HashMap;
import java.util.Iterator;

View file

@ -6,7 +6,7 @@ import com.oitsjustjose.criss_cross.blocks.BlockCropomator;
import com.oitsjustjose.criss_cross.container.ContainerCropomator;
import com.oitsjustjose.criss_cross.lib.ConfigHandler;
import com.oitsjustjose.criss_cross.lib.Lib;
import com.oitsjustjose.criss_cross.recipes.CropomatorRecipes;
import com.oitsjustjose.criss_cross.recipes.machine.CropomatorRecipes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;

View file

@ -6,7 +6,7 @@ import com.oitsjustjose.criss_cross.blocks.BlockElectroextractor;
import com.oitsjustjose.criss_cross.container.ContainerElectroextractor;
import com.oitsjustjose.criss_cross.lib.ConfigHandler;
import com.oitsjustjose.criss_cross.lib.Lib;
import com.oitsjustjose.criss_cross.recipes.ElectroextractorRecipes;
import com.oitsjustjose.criss_cross.recipes.machine.ElectroextractorRecipes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;

View file

@ -5,7 +5,7 @@ import java.util.ArrayList;
import com.oitsjustjose.criss_cross.blocks.BlockScribe;
import com.oitsjustjose.criss_cross.container.ContainerScribe;
import com.oitsjustjose.criss_cross.lib.Lib;
import com.oitsjustjose.criss_cross.recipes.ScribeRecipes;
import com.oitsjustjose.criss_cross.recipes.machine.ScribeRecipes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;

View file

@ -6,7 +6,7 @@ import com.oitsjustjose.criss_cross.blocks.BlockWoodchipper;
import com.oitsjustjose.criss_cross.container.ContainerWoodchipper;
import com.oitsjustjose.criss_cross.lib.ConfigHandler;
import com.oitsjustjose.criss_cross.lib.Lib;
import com.oitsjustjose.criss_cross.recipes.WoodchipperRecipes;
import com.oitsjustjose.criss_cross.recipes.machine.WoodchipperRecipes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;

View file

@ -2,7 +2,7 @@ package com.oitsjustjose.criss_cross.util;
import net.minecraft.util.EnumChatFormatting;
public class ColorUtils
public class ColorHelper
{
public static String[] dyes = { "Black", "Red", "Green", "Brown", "Blue", "Purple", "Cyan", "LightGray", "Gray", "Pink", "Lime", "Yellow", "LightBlue", "Magenta", "Orange", "White" };

View file

@ -5,11 +5,11 @@ import org.apache.logging.log4j.Logger;
import com.oitsjustjose.criss_cross.lib.Lib;
public class CCLog
public class LogHelper
{
private static Logger LOGGER = LogManager.getLogger(Lib.modid);
public CCLog()
public LogHelper()
{
}