equivalent-exchange-3/src/main/java/com/pahimar/ee3/item/ItemAlchemicalDust.java

143 lines
4.2 KiB
Java
Raw Normal View History

2013-08-23 16:59:50 +02:00
package com.pahimar.ee3.item;
import com.pahimar.ee3.EquivalentExchange3;
2013-12-20 12:58:15 +01:00
import com.pahimar.ee3.emc.EmcValue;
import com.pahimar.ee3.lib.Strings;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2013-08-23 16:59:50 +02:00
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
2013-12-20 12:58:15 +01:00
import java.util.ArrayList;
import java.util.List;
2013-08-23 16:59:50 +02:00
/**
* Equivalent-Exchange-3
* <p/>
2013-08-23 16:59:50 +02:00
* ItemAlchemicalDust
*
2013-08-23 16:59:50 +02:00
* @author pahimar
*/
public class ItemAlchemicalDust extends ItemEE
{
2013-12-20 12:58:15 +01:00
public static final String[] ALCHEMICAL_DUST_NAMES = {"Ash", "Minium", "Verdant", "Azure", "Amaranthine", "Iridescent"};
public static final EmcValue[] DEFAULT_EMC_VALUES = {
new EmcValue(0.1f),
new EmcValue(256),
new EmcValue(2048),
new EmcValue(8192),
new EmcValue(73728),
new EmcValue(4718592)
};
2013-08-23 16:59:50 +02:00
@SideOnly(Side.CLIENT)
private Icon[] icons;
public ItemAlchemicalDust(int id)
{
2013-08-23 16:59:50 +02:00
super(id);
this.setHasSubtypes(true);
this.setCreativeTab(EquivalentExchange3.tabsEE3);
maxStackSize = 64;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
2013-12-20 12:58:15 +01:00
return String.format("item.%s%s%s", Strings.RESOURCE_PREFIX, Strings.ALCHEMICAL_DUST_NAME, ALCHEMICAL_DUST_NAMES[MathHelper.clamp_int(itemStack.getItemDamage(), 0, ALCHEMICAL_DUST_NAMES.length - 1)]);
2013-08-23 16:59:50 +02:00
}
@Override
@SideOnly(Side.CLIENT)
/**
* Gets an icon index based on an item's damage value
*/
public Icon getIconFromDamage(int meta)
{
2013-12-20 12:58:15 +01:00
return icons[MathHelper.clamp_int(meta, 0, ALCHEMICAL_DUST_NAMES.length - 1)];
2013-08-23 16:59:50 +02:00
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
2013-08-23 16:59:50 +02:00
icons = new Icon[ALCHEMICAL_DUST_NAMES.length];
for (int i = 0; i < ALCHEMICAL_DUST_NAMES.length; ++i)
{
2013-12-20 12:58:15 +01:00
icons[i] = iconRegister.registerIcon(String.format("%s%s%s", Strings.RESOURCE_PREFIX, Strings.ALCHEMICAL_DUST_NAME, ALCHEMICAL_DUST_NAMES[i]));
2013-08-23 16:59:50 +02:00
}
}
@Override
@SideOnly(Side.CLIENT)
2013-12-20 12:58:15 +01:00
public boolean hasEffect(ItemStack stack, int renderPass)
{
2013-12-20 12:58:15 +01:00
return MathHelper.clamp_int(stack.getItemDamage(), 0, ALCHEMICAL_DUST_NAMES.length - 1) == 5;
2013-08-23 16:59:50 +02:00
}
@Override
public String getItemDisplayName(ItemStack itemStack)
{
2013-12-20 12:58:15 +01:00
switch (MathHelper.clamp_int(itemStack.getItemDamage(), 0, ALCHEMICAL_DUST_NAMES.length - 1))
{
2013-08-23 16:59:50 +02:00
case 0:
2013-12-20 12:58:15 +01:00
{
2013-08-23 16:59:50 +02:00
return EnumChatFormatting.WHITE + super.getItemDisplayName(itemStack);
2013-12-20 12:58:15 +01:00
}
2013-08-23 16:59:50 +02:00
case 1:
2013-12-20 12:58:15 +01:00
{
2013-08-23 16:59:50 +02:00
return EnumChatFormatting.WHITE + super.getItemDisplayName(itemStack);
2013-12-20 12:58:15 +01:00
}
2013-08-23 16:59:50 +02:00
case 2:
2013-12-20 12:58:15 +01:00
{
2013-08-23 16:59:50 +02:00
return EnumChatFormatting.GREEN + super.getItemDisplayName(itemStack);
2013-12-20 12:58:15 +01:00
}
2013-08-23 16:59:50 +02:00
case 3:
2013-12-20 12:58:15 +01:00
{
2013-08-23 16:59:50 +02:00
return EnumChatFormatting.BLUE + super.getItemDisplayName(itemStack);
2013-12-20 12:58:15 +01:00
}
2013-08-23 16:59:50 +02:00
case 4:
2013-12-20 12:58:15 +01:00
{
2013-08-23 16:59:50 +02:00
return EnumChatFormatting.DARK_PURPLE + super.getItemDisplayName(itemStack);
2013-12-20 12:58:15 +01:00
}
2013-08-23 16:59:50 +02:00
case 5:
2013-12-20 12:58:15 +01:00
{
2013-08-23 16:59:50 +02:00
return EnumChatFormatting.GOLD + super.getItemDisplayName(itemStack);
2013-12-20 12:58:15 +01:00
}
2013-08-23 16:59:50 +02:00
default:
2013-12-20 12:58:15 +01:00
{
2013-08-23 16:59:50 +02:00
return EnumChatFormatting.WHITE + super.getItemDisplayName(itemStack);
2013-12-20 12:58:15 +01:00
}
2013-08-23 16:59:50 +02:00
}
}
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
2013-08-23 16:59:50 +02:00
@SideOnly(Side.CLIENT)
public void getSubItems(int id, CreativeTabs creativeTab, List list)
{
2013-12-20 12:58:15 +01:00
for (int meta = 0; meta < ALCHEMICAL_DUST_NAMES.length; ++meta)
{
2013-08-23 16:59:50 +02:00
list.add(new ItemStack(id, 1, meta));
}
}
2013-12-20 12:58:15 +01:00
@Override
public List<ItemStack> getSubTypes()
{
List<ItemStack> alchemicalDustStacks = new ArrayList<ItemStack>();
for (int meta = 0; meta < ALCHEMICAL_DUST_NAMES.length; meta++)
{
alchemicalDustStacks.add(new ItemStack(ModItems.alchemicalDust, 1, meta));
}
2013-12-20 12:58:15 +01:00
return alchemicalDustStacks;
}
2013-08-23 16:59:50 +02:00
}