本文整理汇总了Java中appeng.api.me.util.IMEInventoryHandler类的典型用法代码示例。如果您正苦于以下问题:Java IMEInventoryHandler类的具体用法?Java IMEInventoryHandler怎么用?Java IMEInventoryHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IMEInventoryHandler类属于appeng.api.me.util包,在下文中一共展示了IMEInventoryHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onNeighborBlockChange
import appeng.api.me.util.IMEInventoryHandler; //导入依赖的package包/类
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int neighbourID)
{
if (((TileEntityMEDropper) world.getBlockTileEntity(x, y, z)).todispense != null)
{
ItemStack request = ((TileEntityMEDropper) world.getBlockTileEntity(x, y, z)).todispense;
if (!world.isRemote)
{
if ((world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z)) && unpowered)
{
if (((TileEntityMEDropper) world.getBlockTileEntity(x, y, z)).getGrid() != null)
{
IMEInventoryHandler cellArray = ((TileEntityMEDropper) world.getBlockTileEntity(x, y, z)).getGrid().getCellArray();
if (cellArray != null && cellArray.extractItems(Util.createItemStack(request)) != null)
{
dispense(world, x, y, z, ((TileEntityMEDropper) world.getBlockTileEntity(x, y, z)).getItem().copy());
unpowered = false;
}
}
} else
{
unpowered = true;
}
}
}
}
示例2: getTankInfo
import appeng.api.me.util.IMEInventoryHandler; //导入依赖的package包/类
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from)
{
if (getGrid() != null && from.ordinal() == this.blockMetadata)
{
List<FluidTankInfo> tankInfo = new ArrayList<FluidTankInfo>();
FluidTankInfo[] tankArray = new FluidTankInfo[1];
IMEInventoryHandler cellArray = grid.getCellArray();
if (cellArray != null)
{
for (IAEItemStack item : cellArray.getAvailableItems())
{
if (item.getItem() == FLUIDDISPLAY.getItemInstance())
tankInfo.add(new FluidTankInfo(new FluidStack(FluidRegistry.getFluid(item.getItemDamage()), (int) item.getStackSize()), (int) getGrid().getCellArray().freeBytes()));
}
if (tankInfo.isEmpty())
tankInfo.add(new FluidTankInfo(null, (int) cellArray.freeBytes()));
tankArray = tankInfo.toArray(tankArray);
return tankArray;
}
}
return null;
}
示例3: drainFromNetwork
import appeng.api.me.util.IMEInventoryHandler; //导入依赖的package包/类
@Override
public long drainFromNetwork(FluidStack toDrain, boolean doDrain)
{
if (!isMachineActive() || toDrain == null || grid == null)
return 0;
IMEInventoryHandler cellArray = grid.getCellArray();
if (cellArray == null)
return 0;
IAEItemStack drained = cellArray.extractItems(createFluidItemStack(toDrain));
if (drained == null)
return 0;
if (!doDrain)
cellArray.addItems(drained);
getGrid().useMEEnergy(drained.getStackSize() == 0 ? 0 : drained.getStackSize() / 4, "FluidInterface");
return drained.getStackSize();
}
示例4: 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();
}
示例5: doWork
import appeng.api.me.util.IMEInventoryHandler; //导入依赖的package包/类
private void doWork(FluidMode mode)
{
List<Fluid> fluidFilter = getFilterFluids(inventory.slots);
if (fluidFilter != null && fluidFilter.size() > 0)
{
IMEInventoryHandler cellArray = getGrid().getCellArray();
for (Fluid entry : fluidFilter)
{
if (entry != null && cellArray != null)
{
IAEItemStack entryToAEIS = Util.createItemStack(new ItemStack(FLUIDDISPLAY.getItemInstance(), 1, entry.getID()));
long contained = cellArray.countOfItemType(entryToAEIS);
if (contained > 0)
{
int modeAmount = mode.getAmount() * tickRate;
exportFluid(new FluidStack(entry, contained < modeAmount ? (int) contained : modeAmount), fluidHandler, ForgeDirection.getOrientation(getBlockMetadata()).getOpposite(), mode);
}
}
}
}
}
示例6: exportFluid
import appeng.api.me.util.IMEInventoryHandler; //导入依赖的package包/类
public void exportFluid(FluidStack toExport, IFluidHandler tankToFill, ForgeDirection from, FluidMode mode)
{
IMEInventoryHandler cellArray = grid.getCellArray();
if (cellArray != null)
{
if (toExport == null)
return;
int fillable = tankToFill.fill(from, toExport, false);
if (fillable > 0)
{
IAEItemStack toExtract = Util.createItemStack(new ItemStack(FLUIDDISPLAY.getItemInstance(), fillable, toExport.fluidID));
IAEItemStack extracted = cellArray.extractItems(toExtract);
grid.useMEEnergy(mode.getCost() * tickRate, "Export Fluid");
if (extracted != null)
{
toExport.amount = (int) extracted.getStackSize();
tankToFill.fill(from, new FluidStack(toExport.fluidID, (int) extracted.getStackSize()), true);
}
}
}
}
示例7: onNetworkPatternChange
import appeng.api.me.util.IMEInventoryHandler; //导入依赖的package包/类
@ForgeSubscribe
public void onNetworkPatternChange(GridPatternUpdateEvent e)
{
if (grid != null)
{
IMEInventoryHandler inventoryHandler = grid.getCraftableArray();
if (inventoryHandler != null)
{
craftableFluidsInNetwork = new ArrayList<Fluid>();
for (IAEItemStack stack : inventoryHandler.getAvailableItems())
{
if (stack.getItem() == FLUIDDISPLAY.getItemInstance())
{
craftableFluidsInNetwork.add(FluidRegistry.getFluid(stack.getItemDamage()));
}
}
}
}
PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
}
示例8: 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;
}
示例9: setGrid
import appeng.api.me.util.IMEInventoryHandler; //导入依赖的package包/类
@Override
public void setGrid(IGridInterface gi)
{
if (!worldObj.isRemote)
{
grid = gi;
if (gi != null)
{
IMEInventoryHandler cellArray = gi.getCellArray();
if (cellArray != null)
updateFluids(cellArray.getAvailableItems());
} else
{
setPowerStatus(false);
}
PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
}
}
示例10: setGrid
import appeng.api.me.util.IMEInventoryHandler; //导入依赖的package包/类
@Override
public void setGrid(IGridInterface gi)
{
if (!worldObj.isRemote)
{
grid = gi;
if (gi != null)
{
IMEInventoryHandler cellArray = gi.getCellArray();
if (cellArray != null)
onNetworkInventoryChange(cellArray.getAvailableItems());
} else
{
setPowerStatus(false);
}
PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
}
}
示例11: getCellHandler
import appeng.api.me.util.IMEInventoryHandler; //导入依赖的package包/类
@Override
public IMEInventoryHandler getCellHandler(ItemStack itemstack)
{
if (itemstack.getItem() == ItemEnum.STORAGEFLUID.getItemInstance())
{
ItemStorageFluid cell = (ItemStorageFluid) itemstack.getItem();
return new FluidStorageInventoryHandler(itemstack, cell.getBytes(itemstack), cell.getTotalTypes(itemstack));
}
return null;
}
示例12: getCellArray
import appeng.api.me.util.IMEInventoryHandler; //导入依赖的package包/类
@Override
public List<IMEInventoryHandler> getCellArray()
{
if (powerStatus)
{
List<IMEInventoryHandler> cellArray = new ArrayList<IMEInventoryHandler>();
for (ItemStack current : slots)
{
if (appeng.api.Util.getCellRegistry().isCellHandled(current))
cellArray.add(appeng.api.Util.getCellRegistry().getHandlerForCell(current));
}
return cellArray;
}
return null;
}
示例13: 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;
}
示例14: canFill
import appeng.api.me.util.IMEInventoryHandler; //导入依赖的package包/类
@Override
public boolean canFill(ForgeDirection from, Fluid fluid)
{
if (grid != null)
{
IMEInventoryHandler cellArray = grid.getCellArray();
return cellArray != null && fluid != null && cellArray.canAccept(Util.createItemStack(new ItemStack(FLUIDDISPLAY.getItemInstance(), 1, fluid.getID())));
}
return false;
}
示例15: drainFluid
import appeng.api.me.util.IMEInventoryHandler; //导入依赖的package包/类
private boolean drainFluid(FluidStack toExport)
{
IAEItemStack toDrain = Util.createItemStack(new ItemStack(FLUIDDISPLAY.getItemInstance(), 0, toExport.fluidID));
toDrain.setStackSize(toExport.amount);
if (grid != null)
{
IMEInventoryHandler cellArray = grid.getCellArray();
if (cellArray != null)
{
for (SpecialFluidStack fluidstack : fluidsInNetwork)
{
if (fluidstack.getID() == toExport.fluidID && fluidstack.amount >= toExport.amount)
{
IAEItemStack takenStack = cellArray.extractItems(Util.createItemStack(new ItemStack(toDrain.getItem(), (int) (toDrain.getStackSize()), toDrain.getItemDamage())));
if (takenStack == null)
{
return false;
} else if (takenStack.getStackSize() != (int) toDrain.getStackSize())
{
cellArray.addItems(takenStack);
return false;
} else
{
return true;
}
}
}
}
}
return false;
}