aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/bartcrops
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/bartcrops')
-rw-r--r--src/main/java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java21
-rw-r--r--src/main/java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java109
-rw-r--r--src/main/java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java37
-rw-r--r--src/main/java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java56
-rw-r--r--src/main/java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java69
-rw-r--r--src/main/java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java56
6 files changed, 348 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java b/src/main/java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java
new file mode 100644
index 0000000000..ce7d919431
--- /dev/null
+++ b/src/main/java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java
@@ -0,0 +1,21 @@
+package gtPlusPlus.xmod.bartcrops;
+
+import cpw.mods.fml.common.event.FMLInitializationEvent;
+import cpw.mods.fml.common.event.FMLPostInitializationEvent;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+
+public class HANDLER_CropsPlusPlus {
+
+ public static void preInit(FMLPreInitializationEvent preinit) {
+ LoaderOfTheCrops.load(preinit);
+ }
+
+ public static void init(FMLInitializationEvent init) {
+ //registerItems();
+ }
+
+ public static void postInit(FMLPostInitializationEvent postinit) {
+ LoaderOfTheCrops.register();
+ LoaderOfTheCrops.registerBaseSeed();
+ }
+}
diff --git a/src/main/java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java b/src/main/java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java
new file mode 100644
index 0000000000..48813310d2
--- /dev/null
+++ b/src/main/java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java
@@ -0,0 +1,109 @@
+package gtPlusPlus.xmod.bartcrops;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+import gtPlusPlus.xmod.bartcrops.crops.Crop_Hemp;
+import ic2.api.crops.CropCard;
+import ic2.api.crops.Crops;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Mostly borrowed from the Crops++ Crop Loader.
+ * @author Alkalus
+ */
+
+public class LoaderOfTheCrops {
+
+ private static List<Boolean> mHasCropObj = new ArrayList<Boolean>();
+ private CropCard mCropObj;
+ private ItemStack mBaseSeed;
+ private static List<LoaderOfTheCrops> mCropList = cropLoader();
+
+ public LoaderOfTheCrops(CropCard cropObj) {
+ this.mCropObj = cropObj;
+ }
+
+ public LoaderOfTheCrops(CropCard cropObj, ItemStack baseseed) {
+ this.mCropObj = cropObj;
+ this.mBaseSeed = baseseed;
+ }
+
+ public static CropCard cropUnpackerCC(LoaderOfTheCrops inp) {
+ return inp.mCropObj;
+ }
+
+ private static ItemStack cropUnpackerCG(LoaderOfTheCrops inp) {
+ return inp.mBaseSeed;
+ }
+
+ private static LoaderOfTheCrops cropHelper(CropCard cropObj) {
+ return new LoaderOfTheCrops(cropObj, ItemUtils.getItemStackOfAmountFromOreDict("crop" + cropObj.name(), 0));
+ }
+
+ public static final List<LoaderOfTheCrops> cropLoader() {
+ List<LoaderOfTheCrops> p = new ArrayList<LoaderOfTheCrops>();
+
+ p.add(new LoaderOfTheCrops(new Crop_Hemp(), new ItemStack(Item.getItemById(111), 3)));
+
+ return p;
+ }
+
+ private static final List<CropCard> cropObjs() {
+ List<CropCard> p = new ArrayList<CropCard>();
+
+ for (int i = 0; i < mCropList.size(); ++i) {
+ p.add(cropUnpackerCC((LoaderOfTheCrops) mCropList.get(i)));
+ }
+
+ return p;
+ }
+
+ private static final List<ItemStack> setBaseSeed() {
+ List<ItemStack> p = new ArrayList<ItemStack>();
+
+ for (int i = 0; i < mCropList.size(); ++i) {
+ p.add(cropUnpackerCG((LoaderOfTheCrops) mCropList.get(i)));
+ }
+
+ return p;
+ }
+
+ private static final List<String> setnames() {
+ List<String> s = new ArrayList<String>();
+
+ for (int i = 0; i < mCropList.size(); ++i) {
+ s.add(((CropCard) cropObjs().get(i)).name());
+ }
+
+ return s;
+ }
+
+ public static void load(FMLPreInitializationEvent preinit) {
+ for (int i = 0; i < mCropList.size(); ++i) {
+ mHasCropObj.add(true);
+ }
+ }
+
+ public static void register() {
+ for (int i = 0; i < mCropList.size(); ++i) {
+ if ((Boolean) mHasCropObj.get(i) && cropObjs().get(i) != null) {
+ Crops.instance.registerCrop((CropCard) cropObjs().get(i));
+ }
+ }
+ }
+
+ public static void registerBaseSeed() {
+ List<ItemStack> baseseed = new ArrayList<ItemStack>(setBaseSeed());
+
+ for (int i = 0; i < mCropList.size(); ++i) {
+ if (baseseed.get(i) != null && cropObjs().get(i) != null) {
+ Crops.instance.registerBaseSeed((ItemStack) baseseed.get(i), (CropCard) cropObjs().get(i), 1, 1, 1, 1);
+ }
+ }
+
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java b/src/main/java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java
new file mode 100644
index 0000000000..f62b429acb
--- /dev/null
+++ b/src/main/java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java
@@ -0,0 +1,37 @@
+package gtPlusPlus.xmod.bartcrops.abstracts;
+
+import gtPlusPlus.preloader.CORE_Preloader;
+import ic2.api.crops.ICropTile;
+
+public abstract class BaseAestheticCrop extends BaseHarvestableCrop {
+
+ public int tier() {
+ return 1;
+ }
+
+ public int stat(int n) {
+ switch (n) {
+ case 0 :
+ return 0;
+ case 1 :
+ return 0;
+ case 2 :
+ return 0;
+ case 3 :
+ return 4;
+ case 4 :
+ return 0;
+ default :
+ return 0;
+ }
+ }
+
+ public int growthDuration(ICropTile crop) {
+ return CORE_Preloader.DEBUG_MODE ? 1 : 225;
+ }
+
+ public byte getSizeAfterHarvest(ICropTile crop) {
+ return 1;
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java b/src/main/java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java
new file mode 100644
index 0000000000..ca2a044564
--- /dev/null
+++ b/src/main/java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java
@@ -0,0 +1,56 @@
+package gtPlusPlus.xmod.bartcrops.abstracts;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+import ic2.api.crops.CropCard;
+import ic2.api.crops.ICropTile;
+import java.util.ArrayList;
+import java.util.List;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import speiger.src.crops.api.ICropCardInfo;
+
+public abstract class BaseCrop extends CropCard implements ICropCardInfo {
+ @SideOnly(Side.CLIENT)
+ public void registerSprites(IIconRegister iconRegister) {
+ this.textures = new IIcon[this.maxSize()];
+
+ for (int i = 1; i <= this.textures.length; ++i) {
+ this.textures[i - 1] = iconRegister.registerIcon(CORE.MODID+":crop/blockCrop." + this.name() + "." + i);
+ }
+
+ }
+
+ public float dropGainChance() {
+ return (float) (Math.pow(0.95D, (double) ((float) this.tier())) * (double) 1f);
+ }
+
+ public boolean canCross(ICropTile crop) {
+ return crop.getSize() == this.maxSize();
+ }
+
+ public int getrootslength(ICropTile crop) {
+ return 3;
+ }
+
+ public String discoveredBy() {
+ return "Alkalus";
+ }
+
+ public String owner() {
+ return "Gtplusplus";
+ }
+
+ public List<String> getCropInformation() {
+ List<String> ret = new ArrayList<String>();
+ ret.add(this.attributes().toString());
+ return ret;
+ }
+
+ public ItemStack getDisplayItem(CropCard card) {
+ return ItemUtils.getItemStackOfAmountFromOreDict("crop" + this.name(), 0);
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java b/src/main/java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java
new file mode 100644
index 0000000000..e877233c67
--- /dev/null
+++ b/src/main/java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java
@@ -0,0 +1,69 @@
+package gtPlusPlus.xmod.bartcrops.abstracts;
+
+import gtPlusPlus.preloader.CORE_Preloader;
+import ic2.api.crops.ICropTile;
+
+public abstract class BaseHarvestableCrop extends BaseCrop {
+
+ public int tier() {
+ return 2;
+ }
+
+ public int stat(int n) {
+ switch (n) {
+ case 0 :
+ return 0;
+ case 1 :
+ return 4;
+ case 2 :
+ return 0;
+ case 3 :
+ return 4;
+ case 4 :
+ return 0;
+ default :
+ return 0;
+ }
+ }
+
+ public boolean canGrow(ICropTile crop) {
+ return crop.getSize() < 3;
+ }
+
+ public int getOptimalHavestSize(ICropTile crop) {
+ return 3;
+ }
+
+ public boolean canBeHarvested(ICropTile crop) {
+ return crop.getSize() == 3;
+ }
+
+ public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air) {
+ return (int) ((double) humidity * 1.2D + (double) nutrients * 0.9D + (double) air * 0.9D);
+ }
+
+ public int growthDuration(ICropTile crop) {
+ short r;
+ if (CORE_Preloader.DEBUG_MODE) {
+ r = 1;
+ } else if (crop.getSize() == 2) {
+ r = 200;
+ } else {
+ r = 700;
+ }
+
+ return r;
+ }
+
+ public byte getSizeAfterHarvest(ICropTile crop) {
+ return 2;
+ }
+
+ public int maxSize() {
+ return 3;
+ }
+
+ public String discoveredBy() {
+ return "Alkalus";
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java b/src/main/java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java
new file mode 100644
index 0000000000..95e2766aae
--- /dev/null
+++ b/src/main/java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java
@@ -0,0 +1,56 @@
+package gtPlusPlus.xmod.bartcrops.crops;
+
+import gtPlusPlus.core.item.ModItems;
+import gtPlusPlus.core.util.math.MathUtils;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+import gtPlusPlus.preloader.CORE_Preloader;
+import gtPlusPlus.xmod.bartcrops.abstracts.BaseAestheticCrop;
+import ic2.api.crops.ICropTile;
+import net.minecraft.item.ItemStack;
+
+public class Crop_Hemp extends BaseAestheticCrop {
+
+ public int tier() {
+ return 2;
+ }
+
+ public String name() {
+ return "Hemp";
+ }
+
+ public String discoveredBy() {
+ return "Alkalus";
+ }
+
+ public int growthDuration(ICropTile crop) {
+ int ret = 550;
+
+ /*if (crop.isBlockBelow(Blocks.dirt) || crop.isBlockBelow(Blocks.flowing_water)) {
+ ret = 225;
+ }*/
+
+ if (CORE_Preloader.DEBUG_MODE) {
+ ret = 1;
+ }
+
+ return ret;
+ }
+
+ public String[] attributes() {
+ return new String[]{"Green", "Soil", "Orange"};
+ }
+
+ public ItemStack getGain(ICropTile crop) {
+
+ ItemStack ret = this.getDisplayItem();
+ if (MathUtils.randInt(0, 10) > 8) {
+ ret = ItemUtils.getSimpleStack(ModItems.itemRope, MathUtils.randInt(1, 3));
+ }
+
+ return ret;
+ }
+
+ public ItemStack getDisplayItem() {
+ return ItemUtils.getSimpleStack(ModItems.itemRope, 0);
+ }
+} \ No newline at end of file