Item clean up and change in item registration

This commit is contained in:
DarkGuardsman 2013-10-22 15:51:24 -04:00
parent 116ac28a22
commit adc46d3345
13 changed files with 141 additions and 86 deletions

View file

@ -0,0 +1,2 @@
[InternetShortcut]
URL=http://en.wikipedia.org/wiki/Hardnesses_of_the_elements_(data_page)

View file

@ -0,0 +1,2 @@
[InternetShortcut]
URL=http://en.wikipedia.org/wiki/Mohs_scale_of_mineral_hardness

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 B

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 366 B

View file

@ -32,9 +32,8 @@ public class CoreRecipeLoader extends RecipeLoader
/* ITEMS */
public static Item itemMetals, battery, itemTool, itemParts;
public static ItemWrench wrench;
public static Item wrench;
public static ItemStack ironTube, bronzeTube, obbyTube, netherTube;
public static ItemStack leatherSeal, slimeSeal;
public static ItemStack valvePart;
public static ItemStack unfinishedTank;
@ -54,29 +53,18 @@ public class CoreRecipeLoader extends RecipeLoader
{
if (itemParts instanceof ItemParts)
{
ironTube = new ItemStack(itemParts, 1, Parts.Iron.ordinal());
bronzeTube = new ItemStack(itemParts, 1, Parts.Bronze.ordinal());
obbyTube = new ItemStack(itemParts, 1, Parts.Obby.ordinal());
netherTube = new ItemStack(itemParts, 1, Parts.Nether.ordinal());
leatherSeal = new ItemStack(itemParts, 1, Parts.Seal.ordinal());
slimeSeal = new ItemStack(itemParts, 1, Parts.SlimeSeal.ordinal());
valvePart = new ItemStack(itemParts, 1, Parts.Tank.ordinal());
unfinishedTank = new ItemStack(itemParts, 1, Parts.Tank.ordinal());
// iron tube
new RecipeGrid(this.setStackSize(ironTube, 4), 3, 1).setRowOne(Item.ingotIron, Item.ingotIron, Item.ingotIron).RegisterRecipe();
// bronze tube
new RecipeGrid(this.setStackSize(bronzeTube, 4), 3, 1).setRowOne("ingotBronze", "ingotBronze", "ingotBronze").RegisterRecipe();
// obby tube
new RecipeGrid(this.setStackSize(obbyTube, 4), 3, 1).setRowOne(Block.obsidian, Block.obsidian, Block.obsidian).RegisterRecipe();
// nether tube
new RecipeGrid(this.setStackSize(netherTube, 4), 3, 1).setRowOne(Block.netherrack, Block.netherrack, Block.netherrack).RegisterRecipe();
// seal
new RecipeGrid(this.setStackSize(leatherSeal, 16), 2, 2).setRowOne(Item.leather, Item.leather).setRowTwo(Item.leather, Item.leather).RegisterRecipe();
// slime steal
new RecipeGrid(this.setStackSize(slimeSeal, 4)).setRowOne(null, leatherSeal, null).setRowTwo(leatherSeal, Item.slimeBall, leatherSeal).setRowThree(null, leatherSeal, null).RegisterRecipe();
// part valve
new RecipeGrid(valvePart, 3, 1).setRowOne(ironTube, Block.lever, ironTube).RegisterRecipe();
new RecipeGrid(valvePart, 3, 1).setRowOne(EnumMaterial.getStack(EnumMaterial.IRON, EnumOrePart.TUBE, 1), Block.lever, EnumMaterial.getStack(EnumMaterial.IRON, EnumOrePart.TUBE, 1)).RegisterRecipe();
// unfinished tank
new RecipeGrid(unfinishedTank).setRowOne(null, Item.ingotIron, null).setRowTwo(Item.ingotIron, null, Item.ingotIron).setRowThree(null, Item.ingotIron, null).RegisterRecipe();
new RecipeGrid(unfinishedTank).setRowOne(null, bronze, null).setRowTwo(bronze, null, bronze).setRowThree(null, bronze, null).RegisterRecipe();
@ -157,8 +145,9 @@ public class CoreRecipeLoader extends RecipeLoader
{
tube.stackSize = 3;
new RecipeGrid(tube, 3, 1).setRowOne(ingot, ingot, ingot).RegisterRecipe();
new RecipeGrid(tube, 1, 1).setRowOne(rod).RegisterRecipe();
tube.stackSize = 1;
new RecipeGrid(tube, 1, 1).setRowOne(rod).RegisterRecipe();
}
if (mat.shouldCreateItem(EnumOrePart.ROD))
{

View file

@ -5,14 +5,9 @@ import java.io.File;
import java.util.Arrays;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.oredict.OreDictionary;
import universalelectricity.compatibility.Compatibility;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.ore.OreGenReplaceStone;
import universalelectricity.prefab.ore.OreGenerator;
@ -32,7 +27,6 @@ import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
import dark.api.ProcessorRecipes;
import dark.core.common.blocks.BlockBasalt;
import dark.core.common.blocks.BlockColorGlass;
import dark.core.common.blocks.BlockColorGlowGlass;
@ -47,7 +41,6 @@ import dark.core.common.items.ItemColoredDust;
import dark.core.common.items.ItemCommonTool;
import dark.core.common.items.ItemOreDirv;
import dark.core.common.items.ItemParts;
import dark.core.common.items.ItemParts.Parts;
import dark.core.common.items.ItemReadoutTools;
import dark.core.common.items.ItemWrench;
import dark.core.common.machines.BlockBasicMachine;
@ -56,7 +49,6 @@ import dark.core.common.transmit.BlockWire;
import dark.core.common.transmit.ItemBlockWire;
import dark.core.network.PacketHandler;
import dark.core.prefab.ModPrefab;
import dark.core.prefab.helpers.FluidHelper;
import dark.core.prefab.items.ItemBlockHolder;
import dark.core.prefab.machine.BlockMulti;
import dark.core.registration.ModObjectRegistry;
@ -140,20 +132,6 @@ public class DarkMain extends ModPrefab
}
}
}
if (CoreRecipeLoader.itemParts != null)
{
/* ORE DIRECTORY REGISTER */
OreDictionary.registerOre("bronzeTube", new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Bronze.ordinal()));
OreDictionary.registerOre("ironTube", new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Iron.ordinal()));
OreDictionary.registerOre("netherTube", new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Nether.ordinal()));
OreDictionary.registerOre("obbyTube", new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Obby.ordinal()));
OreDictionary.registerOre("leatherSeal", new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Seal.ordinal()));
OreDictionary.registerOre("leatherSlimeSeal", new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.SlimeSeal.ordinal()));
OreDictionary.registerOre("valvePart", new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Valve.ordinal()));
OreDictionary.registerOre("bronzeTube", new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Bronze.ordinal()));
OreDictionary.registerOre("unfinishedTank", new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Tank.ordinal()));
}
FMLLog.info(" Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " Languages.");
proxy.init();
}
@ -200,25 +178,12 @@ public class DarkMain extends ModPrefab
CoreRecipeLoader.blockSolar = ModObjectRegistry.createNewBlock("DMBlockSolar", DarkMain.MOD_ID, BlockSolarPanel.class, ItemBlockHolder.class);
/* ITEMS */
CoreRecipeLoader.itemTool = new ItemReadoutTools(ITEM_ID_PREFIX++, DarkMain.CONFIGURATION);
if (CONFIGURATION.get("general", "LoadOreItems", true, "Only disable ore items if you have another mod that provides metal dust, ingots, and plates").getBoolean(true))
{
CoreRecipeLoader.itemMetals = new ItemOreDirv(ITEM_ID_PREFIX++, CONFIGURATION);
}
if (CONFIGURATION.get("general", "EnableBattery", true).getBoolean(true))
{
CoreRecipeLoader.battery = new ItemBattery("Battery", ITEM_ID_PREFIX++);
}
if (CONFIGURATION.get("general", "EnableWrench", true).getBoolean(true))
{
CoreRecipeLoader.wrench = new ItemWrench(ITEM_ID_PREFIX++, DarkMain.CONFIGURATION);
}
if (CONFIGURATION.get("general", "LoadCraftingParts", true, "Only disable this if you do not plan to craft, or are not using any mods that need these parts.").getBoolean(true))
{
CoreRecipeLoader.itemParts = new ItemParts(ITEM_ID_PREFIX++, CONFIGURATION);
CoreRecipeLoader.itemGlowingSand = new ItemColoredDust(CONFIGURATION.getItem(Configuration.CATEGORY_ITEM, "GlowingRefinedSandItemID", ITEM_ID_PREFIX++).getInt(), "GlowRefinedSand");
}
CoreRecipeLoader.itemTool = ModObjectRegistry.createNewItem("DMReadoutTools", DarkMain.MOD_ID, ItemReadoutTools.class, true);
CoreRecipeLoader.itemMetals = ModObjectRegistry.createNewItem("DMOreDirvParts", DarkMain.MOD_ID, ItemOreDirv.class, true);
CoreRecipeLoader.battery = ModObjectRegistry.createNewItem("DMItemBattery", DarkMain.MOD_ID, ItemBattery.class, true);
CoreRecipeLoader.wrench = ModObjectRegistry.createNewItem("DMWrench", DarkMain.MOD_ID, ItemWrench.class, true);
CoreRecipeLoader.itemParts = ModObjectRegistry.createNewItem("DMCraftingParts", DarkMain.MOD_ID, ItemParts.class, true);
CoreRecipeLoader.itemGlowingSand = ModObjectRegistry.createNewItem("DMItemGlowingSand", DarkMain.MOD_ID, ItemColoredDust.class, true);
CoreRecipeLoader.itemDiggingTool = ModObjectRegistry.createNewItem("ItemDiggingTools", DarkMain.MOD_ID, ItemCommonTool.class, true);
CONFIGURATION.save();
}

View file

@ -8,12 +8,15 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.core.common.DarkMain;
/** Simple battery to store energy
*
* @author DarkGuardsman */
public class ItemBattery extends ItemElectric
{
public ItemBattery(String name, int id)
public ItemBattery()
{
super(DarkMain.CONFIGURATION.getItem(name, id).getInt(id));
this.setUnlocalizedName(DarkMain.getInstance().PREFIX + name);
super(DarkMain.CONFIGURATION.getItem("Battery", DarkMain.getNextItemId()).getInt());
this.setUnlocalizedName(DarkMain.getInstance().PREFIX + "Battery");
this.setCreativeTab(CreativeTabs.tabRedstone);
}

View file

@ -10,19 +10,19 @@ import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.core.common.DarkMain;
import dark.core.prefab.items.ItemBasic;
public class ItemColoredDust extends Item
public class ItemColoredDust extends ItemBasic
{
@SideOnly(Side.CLIENT)
private Icon theIcon;
public ItemColoredDust(int par1, String name)
public ItemColoredDust()
{
super(par1);
super(DarkMain.getNextItemId(), "GlowRefinedSand", DarkMain.CONFIGURATION);
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.setCreativeTab(CreativeTabs.tabMaterials);
this.setUnlocalizedName(name);
}
@Override

View file

@ -18,23 +18,32 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.StatList;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.entity.player.UseHoeEvent;
import net.minecraftforge.oredict.OreDictionary;
import buildcraft.api.tools.IToolWrench;
import com.google.common.collect.Multimap;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.core.common.DarkMain;
import dark.core.prefab.IExtraInfo.IExtraItemInfo;
/** Flexible tool class that uses NBT to store damage and effect rather than metadata. Metadata
* instead is used to store sub items allowing several different tools to exist within the same item
*
* @author DarkGuardsman */
public class ItemCommonTool extends Item
public class ItemCommonTool extends Item implements IExtraItemInfo
{
protected int enchant = 5;
public static final String BROKEN_NBT = "broken";
public static final String REINFORCED_NBT = "reinforced";
public static final String HEATTREATED_NBT = "heattreated";
public static final String HANDLE_NBT = "handle";
public ItemCommonTool()
{
@ -341,4 +350,37 @@ public class ItemCommonTool extends Item
}
}
@Override
public boolean hasExtraConfigs()
{
// TODO Add configs such as enable broken tools, and allow tools to be salvaged
return false;
}
@Override
public void loadExtraConfigs(Configuration config)
{
// TODO Auto-generated method stub
}
@Override
public void loadOreNames()
{
for (EnumMaterial mat : EnumMaterial.values())
{
if (mat.hasTools)
{
for (EnumTool tool : EnumTool.values())
{
ItemStack stack = EnumMaterial.getTool(tool, mat);
if (tool.enabled && stack != null)
{
OreDictionary.registerOre(EnumTool.getFullName(stack.getItemDamage()), stack);
}
}
}
}
}
}

View file

@ -7,19 +7,21 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.core.common.DarkMain;
import dark.core.prefab.IExtraInfo.IExtraItemInfo;
import dark.core.prefab.items.ItemBasic;
/** A series of items that are derived from a basic material
*
* @author DarkGuardsman */
public class ItemOreDirv extends ItemBasic
public class ItemOreDirv extends ItemBasic implements IExtraItemInfo
{
public ItemOreDirv(int itemID, Configuration config)
public ItemOreDirv()
{
super(itemID, "Metal_Parts", config);
super(DarkMain.getNextItemId(), "Metal_Parts", DarkMain.CONFIGURATION);
this.setHasSubtypes(true);
this.setCreativeTab(CreativeTabs.tabMaterials);
}
@ -76,4 +78,34 @@ public class ItemOreDirv extends ItemBasic
}
}
@Override
public boolean hasExtraConfigs()
{
return false;
}
@Override
public void loadExtraConfigs(Configuration config)
{
// TODO Auto-generated method stub
}
@Override
public void loadOreNames()
{
for (EnumMaterial mat : EnumMaterial.values())
{
for (EnumOrePart part : EnumOrePart.values())
{
ItemStack stack = EnumMaterial.getStack(mat, part, 1);
if (stack != null && mat.shouldCreateItem(part) && mat.itemIcons[part.ordinal()] != null)
{
OreDictionary.registerOre(EnumOrePart.getFullName(stack.getItemDamage()), stack);
}
}
}
}
}

View file

@ -13,14 +13,13 @@ import dark.core.common.DarkMain;
import dark.core.prefab.items.ItemBasic;
/** A metadata item containing parts of various machines in Liquid Mechanics Mod.
*
* @author Rs */
*
* @author DarkGuardsman */
public class ItemParts extends ItemBasic
{
public ItemParts(int par1, Configuration config)
public ItemParts()
{
super(par1, "DMParts", config);
super(DarkMain.getNextItemId(), "DMParts", DarkMain.CONFIGURATION);
this.setHasSubtypes(true);
this.setMaxDamage(0);
this.setMaxStackSize(64);
@ -76,10 +75,6 @@ public class ItemParts extends ItemBasic
public static enum Parts
{
Bronze("BronzeTube"),
Iron("IronTube"),
Obby("ObbyTube"),
Nether("NetherTube"),
Seal("LeatherSeal"),
SlimeSeal("SlimeSeal"),
Tank("UnfinishedTank"),

View file

@ -32,9 +32,9 @@ public class ItemReadoutTools extends ItemBasic
{
Icon pipeGuage, multiMeter;
public ItemReadoutTools(int id, Configuration config)
public ItemReadoutTools()
{
super(id, "DMTools", config);
super(DarkMain.getNextItemId(), "DMTools", DarkMain.CONFIGURATION);
this.setHasSubtypes(true);
this.setCreativeTab(CreativeTabs.tabTools);
this.setMaxStackSize(1);

View file

@ -7,22 +7,23 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import buildcraft.api.tools.IToolWrench;
import dark.core.common.DarkMain;
import dark.core.prefab.IExtraInfo.IExtraItemInfo;
import dark.core.prefab.items.ItemBasic;
public class ItemWrench extends ItemBasic implements IToolWrench
public class ItemWrench extends ItemBasic implements IToolWrench, IExtraItemInfo
{
static boolean damageWrench = false;
public static boolean damageWrench = false;
public ItemWrench(int id, Configuration config)
public ItemWrench()
{
super(id, "wrench", config);
damageWrench = config.get("general", "DamageWrench", false).getBoolean(false);
super(DarkMain.getNextItemId(), "wrench", DarkMain.CONFIGURATION);
this.setMaxStackSize(1);
this.setMaxDamage(500 + config.get("general", "AddedWrenchUses", 500).getInt());
this.setCreativeTab(CreativeTabs.tabTools);
this.setTextureName(DarkMain.getInstance().PREFIX + "wrench");
}
@Override
@ -71,7 +72,7 @@ public class ItemWrench extends ItemBasic implements IToolWrench
@Override
public void wrenchUsed(EntityPlayer player, int x, int y, int z)
{
if (damageWrench && player != null && !player.worldObj.isRemote)
if (player != null && !player.worldObj.isRemote && !player.capabilities.isCreativeMode)
{
ItemStack stack = player.getHeldItem();
if (stack != null && stack.itemID == this.itemID)
@ -79,6 +80,30 @@ public class ItemWrench extends ItemBasic implements IToolWrench
stack.damageItem(1, player);
}
}
}
@Override
public boolean isDamageable()
{
return damageWrench;
}
@Override
public boolean hasExtraConfigs()
{
return true;
}
@Override
public void loadExtraConfigs(Configuration config)
{
damageWrench = config.get("general", "DamageWrench", false).getBoolean(false);
this.setMaxDamage(500 + config.get("general", "AddedWrenchUses", 500).getInt());
}
@Override
public void loadOreNames()
{
OreDictionary.registerOre("wench", this);
}
}