2015-01-16 11:22:50 -05:00
|
|
|
package WayofTime.alchemicalWizardry.common.items.routing;
|
|
|
|
|
2015-01-31 11:46:49 -05:00
|
|
|
import java.util.List;
|
|
|
|
|
2015-01-16 11:22:50 -05:00
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
2015-01-31 11:46:49 -05:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
2015-02-20 15:52:11 -05:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2015-01-31 11:46:49 -05:00
|
|
|
import net.minecraft.item.Item;
|
2015-01-23 07:53:40 -05:00
|
|
|
import net.minecraft.item.ItemStack;
|
2015-02-20 15:52:11 -05:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2015-01-20 17:27:53 -05:00
|
|
|
import net.minecraft.util.IIcon;
|
2015-02-20 15:52:11 -05:00
|
|
|
import net.minecraft.util.StatCollector;
|
2015-01-20 17:27:53 -05:00
|
|
|
import WayofTime.alchemicalWizardry.api.RoutingFocusLogic;
|
2015-02-20 15:52:11 -05:00
|
|
|
import WayofTime.alchemicalWizardry.api.RoutingFocusLogicLimitDefault;
|
|
|
|
import WayofTime.alchemicalWizardry.api.RoutingFocusLogicLimitIgnMeta;
|
|
|
|
import WayofTime.alchemicalWizardry.api.RoutingFocusLogicLimitMatchNBT;
|
|
|
|
import WayofTime.alchemicalWizardry.api.RoutingFocusLogicLimitModItems;
|
2015-01-16 11:22:50 -05:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
2015-02-20 15:52:11 -05:00
|
|
|
public class OutputRoutingFocus extends RoutingFocus implements ILimitedRoutingFocus
|
2015-01-16 11:22:50 -05:00
|
|
|
{
|
2015-01-23 07:53:40 -05:00
|
|
|
IIcon modItemIcon;
|
2015-02-20 15:52:11 -05:00
|
|
|
IIcon ignMetaIcon;
|
|
|
|
IIcon matchNBTIcon;
|
|
|
|
|
2015-01-16 11:22:50 -05:00
|
|
|
public OutputRoutingFocus()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
2015-02-20 15:52:11 -05:00
|
|
|
@Override
|
|
|
|
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
|
|
|
{
|
|
|
|
super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4);
|
|
|
|
|
|
|
|
if (!(par1ItemStack.getTagCompound() == null))
|
|
|
|
{
|
|
|
|
int limit = this.getRoutingFocusLimit(par1ItemStack);
|
|
|
|
if(limit > 0)
|
|
|
|
{
|
|
|
|
par3List.add(StatCollector.translateToLocal("tooltip.routingFocus.limit") + " " + limit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-16 11:22:50 -05:00
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void registerIcons(IIconRegister iconRegister)
|
|
|
|
{
|
2015-01-20 17:27:53 -05:00
|
|
|
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:OutputRoutingFocus");
|
2015-01-23 07:53:40 -05:00
|
|
|
this.modItemIcon = iconRegister.registerIcon("AlchemicalWizardry:OutputRoutingFocusModItems");
|
2015-02-20 15:52:11 -05:00
|
|
|
this.ignMetaIcon = iconRegister.registerIcon("AlchemicalWizardry:OutputRoutingFocusIgnMeta");
|
|
|
|
this.matchNBTIcon = iconRegister.registerIcon("AlchemicalWizardry:OutputRoutingFocusMatchNBT");
|
2015-01-16 11:22:50 -05:00
|
|
|
}
|
|
|
|
|
2015-01-20 17:27:53 -05:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public IIcon getIconFromDamage(int damage)
|
|
|
|
{
|
|
|
|
switch(damage)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return this.itemIcon;
|
2015-01-23 07:53:40 -05:00
|
|
|
case 1:
|
|
|
|
return this.modItemIcon;
|
2015-02-20 15:52:11 -05:00
|
|
|
case 2:
|
|
|
|
return this.ignMetaIcon;
|
|
|
|
case 3:
|
|
|
|
return this.matchNBTIcon;
|
2015-01-20 17:27:53 -05:00
|
|
|
}
|
|
|
|
return this.itemIcon;
|
|
|
|
}
|
|
|
|
|
2015-01-23 07:53:40 -05:00
|
|
|
@Override
|
|
|
|
public String getUnlocalizedName(ItemStack itemStack)
|
|
|
|
{
|
|
|
|
String addedString = "";
|
|
|
|
|
|
|
|
switch(itemStack.getItemDamage())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
addedString = "default";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
addedString = "modItem";
|
|
|
|
break;
|
2015-01-31 11:46:49 -05:00
|
|
|
case 2:
|
|
|
|
addedString = "ignMeta";
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
addedString = "matchNBT";
|
|
|
|
break;
|
2015-01-23 07:53:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return super.getUnlocalizedName() + "." + addedString;
|
|
|
|
}
|
|
|
|
|
2015-01-31 11:46:49 -05:00
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void getSubItems(Item id, CreativeTabs creativeTab, List list)
|
|
|
|
{
|
|
|
|
for (int meta = 0; meta < 4; ++meta)
|
|
|
|
{
|
|
|
|
list.add(new ItemStack(id, 1, meta));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-02-20 15:52:11 -05:00
|
|
|
public RoutingFocusLogic getLogic(ItemStack itemStack)
|
2015-01-16 11:22:50 -05:00
|
|
|
{
|
2015-02-20 15:52:11 -05:00
|
|
|
if(itemStack != null)
|
2015-01-20 17:27:53 -05:00
|
|
|
{
|
2015-02-20 15:52:11 -05:00
|
|
|
switch(itemStack.getItemDamage())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return new RoutingFocusLogicLimitDefault(itemStack);
|
|
|
|
case 1:
|
|
|
|
return new RoutingFocusLogicLimitModItems(itemStack);
|
|
|
|
case 2:
|
|
|
|
return new RoutingFocusLogicLimitIgnMeta(itemStack);
|
|
|
|
case 3:
|
|
|
|
return new RoutingFocusLogicLimitMatchNBT(itemStack);
|
|
|
|
}
|
2015-01-20 17:27:53 -05:00
|
|
|
}
|
2015-02-20 15:52:11 -05:00
|
|
|
|
2015-01-20 17:27:53 -05:00
|
|
|
return new RoutingFocusLogic();
|
2015-02-20 15:52:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getDefaultStackLimit(int damage)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getRoutingFocusLimit(ItemStack itemStack)
|
|
|
|
{
|
|
|
|
if (!(itemStack.getTagCompound() == null))
|
|
|
|
{
|
|
|
|
return itemStack.getTagCompound().getInteger("stackLimit");
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
return getDefaultStackLimit(itemStack.getItemDamage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRoutingFocusLimit(ItemStack itemStack, int amt)
|
|
|
|
{
|
|
|
|
if ((itemStack.getTagCompound() == null))
|
|
|
|
{
|
|
|
|
itemStack.setTagCompound(new NBTTagCompound());
|
|
|
|
}
|
|
|
|
|
|
|
|
itemStack.getTagCompound().setInteger("stackLimit", amt);
|
|
|
|
}
|
2015-01-16 11:22:50 -05:00
|
|
|
}
|