2015-04-17 20:39:14 +02:00
|
|
|
package techreborn.compat.recipes;
|
|
|
|
|
2015-09-08 19:39:59 +02:00
|
|
|
import buildcraft.api.fuels.IFuel;
|
2015-06-08 19:26:22 +02:00
|
|
|
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;
|
2015-06-13 08:45:12 +02:00
|
|
|
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;
|
2015-09-08 19:39:59 +02:00
|
|
|
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
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
public static Block quarryBlock;
|
2015-06-08 19:26:22 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
public static void removeRecipes() {
|
|
|
|
RecipeRemover.removeAnyRecipe(new ItemStack(
|
|
|
|
quarryBlock));
|
|
|
|
}
|
2015-06-12 19:40:08 +02:00
|
|
|
|
2015-08-09 12:05:32 +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
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@Override
|
|
|
|
public void preInit(FMLPreInitializationEvent event) {
|
2015-06-12 19:40:08 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
}
|
2015-06-12 19:40:08 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@Override
|
|
|
|
public void init(FMLInitializationEvent event) {
|
2015-09-08 19:39:59 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
}
|
2015-06-13 08:45:12 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@Override
|
|
|
|
public void postInit(FMLPostInitializationEvent event) {
|
2015-11-08 13:15:45 +01:00
|
|
|
Core.logHelper.info("Trying to change the quarry recipe");
|
2015-08-09 12:05:32 +02:00
|
|
|
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");
|
2015-08-09 12:05:32 +02:00
|
|
|
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");
|
2015-08-09 12:05:32 +02:00
|
|
|
} else {
|
2015-11-08 13:15:45 +01:00
|
|
|
Core.logHelper.fatal("Could not retrieve quarry block from Buildcraft! This is a fatal error!");
|
2015-08-09 12:05:32 +02:00
|
|
|
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!");
|
2015-08-09 12:05:32 +02:00
|
|
|
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-08-09 12:05:32 +02:00
|
|
|
}
|
2015-04-24 15:20:09 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@Override
|
|
|
|
public void serverStarting(FMLServerStartingEvent event) {
|
2015-06-12 19:40:08 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
}
|
2015-04-17 20:39:14 +02:00
|
|
|
}
|