More work on the cables, and add items
This commit is contained in:
parent
1cd886e770
commit
e4b8918224
7 changed files with 98 additions and 26 deletions
69
src/main/java/techreborn/items/ItemCables.java
Normal file
69
src/main/java/techreborn/items/ItemCables.java
Normal file
|
@ -0,0 +1,69 @@
|
|||
package techreborn.items;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Mark on 27/02/2016.
|
||||
*/
|
||||
public class ItemCables extends ItemTextureBase {
|
||||
|
||||
public static ItemStack getCableByName(String name, int count) {
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (types[i].equalsIgnoreCase(name)) {
|
||||
return new ItemStack(ModItems.cables, count, i);
|
||||
}
|
||||
}
|
||||
throw new InvalidParameterException("The cabel " + name + " could not be found.");
|
||||
}
|
||||
|
||||
public static ItemStack getCableByName(String name) {
|
||||
return getCableByName(name, 1);
|
||||
}
|
||||
|
||||
public static final String[] types = new String[]
|
||||
{"copper", "gold"};
|
||||
|
||||
|
||||
public ItemCables() {
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
setHasSubtypes(true);
|
||||
setUnlocalizedName("techreborn.cable");
|
||||
}
|
||||
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureName(int damage) {
|
||||
return ModInfo.MOD_ID + ":items/cables/" + types[damage];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxMeta() {
|
||||
return types.length;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue