Applied-Energistics-2-tiler.../items/tools/powered/powersink/IC2.java

120 lines
2.8 KiB
Java
Raw Normal View History

package appeng.items.tools.powered.powersink;
import ic2.api.item.IElectricItemManager;
2014-06-02 18:23:47 +02:00
import ic2.api.item.ISpecialElectricItem;
import net.minecraft.entity.EntityLivingBase;
2014-06-02 18:23:47 +02:00
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import appeng.api.config.PowerUnits;
import appeng.transformer.annotations.integration.Interface;
2014-06-02 18:23:47 +02:00
import appeng.transformer.annotations.integration.InterfaceList;
import appeng.transformer.annotations.integration.Method;
@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
{
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)
{
2014-06-29 00:32:40 +02:00
double addedAmt = amount;
double limit = getTransferLimit( is );
if ( !ignoreTransferLimit && amount > limit )
2014-06-02 18:23:47 +02:00
addedAmt = limit;
2014-06-02 18:23:47 +02:00
return addedAmt - ((int) injectExternalPower( PowerUnits.EU, is, addedAmt, simulate ));
}
@Override
2014-06-29 00:32:40 +02:00
public double discharge(ItemStack itemStack, double amount, int tier, boolean ignoreTransferLimit, boolean externaly, boolean simulate)
{
return 0;
}
@Override
2014-06-29 00:32:40 +02:00
public double getCharge(ItemStack is)
{
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)
{
return getCharge( is ) > amount;
}
@Override
2014-06-29 00:32:40 +02:00
public boolean use(ItemStack is, double 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
public boolean canProvideEnergy(ItemStack itemStack)
{
2014-06-02 18:23:47 +02:00
return false;
}
@Override
public Item getChargedItem(ItemStack itemStack)
{
2014-06-02 18:23:47 +02:00
return itemStack.getItem();
}
@Override
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-29 00:32:40 +02:00
return PowerUnits.AE.convertTo( PowerUnits.EU, getAEMaxPower( itemStack ) );
2014-06-02 18:23:47 +02:00
}
@Override
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)
{
return Math.max( 32, getMaxCharge( itemStack ) / 200 );
2014-06-02 18:23:47 +02:00
}
@Override
@Method(iname = "IC2")
public IElectricItemManager getManager(ItemStack itemStack)
{
2014-06-02 18:23:47 +02:00
return this;
}
}