本文整理汇总了Java中ic2.api.item.IElectricItem类的典型用法代码示例。如果您正苦于以下问题:Java IElectricItem类的具体用法?Java IElectricItem怎么用?Java IElectricItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IElectricItem类属于ic2.api.item包,在下文中一共展示了IElectricItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: chargeItemStack
import ic2.api.item.IElectricItem; //导入依赖的package包/类
public void chargeItemStack(ItemStack itemstack)
{
if(itemstack != null)
{
if(itemstack.getItem() instanceof IEnergizedItem)
{
setEnergy(getEnergy() - EnergizedItemManager.charge(itemstack, getEnergy()));
}
else if(MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem)
{
double sent = ElectricItem.manager.charge(itemstack, (int)(getEnergy()*general.TO_IC2), 4, true, false)*general.FROM_IC2;
setEnergy(getEnergy() - sent);
}
else if(MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem)
{
IEnergyContainerItem item = (IEnergyContainerItem)itemstack.getItem();
int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemstack)), item.getMaxEnergyStored(itemstack) - item.getEnergyStored(itemstack)));
int toTransfer = (int)Math.round(Math.min(itemEnergy, (getEnergy()*general.TO_TE)));
setEnergy(getEnergy() - (item.receiveEnergy(itemstack, toTransfer, false)*general.FROM_TE));
}
}
}
示例2: isItemValid
import ic2.api.item.IElectricItem; //导入依赖的package包/类
@Override
public boolean isItemValid(int slotIndex, ItemStack itemstack) {
switch (slotIndex) {
case SLOT_CHARGER:
if (Item.getIdFromItem(itemstack.getItem()) == Item.getIdFromItem(IC2Items.getItem("suBattery").getItem()))
return true;
if (itemstack.getItem() instanceof IElectricItem) {
IElectricItem item = (IElectricItem) itemstack.getItem();
if (item.canProvideEnergy(itemstack) && item.getTier(itemstack) <= tier) {
return true;
}
}
return false;
case SLOT_CARD:
return itemstack.getItem() instanceof ItemCardReactorSensorLocation
|| itemstack.getItem() instanceof ItemCard55Reactor;
default:
return itemstack.isItemEqual(IC2Items.getItem("transformerUpgrade"))
|| itemstack.isItemEqual(IC2Items.getItem("energyStorageUpgrade"))
|| (itemstack.getItem() instanceof ItemUpgrade && itemstack.getItemDamage() == ItemUpgrade.DAMAGE_RANGE);
}
}
示例3: chargeItem
import ic2.api.item.IElectricItem; //导入依赖的package包/类
private void chargeItem() {
ItemStack itemStack = getStackInSlot(0);
IElectricItemManager itemManager = ic2.api.item.ElectricItem.manager;
if(itemStack != null && itemStack.getItem() instanceof IElectricItem) {
IElectricItem elecItem = (IElectricItem) itemStack.getItem();
if(elecItem.getTier(itemStack) <= this.tier) {
double missingEU = elecItem.getMaxCharge(itemStack) - itemManager.getCharge(itemStack);
int toTransfer = (int) Math.min(elecItem.getTransferLimit(itemStack), Math.min(sink.getEnergyStored(), missingEU));
if(sink.useEnergy(toTransfer)) {
itemManager.charge(itemStack, toTransfer, this.tier, false, false);
}
}
}
}
示例4: isItemValidForSlot
import ic2.api.item.IElectricItem; //导入依赖的package包/类
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
if(itemstack == null)
return true;
switch(slot) {
case 0: // Input
if(itemstack.getItem() == ic2.api.item.IC2Items.getItem("energiumDust").getItem())
return true;
return false;
case 1: // Energy input
if(itemstack.getItem() instanceof IElectricItem) {
IElectricItem elecItem = (IElectricItem)(itemstack.getItem());
if(elecItem.canProvideEnergy(itemstack) && elecItem.getTier(itemstack) <= sink.getTier())
return true;
}
return false;
case 2: // Output
return false;
default:
return false;
}
}
示例5: charge
import ic2.api.item.IElectricItem; //导入依赖的package包/类
/**
* Universally charges an item, and updates the TileEntity's energy level.
* @param slotID - ID of the slot of which to discharge
* @param storer - TileEntity the item is being discharged in
*/
public static void charge(int slotID, IStrictEnergyStorage storer)
{
IInventory inv = (TileEntityContainerBlock)storer;
if(inv.getStackInSlot(slotID) != null && storer.getEnergy() > 0)
{
if(inv.getStackInSlot(slotID).getItem() instanceof IEnergizedItem)
{
storer.setEnergy(storer.getEnergy() - EnergizedItemManager.charge(inv.getStackInSlot(slotID), storer.getEnergy()));
}
else if(MekanismUtils.useIC2() && inv.getStackInSlot(slotID).getItem() instanceof IElectricItem)
{
double sent = ElectricItem.manager.charge(inv.getStackInSlot(slotID), (int)(storer.getEnergy()* general.TO_IC2), 4, true, false)* general.FROM_IC2;
storer.setEnergy(storer.getEnergy() - sent);
}
else if(MekanismUtils.useRF() && inv.getStackInSlot(slotID).getItem() instanceof IEnergyContainerItem)
{
ItemStack itemStack = inv.getStackInSlot(slotID);
IEnergyContainerItem item = (IEnergyContainerItem)inv.getStackInSlot(slotID).getItem();
int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemStack)), item.getMaxEnergyStored(itemStack) - item.getEnergyStored(itemStack)));
int toTransfer = (int)Math.round(Math.min(itemEnergy, (storer.getEnergy()* general.TO_TE)));
storer.setEnergy(storer.getEnergy() - (item.receiveEnergy(itemStack, toTransfer, false)* general.FROM_TE));
}
}
}
示例6: canBeDischarged
import ic2.api.item.IElectricItem; //导入依赖的package包/类
/**
* Whether or not a defined ItemStack can be discharged for energy in some way.
* @param itemstack - ItemStack to check
* @return if the ItemStack can be discharged
*/
public static boolean canBeDischarged(ItemStack itemstack)
{
return (MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack)) ||
(itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canSend(itemstack)) ||
(MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).extractEnergy(itemstack, 1, true) != 0) ||
itemstack.getItem() == Items.redstone;
}
示例7: canBeCharged
import ic2.api.item.IElectricItem; //导入依赖的package包/类
/**
* Whether or not a defined ItemStack can be charged with energy in some way.
* @param itemstack - ItemStack to check
* @return if the ItemStack can be discharged
*/
public static boolean canBeCharged(ItemStack itemstack)
{
return (MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem) ||
(itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canReceive(itemstack)) ||
(MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).receiveEnergy(itemstack, 1, true) != 0);
}
示例8: getMeta
import ic2.api.item.IElectricItem; //导入依赖的package包/类
@Override
public Object getMeta(IElectricItem target, ItemStack stack) {
Map<String, Object> electricInfo = Maps.newHashMap();
electricInfo.put("tier", target.getTier(stack));
electricInfo.put("maxCharge", target.getMaxCharge(stack));
electricInfo.put("transferLimit", target.getTransferLimit(stack));
electricInfo.put("canProvideEnergy", target.canProvideEnergy(stack));
electricInfo.put("charge", ElectricItem.manager.getCharge(stack));
return electricInfo;
}
示例9: updateEntity
import ic2.api.item.IElectricItem; //导入依赖的package包/类
@Override
public void updateEntity() {
super.updateEntity();
if (!worldObj.isRemote) { //If is server
int consumption = IC2NuclearControl.instance.remoteThermalMonitorEnergyConsumption;
if (inventory[SLOT_CHARGER] != null) {
if (energy < maxStorage) {
if (inventory[SLOT_CHARGER].getItem() instanceof IElectricItem) {
IElectricItem ielectricitem = (IElectricItem) inventory[SLOT_CHARGER].getItem();
if (ielectricitem.canProvideEnergy(inventory[SLOT_CHARGER])) {
double k = ElectricItem.manager.discharge(inventory[SLOT_CHARGER], maxStorage - energy, tier, false, false, false);
energy += k;
}
}else if (Item.getIdFromItem(inventory[SLOT_CHARGER].getItem()) == Item.getIdFromItem((IC2Items.getItem("suBattery")).getItem())){
if (ENERGY_SU_BATTERY <= maxStorage - energy || energy == 0) {
inventory[SLOT_CHARGER].stackSize--;
if (inventory[SLOT_CHARGER].stackSize <= 0) {
inventory[SLOT_CHARGER] = null;
}
energy += ENERGY_SU_BATTERY;
if (energy > maxStorage)
energy = maxStorage;
}
}
}
}
if (energy >= consumption) {
energy -= consumption;
}else{
energy = 0;
}
setEnergy(energy);
}
}
示例10: isItemValidForSlot
import ic2.api.item.IElectricItem; //导入依赖的package包/类
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
if(itemstack.getItem() instanceof IElectricItem) {
IElectricItem elecItem = (IElectricItem)(itemstack.getItem());
if(elecItem.getTier(itemstack) <= sink.getTier())
return true;
}
return false;
}
示例11: fillEnergyFromInput
import ic2.api.item.IElectricItem; //导入依赖的package包/类
private void fillEnergyFromInput() {
ItemStack energyStack = getStackInSlot(Slots.ENERGY_INPUT);
if(sink.getEnergyStored() < sink.getCapacity() &&
energyStack != null && energyStack.getItem() instanceof IElectricItem) {
IElectricItem powerSource = (IElectricItem)(energyStack.getItem());
if(powerSource.canProvideEnergy(energyStack)) {
int toTransfer = (int) Math.min(powerSource.getTransferLimit(energyStack), (int) (sink.getCapacity() - sink.getEnergyStored()));
if(toTransfer > 0) {
double energyRetrieved = ic2.api.item.ElectricItem.manager.discharge(energyStack, toTransfer, 1, false, true, false);
sink.injectEnergy(ForgeDirection.UNKNOWN, energyRetrieved, 42); //FIXME what's voltage?!
}
}
}
}
示例12: chargeFromArmor
import ic2.api.item.IElectricItem; //导入依赖的package包/类
static void chargeFromArmor (ItemStack stack, EntityPlayer player)
{
boolean inContainer = false;
for (int armorIter = 0; armorIter < 4; ++armorIter)
{
ItemStack armor = player.inventory.armorInventory[armorIter];
if (armor != null && armor.getItem() instanceof IElectricItem)
{
IElectricItem electricArmor = (IElectricItem) armor.getItem();
ToolCore tool = (ToolCore) stack.getItem();
if (electricArmor.canProvideEnergy(stack) && electricArmor.getTier(stack) >= ((IElectricItem) stack.getItem()).getTier(stack))
{
int chargeAmount = tool.charge(stack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true);
chargeAmount = discharge(armor, chargeAmount, Integer.MAX_VALUE, true, false);
if (chargeAmount > 0)
{
tool.charge(stack, chargeAmount, Integer.MAX_VALUE, true, false);
inContainer = true;
}
}
}
}
if (inContainer)
{
player.openContainer.detectAndSendChanges();
}
}
示例13: isItemStackValidElectrical
import ic2.api.item.IElectricItem; //导入依赖的package包/类
public static boolean isItemStackValidElectrical(ItemStack itemStack) {
Item item = itemStack.getItem();
if (ModCompatibility.IC2Loaded) {
if (item instanceof IElectricItem) {
return ((IElectricItem) item).canProvideEnergy(itemStack);
}
}
return item instanceof IEnergyContainerItem;
}
示例14: canTransfer
import ic2.api.item.IElectricItem; //导入依赖的package包/类
private boolean canTransfer(ItemStack slotStack)
{
return MekanismUtils.useIC2() && slotStack.getItem() instanceof IElectricItem;
}
示例15: hasIC2
import ic2.api.item.IElectricItem; //导入依赖的package包/类
public static boolean hasIC2(ItemStack stack) {
return (stack.getItem() instanceof IElectricItem || stack.getItem() instanceof ISpecialElectricItem);
}