Search in sources :

Example 1 with TileInfiniteWaterSource

use of com.cjm721.overloaded.block.tile.TileInfiniteWaterSource in project Overloaded by CJ-MC-Mods.

the class BlockInfiniteWaterSource method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!worldIn.isRemote && hand == EnumHand.MAIN_HAND) {
        TileEntity te = worldIn.getTileEntity(pos);
        if (te != null && te instanceof TileInfiniteWaterSource) {
            IFluidHandler handler = te.getCapability(FLUID_HANDLER_CAPABILITY, facing);
            // FluidUtil.interactWithFluidHandler(playerIn.getHeldItem(hand), te.getCapability(FLUID_HANDLER_CAPABILITY, facing), playerIn);
            FluidActionResult result = FluidUtil.tryFillContainerAndStow(playerIn.getHeldItem(hand), handler, null, Integer.MAX_VALUE, playerIn);
            if (result.isSuccess())
                playerIn.setHeldItem(hand, result.getResult());
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidActionResult(net.minecraftforge.fluids.FluidActionResult) TileInfiniteWaterSource(com.cjm721.overloaded.block.tile.TileInfiniteWaterSource) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Aggregations

TileInfiniteWaterSource (com.cjm721.overloaded.block.tile.TileInfiniteWaterSource)1 TileEntity (net.minecraft.tileentity.TileEntity)1 FluidActionResult (net.minecraftforge.fluids.FluidActionResult)1 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)1