ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatUtil.java

59 lines
2.2 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
2016-05-16 22:52:27 +02:00
* This file ("CompatUtil.java") is part of the Actually Additions mod for Minecraft.
2015-08-29 14:33:25 +02:00
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
2015-08-29 14:33:25 +02:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-05-16 22:54:42 +02:00
* © 2015-2016 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2016-06-17 14:00:52 +02:00
package de.ellpeck.actuallyadditions.mod.util.compat;
2015-06-28 03:12:32 +02:00
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
2015-06-28 03:12:32 +02:00
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
2015-06-28 03:12:32 +02:00
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.common.Loader;
2016-01-07 18:20:59 +01:00
import net.minecraftforge.fml.common.event.FMLInterModComms;
2015-06-28 03:12:32 +02:00
import java.lang.reflect.Method;
2016-06-17 23:50:38 +02:00
public final class CompatUtil{
2015-06-28 03:12:32 +02:00
public static void registerPlant(Block block){
registerMFRPlant(block);
registerBloodMagicPlant(block);
}
private static void registerMFRPlant(Block block){
2015-06-28 03:12:32 +02:00
FMLInterModComms.sendMessage("MineFactoryReloaded", "registerHarvestable_Crop", new ItemStack(block, 1, 7));
NBTTagCompound compound = new NBTTagCompound();
2016-04-20 21:39:03 +02:00
compound.setString("plant", block.getRegistryName().toString());
2015-06-28 03:12:32 +02:00
FMLInterModComms.sendMessage("MineFactoryReloaded", "registerFertilizable_Crop", compound);
}
public static void registerMFRSeed(Item item, Block plant){
2015-06-28 03:12:32 +02:00
NBTTagCompound compound = new NBTTagCompound();
2016-04-20 21:39:03 +02:00
compound.setString("seed", item.getRegistryName().toString());
compound.setString("crop", plant.getRegistryName().toString());
2015-06-28 03:12:32 +02:00
FMLInterModComms.sendMessage("MineFactoryReloaded", "registerPlantable_Crop", compound);
}
private static void registerBloodMagicPlant(Block block){
if(Loader.isModLoaded("bloodmagic")){
try{
Class regClass = Class.forName("WayofTime.bloodmagic.api.registry.HarvestRegistry");
Method regMethod = regClass.getDeclaredMethod("registerStandardCrop", Block.class, int.class);
regMethod.invoke(null, block, ((BlockCrops)block).getMaxAge());
}
catch(Exception e){
ModUtil.LOGGER.error("Failed to add farming compatibility for Blood Magic!", e);
}
}
}
2015-06-28 03:12:32 +02:00
}