当前位置: 首页>>代码示例>>Java>>正文


Java IElectricItem.canProvideEnergy方法代码示例

本文整理汇总了Java中ic2.api.item.IElectricItem.canProvideEnergy方法的典型用法代码示例。如果您正苦于以下问题:Java IElectricItem.canProvideEnergy方法的具体用法?Java IElectricItem.canProvideEnergy怎么用?Java IElectricItem.canProvideEnergy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ic2.api.item.IElectricItem的用法示例。


在下文中一共展示了IElectricItem.canProvideEnergy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
	}

}
 
开发者ID:xbony2,项目名称:Nuclear-Control,代码行数:24,代码来源:TileEntityRemoteThermo.java

示例2: 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;
	}
}
 
开发者ID:tobast,项目名称:ElectricAddons,代码行数:24,代码来源:TileEntityCrystallizer.java

示例3: 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);
	}
}
 
开发者ID:xbony2,项目名称:Nuclear-Control,代码行数:39,代码来源:TileEntityRemoteThermo.java

示例4: 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?!
			}
		}
	}
}
 
开发者ID:tobast,项目名称:ElectricAddons,代码行数:15,代码来源:TileEntityCrystallizer.java

示例5: 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();
    }
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:33,代码来源:AbilityHelper.java


注:本文中的ic2.api.item.IElectricItem.canProvideEnergy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。