package org.squiddev.plethora.integration.vanilla.converter;

import net.minecraft.inventory.IInventory;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.InvWrapper;
import org.squiddev.plethora.api.converter.IConverter;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

@IConverter.Inject(IInventory.class)
public class ConverterItemHandler implements IConverter<IInventory, IItemHandler> {
	@Nullable
	@Override
	public IItemHandler convert(@Nonnull IInventory from) {
		return new InvWrapper(from);
	}
}

package org.squiddev.plethora.integration.vanilla.converter;

import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import org.squiddev.plethora.api.converter.IConverter;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

@IConverter.Inject(ICapabilityProvider.class)
public class ConverterItemHandler implements IConverter<ICapabilityProvider, IItemHandler> {
	@Nullable
	@Override
	public IItemHandler convert(@Nonnull ICapabilityProvider from) {
		return from.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
	}
}

Convert from IItemHandler capability