Merge pull request #497 from MauveCloud/experimental
Added Crop Calculator support.
This commit is contained in:
commit
fd99216b35
2 changed files with 59 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
package gregtech.api.util;
|
package gregtech.api.util;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Loader;
|
||||||
import gregtech.GT_Mod;
|
import gregtech.GT_Mod;
|
||||||
import gregtech.api.GregTech_API;
|
import gregtech.api.GregTech_API;
|
||||||
import gregtech.api.enums.ConfigCategories;
|
import gregtech.api.enums.ConfigCategories;
|
||||||
|
@ -16,18 +17,21 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import speiger.src.crops.api.ICropCardInfo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import static gregtech.api.enums.GT_Values.E;
|
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>();
|
public static ArrayList<GT_BaseCrop> sCropList = new ArrayList<GT_BaseCrop>();
|
||||||
private String mName = E, mDiscoveredBy = "Gregorius Techneticies", mAttributes[];
|
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 int mTier = 0, mMaxSize = 0, mAfterHarvestSize = 0, mHarvestSize = 0, mStats[] = new int[5], mGrowthSpeed = 0;
|
||||||
private ItemStack mDrop = null, mSpecialDrops[] = null;
|
private ItemStack mDrop = null, mSpecialDrops[] = null;
|
||||||
private Materials mBlock = null;
|
private Materials mBlock = null;
|
||||||
|
private static boolean bIc2NeiLoaded = Loader.isModLoaded("Ic2Nei");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To create new Crops
|
* 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);
|
if (aBaseSeed != null) Crops.instance.registerBaseSeed(aBaseSeed, this, 1, 1, 1, 1);
|
||||||
sCropList.add(this);}
|
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
|
@Override
|
||||||
|
@ -212,4 +235,20 @@ public class GT_BaseCrop extends CropCard {
|
||||||
return false;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
19
src/main/java/speiger/src/crops/api/ICropCardInfo.java
Normal file
19
src/main/java/speiger/src/crops/api/ICropCardInfo.java
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package speiger.src.crops.api;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Speiger
|
||||||
|
* Class to add Informations from CropCards.
|
||||||
|
* This has Priorty over the ICropInfo
|
||||||
|
* @requirement: The class that implement this class need to extends CropCard
|
||||||
|
*/
|
||||||
|
public interface ICropCardInfo
|
||||||
|
{
|
||||||
|
public List<String> getCropInformation();
|
||||||
|
|
||||||
|
public ItemStack getDisplayItem();
|
||||||
|
}
|
Loading…
Reference in a new issue