Worked on Ore enums & recipes a bit

Still have a lot of work to do but at least its better than nothing
This commit is contained in:
DarkGuardsman 2013-09-21 12:39:15 -04:00
parent be157ae1fc
commit 4e1204ed7b
9 changed files with 228 additions and 176 deletions

View file

@ -6,8 +6,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import cpw.mods.fml.common.registry.GameRegistry;
import dark.core.common.blocks.BlockBasalt;
import dark.core.common.items.EnumMeterials;
import dark.core.common.items.EnumOreParts;
import dark.core.common.blocks.BlockOre.OreData;
import dark.core.common.items.EnumMaterial;
import dark.core.common.items.EnumOrePart;
import dark.core.common.items.ItemParts.Parts;
import dark.core.common.items.ItemWrench;
@ -79,13 +80,10 @@ public class CoreRecipeLoader extends RecipeLoader
{
if (blockOre != null && itemMetals != null)
{
for (int i = 0; i < EnumMeterials.values().length; i++)
for (int i = 0; i < EnumMaterial.values().length; i++)
{
if (EnumMeterials.values()[i].doWorldGen)
{
FurnaceRecipes.smelting().addSmelting(blockOre.blockID, i, new ItemStack(itemMetals.itemID, 1, 40 + i), 0.6f);
}
if (EnumMeterials.values()[i].shouldCreateItem(EnumOreParts.DUST) && EnumMeterials.values()[i] != EnumMeterials.WOOD && EnumMeterials.values()[i] != EnumMeterials.COAL)
if (EnumMaterial.values()[i].shouldCreateItem(EnumOrePart.DUST) && EnumMaterial.values()[i] != EnumMaterial.WOOD && EnumMaterial.values()[i] != EnumMaterial.COAL)
{
FurnaceRecipes.smelting().addSmelting(itemMetals.itemID, i + 20, new ItemStack(itemMetals.itemID, 1, 40 + i), 0.6f);
}

View file

@ -36,10 +36,11 @@ import dark.core.common.blocks.BlockColorGlass;
import dark.core.common.blocks.BlockColorGlowGlass;
import dark.core.common.blocks.BlockColorSand;
import dark.core.common.blocks.BlockOre;
import dark.core.common.blocks.BlockOre.OreData;
import dark.core.common.blocks.ItemBlockColored;
import dark.core.common.blocks.ItemBlockOre;
import dark.core.common.debug.BlockDebug;
import dark.core.common.items.EnumMeterials;
import dark.core.common.items.EnumMaterial;
import dark.core.common.items.ItemBattery;
import dark.core.common.items.ItemColoredDust;
import dark.core.common.items.ItemOreDirv;
@ -132,12 +133,12 @@ public class DarkMain extends ModPrefab
ProcessorRecipes.parseOreNames();
if (CoreRecipeLoader.blockOre != null)
{
for (int i = 0; i < EnumMeterials.values().length; i++)
for (OreData data : OreData.values())
{
if (EnumMeterials.values()[i].doWorldGen)
if (data.doWorldGen)
{
OreGenReplaceStone gen = EnumMeterials.values()[i].getGeneratorSettings();
if (gen != null && gen.shouldGenerate)
OreGenReplaceStone gen = data.getGeneratorSettings();
if (gen != null)
{
OreGenerator.addOre(gen);
}

View file

@ -8,21 +8,28 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.oredict.OreDictionary;
import universalelectricity.prefab.ore.OreGenReplaceStone;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.api.ProcessorRecipes;
import dark.api.ProcessorRecipes.ProcessorType;
import dark.core.common.CoreRecipeLoader;
import dark.core.common.DarkMain;
import dark.core.common.items.EnumMeterials;
import dark.core.common.items.EnumMaterial;
import dark.core.common.items.EnumOrePart;
import dark.core.common.items.ItemOreDirv;
import dark.core.prefab.IExtraObjectInfo;
import dark.core.prefab.ModPrefab;
import dark.core.prefab.helpers.Pair;
public class BlockOre extends Block implements IExtraObjectInfo
{
Icon[] icons = new Icon[EnumMeterials.values().length];
Icon[] icons = new Icon[EnumMaterial.values().length];
public BlockOre()
{
@ -69,6 +76,25 @@ public class BlockOre extends Block implements IExtraObjectInfo
@Override
public void loadRecipes()
{
for (OreData data : OreData.values())
{
if (CoreRecipeLoader.itemMetals instanceof ItemOreDirv)
{
ItemStack oreStack = new ItemStack(this.blockID, 1, data.ordinal());
ItemStack dust = EnumMaterial.getStack(data.mat, EnumOrePart.DUST, 1);
ItemStack ingot = EnumMaterial.getStack(data.mat, EnumOrePart.INGOTS, 1);
FurnaceRecipes.smelting().addSmelting(this.blockID, data.ordinal(),ingot , 0.6f);
ProcessorRecipes.createRecipe(ProcessorType.CRUSHER, oreStack, EnumMaterial.getStack(data.mat, EnumOrePart.RUBBLE, 1));
dust.stackSize = 2;
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, EnumMaterial.getStack(data.mat, EnumOrePart.RUBBLE, 1), dust);
dust.stackSize = 1;
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, EnumMaterial.getStack(data.mat, EnumOrePart.SCRAPS, 1), dust);
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, ingot, dust);
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, EnumMaterial.getStack(data.mat, EnumOrePart.PLATES, 1), EnumMaterial.getStack(data.mat, EnumOrePart.SCRAPS, 2));
ProcessorRecipes.createRecipe(ProcessorType.PRESS, EnumMaterial.getStack(data.mat, EnumOrePart.INGOTS, 3), EnumMaterial.getStack(data.mat, EnumOrePart.PLATES, 1));
FurnaceRecipes.smelting().addSmelting(dust.itemID, dust.getItemDamage(), ingot, 0.6f);
}
}
}
@Override
@ -100,21 +126,42 @@ public class BlockOre extends Block implements IExtraObjectInfo
public static enum OreData
{
TIN("tin", "oreTin"),
COPPER("copper", "copperOre"),
SILVER("silver", "silverOre"),
LEAD("lead","leadOre"),
Bauxite("bauxite","bauxiteOre");
TIN(EnumMaterial.TIN, "tin", "oreTin", 70, 22, 10),
COPPER(EnumMaterial.COPPER, "copper", "copperOre", 70, 22, 10),
SILVER(EnumMaterial.SILVER, "silver", "silverOre", 40, 15, 6),
LEAD(EnumMaterial.LEAD, "lead", "leadOre", 50, 8, 3),
Bauxite(EnumMaterial.ALUMINIUM, "bauxite", "bauxiteOre", 50, 8, 3);
public String name, oreName;
public ItemStack stack;
public EnumMaterial mat;
@SideOnly(Side.CLIENT)
public Icon oreIcon;
private OreData(String name, String oreName)
/* ORE GENERATOR OPTIONS */
public boolean doWorldGen = true;
public int ammount, branch, maxY;
private OreData(EnumMaterial mat, String name, String oreName, int ammount, int branch, int maxY)
{
this.name = name;
this.oreName = oreName;
this.mat = mat;
this.maxY = maxY;
this.ammount = ammount;
this.branch = branch;
}
public OreGenReplaceStone getGeneratorSettings()
{
if (this.doWorldGen)
{
ItemStack stack = new ItemStack(CoreRecipeLoader.blockOre, 1, this.ordinal());
return (OreGenReplaceStone) new OreGenReplaceStone(this.name, this.name + "Ore", stack, this.maxY, this.ammount, this.branch).enable(DarkMain.getInstance().CONFIGURATION);
}
return null;
}
}
}

View file

@ -4,7 +4,7 @@ import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import dark.core.common.DarkMain;
import dark.core.common.blocks.BlockOre.OreData;
import dark.core.common.items.EnumMeterials;
import dark.core.common.items.EnumMaterial;
public class ItemBlockOre extends ItemBlock
{

View file

@ -0,0 +1,102 @@
package dark.core.common.items;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.core.common.CoreRecipeLoader;
/** Class for storing materials, there icon names, sub items to be made from them or there sub ores
*
*
* @author DarkGuardsman */
public enum EnumMaterial
{
WOOD("Wood", EnumOrePart.INGOTS, EnumOrePart.PLATES, EnumOrePart.RUBBLE, EnumOrePart.ROD),
STONE("Stone", EnumOrePart.INGOTS),
COPPER("Copper"),
TIN("Tin", EnumOrePart.GEARS, EnumOrePart.TUBE),
IRON("Iron", EnumOrePart.INGOTS),
OBBY("Obby", EnumOrePart.INGOTS, EnumOrePart.RUBBLE),
LEAD("Lead", EnumOrePart.GEARS, EnumOrePart.TUBE),
ALUMINIUM("Aluminum", EnumOrePart.GEARS, EnumOrePart.TUBE),
SILVER("Silver", EnumOrePart.GEARS),
GOLD("Gold", EnumOrePart.GEARS, EnumOrePart.INGOTS),
COAL("Coal", EnumOrePart.GEARS, EnumOrePart.TUBE, EnumOrePart.PLATES, EnumOrePart.RUBBLE),
STEEL("Steel", EnumOrePart.RUBBLE),
BRONZE("Bronze", EnumOrePart.RUBBLE);
/** Name of the material */
public String simpleName;
/** List of ore parts that to not be created for the material */
public List<EnumOrePart> unneedItems;
/** Limit by which each material is restricted by for creating orePart sub items */
public static final int itemCountPerMaterial = 50;
/** Client side only var used by ore items to store icon per material set */
@SideOnly(Side.CLIENT)
Icon[] itemIcons;
private EnumMaterial(String name, EnumOrePart... enumOreParts)
{
this.simpleName = name;
unneedItems = new ArrayList<EnumOrePart>();
for (int i = 0; enumOreParts != null && i < enumOreParts.length; i++)
{
unneedItems.add(enumOreParts[i]);
}
}
/** Creates a new item stack using material and part given. Uses a preset length of 50 for parts
* enum so to prevent any unwanted changes in loading of itemStacks metadata.
*
* @param mat - material
* @param part - part
* @return new ItemStack created from the two enums as long as everything goes right */
public static ItemStack getStack(EnumMaterial mat, EnumOrePart part, int ammount)
{
ItemStack reStack = null;
if (CoreRecipeLoader.itemMetals instanceof ItemOreDirv && mat != null && part != null)
{
if (part == EnumOrePart.INGOTS)
{
switch (EnumMaterial.IRON)
{
case IRON:
return new ItemStack(Item.ingotIron, 1);
case GOLD:
return new ItemStack(Item.ingotGold, 1);
}
}
int meta = mat.ordinal() * itemCountPerMaterial;
meta += part.ordinal();
return new ItemStack(CoreRecipeLoader.itemMetals.itemID, ammount, meta);
}
return reStack;
}
public static Icon getIcon(int metadata)
{
int mat = metadata / EnumMaterial.itemCountPerMaterial;
if (mat < EnumMaterial.values().length)
{
return EnumMaterial.values()[metadata / EnumMaterial.itemCountPerMaterial].itemIcons[metadata % EnumMaterial.itemCountPerMaterial];
}
return null;
}
public boolean shouldCreateItem(EnumOrePart part)
{
if (part == EnumOrePart.ROD || part == EnumOrePart.TUBE || part == EnumOrePart.RUBBLE)
{
return false;
}
return this.unneedItems == null || !this.unneedItems.contains(part);
}
}

View file

@ -1,92 +0,0 @@
package dark.core.common.items;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import universalelectricity.prefab.ore.OreGenReplaceStone;
import dark.core.common.CoreRecipeLoader;
import dark.core.common.DarkMain;
/** Class for storing materials, there icon names, sub items to be made from them or there sub ores
*
*
* @author DarkGuardsman */
public enum EnumMeterials
{
WOOD("Wood", EnumOreParts.INGOTS, EnumOreParts.PLATES, EnumOreParts.RUBBLE, EnumOreParts.ROD),
STONE("Stone", EnumOreParts.INGOTS),
COPPER("Copper", true, true, 70, 22, 10),
TIN("Tin", true, true, 70, 22, 10, EnumOreParts.GEARS, EnumOreParts.TUBE),
IRON("Iron", EnumOreParts.INGOTS),
OBBY("Obby", EnumOreParts.INGOTS, EnumOreParts.RUBBLE),
LEAD("Lead", true, true, 50, 8, 3, EnumOreParts.GEARS, EnumOreParts.TUBE),
ALUMINIUM("Aluminum", true, true, 50, 8, 3, EnumOreParts.GEARS, EnumOreParts.TUBE),
SILVER("Silver", true, true, 40, 15, 6, EnumOreParts.GEARS),
GOLD("Gold", EnumOreParts.GEARS, EnumOreParts.INGOTS),
COAL("Coal", EnumOreParts.GEARS, EnumOreParts.TUBE, EnumOreParts.PLATES, EnumOreParts.RUBBLE),
STEEL("Steel", true, false, 0, 0, 0, EnumOreParts.RUBBLE),
BRONZE("Bronze", true, false, 0, 0, 0, EnumOreParts.RUBBLE);
/* UNLOCALIZED NAME AND ICON PREFIX */
public String name;
/* CREATE AN ITEM FOR THIS ORE */
public List<EnumOreParts> unneedItems;
public boolean block;
/* ORE GENERATOR OPTIONS */
public boolean doWorldGen;
public int ammount, branch, maxY;
private EnumMeterials(String name, boolean block, boolean canWorldGen, int ammount, int branch, int maxY, EnumOreParts... enumOreParts)
{
this.name = name;
unneedItems = new ArrayList<EnumOreParts>();
for (int i = 0; enumOreParts != null && i < enumOreParts.length; i++)
{
unneedItems.add(enumOreParts[i]);
}
this.block = block;
this.doWorldGen = canWorldGen;
this.maxY = maxY;
this.ammount = ammount;
this.branch = branch;
}
private EnumMeterials(String name, EnumOreParts... enumOreParts)
{
this.name = name;
this.block = false;
unneedItems = new ArrayList<EnumOreParts>();
for (int i = 0; enumOreParts != null && i < enumOreParts.length; i++)
{
unneedItems.add(enumOreParts[i]);
}
this.doWorldGen = false;
this.maxY = 0;
this.ammount = 0;
this.branch = 0;
}
public OreGenReplaceStone getGeneratorSettings()
{
if (this.doWorldGen)
{
ItemStack stack = new ItemStack(CoreRecipeLoader.blockOre, 1, this.ordinal());
return (OreGenReplaceStone) new OreGenReplaceStone(this.name, this.name + "Ore", stack, this.maxY, this.ammount, this.branch).enable(DarkMain.getInstance().CONFIGURATION);
}
return null;
}
public boolean shouldCreateItem(EnumOreParts part)
{
if (part == EnumOreParts.ROD || part == EnumOreParts.TUBE || part == EnumOreParts.RUBBLE)
{
return false;
}
return this.unneedItems == null || !this.unneedItems.contains(part);
}
}

View file

@ -0,0 +1,42 @@
package dark.core.common.items;
public enum EnumOrePart
{
RUBBLE("Rubble"),
DUST("Dust"),
INGOTS("Ingot"),
PLATES("Plate"),
GEARS("Gears"),
TUBE("Tube"),
ROD("Rod"),
SCRAPS("Scraps");
public String simpleName;
private EnumOrePart(String name)
{
this.simpleName = name;
}
public static String getPartName(int meta)
{
int partID = meta % EnumMaterial.itemCountPerMaterial;
if (partID < EnumOrePart.values().length)
{
return EnumOrePart.values()[partID].simpleName;
}
return "Part[" + partID + "]";
}
public static String getFullName(int meta)
{
int matID = meta / EnumMaterial.itemCountPerMaterial;
int partID = meta % EnumMaterial.itemCountPerMaterial;
if (matID < EnumMaterial.values().length && partID < EnumOrePart.values().length)
{
return EnumMaterial.values()[matID].simpleName + EnumOrePart.values()[partID].simpleName;
}
return "OrePart[" + matID + "][" + partID + "]";
}
}

View file

@ -1,41 +0,0 @@
package dark.core.common.items;
public enum EnumOreParts
{
RUBBLE("Rubble", 0),
DUST("Dust", 20),
INGOTS("Ingot", 40),
PLATES("Plate", 60),
GEARS("Gears", 80),
TUBE("Tube", 100),
ROD("Rod", 120),
SCRAPS("Scraps", 140);
public int meta;
public String name;
private EnumOreParts(String name, int meta)
{
this.meta = meta;
this.name = name;
}
public static String getPartName(int meta)
{
if (meta < (EnumOreParts.values().length * 20))
{
return EnumOreParts.values()[meta / 20].name;
}
return "";
}
public static String getFullName(int meta)
{
if (meta < (EnumOreParts.values().length * 20))
{
return EnumMeterials.values()[meta % 20].name + EnumOreParts.values()[meta / 20].name;
}
return "";
}
}

View file

@ -12,30 +12,24 @@ import cpw.mods.fml.relauncher.SideOnly;
import dark.core.common.DarkMain;
import dark.core.prefab.items.ItemBasic;
/** A series of items that are derived from a basic ore block
*
/** A series of items that are derived from a basic material
*
* @author DarkGuardsman */
public class ItemOreDirv extends ItemBasic
{
/* EACH SUB IS ALLOCATED 20 metadata to store items in its group */
public ItemOreDirv(int itemID, Configuration config)
{
super(itemID, "Metal_Parts", config);
this.setHasSubtypes(true);
this.setMaxDamage(0);
this.setCreativeTab(CreativeTabs.tabMaterials);
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
if (itemStack != null)
{
int meta = itemStack.getItemDamage();
return "item." + DarkMain.getInstance().PREFIX + EnumOreParts.getFullName(meta);
return "item." + DarkMain.getInstance().PREFIX + EnumOrePart.getFullName(itemStack.getItemDamage());
}
else
{
@ -46,20 +40,22 @@ public class ItemOreDirv extends ItemBasic
@Override
public Icon getIconFromDamage(int i)
{
return ICONS[i];
return EnumMaterial.getIcon(i);
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IconRegister iconRegister)
{
for (int j = 0; j < EnumOreParts.values().length; j++)
for (EnumMaterial mat : EnumMaterial.values())
{
String suf = EnumOreParts.values()[j].name;
int meta = EnumOreParts.values()[j].meta;
for (int i = 0; i < EnumMeterials.values().length; i++)
mat.itemIcons = new Icon[EnumOrePart.values().length];
for (EnumOrePart part : EnumOrePart.values())
{
ICONS[i + meta] = iconRegister.registerIcon(DarkMain.getInstance().PREFIX + EnumMeterials.values()[i].name + suf);
if (mat.shouldCreateItem(part))
{
mat.itemIcons[part.ordinal()] = iconRegister.registerIcon(DarkMain.getInstance().PREFIX + mat.simpleName + part.simpleName);
}
}
}
}
@ -67,15 +63,14 @@ public class ItemOreDirv extends ItemBasic
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int j = 0; j < EnumOreParts.values().length; j++)
for (EnumMaterial mat : EnumMaterial.values())
{
String suf = EnumOreParts.values()[j].name;
int i = EnumOreParts.values()[j].meta;
for (; i < EnumMeterials.values().length + EnumOreParts.values()[j].meta; i++)
for (EnumOrePart part : EnumOrePart.values())
{
if (EnumMeterials.values()[i - EnumOreParts.values()[j].meta].shouldCreateItem(EnumOreParts.values()[j]))
ItemStack stack = mat.getStack(mat, part, 1);
if (stack != null && mat.shouldCreateItem(part) && mat.itemIcons[part.ordinal()] != null)
{
par3List.add(new ItemStack(this, 1, i));
par3List.add(stack);
}
}
}