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


Java IEnergyContainerItem.getEnergyStored方法代码示例

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


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

示例1: findRFItems

import cofh.api.energy.IEnergyContainerItem; //导入方法依赖的package包/类
private void findRFItems(IInventory inventory,List<ItemStack> rf_items)
{
  if(inventory == null)
  {
    return;
  }
  for(int i = 0; i < inventory.getSizeInventory(); i++)
  {
    ItemStack stack = inventory.getStackInSlot(i);
    if(stack != null && stack.getItem() instanceof IEnergyContainerItem)
    {
      IEnergyContainerItem rf_item = (IEnergyContainerItem) stack.getItem();
      if(rf_item.getEnergyStored(stack) < rf_item.getMaxEnergyStored(stack))
      {
        rf_items.add(stack);
      }
    }
  }
}
 
开发者ID:EXTER7,项目名称:FluxPads,代码行数:20,代码来源:TileEntityFluxPad.java

示例2: matchItem

import cofh.api.energy.IEnergyContainerItem; //导入方法依赖的package包/类
@Override
public boolean matchItem(final ItemStack item) {
    if (!super.matchItem(item)) {
        return false;
    }
    final IEnergyContainerItem energyContainerItem = (IEnergyContainerItem)item.getItem();
    final int maxEnergyStored = energyContainerItem.getMaxEnergyStored(item);
    return maxEnergyStored > 0 && energyContainerItem.getEnergyStored(item) <= maxEnergyStored >> 1;
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:10,代码来源:AdvancedNodeUpgrades.java

示例3: updateEntity

import cofh.api.energy.IEnergyContainerItem; //导入方法依赖的package包/类
public void updateEntity() {
	super.updateEntity();
	ItemStack block = new ItemStack(worldObj.getBlock(xCoord, yCoord, zCoord));
	if (timer == 0 && !worldObj.isRemote) {
		timer = 1;
		if(NBTHelper.getInt(block, "energy")>0){
			worldObj.spawnParticle("flame", xCoord, yCoord, zCoord, 1, 1, 1);
		}
		List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord - 5, yCoord - 5, zCoord - 5, xCoord + 5, yCoord + 5, zCoord + 5));
		for (EntityPlayer player : players) {
			for (int i = 0; i < 4; i++) {
				if (BaublesApi.getBaubles(player).getStackInSlot(i) != null) {
					ItemStack bauble = BaublesApi.getBaubles(player).getStackInSlot(i);
					if (bauble.getItem() instanceof IEnergyContainerItem) {
						IEnergyContainerItem energyContainer = (IEnergyContainerItem) bauble.getItem();
						if (energyContainer.getEnergyStored(bauble) < energyContainer.getMaxEnergyStored(bauble)) {
							NBTHelper.setInteger(bauble, "energy", energyContainer.getEnergyStored(bauble) + energyContainer.receiveEnergy(bauble, energyContainer.getMaxEnergyStored(bauble), false));
							if (NBTHelper.getInt(bauble, "energy") > energyContainer.getMaxEnergyStored(bauble)) {
								NBTHelper.setInteger(bauble, "energy", energyContainer.getMaxEnergyStored(bauble));
							}
						}
					}
				}
			}

			for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
				if (player.inventory.getStackInSlot(i) != null && player.inventory.getStackInSlot(i).getItem() instanceof IEnergyContainerItem) {
					IEnergyContainerItem energyItem = (IEnergyContainerItem) player.inventory.getStackInSlot(i).getItem();
					energyItem.receiveEnergy(player.inventory.getStackInSlot(i), energyItem.getMaxEnergyStored(player.inventory.getStackInSlot(i)), false);
				}
			}
		}
	}
	timer--;
}
 
开发者ID:jaredlll08,项目名称:Fluxed-Trinkets,代码行数:36,代码来源:TileEntityWirelessCharger.java

示例4: isEmpty

import cofh.api.energy.IEnergyContainerItem; //导入方法依赖的package包/类
/**
 * Is the enrgy in the stack depleted
 * 
 * @param stack
 * @return whether the stack is depeleted, or false if it does not contain
 *         any energy.
 */
public static boolean isEmpty(ItemStack stack) {
    if (EnergyHelper.isEnergyContainerItem(stack)) {

        IEnergyContainerItem item = (IEnergyContainerItem) stack.getItem();

        return item.getEnergyStored(stack) == 0;
    }

    return false;
}
 
开发者ID:chbachman,项目名称:ModularArmour,代码行数:18,代码来源:EnergyUtil.java

示例5: isFull

import cofh.api.energy.IEnergyContainerItem; //导入方法依赖的package包/类
/**
 * Is the energy full
 * 
 * @param stack
 * @return whether the stack is full, or false if it is not an energy item
 */
public static boolean isFull(ItemStack stack) {
    if (EnergyHelper.isEnergyContainerItem(stack)) {

        IEnergyContainerItem item = (IEnergyContainerItem) stack.getItem();

        return item.getEnergyStored(stack) == item.getMaxEnergyStored(stack);
    }

    return false;
}
 
开发者ID:chbachman,项目名称:ModularArmour,代码行数:17,代码来源:EnergyUtil.java

示例6: update

import cofh.api.energy.IEnergyContainerItem; //导入方法依赖的package包/类
@Override
public void update() {
	super.update();
	if (!world.isRemote) {
		if (isBurning()) {
			changeCharge(generationRate);
			checkForFire();
		}
		
		//Charge items in charge slot
		if (!slots[SLOT_CHARGER].isEmpty()) {
			if (currentStorage>0) {
				if (slots[SLOT_CHARGER].getItem() instanceof IEnergyContainerItem) {
					IEnergyContainerItem container = (IEnergyContainerItem)slots[SLOT_CHARGER].getItem();
					if (container.getEnergyStored(slots[SLOT_CHARGER]) < container.getMaxEnergyStored(slots[SLOT_CHARGER])) {
						int giveAmount = container.receiveEnergy(slots[SLOT_CHARGER], currentStorage, false);
						if (giveAmount>0) changeCharge(giveAmount * -1);
					}
				}
			}
		}

		//output the energy to connected devices....
		outputEnergy();
	} else {
		checkUpdate();
	}
}
 
开发者ID:Vanhal,项目名称:ProgressiveAutomation,代码行数:29,代码来源:TileGenerator.java

示例7: update

import cofh.api.energy.IEnergyContainerItem; //导入方法依赖的package包/类
@Override
public void update() {
	super.update();
	if (!world.isRemote) {
		//Charge items in charge slot
		if (!slots[SLOT_CHARGER].isEmpty()) {
			if (currentStorage>0) {
				if (slots[SLOT_CHARGER].getItem() instanceof IEnergyContainerItem) {
					IEnergyContainerItem container = (IEnergyContainerItem)slots[SLOT_CHARGER].getItem();
					if (container.getEnergyStored(slots[SLOT_CHARGER]) < container.getMaxEnergyStored(slots[SLOT_CHARGER])) {
						int giveAmount = container.receiveEnergy(slots[SLOT_CHARGER], currentStorage, false);
						if (giveAmount>0) changeCharge(giveAmount * -1);
					}
				}
			}
		}
		
		//output only of we don't get a redstone signal
		if(world.getRedstonePower(pos, EnumFacing.UP)==0 ||
			world.getRedstonePower(pos, EnumFacing.DOWN)==0 ||
			world.getRedstonePower(pos, EnumFacing.NORTH)==0 ||
			world.getRedstonePower(pos, EnumFacing.SOUTH)==0 ||
			world.getRedstonePower(pos, EnumFacing.WEST)==0 ||
			world.getRedstonePower(pos, EnumFacing.EAST)==0) {
			//output the energy to connected devices....
			outputEnergy();
		}
	}
}
 
开发者ID:Vanhal,项目名称:ProgressiveAutomation,代码行数:30,代码来源:TileCapacitor.java

示例8: handleUpgrade

import cofh.api.energy.IEnergyContainerItem; //导入方法依赖的package包/类
public void handleUpgrade(ItemStack leftInput, ItemStack rightInput, AnvilUpdateEvent event)
{
	if (leftInput.getItem() == HZ_Items.ItemHammer && rightInput.func_190916_E() == 1 && HammerInfoHandler.isStackDarkSteelHammer(leftInput))
	{
		ItemStack Output = leftInput.copy();

		List<IUpgrade> upgrades = UpgradeManager.getInstance().getUpgradeList();
		Iterator<IUpgrade> iterator = upgrades.iterator();

		while (iterator.hasNext())
		{
			IUpgrade upgrade = iterator.next();
			if (rightInput.getItem() == upgrade.getItem().getItem() && rightInput.getItemDamage() == upgrade.getItem().getItemDamage())
			{
				NBTTagCompound tagCompound = RandomUtils.getNBT(Output);
				if (tagCompound.getInteger(ItemHammer.Key_Empower) == upgrade.getLevel() - 1)
				{
					tagCompound.setInteger(ItemHammer.Key_Empower, upgrade.getLevel());

					Output.setTagCompound(tagCompound);
					if(rightInput.getItem() instanceof IEnergyContainerItem)
					{
						IEnergyContainerItem item = (IEnergyContainerItem) rightInput.getItem();
						int energy = item.getEnergyStored(rightInput);
						if(Output.getItem() instanceof ItemHammer)
						{
							NBTTagCompound finalCompound = RandomUtils.getNBT(Output);
							int hammerEnergy = finalCompound.getInteger(ItemHammer.Tag_DarkSteelEnergy);
							if(hammerEnergy + energy > EnergyHandler.getMaxEnergyStored(Output))
							{
								finalCompound.setInteger(ItemHammer.Tag_DarkSteelEnergy, EnergyHandler.getMaxEnergyStored(Output));
							}
							else
							{
								finalCompound.setInteger(ItemHammer.Tag_DarkSteelEnergy, hammerEnergy + energy);
							}

						}
					}
					event.setCost(upgrade.getCost());
					event.setMaterialCost(1);
					event.setOutput(Output);
					return;
				}
			}
		}
	}

}
 
开发者ID:VapourDrive,项目名称:Hammerz,代码行数:50,代码来源:AnvilEvent.java


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