Added ability to lookup registered IC2 Crops

This commit is contained in:
bculkin2442 committed 2015-07-26 17:03:08 -04:00
1 parent 7d1e65dae6
commit ab6608368c
1 file changed
+42 -1
@@ -1,5 +1,9 @@
package minetweaker.mods.ic2.crops;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import ic2.api.crops.CropCard;
import ic2.api.crops.Crops;
import minetweaker.MineTweakerAPI;
@@ -10,7 +14,7 @@ import minetweaker.api.minecraft.MineTweakerMC;
import net.minecraftforge.common.BiomeDictionary;
import stanhebben.zenscript.annotations.ZenCaster;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
/**
* Provides access to IC2 crop system in general
* @author ben
@@ -218,4 +222,41 @@ public class CropsConfig {
int growth, int gain, int resist) {
MineTweakerAPI.apply(new RegisterBaseSeedAction(seed, c, sz, growth, gain, resist));
}
/**
* Get a crop by its name and owning mod
* @param owner The mod that owns the crop
* @param name The name of the crop
* @return A crop with the given name, owned by the given mod
*/
@ZenMethod
public static Crop getCrop(String owner, String name) {
return new Crop(Crops.instance.getCropCard(owner, name));
}
/**
* Get a crop by the seed that plants it
* @param seed The seed that plants the crop
* @return The crop planted by the seed
*/
@ZenMethod
public static Crop getCrop(IItemStack seed) {
return new Crop(Crops.instance.getCropCard(MineTweakerMC.getItemStack(seed)));
}
/**
* Get all of the currently registered crops
* @return All of the currently registered crops
*/
@ZenGetter("crops")
public static List<Crop> getAllCrops() {
Collection<CropCard> ccList = Crops.instance.getCrops();
List<Crop> cList = new ArrayList<Crop>(ccList.size());
for (CropCard cropCard : ccList) {
cList.add(new Crop(cropCard));
}
return cList;
}
}