Package mods.railcraft.common.modules

Source Code of mods.railcraft.common.modules.ModuleIC2

/*
* Copyright (c) CovertJaguar, 2014 http://railcraft.info
*
* This code is the property of CovertJaguar
* and may only be used with explicit written
* permission unless otherwise specified on the
* license page at http://railcraft.info/wiki/info:license.
*/
package mods.railcraft.common.modules;

import ic2.api.recipe.Recipes;
import org.apache.logging.log4j.Level;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import mods.railcraft.common.plugins.forge.ItemRegistry;
import mods.railcraft.common.blocks.RailcraftBlocks;
import mods.railcraft.common.blocks.detector.BlockDetector;
import mods.railcraft.common.blocks.detector.EnumDetector;
import mods.railcraft.common.blocks.machine.gamma.EnumMachineGamma;
import mods.railcraft.common.carts.EnumCart;
import mods.railcraft.common.core.RailcraftConfig;
import mods.railcraft.common.items.ItemPlate.EnumPlate;
import mods.railcraft.common.items.ItemRailcraft;
import mods.railcraft.common.items.RailcraftItem;
import mods.railcraft.common.plugins.forge.CraftingPlugin;
import mods.railcraft.common.plugins.ic2.IC2Plugin;
import mods.railcraft.common.util.misc.Game;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;

public class ModuleIC2 extends RailcraftModule {

    public static Item lapotronUpgrade;
//    private static Item creosoteWood;

    @Override
    public boolean canModuleLoad() {
        return IC2Plugin.isModInstalled();
    }

    @Override
    public void printLoadError() {
        Game.log(Level.INFO, "Module disabled: {0}, IC2 not detected", this);
    }

    @Override
    public void initFirst() {

        BlockDetector.registerBlock();
        RailcraftBlocks.registerBlockMachineGamma();

        if (RailcraftConfig.isItemEnabled("ic2.upgrade.lapotron")) {
            lapotronUpgrade = new ItemRailcraft().setUnlocalizedName("railcraft.upgrade.lapotron").setMaxStackSize(9);

            ItemRegistry.registerItem(lapotronUpgrade);

            ItemRegistry.registerItemStack("ic2.upgrade.lapotron", new ItemStack(lapotronUpgrade));
        }

        EnumCart.ENERGY_BATBOX.setup();
        EnumCart.ENERGY_MFE.setup();
        EnumCart.ENERGY_CESU.setup();

//        id = RailcraftConfig.getItemId("item.creosote.wood");
//        if(id > 0){
//            creosoteWood = new ItemRailcraft(id).setItemName("creosoteWood").setIconIndex(184);
//            ItemStack wood = new ItemStack(creosoteWood);
//            RailcraftLanguage.getInstance().registerItemName(creosoteWood, "Creosote Wood");
//
//            ItemStack oil = RailcraftPartItems.getCreosoteOil(2);
//            Ic2Recipes.addExtractorRecipe(wood, oil);
//
//            CropCard bush = new CreosoteBush(wood);
//
//            if(!CropCard.registerCrop(bush, 156)){
//                CropCard.registerCrop(bush);
//            }
//        }
    }

    @Override
    public void postInit() {
        createRecipes();
    }

    private static void createRecipes() {
        Block blockDetector = BlockDetector.getBlock();

        if (blockDetector != null) {
            ItemStack stack = EnumDetector.ENERGY.getItem();
            Object tin = RailcraftItem.plate.getRecipeObject(EnumPlate.TIN);
            if (tin == null)
                tin = "ingotTin";
            CraftingPlugin.addShapedRecipe(stack, false,
                    "XXX",
                    "XPX",
                    "XXX",
                    'X', tin,
                    'P', Blocks.stone_pressure_plate);
        }

        ItemStack batbox = IC2Plugin.getItem("batBox");
        if (batbox != null) {
            EnumCart cart = EnumCart.ENERGY_BATBOX;
            cart.setContents(batbox);
            ItemStack stack = cart.getCartItem();
            if (stack != null) {
                CraftingPlugin.addShapedRecipe(stack, new Object[]{
                    "E",
                    "M",
                    'E', batbox,
                    'M', Items.minecart
                });
                CraftingPlugin.addShapelessRecipe(new ItemStack(Items.minecart), stack);
            }
        }

        ItemStack cesu = IC2Plugin.getItem("cesuUnit");
        if (cesu != null) {
            EnumCart cart = EnumCart.ENERGY_CESU;
            cart.setContents(batbox);
            ItemStack stack = cart.getCartItem();
            if (stack != null) {
                CraftingPlugin.addShapedRecipe(stack, new Object[]{
                    "E",
                    "M",
                    'E', cesu,
                    'M', Items.minecart
                });
                CraftingPlugin.addShapelessRecipe(new ItemStack(Items.minecart), stack);
            }
        }

        ItemStack mfe = IC2Plugin.getItem("mfeUnit");
        if (mfe != null) {
            EnumCart cart = EnumCart.ENERGY_MFE;
            cart.setContents(batbox);
            ItemStack stack = cart.getCartItem();
            if (stack != null) {
                CraftingPlugin.addShapedRecipe(stack, new Object[]{
                    "E",
                    "M",
                    'E', mfe,
                    'M', Items.minecart
                });
                CraftingPlugin.addShapelessRecipe(new ItemStack(Items.minecart), stack);
            }
        }

        ItemStack battery = IC2Plugin.getItem("reBattery");
        ItemStack machine = IC2Plugin.getItem("machine");

        ItemStack detector;
        if (blockDetector != null)
            detector = EnumDetector.ENERGY.getItem();
        else
            detector = new ItemStack(Blocks.stone_pressure_plate);

        if (battery != null && machine != null) {
            if (EnumMachineGamma.ENERGY_LOADER.isAvaliable())
                Recipes.advRecipes.addRecipe(EnumMachineGamma.ENERGY_LOADER.getItem(),
                        "BLB",
                        "BIB",
                        "BDB",
                        'D', detector,
                        'B', battery,
                        'I', machine,
                        'L', new ItemStack(Blocks.hopper));

            if (EnumMachineGamma.ENERGY_UNLOADER.isAvaliable())
                Recipes.advRecipes.addRecipe(EnumMachineGamma.ENERGY_UNLOADER.getItem(),
                        "BDB",
                        "BIB",
                        "BLB",
                        'D', detector,
                        'B', battery,
                        'I', machine,
                        'L', new ItemStack(Blocks.hopper));
        }

        if (RailcraftConfig.isItemEnabled("ic2.upgrade.lapotron")) {
            ItemStack lapotron = IC2Plugin.getItem("lapotronCrystal");
            ItemStack glassCable = IC2Plugin.getItem("glassFiberCableItem");
            ItemStack circuit = IC2Plugin.getItem("advancedCircuit");

            if (lapotron != null && glassCable != null && circuit != null) {
                lapotron.copy();
//                lapotron.setItemDamage(-1);
                Recipes.advRecipes.addRecipe(new ItemStack(lapotronUpgrade), new Object[]{
                    "GGG",
                    "wLw",
                    "GCG",
                    'G', new ItemStack(Blocks.glass, 1, 0),
                    'w', glassCable,
                    'C', circuit,
                    'L', lapotron,});
            }
        }
    }

    public static ItemStack getLapotronUpgrade() {
        if (lapotronUpgrade == null)
            return null;
        return new ItemStack(lapotronUpgrade);
    }

}
TOP

Related Classes of mods.railcraft.common.modules.ModuleIC2

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.