package com.infinityraider.agricraft.plugins.minecraft;

import com.infinityraider.agricraft.api.v1.adapter.IAgriAdapter;
import com.infinityraider.agricraft.api.v1.crop.CropCapability;
import com.infinityraider.agricraft.api.v1.genetics.IAgriGenome;
import com.infinityraider.agricraft.api.v1.genetics.IAgriGenomeProvider;
import net.minecraftforge.common.capabilities.ICapabilityProvider;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Optional;

public class GenomeWrapper implements IAgriAdapter<IAgriGenome> {
    @Override
    public boolean accepts(@Nullable Object obj) {
        return obj instanceof IAgriGenomeProvider || obj instanceof ICapabilityProvider;
    }

    @Nonnull
    @Override
    public Optional<IAgriGenome> valueOf(@Nullable Object obj) {
        if(obj instanceof IAgriGenomeProvider) {
            return ((IAgriGenomeProvider) obj).getGenome();
        }
        if(obj instanceof ICapabilityProvider) {
            ICapabilityProvider capabilityProvider = (ICapabilityProvider) obj;
            return capabilityProvider.getCapability(CropCapability.getCapability())
                    .map(crop -> crop)
                    .flatMap(IAgriGenomeProvider::getGenome);
        }
        return Optional.empty();
    }
}

@@ -341,53 +341,30 @@
 raft
-forge.common.capabilities.ICapabilityProvider
+.tileentity.TileEntity
 ;%0A%0Ai
@@ -656,35 +656,26 @@
 tanceof 
-ICapabilityProvider
+TileEntity
 ;%0A    %7D%0A
@@ -916,104 +916,63 @@
 eof 
-ICapabilityProvider) %7B%0A            ICapabilityProvider capabilityProvider = (ICapabilityProvider
+TileEntity) %7B%0A            TileEntity tile = (TileEntity
 ) ob
@@ -997,26 +997,12 @@
 urn 
-capabilityProvider
+tile
 .get

Fix bug where it was impossible to plant seeds on crop sticks