2013-12-27 23:59:59 +01:00
|
|
|
package appeng.items.tools.powered.powersink;
|
|
|
|
|
|
|
|
import ic2.api.item.IElectricItemManager;
|
2014-06-02 18:23:47 +02:00
|
|
|
import ic2.api.item.ISpecialElectricItem;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2014-06-02 18:23:47 +02:00
|
|
|
import net.minecraft.item.Item;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import appeng.api.config.PowerUnits;
|
2014-04-06 08:55:24 +02:00
|
|
|
import appeng.transformer.annotations.integration.Interface;
|
2014-06-02 18:23:47 +02:00
|
|
|
import appeng.transformer.annotations.integration.InterfaceList;
|
2014-06-03 15:39:46 +02:00
|
|
|
import appeng.transformer.annotations.integration.Method;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-06-03 15:39:46 +02:00
|
|
|
@InterfaceList(value = { @Interface(iface = "ic2.api.item.ISpecialElectricItem", iname = "IC2"),
|
|
|
|
@Interface(iface = "ic2.api.item.IElectricItemManager", iname = "IC2") })
|
2014-06-02 18:23:47 +02:00
|
|
|
public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpecialElectricItem
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
public IC2(Class c, String subname) {
|
|
|
|
super( c, subname );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int charge(ItemStack is, int amount, int tier, boolean ignoreTransferLimit, boolean simulate)
|
|
|
|
{
|
2014-06-02 18:23:47 +02:00
|
|
|
int addedAmt = amount;
|
|
|
|
int limit = getTransferLimit( is );
|
2014-06-03 15:39:46 +02:00
|
|
|
|
|
|
|
if ( !ignoreTransferLimit && amount > limit )
|
2014-06-02 18:23:47 +02:00
|
|
|
addedAmt = limit;
|
2014-06-03 15:39:46 +02:00
|
|
|
|
2014-06-02 18:23:47 +02:00
|
|
|
return addedAmt - ((int) injectExternalPower( PowerUnits.EU, is, addedAmt, simulate ));
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int discharge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getCharge(ItemStack is)
|
|
|
|
{
|
|
|
|
return (int) PowerUnits.AE.convertTo( PowerUnits.EU, getAECurrentPower( is ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canUse(ItemStack is, int amount)
|
|
|
|
{
|
|
|
|
return getCharge( is ) > amount;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean use(ItemStack is, int amount, EntityLivingBase entity)
|
|
|
|
{
|
|
|
|
if ( canUse( is, amount ) )
|
|
|
|
{
|
|
|
|
// use the power..
|
|
|
|
extractAEPower( is, PowerUnits.EU.convertTo( PowerUnits.AE, amount ) );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void chargeFromArmor(ItemStack itemStack, EntityLivingBase entity)
|
|
|
|
{
|
|
|
|
// wtf?
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getToolTip(ItemStack itemStack)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2014-06-02 18:23:47 +02:00
|
|
|
@Override
|
2014-06-03 15:39:46 +02:00
|
|
|
public boolean canProvideEnergy(ItemStack itemStack)
|
|
|
|
{
|
2014-06-02 18:23:47 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-06-03 15:39:46 +02:00
|
|
|
public Item getChargedItem(ItemStack itemStack)
|
|
|
|
{
|
2014-06-02 18:23:47 +02:00
|
|
|
return itemStack.getItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-06-03 15:39:46 +02:00
|
|
|
public Item getEmptyItem(ItemStack itemStack)
|
|
|
|
{
|
2014-06-02 18:23:47 +02:00
|
|
|
return itemStack.getItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-06-03 15:39:46 +02:00
|
|
|
public int getMaxCharge(ItemStack itemStack)
|
|
|
|
{
|
2014-06-02 18:23:47 +02:00
|
|
|
return (int) PowerUnits.AE.convertTo( PowerUnits.EU, getAEMaxPower( itemStack ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-06-03 15:39:46 +02:00
|
|
|
public int getTier(ItemStack itemStack)
|
|
|
|
{
|
2014-06-02 18:23:47 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-06-03 15:39:46 +02:00
|
|
|
public int getTransferLimit(ItemStack itemStack)
|
|
|
|
{
|
|
|
|
return Math.max( 32, getMaxCharge( itemStack ) / 200 );
|
2014-06-02 18:23:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-06-03 15:39:46 +02:00
|
|
|
@Method(iname = "IC2")
|
|
|
|
public IElectricItemManager getManager(ItemStack itemStack)
|
|
|
|
{
|
2014-06-02 18:23:47 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|