Added basic Item for all the dusts
This commit is contained in:
parent
ce031af8e7
commit
0e2ad2637f
2 changed files with 91 additions and 5 deletions
|
@ -1,19 +1,22 @@
|
|||
package techreborn;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import techreborn.blocks.BlockThermalGenerator;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.items.ItemDusts;
|
||||
import techreborn.tiles.TileThermalGenerator;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import techreborn.blocks.BlockThermalGenerator;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.tiles.TileThermalGenerator;
|
||||
|
||||
@Mod(modid = "techreborn", name = "TechReborn", version = "@MODVERSION@")
|
||||
public class Core {
|
||||
|
||||
public static Block thermalGenerator;
|
||||
public static Item dusts;
|
||||
|
||||
@Mod.Instance
|
||||
public static Core INSTANCE;
|
||||
|
@ -23,6 +26,8 @@ public class Core {
|
|||
thermalGenerator = new BlockThermalGenerator().setBlockName("techreborn.thermalGenerator").setBlockTextureName("techreborn:ThermalGenerator_other").setCreativeTab(TechRebornCreativeTab.instance);
|
||||
GameRegistry.registerBlock(thermalGenerator, "techreborn.thermalGenerator");
|
||||
GameRegistry.registerTileEntity(TileThermalGenerator.class, "TileThermalGenerator");
|
||||
dusts = new ItemDusts();
|
||||
GameRegistry.registerItem(dusts, "dust");
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler());
|
||||
}
|
||||
|
|
81
src/main/java/techreborn/items/ItemDusts.java
Normal file
81
src/main/java/techreborn/items/ItemDusts.java
Normal file
|
@ -0,0 +1,81 @@
|
|||
package techreborn.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import techreborn.Core;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class ItemDusts extends Item
|
||||
{
|
||||
public static final String[] types = new String[]
|
||||
{
|
||||
"Almandine", "Aluminium", "Andradite", "Ashes", "Basalt", "Bauxite", "Brass", "Bronze",
|
||||
"Calcite","Charcoal", "Chrome", "Cinnabar", "Clay", "Coal", "Copper", "Dark Ashes", "Diamond",
|
||||
"Electrum","Emerald", "Ender Eye", "Ender Pearl", "Endstone", "Flint", "Gold", "Green Sapphire", "Grossular",
|
||||
"Invar", "Iron", "Lazurite", "Lead", "Magnesium", "Marble", "Netherrack", "Nickel", "Obsidian",
|
||||
"Olivine","Phosphor", "Platinum", "Pyrite", "Pyrope", "Red Garnet", "Redrock", "Ruby", "Saltpeter", "Sapphire",
|
||||
"Silver", "Sodalite", "Spessartine", "Sphalerite", "Steel", "Sulfur", "Tin", "Titanium", "Tungsten", "Uranium",
|
||||
"Uvarovite", "Yellow Garnet", "Zinc"
|
||||
};
|
||||
|
||||
private IIcon[] textures;
|
||||
|
||||
public ItemDusts()
|
||||
{
|
||||
setUnlocalizedName("dust");
|
||||
setHasSubtypes(true);
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
// Registers Textures For All Dusts
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
textures = new IIcon[types.length];
|
||||
|
||||
for (int i = 0; i < types.length; ++i)
|
||||
{
|
||||
textures[i] = iconRegister.registerIcon("techreborn" + "dust");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
// Adds Texture what match's meta data
|
||||
public IIcon getIconFromDamage(int meta)
|
||||
{
|
||||
if (meta < 0 || meta >= textures.length)
|
||||
{
|
||||
meta = 0;
|
||||
}
|
||||
|
||||
return textures[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
// gets Unlocalized Name depending on meta data
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
int meta = itemStack.getItemDamage();
|
||||
if (meta < 0 || meta >= types.length)
|
||||
{
|
||||
meta = 0;
|
||||
}
|
||||
|
||||
return super.getUnlocalizedName() + "." + types[meta];
|
||||
}
|
||||
|
||||
// Adds Dusts SubItems To Creative Tab
|
||||
public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
|
||||
{
|
||||
for (int meta = 0; meta < types.length; ++meta)
|
||||
{
|
||||
list.add(new ItemStack(item, 1, meta));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue