From 784c65a88403a6d6849c731f332cc222efad724a Mon Sep 17 00:00:00 2001 From: MauveCloud Date: Tue, 26 Apr 2016 13:30:26 -0700 Subject: Added Crop Calculator support. --- src/main/java/gregtech/api/util/GT_BaseCrop.java | 41 +++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api/util/GT_BaseCrop.java') diff --git a/src/main/java/gregtech/api/util/GT_BaseCrop.java b/src/main/java/gregtech/api/util/GT_BaseCrop.java index 5ca5af2e97..304a0f3c62 100644 --- a/src/main/java/gregtech/api/util/GT_BaseCrop.java +++ b/src/main/java/gregtech/api/util/GT_BaseCrop.java @@ -1,5 +1,6 @@ package gregtech.api.util; +import cpw.mods.fml.common.Loader; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; @@ -16,18 +17,21 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import speiger.src.crops.api.ICropCardInfo; import java.util.ArrayList; +import java.util.List; import java.util.Random; import static gregtech.api.enums.GT_Values.E; -public class GT_BaseCrop extends CropCard { +public class GT_BaseCrop extends CropCard implements ICropCardInfo { public static ArrayList sCropList = new ArrayList(); private String mName = E, mDiscoveredBy = "Gregorius Techneticies", mAttributes[]; private int mTier = 0, mMaxSize = 0, mAfterHarvestSize = 0, mHarvestSize = 0, mStats[] = new int[5], mGrowthSpeed = 0; private ItemStack mDrop = null, mSpecialDrops[] = null; private Materials mBlock = null; + private static boolean bIc2NeiLoaded = Loader.isModLoaded("Ic2Nei"); /** * To create new Crops @@ -85,6 +89,25 @@ public class GT_BaseCrop extends CropCard { if (aBaseSeed != null) Crops.instance.registerBaseSeed(aBaseSeed, this, 1, 1, 1, 1); sCropList.add(this);} } + if (bIc2NeiLoaded) { + try { + Class.forName("speiger.src.crops.api.CropPluginAPI").getMethod("registerCropInfo", Class.forName("speiger.src.crops.api.ICropCardInfo")).invoke(Class.forName("speiger.src.crops.api.CropPluginAPI").getField("instance"), this); + } catch (IllegalAccessException ex) { + bIc2NeiLoaded = false; + } catch (IllegalArgumentException ex) { + bIc2NeiLoaded = false; + } catch (java.lang.reflect.InvocationTargetException ex) { + bIc2NeiLoaded = false; + } catch (NoSuchFieldException ex) { + bIc2NeiLoaded = false; + } catch (NoSuchMethodException ex) { + bIc2NeiLoaded = false; + } catch (SecurityException ex) { + bIc2NeiLoaded = false; + } catch (ClassNotFoundException ex) { + bIc2NeiLoaded = false; + } + } } @Override @@ -212,4 +235,20 @@ public class GT_BaseCrop extends CropCard { return false; } + public List getCropInformation() { + if (mBlock != null) { + ArrayList result = new ArrayList(1); + result.add(String.format("Requires %s Ore or Block of %s as soil block to reach full growth.", mBlock.name(), mBlock.name())); + return result; + } + return null; + } + + public ItemStack getDisplayItem() { + if (mSpecialDrops != null && mSpecialDrops[mSpecialDrops.length - 1] != null) { + return GT_Utility.copy(mSpecialDrops[mSpecialDrops.length - 1]); + } + return GT_Utility.copy(mDrop); + } + } -- cgit