diff options
author | Blood-Asp <bloodasphendrik@gmail.com> | 2016-04-27 21:18:05 +0200 |
---|---|---|
committer | Blood-Asp <bloodasphendrik@gmail.com> | 2016-04-27 21:18:05 +0200 |
commit | fd99216b350a3f2597ba7d82e97da17b976b6116 (patch) | |
tree | a710cd086892f42955d05dceab44859a65f283c5 /src/main/java/gregtech | |
parent | c98736b7b3f8911e70654047e963ed80b1f4d34a (diff) | |
parent | 784c65a88403a6d6849c731f332cc222efad724a (diff) | |
download | GT5-Unofficial-fd99216b350a3f2597ba7d82e97da17b976b6116.tar.gz GT5-Unofficial-fd99216b350a3f2597ba7d82e97da17b976b6116.tar.bz2 GT5-Unofficial-fd99216b350a3f2597ba7d82e97da17b976b6116.zip |
Merge pull request #497 from MauveCloud/experimental
Added Crop Calculator support.
Diffstat (limited to 'src/main/java/gregtech')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_BaseCrop.java | 41 |
1 files changed, 40 insertions, 1 deletions
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<GT_BaseCrop> sCropList = new ArrayList<GT_BaseCrop>(); 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<String> getCropInformation() { + if (mBlock != null) { + ArrayList<String> result = new ArrayList<String>(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); + } + } |