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


Java IElectricItem类代码示例

本文整理汇总了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));
		}
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:25,代码来源:TileEntityChargepad.java

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

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

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

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

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

示例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;
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:13,代码来源:ChargeUtils.java

示例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);
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:12,代码来源:ChargeUtils.java

示例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;
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral-Integration,代码行数:13,代码来源:ElectricItemMetaProvider.java

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

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

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

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

示例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;
}
 
开发者ID:Keridos,项目名称:FloodLights,代码行数:10,代码来源:GeneralUtil.java

示例14: canTransfer

import ic2.api.item.IElectricItem; //导入依赖的package包/类
private boolean canTransfer(ItemStack slotStack)
{
	return MekanismUtils.useIC2() && slotStack.getItem() instanceof IElectricItem;
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:5,代码来源:ContainerEnergyCube.java

示例15: hasIC2

import ic2.api.item.IElectricItem; //导入依赖的package包/类
public static boolean hasIC2(ItemStack stack) {

        return (stack.getItem() instanceof IElectricItem || stack.getItem() instanceof ISpecialElectricItem);
    }
 
开发者ID:CreeperShift,项目名称:WirelessCharger,代码行数:5,代码来源:IC2Compat.java


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