本文整理汇总了Java中com.enderio.core.common.util.FluidUtil.tryDrainContainer方法的典型用法代码示例。如果您正苦于以下问题:Java FluidUtil.tryDrainContainer方法的具体用法?Java FluidUtil.tryDrainContainer怎么用?Java FluidUtil.tryDrainContainer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.enderio.core.common.util.FluidUtil
的用法示例。
在下文中一共展示了FluidUtil.tryDrainContainer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matches
import com.enderio.core.common.util.FluidUtil; //导入方法依赖的package包/类
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
boolean foundStick = false;
boolean foundFluid = false;
for (int i = 0; i < inv.getSizeInventory() && (!foundStick || !foundFluid); i++) {
ItemStack stack = inv.getStackInSlot(i);
if (Prep.isValid(stack)) {
foundStick |= isStick(stack);
if (!foundFluid) {
final FluidStack fluidStack = FluidUtil.tryDrainContainer(stack, new NutDistTank()).result.fluidStack;
if (fluidStack != null && fluidStack.amount >= Fluid.BUCKET_VOLUME) {
foundFluid = true;
}
}
}
}
return foundStick && foundFluid;
}
示例2: drainFullContainer
import com.enderio.core.common.util.FluidUtil; //导入方法依赖的package包/类
private boolean drainFullContainer() {
FluidAndStackResult fill = FluidUtil.tryDrainContainer(inventory[getSlotDefinition().getMinInputSlot()], this);
if (fill.result.fluidStack == null) {
return false;
}
int slot = getSlotDefinition().getMinOutputSlot();
if (inventory[slot] != null && fill.result.itemStack != null) {
if (inventory[slot].isStackable() && ItemUtil.areStackMergable(inventory[slot], fill.result.itemStack)
&& inventory[slot].stackSize < inventory[slot].getMaxStackSize()) {
fill.result.itemStack.stackSize += inventory[slot].stackSize;
} else {
return false;
}
}
getInputTank(fill.result.fluidStack).setFluid(fill.remainder.fluidStack);
setInventorySlotContents(getSlotDefinition().getMinInputSlot(), fill.remainder.itemStack);
if (fill.result.itemStack != null) {
setInventorySlotContents(slot, fill.result.itemStack);
}
setTanksDirty();
markDirty();
return false;
}
示例3: drainFullContainer
import com.enderio.core.common.util.FluidUtil; //导入方法依赖的package包/类
private boolean drainFullContainer() {
final int input = getSlotDefinition().getMinInputSlot();
final ItemStack inputStack = getStackInSlot(input);
if (Prep.isInvalid(inputStack) || tank.isFull()) {
return false;
}
final FluidAndStackResult fill = FluidUtil.tryDrainContainer(inputStack, this);
if (fill.result.fluidStack == null) {
return false;
}
final int output = getSlotDefinition().getMinOutputSlot();
final ItemStack outputStack = getStackInSlot(output);
if (Prep.isValid(outputStack) && Prep.isValid(fill.result.itemStack)) {
if (outputStack.isStackable() && ItemUtil.areStackMergable(outputStack, fill.result.itemStack)
&& (fill.result.itemStack.getCount() + outputStack.getCount()) <= outputStack.getMaxStackSize()) {
fill.result.itemStack.grow(outputStack.getCount());
} else {
return false;
}
}
getInputTank(fill.result.fluidStack).setFluid(fill.remainder.fluidStack);
setInventorySlotContents(input, fill.remainder.itemStack);
if (Prep.isValid(fill.result.itemStack)) {
setInventorySlotContents(output, fill.result.itemStack);
}
setTanksDirty();
markDirty();
return false;
}
示例4: getResult
import com.enderio.core.common.util.FluidUtil; //导入方法依赖的package包/类
private @Nonnull ItemStack getResult(@Nonnull ItemStack in) {
if (Prep.isValid(in)) {
FluidAndStackResult fill = FluidUtil.tryDrainContainer(in, new NutDistTank());
return fill.result.itemStack;
}
return Prep.getEmpty();
}