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
|
2014-06-29 00:32:40 +02:00
|
|
|
public double charge(ItemStack is, double amount, int tier, boolean ignoreTransferLimit, boolean simulate)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-06-29 00:32:40 +02:00
|
|
|
double addedAmt = amount;
|
|
|
|
double 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
|
2014-06-29 00:32:40 +02:00
|
|
|
public double discharge(ItemStack itemStack, double amount, int tier, boolean ignoreTransferLimit, boolean externaly, boolean simulate)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-06-29 00:32:40 +02:00
|
|
|
public double getCharge(ItemStack is)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
return (int) PowerUnits.AE.convertTo( PowerUnits.EU, getAECurrentPower( is ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-06-29 00:32:40 +02:00
|
|
|
public boolean canUse(ItemStack is, double amount)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
return getCharge( is ) > amount;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-06-29 00:32:40 +02:00
|
|
|
public boolean use(ItemStack is, double amount, EntityLivingBase entity)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
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-29 00:32:40 +02:00
|
|
|
public double getMaxCharge(ItemStack itemStack)
|
2014-06-03 15:39:46 +02:00
|
|
|
{
|
2014-06-29 00:32:40 +02:00
|
|
|
return PowerUnits.AE.convertTo( PowerUnits.EU, getAEMaxPower( itemStack ) );
|
2014-06-02 18:23:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@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-29 00:32:40 +02:00
|
|
|
public double getTransferLimit(ItemStack itemStack)
|
2014-06-03 15:39:46 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|