Example usage for net.minecraftforge.fluids FluidActionResult FAILURE

List of usage examples for net.minecraftforge.fluids FluidActionResult FAILURE

Introduction

In this page you can find the example usage for net.minecraftforge.fluids FluidActionResult FAILURE.

Prototype

FluidActionResult FAILURE

To view the source code for net.minecraftforge.fluids FluidActionResult FAILURE.

Click Source Link

Usage

From source file:com.lothrazar.cyclicmagic.block.autouser.TileEntityUser.java

License:Open Source License

/**
 * Pickup or place fluid in the world//from  w  w w .j a v a2  s  .c om
 * 
 * @param targetPos
 * @return
 */
private boolean rightClickFluidAir(BlockPos targetPos) {
    FakePlayer player = fakePlayer.get();
    ItemStack playerHeld = player.getHeldItemMainhand();
    //item stack does not hve fluid handler
    //dispense stack so either pickup or place liquid
    if (UtilFluid.isEmptyOfFluid(playerHeld)) {
        FluidActionResult res = UtilFluid.fillContainer(world, targetPos, playerHeld, this.getCurrentFacing());
        if (res != FluidActionResult.FAILURE) {
            player.setHeldItem(EnumHand.MAIN_HAND, res.getResult());
            this.tryDumpFakePlayerInvo(true);
            //        UtilItemStack.dropItemStackInWorld(world, getCurrentFacingPos(), res.getResult());
            return true;
        }
    } else {
        ItemStack drainedStackOrNull = UtilFluid.dumpContainer(world, targetPos, playerHeld);
        if (!drainedStackOrNull.isItemEqual(playerHeld)) {
            player.setHeldItem(EnumHand.MAIN_HAND, drainedStackOrNull);
            this.tryDumpFakePlayerInvo(true);
            return true;
        }
    }
    return false;
}