TechReborn/ToAddBack/compat/recipes/RecipesBuildcraft.java

95 lines
3.5 KiB
Java
Raw Normal View History

2015-04-17 20:39:14 +02:00
package techreborn.compat.recipes;
import buildcraft.api.fuels.IFuel;
import buildcraft.core.Version;
2015-11-23 15:40:30 +01:00
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
2015-05-01 21:05:34 +02:00
import ic2.api.item.IC2Items;
import net.minecraft.block.Block;
2015-06-27 02:29:20 +02:00
import net.minecraft.item.Item;
2015-04-17 20:39:14 +02:00
import net.minecraft.item.ItemStack;
2015-06-27 02:29:20 +02:00
import net.minecraftforge.oredict.OreDictionary;
2015-11-08 13:15:45 +01:00
import reborncore.api.fuel.FluidPowerManager;
import reborncore.common.util.CraftingHelper;
import reborncore.common.util.RecipeRemover;
import techreborn.Core;
2015-06-12 19:40:08 +02:00
import techreborn.compat.ICompatModule;
import techreborn.config.ConfigTechReborn;
2015-04-17 20:39:14 +02:00
2015-06-12 19:40:08 +02:00
public class RecipesBuildcraft implements ICompatModule {
2015-04-24 15:20:09 +02:00
public static Block quarryBlock;
public static void removeRecipes() {
RecipeRemover.removeAnyRecipe(new ItemStack(
quarryBlock));
}
2015-06-12 19:40:08 +02:00
public static void addRecipies() {
Item drill = IC2Items.getItem("diamondDrill").getItem();
ItemStack drillStack = new ItemStack(drill, 1, OreDictionary.WILDCARD_VALUE);
//Quarry
CraftingHelper.addShapedOreRecipe(new ItemStack(quarryBlock), new Object[]
{
"IAI", "GIG", "DED",
'I', "gearIron",
'G', "gearGold",
'D', "gearDiamond",
'A', IC2Items.getItem("advancedCircuit"),
'E', drillStack
}
);
}
2015-06-12 19:40:08 +02:00
@Override
public void preInit(FMLPreInitializationEvent event) {
2015-06-12 19:40:08 +02:00
}
2015-06-12 19:40:08 +02:00
@Override
public void init(FMLInitializationEvent event) {
}
@Override
public void postInit(FMLPostInitializationEvent event) {
2015-11-08 13:15:45 +01:00
Core.logHelper.info("Trying to change the quarry recipe");
try {
String itemClass = "buildcraft.BuildCraftBuilders";
if (!Version.getVersion().startsWith("7")) {//Buildcraft 6
if (Loader.isModLoaded("BuildCraft|Factory")) {
itemClass = "buildcraft.BuildCraftFactory";
}
} else if (!Version.getVersion().startsWith("7") && !Loader.isModLoaded("BuildCraft|Builders")) { //Buildcraft 7
2015-11-08 13:15:45 +01:00
Core.logHelper.info("Buildcraft not found");
return;
}
Object obj = Class.forName(itemClass).getField("quarryBlock").get(null);
if (obj instanceof Block) {
quarryBlock = (Block) obj;
2015-11-08 13:15:45 +01:00
Core.logHelper.info("Found Quarry Block from buildcraft at " + itemClass + ":quarryBlock");
} else {
2015-11-08 13:15:45 +01:00
Core.logHelper.fatal("Could not retrieve quarry block from Buildcraft! This is a fatal error!");
return;
}
} catch (Exception ex) {
2015-11-08 13:15:45 +01:00
Core.logHelper.fatal("Could not retrieve quarry block from Buildcraft! This is a fatal error!");
ex.printStackTrace();
return;
}
removeRecipes();
addRecipies();
2015-11-08 13:15:45 +01:00
for (IFuel fuel : buildcraft.energy.fuels.FuelManager.INSTANCE.getFuels()) {
FluidPowerManager.fluidPowerValues.put(fuel.getFluid(), (double) fuel.getPowerPerCycle() / ConfigTechReborn.euPerRF);
}
}
2015-04-24 15:20:09 +02:00
@Override
public void serverStarting(FMLServerStartingEvent event) {
2015-06-12 19:40:08 +02:00
}
2015-04-17 20:39:14 +02:00
}