package com.InfinityRaider.AgriCraft.compatibility.harvestcraft;

import com.InfinityRaider.AgriCraft.compatibility.ModHelper;
import com.InfinityRaider.AgriCraft.farming.CropPlantHandler;
import com.InfinityRaider.AgriCraft.handler.ConfigurationHandler;
import com.InfinityRaider.AgriCraft.reference.Names;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSeeds;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

public final class HarvestcraftHelper extends ModHelper {
    @Override
    protected String modId() {
        return Names.Mods.harvestcraft;
    }

    @Override
    protected void init() {}

    @Override
    protected void initPlants() {
        Class hc_ItemRegistry = null;
        try {
            hc_ItemRegistry = Class.forName("com.pam.harvestcraft.ItemRegistry");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        assert hc_ItemRegistry != null;
        Field[] fields = hc_ItemRegistry.getDeclaredFields();
        for(Field field : fields) {
            if(Modifier.isStatic(field.getModifiers())) {
                try {
                    Object obj = field.get(null);
                    if(obj instanceof ItemSeeds) {
                        ItemSeeds seed = (ItemSeeds) obj;
                        if(seed== Item.itemRegistry.getObject("harvestcraft:cottonItem")) {
                            //cotton, the produce of cotton seeds is also instance of ItemSeeds, but we want to ignore it
                            continue;
                        }
                        CropPlantHandler.registerPlant(new CropPlantHarvestCraft(seed));
                    }
                } catch (Exception e) {
                    if (ConfigurationHandler.debug) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}

@@ -59,16 +59,74 @@
 craft;%0A%0A
+import com.InfinityRaider.AgriCraft.api.v1.BlockWithMeta;%0A
 import c
@@ -280,36 +280,155 @@
 aft.
-handler.ConfigurationHandler
+farming.GrowthRequirementHandler;%0Aimport com.InfinityRaider.AgriCraft.handler.ConfigurationHandler;%0Aimport com.InfinityRaider.AgriCraft.init.Blocks
 ;%0Aim
@@ -1488,16 +1488,17 @@
  if(seed
+ 
 == Item.
@@ -1825,16 +1825,345 @@
 seed));%0A
+                        if(seed == Item.itemRegistry.getObject(%22harvestcraft:seaweedseedItem%22) %7C%7C seed == Item.itemRegistry.getObject(%22harvestcraft:riceseedItem%22)) %7B%0A                            GrowthRequirementHandler.getGrowthRequirement(seed, 0).setSoil(new BlockWithMeta(Blocks.blockWaterPadFull));%0A                        %7D%0A
         

Make harvestcraft rice and seewead require water pads as soil