本文整理匯總了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();
}