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


Java IEnergyContainerItem.receiveEnergy方法代码示例

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


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

示例1: onUpdate

import cofh.api.energy.IEnergyContainerItem; //导入方法依赖的package包/类
@Override
public void onUpdate(ItemStack container, World world, Entity entity, int i_, boolean b_) {
	if (! (entity instanceof EntityPlayer)) {
		return;
	}
	if (TweakCraft.config.fluxStarChargeItemRate < 1) {
		return;
	}
	EntityPlayer player = (EntityPlayer) entity;
	for (int slot = 0; slot < player.inventory.getSizeInventory(); ++slot) {
		ItemStack target = player.inventory.getStackInSlot(slot);
		if ( (target != null) && (target.getItem() instanceof IEnergyContainerItem)) {
			Item tItem = target.getItem();
			if ( (tItem != TCItems.fluxedNetherStar.getItem()) && (tItem != TCItems.fluxedNetherStarRaw.getItem())) {
				IEnergyContainerItem item = (IEnergyContainerItem) tItem;
				item.receiveEnergy(target, extractRate(), false);
			}
		}
	}
}
 
开发者ID:PrincessRTFM,项目名称:TweakCraft,代码行数:21,代码来源:ItemFluxedNetherStar.java

示例2: chargeInventory

import cofh.api.energy.IEnergyContainerItem; //导入方法依赖的package包/类
public void chargeInventory(EntityPlayer player)
{
  List<ItemStack> rf_items = new ArrayList<ItemStack>();

  findRFItems(player.inventory,rf_items);
  findRFItems(BaublesApi.getBaubles(player),rf_items);
  
  if(rf_items.size() > 0)
  {
    int supply = energy.extractEnergy(energy.getMaxExtract(), true) / rf_items.size();
    int used = 0;
    for(ItemStack stack : rf_items)
    {
      IEnergyContainerItem rf_item = (IEnergyContainerItem) stack.getItem();
      used += rf_item.receiveEnergy(stack, supply, false);
    }
    energy.extractEnergy(used, false);
  }
}
 
开发者ID:EXTER7,项目名称:FluxPads,代码行数:20,代码来源:TileEntityFluxPad.java

示例3: chargeInventory

import cofh.api.energy.IEnergyContainerItem; //导入方法依赖的package包/类
protected void chargeInventory(EntityLivingBase user, ItemStack stack, ItemPack item) {
    if (this.fuelType == FuelType.ENERGY) {
        for (int i = 0; i <= 4; i++) {
            ItemStack currentStack = user.getEquipmentInSlot(i);
            if (currentStack != null && currentStack != stack && currentStack.getItem() instanceof IEnergyContainerItem) {
                IEnergyContainerItem heldEnergyItem = (IEnergyContainerItem) currentStack.getItem();
                if (this.usesFuel) {
                    int energyToAdd = Math.min(item.useFuel(stack, this.fuelPerTickOut, true), heldEnergyItem.receiveEnergy(currentStack, this.fuelPerTickOut, true));
                    item.useFuel(stack, energyToAdd, false);
                    heldEnergyItem.receiveEnergy(currentStack, energyToAdd, false);
                } else {
                    heldEnergyItem.receiveEnergy(currentStack, this.fuelPerTickOut, false);
                }
            }
        }
    }
}
 
开发者ID:Tonius,项目名称:SimplyJetpacks,代码行数:18,代码来源:PackBase.java

示例4: 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

示例5: 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

示例6: 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


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