mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-26 06:53:24 +00:00
- Add storage blocks for alloys and other metals - Register quite clear glass as "blockGlass" as well for compatability - Add registration for all nuggets
82 lines
2.2 KiB
Java
82 lines
2.2 KiB
Java
package crazypants.enderio.material;
|
|
|
|
import java.util.List;
|
|
|
|
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;
|
|
import net.minecraft.util.MathHelper;
|
|
import cpw.mods.fml.common.registry.GameRegistry;
|
|
import crazypants.enderio.EnderIOTab;
|
|
import crazypants.enderio.ModObject;
|
|
|
|
public class ItemAlloy extends Item {
|
|
|
|
static final boolean useNuggets = false;
|
|
|
|
private final IIcon[] icons;
|
|
private final int numItems;
|
|
|
|
public static ItemAlloy create() {
|
|
ItemAlloy alloy = new ItemAlloy();
|
|
alloy.init();
|
|
return alloy;
|
|
}
|
|
|
|
private ItemAlloy() {
|
|
setHasSubtypes(true);
|
|
setMaxDamage(0);
|
|
setCreativeTab(EnderIOTab.tabEnderIO);
|
|
setUnlocalizedName(ModObject.itemAlloy.unlocalisedName);
|
|
|
|
numItems = Alloy.values().length;
|
|
if(useNuggets) {
|
|
numItems = numItems * 2;
|
|
}
|
|
icons = new IIcon[numItems];
|
|
}
|
|
|
|
private void init() {
|
|
GameRegistry.registerItem(this, ModObject.itemAlloy.unlocalisedName);
|
|
}
|
|
|
|
@Override
|
|
public IIcon getIconFromDamage(int damage) {
|
|
damage = MathHelper.clamp_int(damage, 0, numItems - 1);
|
|
return icons[damage];
|
|
}
|
|
|
|
@Override
|
|
public void registerIcons(IIconRegister IIconRegister) {
|
|
int numAlloys = Alloy.values().length;
|
|
for (int i = 0; i < numAlloys; i++) {
|
|
icons[i] = IIconRegister.registerIcon(Alloy.values()[i].iconKey);
|
|
}
|
|
if(useNuggets) {
|
|
for (int i = 0; i < numAlloys; i++) {
|
|
icons[i + numAlloys] = IIconRegister.registerIcon(Alloy.values()[i].iconKey + "Nugget");
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getUnlocalizedName(ItemStack par1ItemStack) {
|
|
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, numItems - 1);
|
|
if(i < Alloy.values().length) {
|
|
return Alloy.values()[i].unlocalisedName;
|
|
} else {
|
|
return Alloy.values()[i - Alloy.values().length].unlocalisedName + "Nugget";
|
|
}
|
|
}
|
|
|
|
@Override
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
|
for (int j = 0; j < numItems; ++j) {
|
|
par3List.add(new ItemStack(par1, 1, j));
|
|
}
|
|
}
|
|
}
|