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
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 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
|
|
|
|
2017-04-01 19:40:39 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerCrafter;
|
2016-12-28 15:57:15 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
2015-06-28 03:12:32 +02:00
|
|
|
import net.minecraft.block.Block;
|
2016-12-28 15:57:15 +01:00
|
|
|
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;
|
2016-12-28 15:57:15 +01:00
|
|
|
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
|
|
|
|
2016-12-28 15:57:15 +01: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
|
|
|
|
2016-12-28 15:57:15 +01: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);
|
|
|
|
}
|
|
|
|
|
2016-06-27 19:25:46 +02:00
|
|
|
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());
|
2016-06-27 19:25:46 +02:00
|
|
|
compound.setString("crop", plant.getRegistryName().toString());
|
2015-06-28 03:12:32 +02:00
|
|
|
FMLInterModComms.sendMessage("MineFactoryReloaded", "registerPlantable_Crop", compound);
|
|
|
|
}
|
|
|
|
|
2016-12-28 15:57:15 +01:00
|
|
|
private static void registerBloodMagicPlant(Block block){
|
|
|
|
if(Loader.isModLoaded("bloodmagic")){
|
|
|
|
try{
|
2017-08-02 14:01:41 +02:00
|
|
|
Class<?> regClass = Class.forName("WayofTime.bloodmagic.api.registry.HarvestRegistry");
|
2016-12-28 15:57:15 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-01 19:40:39 +02:00
|
|
|
|
|
|
|
public static void registerCraftingTweaksCompat(){
|
|
|
|
NBTTagCompound tagCompound = new NBTTagCompound();
|
|
|
|
tagCompound.setString("ContainerClass", ContainerCrafter.class.getName());
|
|
|
|
tagCompound.setString("AlignToGrid", "left");
|
|
|
|
FMLInterModComms.sendMessage("craftingtweaks", "RegisterProvider", tagCompound);
|
|
|
|
}
|
2015-06-28 03:12:32 +02:00
|
|
|
}
|