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


Java IMEInventoryHandler.calculateItemAddition方法代码示例

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


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

示例1: fillToNetwork

import appeng.api.me.util.IMEInventoryHandler; //导入方法依赖的package包/类
@Override
public long fillToNetwork(FluidStack toFill, boolean doFill)
{
	if (!isMachineActive() || toFill == null || grid == null)
		return 0;
	IMEInventoryHandler cellArray = grid.getCellArray();
	if (cellArray == null)
		return 0;
	IAEItemStack notFilled = cellArray.calculateItemAddition(createFluidItemStack(toFill));
	IAEItemStack filled = createFluidItemStack(toFill);
	if (notFilled != null)
		filled = createFluidItemStack(new SpecialFluidStack(notFilled.getItemDamage(), toFill.amount - notFilled.getStackSize()));
	if (doFill)
		cellArray.addItems(filled);

	getGrid().useMEEnergy(filled.getStackSize() == 0 ? 0 : filled.getStackSize() / 4, "FluidInterface");
	return filled.getStackSize();
}
 
开发者ID:ExtraCells,项目名称:ExtraCells1,代码行数:19,代码来源:TileEntityInterfaceFluid.java

示例2: fillFluid

import appeng.api.me.util.IMEInventoryHandler; //导入方法依赖的package包/类
private boolean fillFluid(FluidStack toImport)
{
	IAEItemStack toFill = Util.createItemStack(new ItemStack(FLUIDDISPLAY.getItemInstance(), 0, toImport.fluidID));
	toFill.setStackSize(toImport.amount);
	if (grid != null)
	{
		IMEInventoryHandler cellArray = grid.getCellArray();
		if (cellArray != null)
		{
			IAEItemStack sim = cellArray.calculateItemAddition(toFill.copy());

			if (sim != null)
			{
				return false;
			}

			cellArray.addItems(toFill.copy());
			return true;
		}
	}
	return false;
}
 
开发者ID:ExtraCells,项目名称:ExtraCells1,代码行数:23,代码来源:TileEntityTerminalFluid.java

示例3: fill

import appeng.api.me.util.IMEInventoryHandler; //导入方法依赖的package包/类
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{
	if(!redstoneStatus && getRedstoneMode() == RedstoneModeInput.WhenOn || redstoneStatus && getRedstoneMode() == RedstoneModeInput.WhenOff)
		return 0;
	if (resource != null && getGrid() != null && isPowered() && from.ordinal() == this.blockMetadata)
	{
		IAEItemStack added;
		int amount = resource.amount;
		int fluidID = resource.fluidID;
		IAEItemStack temp = Util.createItemStack(new ItemStack(FLUIDDISPLAY.getItemInstance(), amount, fluidID));
		temp.setStackSize(amount);
		IMEInventoryHandler cellArray = getGrid().getCellArray();
		if (cellArray != null)
		{
			if (doFill)
			{
				added = cellArray.addItems(temp);
			} else
			{
				added = cellArray.calculateItemAddition(temp);
			}
			if (added == null)
			{
				if (doFill)
					getGrid().useMEEnergy(amount / 50, "Import Fluid");
				return resource.amount;
			} else if (added.getStackSize() > 0)
			{
				if (doFill)
					getGrid().useMEEnergy((amount - added.getStackSize()) / 50, "Import Fluid");
				return (int) (resource.amount - added.getStackSize());
			}
		}
	}
	return 0;
}
 
开发者ID:ExtraCells,项目名称:ExtraCells1,代码行数:38,代码来源:TileEntityBusFluidImport.java

示例4: doWork

import appeng.api.me.util.IMEInventoryHandler; //导入方法依赖的package包/类
public void doWork()
{
	if (isMachineActive() && getGrid() != null)
	{
		ForgeDirection orientation = ForgeDirection.getOrientation(getBlockMetadata());

		int offsetID = worldObj.getBlockId(xCoord + orientation.offsetX, yCoord + orientation.offsetY, zCoord + orientation.offsetZ);
		int offsetMeta = worldObj.getBlockMetadata(xCoord + orientation.offsetX, yCoord + orientation.offsetY, zCoord + orientation.offsetZ);

		IMEInventoryHandler cellArray = getGrid().getCellArray();
		if (cellArray != null)
		{
			try
			{
				if (Block.blocksList[offsetID] instanceof IFluidBlock)
				{
					FluidStack simulation = ((IFluidBlock) Block.blocksList[offsetID]).drain(worldObj, xCoord + orientation.offsetX, yCoord + orientation.offsetY, zCoord + orientation.offsetZ, false);

					if (simulation != null && cellArray.calculateItemAddition(Util.createItemStack(new ItemStack(ItemEnum.FLUIDDISPLAY.getItemInstance(), simulation.amount, simulation.fluidID))) == null)
					{
						((IFluidBlock) Block.blocksList[offsetID]).drain(worldObj, xCoord + orientation.offsetX, yCoord + orientation.offsetY, zCoord + orientation.offsetZ, true);
						cellArray.addItems(Util.createItemStack(new ItemStack(ItemEnum.FLUIDDISPLAY.getItemInstance(), simulation.amount, simulation.fluidID)));
					}
				} else if (offsetID == FluidRegistry.WATER.getBlockID() && offsetMeta == 0)
				{
					if (cellArray.calculateItemAddition(Util.createItemStack(new ItemStack(ItemEnum.FLUIDDISPLAY.getItemInstance(), 1000, FluidRegistry.WATER.getID()))) == null)
					{
						worldObj.setBlockToAir(xCoord + orientation.offsetX, yCoord + orientation.offsetY, zCoord + orientation.offsetZ);
						cellArray.addItems(Util.createItemStack(new ItemStack(ItemEnum.FLUIDDISPLAY.getItemInstance(), 1000, FluidRegistry.WATER.getID())));
					}
				} else if (offsetID == FluidRegistry.LAVA.getBlockID() && offsetMeta == 0)
				{
					if (cellArray.calculateItemAddition(Util.createItemStack(new ItemStack(ItemEnum.FLUIDDISPLAY.getItemInstance(), 1000, FluidRegistry.LAVA.getID()))) == null)
					{
						worldObj.setBlockToAir(xCoord + orientation.offsetX, yCoord + orientation.offsetY, zCoord + orientation.offsetZ);
						cellArray.addItems(Util.createItemStack(new ItemStack(ItemEnum.FLUIDDISPLAY.getItemInstance(), 1000, FluidRegistry.LAVA.getID())));
					}
				}
			} catch (Throwable wontHappen)
			{
				// Nothing
			}
		}
	}
}
 
开发者ID:ExtraCells,项目名称:ExtraCells1,代码行数:46,代码来源:TileEntityTransitionPlaneFluid.java


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