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


Java IEnergyContainerItem类代码示例

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


IEnergyContainerItem类属于cofh.api.energy包,在下文中一共展示了IEnergyContainerItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getCraftingResult

import cofh.api.energy.IEnergyContainerItem; //导入依赖的package包/类
@Override
public ItemStack getCraftingResult(InventoryCrafting inventory) {
    if(!(getRecipeOutput().getItem() instanceof IEnergyTool))
        return super.getCraftingResult(inventory);
    IEnergyTool energyTool = (IEnergyTool) getRecipeOutput().getItem();

    int energy = 0;

    for(int slot = 0; slot < inventory.getSizeInventory(); slot++){
        if(inventory.getStackInSlot(slot) != null) {
            ItemStack stack = inventory.getStackInSlot(slot);
            if (stack.getItem() instanceof IEnergyContainerItem)
                energy += ((IEnergyContainerItem) stack.getItem()).getEnergyStored(stack);
        }
    }

    return energyTool.setEnergy(getRecipeOutput().copy(), energy).copy();
}
 
开发者ID:goldenapple3,项目名称:RFDrills,代码行数:19,代码来源:ShapedUpgradeRecipe.java

示例3: getCraftingResult

import cofh.api.energy.IEnergyContainerItem; //导入依赖的package包/类
@Override
public ItemStack getCraftingResult(InventoryCrafting inventory) {
    if(!(getRecipeOutput().getItem() instanceof IEnergyTool))
        return super.getCraftingResult(inventory);
    IEnergyTool energyTool = (IEnergyTool) getRecipeOutput().getItem();

    int energy = 0;

    for(int slot = 0; slot < inventory.getSizeInventory(); slot++){
        if(inventory.getStackInSlot(slot) != null) {
            ItemStack stack = inventory.getStackInSlot(slot);
            if (stack.getItem() instanceof IEnergyContainerItem)
                energy += ((IEnergyContainerItem) stack.getItem()).getEnergyStored(stack);
        }
    }

    return energyTool.setEnergy(super.getCraftingResult(inventory), energy).copy();
}
 
开发者ID:goldenapple3,项目名称:RFDrills,代码行数:19,代码来源:ShapelessUpgradeRecipe.java

示例4: chargeItemStack

import cofh.api.energy.IEnergyContainerItem; //导入依赖的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

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

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

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

示例8: getResult

import cofh.api.energy.IEnergyContainerItem; //导入依赖的package包/类
public static ItemStack getResult(ItemStack target, InventoryCrafting var1) {
    // ItemStack target = super.getCraftingResult(var1);
    if (!(target.getItem() instanceof IEnergyContainerItem))
        return target;
    // IEnergyContainerItem item = (IEnergyContainerItem)target.getItem();
    int energyStored = 0;
    for (int i = 0; i < var1.getSizeInventory(); i++) {
        ItemStack is = var1.getStackInSlot(i);
        if (is != null && is.getItem() instanceof IEnergyContainerItem)
            energyStored += ((IEnergyContainerItem) is.getItem())
                    .getEnergyStored(is);
    }
    int maxStorage = ((IEnergyContainerItem) target.getItem())
            .getMaxEnergyStored(target);
    if (energyStored > maxStorage)
        energyStored = maxStorage;
    if (target.getTagCompound() == null)
        target.setTagCompound(new NBTTagCompound());
    target.getTagCompound().setInteger("Energy", energyStored);
    return target;
}
 
开发者ID:mak326428,项目名称:EnderAmmunition,代码行数:22,代码来源:ShapedRFRecipe.java

示例9: tickRF

import cofh.api.energy.IEnergyContainerItem; //导入依赖的package包/类
private void tickRF(){

        if(getEnergyStored(null) > 0) {
            InventoryPlayer inv = getPlayerInventory();
            if(inv != null) {
                for(int i = 0; i < inv.getSizeInventory(); i++) {
                    ItemStack stack = inv.getStackInSlot(i);
                    if(stack != null && stack.getItem() instanceof IEnergyContainerItem) {
                        IEnergyContainerItem chargingItem = (IEnergyContainerItem)stack.getItem();
                        int energyLeft = getEnergyStored(null);
                        if(energyLeft > 0) {
                            getEnergy().extractEnergy(chargingItem.receiveEnergy(stack, energyLeft, false), false);
                        } else {
                            break;
                        }
                    }
                }
            }
        }
    }
 
开发者ID:MineMaarten,项目名称:PneumaticCraft,代码行数:21,代码来源:TileEntityAerialInterface.java

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

示例11: processBuffer

import cofh.api.energy.IEnergyContainerItem; //导入依赖的package包/类
@Override
public void processBuffer() {
    if (this.powerHandlerIC2 != null) {
        this.powerHandlerIC2.updateEntity();
        this.powerHandlerIC2.useEnergy(toIC2(this.powerHandler.receiveEnergy(fromIC2(this.powerHandlerIC2.getEnergyStored()), false)));
    }
    if (this.powerHandler.getEnergyStored() > 0) {
        for (int i = 0; i < this.upgrades.getSizeInventory(); ++i) {
            final ItemStack itemstack = this.upgrades.getStackInSlot(i);
            if (itemstack != null && itemstack.getItem() instanceof IEnergyContainerItem) {
                final int a = ((IEnergyContainerItem)itemstack.getItem()).receiveEnergy(itemstack, this.powerHandler.extractEnergy(10000, true), false);
                this.powerHandler.extractEnergy(a, false);
                if (a > 0) {
                    this.markDirty();
                }
            }
        }
    }
    if (this.upgradeNo(4) > 0) {
        this.powerHandler.setEnergyStored(6400000);
    }
    if (this.coolDown > 0) {
        this.coolDown -= this.stepCoolDown;
    }
    while (this.coolDown <= 0) {
        this.coolDown += TileEntityTransferNodeEnergy.baseMaxCoolDown;
        this.findMachines();
    }
    this.sendEnergy();
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:31,代码来源:TileEntityTransferNodeEnergy.java

示例12: detectInputStack

import cofh.api.energy.IEnergyContainerItem; //导入依赖的package包/类
protected void detectInputStack() {
	final ItemStack stack = inventory.getStackInSlot(INPUT);
	if (stack == input)
		return;

	if (stack != null && stack.getItem() instanceof IEnergyContainerItem) {
		input = stack;
		energyContainer = (IEnergyContainerItem) stack.getItem();
	} else {
		input = null;
		energyContainer = null;
	}
}
 
开发者ID:OreCruncher,项目名称:ThermalRecycling,代码行数:14,代码来源:BatteryRackTileEntity.java

示例13: charge

import cofh.api.energy.IEnergyContainerItem; //导入依赖的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

示例14: canBeDischarged

import cofh.api.energy.IEnergyContainerItem; //导入依赖的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

示例15: canBeCharged

import cofh.api.energy.IEnergyContainerItem; //导入依赖的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


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