This is all greatly WIP

This commit is contained in:
oitsjustjose 2015-10-14 11:34:22 -04:00
commit 42e12d41e5
5 changed files with 96 additions and 15 deletions

View file

@ -1,40 +1,98 @@
package com.oitsjustjose.criss_cross.Recipes;
import java.util.ArrayList;
import java.util.List;
import com.mojang.authlib.GameProfile;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityCropomator;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityWoodchipper;
import com.oitsjustjose.criss_cross.Util.ConfigHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.oredict.OreDictionary;
public class WoodchipperRecipes
{
public static void initRecipes()
{
ArrayList<ItemStack> logs = OreDictionary.getOres("logWood");
ArrayList<ItemStack> planks = OreDictionary.getOres("plankWood");
for(int i = 0; i < logs.size(); i++)
//Iterates through the inputItems String array
for(int i = 0; i < ConfigHandler.woodchipperLogs.length; i++)
{
for(int j = 0; j < planks.size(); j++)
//Done in a try loop just in case there's an issue with reading a value in.
try
{
ItemStack tempLog = logs.get(i);
ItemStack tempPlank = planks.get(j);
//Splits the modid:item / modid:item:metadata string at the ':' and makes a
//new Array of strings, each element containing the newly separated parts.
String[] logs = ConfigHandler.woodchipperLogs[i].split(":");
String[] planks = ConfigHandler.woodchipperPlanks[i].split(":");
String logName = tempLog.getDisplayName().toLowerCase();
String plankName = tempPlank.getDisplayName().toLowerCase();
logName.replaceFirst("wood", "");
logName.trim();
ItemStack log = GameRegistry.findItemStack(logs[0], logs[1], 1);
ItemStack plank = GameRegistry.findItemStack(planks[0], planks[1], 1);
if(plankName.contains(logName))
TileEntityWoodchipper.addRecipe(tempLog, tempPlank);
boolean flag = (log != null) && (plank != null);
if(!flag)
{
if(log == null)
System.out.println("[CrissCross] Item " + ConfigHandler.woodchipperLogs[i] + " could not be added to the Woodchipper's recipe list. Please confirm you have the name and formatting correct.");
if(plank == null)
System.out.println("[CrissCross] Item " + ConfigHandler.woodchipperPlanks[i] + " could not be added to the Woodchipper's recipe list. Please confirm you have the name and formatting correct.");
break;
}
//Checks the read in string as modid:item
if(flag)
{
if(logs.length == 2)
{
if(planks.length == 2)
{
TileEntityWoodchipper.addRecipe(log, plank);
}
else if(planks.length == 3)
{
TileEntityWoodchipper.addRecipe(log, new ItemStack(plank.getItem(), 1, Integer.parseInt(planks[2])));
}
}
else if(logs.length == 3)
{
if(planks.length == 2)
{
TileEntityWoodchipper.addRecipe(new ItemStack(log.getItem(), 1, Integer.parseInt(logs[2])), plank);
}
else if(planks.length == 3)
{
TileEntityWoodchipper.addRecipe(new ItemStack(log.getItem(), 1, Integer.parseInt(logs[2])), new ItemStack(plank.getItem(), 1, Integer.parseInt(planks[2])));
}
}
}
}
//Gotta catch em all
catch(Exception e)
{
System.out.println("[CrissCross]: Error reading itemstack for inputs from input file at item: " + (i + 1));
}
}
}
public static void initFuels()
{
for(int i = 0; i < ConfigHandler.woodchipperFuels.length; i++)

View file

@ -3,7 +3,6 @@ package com.oitsjustjose.criss_cross.TileEntity;
import java.util.ArrayList;
import com.oitsjustjose.criss_cross.Blocks.BlockCropomator;
import com.oitsjustjose.criss_cross.Recipes.WoodchipperRecipes;
import com.oitsjustjose.criss_cross.Util.ConfigHandler;
import cpw.mods.fml.relauncher.Side;

View file

@ -44,10 +44,24 @@ public class ConfigHandler
public static int woodchipperOutput;
public static String woodchipperRecipeItem;
public static String[] woodchipperFuels;
public static String[] woodchipperLogs;
public static String[] woodchipperPlanks;
public static String[] defaultWoodchipperLogs = new String[]
{
"minecraft:log:0", "minecraft:log:1", "minecraft:log:2",
"minecraft:log:3", "minecraft:log2:0", "minecraft:log2:1"
};
public static String[] defaultWoodchipperPlanks = new String[]
{
"minecraft:planks:0", "minecraft:planks:1", "minecraft:planks:2",
"minecraft:planks:3", "minecraft:planks:4", "minecraft:planks:5"
};
public static String[] defaultWoodchipperFuels = new String[]
{
"minecraft:water_bucket"
"minecraft:water_bucket", "minecraft:potion:0"
};
public static void init(File configFile)
@ -104,6 +118,14 @@ public class ConfigHandler
woodchipperRecipeItem = config.getString("Key crafting item of the Woodchipper", 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>.");
woodchipperLogs = config.get(config.CATEGORY_GENERAL, "Items that the Woodchipper shall consider as logs.", defaultWoodchipperLogs,
"These should 1:1 match what you put in the list of planks. So the first item on this list corresponds to the first item on the planks list, etc. etc." + "\n" +
"Formatted as: <modid>:<item>:<meta> or <modid>:<item>.").getStringList();
woodchipperPlanks = config.get(config.CATEGORY_GENERAL, "Items that the Woodchipper shall consider as planks.", defaultWoodchipperPlanks,
"These should 1:1 match what you put in the list of logs. So the first item on this list corresponds to the first item on the logs list, etc. etc." + "\n" +
"Formatted as: <modid>:<item>:<meta> or <modid>:<item>.").getStringList();
if (config.hasChanged())
config.save();
}

View file

@ -1,6 +1,7 @@
#Tiles
tile.CrissCross.Cropomator.name=Cropomator
tile.CrissCross.ElectroExtractor.name=ElectroExtractor
tile.CrissCross.WoodChipper.name=Wood Chipper
#Items
item.CrissCross.Iron.name=Electrolytic Iron Dust
@ -8,4 +9,5 @@ item.CrissCross.Gold.name=Electrolytic Gold Dust
#Containers
container.cropomator=Cropomator
container.electroextractor=ElectroExtractor
container.electroextractor=ElectroExtractor
container.woodchipper=Wood Chipper

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB