use of powercrystals.minefactoryreloaded.modhelpers.FertilizableCropReflection in project MineFactoryReloaded by powercrystals.
the class Pam method registerPamMod.
private static void registerPamMod(String modName, String cropName, Category category, boolean isPerennial, boolean hasWild, int plantableBlockId) {
try {
Class<?> mod;
int blockIdCrop;
int blockIdWild;
int seedId;
final String cropNameLC;
cropNameLC = cropName.toLowerCase();
final String baseClassPath;
baseClassPath = String.format("mods.PamHarvestCraft.%s.%s", category.getPackageName(), modName.toLowerCase());
mod = Class.forName(String.format("%s.PamHC%s", baseClassPath, modName));
blockIdCrop = ((Block) mod.getField(String.format("pam%sCrop", cropNameLC)).get(null)).blockID;
seedId = ((Item) mod.getField(String.format("%sseedItem", cropNameLC)).get(null)).itemID;
if (plantableBlockId == Block.tilledField.blockID) {
MFRRegistry.registerPlantable(new PlantableCropPlant(seedId, blockIdCrop));
} else {
MFRRegistry.registerPlantable(new PlantablePamSpecial(blockIdCrop, seedId, plantableBlockId));
}
if (hasWild) {
blockIdWild = ((Block) mod.getField(String.format("pam%sWild", cropNameLC)).get(null)).blockID;
MFRRegistry.registerHarvestable(new HarvestableStandard(blockIdWild, HarvestType.Normal));
}
if (isPerennial) {
MFRRegistry.registerHarvestable(new HarvestablePamsPerennial(blockIdCrop));
} else {
MFRRegistry.registerHarvestable(new HarvestablePams(blockIdCrop));
}
MFRRegistry.registerFertilizable(new FertilizableCropReflection(blockIdCrop, Class.forName(String.format(isPerennial ? "mods.PamHarvestCraft.BlockPamRegrowCrop" : "mods.PamHarvestCraft.BlockPamCrop")).getMethod("fertilize", World.class, int.class, int.class, int.class), 7));
} catch (ClassNotFoundException x) {
FMLLog.warning("Unable to load Pam support for %s", modName);
} catch (Exception x) {
x.printStackTrace();
}
}
use of powercrystals.minefactoryreloaded.modhelpers.FertilizableCropReflection in project MineFactoryReloaded by powercrystals.
the class Pam method load.
@Init
public static void load(FMLInitializationEvent e) {
if (!Loader.isModLoaded("PamHarvestCraft")) {
FMLLog.warning("Pam's HC base missing - MFR Pam HC Compat not loading");
} else {
// Bushes
registerBush("Blackberry", true, true);
registerBush("Blueberry", true, true);
registerBush("Grape", true, true);
registerBush("Kiwi", true, true);
registerBush("Raspberry", true, true);
registerBush("Spiceleaf", true, true);
registerBush("Strawberry", true, true);
registerBush("Sunflower", false, true);
// Crops
registerCrop("Asparagus", false, false);
registerCrop("Bean", false, false);
registerCrop("Beet", false, false);
registerCrop("Bellpepper", true, false);
registerCrop("Broccoli", false, false);
registerCrop("Cantaloupe", true, false);
registerCrop("Celery", false, false);
registerCrop("Chilipepper", true, false);
registerCrop("Coffee", true, false);
registerCrop("Corn", true, false);
registerCrop("Cucumber", true, false);
registerCrop("Eggplant", true, false);
registerCrop("Garlic", false, false);
registerCrop("Ginger", false, false);
registerCrop("Lettuce", false, false);
registerCrop("Mustard", true, false);
registerCrop("Onion", false, false);
registerCrop("Peanut", false, false);
registerCrop("Peas", true, false);
registerCrop("Pineapple", false, false);
registerCrop("Radish", false, false);
registerCrop("Sweetpotato", false, false);
registerCrop("Tea", false, false);
registerCrop("Tomato", true, false);
registerCrop("Turnip", false, false);
registerCrop("Zucchini", true, false);
// misc types
registerPamMod("Candle", "Candleberry", Category.MISC, true, true, Block.tilledField.blockID);
registerMisc("Cotton", true, true);
// plants that require different base soils
registerPamMod("Rice", "Rice", Category.CROP, false, false, Block.waterStill.blockID);
registerPamMod("Cranberry", "Cranberry", Category.BUSH, false, true, Block.waterStill.blockID);
registerPamMod("Whitemushroom", "Whitemushroom", Category.BUSH, false, true, Block.wood.blockID);
registerPamMod("Rotten", "Rotten", Category.CROP, false, false, Block.slowSand.blockID);
registerPamMod("Cactusfruit", "Cactusfruit", Category.BUSH, true, true, Block.sand.blockID);
// fruits
registerFruit("Apple");
registerFruit("Avocado");
registerFruit("Banana");
registerFruit("Cherry");
registerFruit("Coconut");
registerFruit("Lemon");
registerFruit("Lime");
registerFruit("Mango");
registerFruit("Nutmeg");
registerFruit("Olive");
registerFruit("Orange");
registerFruit("Papaya");
registerFruit("Peach");
registerFruit("Pear");
registerFruit("Peppercorn");
registerFruit("Plum");
registerFruit("Pomegranate");
registerFruit("Starfruit");
registerFruit("Vanillabean");
registerFruit("Walnut");
// special case for candle and cinnamon
registerCandle();
registerCinnamon();
try {
Class<?> mod = Class.forName("mods.PamHarvestCraft.PamHarvestCraft");
MFRRegistry.registerSludgeDrop(25, new ItemStack((Item) mod.getField("saltItem").get(null)));
} catch (Exception x) {
x.printStackTrace();
}
}
if (!Loader.isModLoaded("PamWeeeFlowers")) {
FMLLog.warning("Pam's Weee! Flowers missing - MFR Pam Weee! Flowers Compat not loading");
} else {
String[] flowers = { "White", "Orange", "Magenta", "LightBlue", "Yellow", "Lime", "Pink", "LightGrey", "DarkGrey", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black" };
try {
Class<?> mod = Class.forName("mods.PamWeeeFlowers.PamWeeeFlowers");
MFRRegistry.registerHarvestable(new HarvestableStandard(((Block) mod.getField("pamFlower").get(null)).blockID, HarvestType.Normal));
for (String flower : flowers) {
int seedId = ((Item) mod.getField(flower.toLowerCase() + "flowerseedItem").get(null)).itemID;
int blockId = ((Block) mod.getField("pam" + flower.toLowerCase() + "flowerCrop").get(null)).blockID;
Method fertilize = Class.forName("mods.PamWeeeFlowers.BlockPamFlowerCrop").getMethod("fertilize", World.class, int.class, int.class, int.class);
MFRRegistry.registerPlantable(new PlantableCropPlant(seedId, blockId));
MFRRegistry.registerHarvestable(new HarvestablePams(blockId));
MFRRegistry.registerFertilizable(new FertilizableCropReflection(blockId, fertilize, 7));
}
} catch (ClassNotFoundException x) {
FMLLog.warning("Unable to load Pam support for Weee! Flowers even though Weee! FLowers was present");
} catch (Exception x) {
x.printStackTrace();
}
}
}
use of powercrystals.minefactoryreloaded.modhelpers.FertilizableCropReflection in project MineFactoryReloaded by powercrystals.
the class MagicalCrops method load.
@Init
public static void load(FMLInitializationEvent e) {
if (!Loader.isModLoaded("Magical-Crops")) {
FMLLog.warning("Magical Crops missing - MFR Compat: Magical Crops not loading");
return;
}
try {
Class<?> mod = Class.forName("magicCrop.mod_mCrops");
// the various plants are separated by type to make future changes easier (mostly considering magicFertilizer behavior)
String[] crops = { "Sberry", "Tomato", "Sweetcorn", "Cucum", "Melon", "Bberry", "Rberry", "Grape", "Chil" };
String[] namedAsMagicalCropButExtendsBlockCrops = { "Nether" };
String[] magicalCrops = { "Coal", "Dye", "Iron", "Redstone", "Glowstone", "Gold", "Diamond", "Lapis", "Blaze", "Emerald", "Ender", "Gunpowder", "XP", "Copper", "Tin", "Obsidian" };
String[] soulCrops = { "Cow", "Pigmen", "Skele", "Spider" };
int seedId;
int blockId;
Method fertilize;
for (String crop : crops) {
seedId = ((Item) mod.getField("seed" + crop).get(null)).itemID;
blockId = ((Block) mod.getField("crop" + crop).get(null)).blockID;
fertilize = Class.forName("magicCrop.crop" + crop).getMethod("func_72272_c_", World.class, int.class, int.class, int.class);
MFRRegistry.registerPlantable(new PlantableCropPlant(seedId, blockId));
MFRRegistry.registerHarvestable(new HarvestableCropPlant(blockId, 7));
MFRRegistry.registerFertilizable(new FertilizableCropReflection(blockId, fertilize, 7));
}
for (String crop : namedAsMagicalCropButExtendsBlockCrops) {
seedId = ((Item) mod.getField("mSeeds" + crop).get(null)).itemID;
blockId = ((Block) mod.getField("mCrop" + crop).get(null)).blockID;
fertilize = Class.forName("magicCrop.mCrop" + crop).getMethod("func_72272_c_", World.class, int.class, int.class, int.class);
MFRRegistry.registerPlantable(new PlantableCropPlant(seedId, blockId));
MFRRegistry.registerHarvestable(new HarvestableCropPlant(blockId, 7));
MFRRegistry.registerFertilizable(new FertilizableCropReflection(blockId, fertilize, 7));
}
for (String magicalCrop : magicalCrops) {
seedId = ((Item) mod.getField("mSeeds" + magicalCrop).get(null)).itemID;
blockId = ((Block) mod.getField("mCrop" + magicalCrop).get(null)).blockID;
fertilize = Class.forName("magicCrop.mCrop" + magicalCrop).getMethod("fertilize", World.class, int.class, int.class, int.class);
MFRRegistry.registerPlantable(new PlantableCropPlant(seedId, blockId));
MFRRegistry.registerHarvestable(new HarvestableCropPlant(blockId, 7));
MFRRegistry.registerFertilizable(new FertilizableMagicalCropReflection(blockId, fertilize, 7));
}
for (String soulCrop : soulCrops) {
seedId = ((Item) mod.getField("soulSeed" + soulCrop).get(null)).itemID;
blockId = ((Block) mod.getField("soulCrop" + soulCrop).get(null)).blockID;
fertilize = Class.forName("magicCrop.soulCrop" + soulCrop).getMethod("fertilize", World.class, int.class, int.class, int.class);
MFRRegistry.registerPlantable(new PlantableCropPlant(seedId, blockId));
MFRRegistry.registerHarvestable(new HarvestableCropPlant(blockId, 7));
MFRRegistry.registerFertilizable(new FertilizableMagicalCropReflection(blockId, fertilize, 7));
}
Item magicalFertilizer = (Item) mod.getField("magicFertilizer").get(null);
if (magicalFertilizer != null) {
MFRRegistry.registerFertilizer(new FertilizerStandard(magicalFertilizer.itemID, 0, FertilizerType.GrowMagicalCrop));
}
} catch (Exception x) {
FMLLog.warning("Something went wrong in MFR Compat: Magical Crops. Probably Emy's fault.");
System.out.println("Last updated for " + lastUpdated);
x.printStackTrace();
}
}
use of powercrystals.minefactoryreloaded.modhelpers.FertilizableCropReflection in project MineFactoryReloaded by powercrystals.
the class Atum method load.
@SuppressWarnings("rawtypes")
@Init
public static void load(FMLInitializationEvent e) {
if (!Loader.isModLoaded("Atum")) {
FMLLog.warning("Atum missing - MFR Atum Compat not loading");
return;
}
try {
Class AtumItems = Class.forName("rebelkeithy.mods.atum.AtumItems");
Class AtumBlocks = Class.forName("rebelkeithy.mods.atum.AtumBlocks");
String entityprefix = "rebelkeithy.mods.atum.entities.Entity";
Class banditWarlord = Class.forName(entityprefix + "BanditWarlord");
Class pharaoh = Class.forName(entityprefix + "Pharaoh");
int atumLogId = ((Block) AtumBlocks.getField("log").get(null)).blockID;
int atumLeavesId = ((Block) AtumBlocks.getField("leaves").get(null)).blockID;
int atumSaplingId = ((Block) AtumBlocks.getField("palmSapling").get(null)).blockID;
int flaxSeedsId = ((Item) AtumItems.getField("flaxSeeds").get(null)).itemID;
int flaxId = ((Block) AtumBlocks.getField("flax").get(null)).blockID;
int papyrusId = ((Block) AtumBlocks.getField("papyrus").get(null)).blockID;
int shrubId = ((Block) AtumBlocks.getField("shrub").get(null)).blockID;
int weedId = ((Block) AtumBlocks.getField("weed").get(null)).blockID;
Method atumSaplingGrowTree = Class.forName("rebelkeithy.mods.atum.blocks.BlockPalmSapling").getMethod("growTree", World.class, int.class, int.class, int.class, Random.class);
Method atumFlaxFertilize = Class.forName("rebelkeithy.mods.atum.blocks.BlockFlax").getMethod("fertilize", World.class, int.class, int.class, int.class);
MFRRegistry.registerSafariNetBlacklist(banditWarlord);
MFRRegistry.registerSafariNetBlacklist(pharaoh);
MFRRegistry.registerGrinderBlacklist(banditWarlord);
MFRRegistry.registerGrinderBlacklist(pharaoh);
MFRRegistry.registerPlantable(new PlantableStandard(atumSaplingId, atumSaplingId));
MFRRegistry.registerPlantable(new PlantableStandard(flaxSeedsId, flaxId));
MFRRegistry.registerFertilizable(new FertilizableCropReflection(flaxId, atumFlaxFertilize, 5));
MFRRegistry.registerFertilizable(new FertilizableSaplingReflection(atumSaplingId, atumSaplingGrowTree));
MFRRegistry.registerHarvestable(new HarvestableStandard(atumLogId, HarvestType.Tree));
MFRRegistry.registerHarvestable(new HarvestableTreeLeaves(atumLeavesId));
MFRRegistry.registerHarvestable(new HarvestableStandard(flaxId, HarvestType.Normal));
MFRRegistry.registerHarvestable(new HarvestableStandard(papyrusId, HarvestType.LeaveBottom));
MFRRegistry.registerHarvestable(new HarvestableStandard(shrubId, HarvestType.Normal));
MFRRegistry.registerHarvestable(new HarvestableStandard(weedId, HarvestType.Normal));
} catch (Exception x) {
System.out.println("Last updated for " + lastUpdated);
x.printStackTrace();
}
}
Aggregations