本文整理汇总了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();
}
示例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;
}
示例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;
}
示例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
}
}
}
}