Package pneumaticCraft.common.thirdparty.forestry

Source Code of pneumaticCraft.common.thirdparty.forestry.Forestry$FarmLogicLightning

package pneumaticCraft.common.thirdparty.forestry;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.HashSet;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import pneumaticCraft.common.block.Blockss;
import pneumaticCraft.common.item.Itemss;
import pneumaticCraft.common.thirdparty.IThirdParty;
import pneumaticCraft.lib.Log;
import cpw.mods.fml.relauncher.ReflectionHelper;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.ICircuit;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.farming.Farmables;
import forestry.api.farming.IFarmHousing;
import forestry.api.recipes.RecipeManagers;

public class Forestry implements IThirdParty{

    public static HashSet<Block> farmStructureBlocks;
    public static Item plasticElectronTube;
    private static Class[] logics = new Class[]{FarmLogicSquid.class, FarmLogicFire.class, FarmLogicCreeper.class, FarmLogicSlime.class, FarmLogicRain.class, FarmLogicEnder.class, FarmLogicLightning.class, null, FarmLogicBurst.class, FarmLogicPotion.class, FarmLogicRepulsion.class, FarmLogicHelium.class, FarmLogicChopper.class, null, FarmLogicPropulsion.class, FarmLogicFlying.class};

    @Override
    public void preInit(){
        plasticElectronTube = new ItemPlasticElectronTube("plasticElectronTube");
        Itemss.registerItem(plasticElectronTube);

        Collection col = Farmables.farmables.get("farmVegetables");
        // if(col != null) {
        ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed");

        try {
            Field field = ReflectionHelper.findField(Class.forName("forestry.farming.gadgets.StructureLogicFarm"), "bricks");
            farmStructureBlocks = (HashSet<Block>)field.get(null);
        } catch(Throwable e) {
            Log.warning("Failed on getting Forestry's farm blocks, using defaults");
            farmStructureBlocks = new HashSet<Block>();
            farmStructureBlocks.add(Blocks.brick_block);
            farmStructureBlocks.add(Blocks.stonebrick);
            farmStructureBlocks.add(Blocks.sandstone);
            farmStructureBlocks.add(Blocks.nether_brick);
            farmStructureBlocks.add(Blocks.quartz_block);
        }

        try {
            Constructor c = Class.forName("forestry.farming.circuits.CircuitFarmLogic").getConstructor(String.class, Class.class);
            for(ItemStack stack : ((ItemPlasticElectronTube)plasticElectronTube).getSubItems()) {
                int meta = stack.getItemDamage();
                if(logics[meta] != null) {
                    ChipsetManager.solderManager.addRecipe(layoutManaged, new ItemStack(plasticElectronTube, 1, meta), (ICircuit)c.newInstance("plasticPlant" + meta, logics[meta]));
                }
            }
        } catch(Throwable e) {
            Log.error("Something happened when trying to register forestry farm logic");
            e.printStackTrace();
        }

        /*  } else {
              Log.info("Forestry was found, but the 'farmVegetables' farmable wasn't. Is this forestry plugin loaded?");
          }*/
    }

    @Override
    public void init(){
        for(ItemStack stack : ((ItemPlasticElectronTube)plasticElectronTube).getSubItems()) {
            RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack("glass", 500), stack.copy(), new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', new ItemStack(Itemss.plastic, 1, stack.getItemDamage())});
        }

    }

    @Override
    public void postInit(){

    }

    @Override
    public void clientSide(){

    }

    public static class FarmLogicFire extends FarmLogicPlasticCustomEarth{
        public FarmLogicFire(IFarmHousing housing) throws Throwable{
            super(housing);
        }

        @Override
        protected Block getBlock(){
            return Blockss.fireFlower;
        }

        @Override
        protected ItemStack getEarth(){
            return new ItemStack(Blocks.netherrack);
        }
    }

    public static class FarmLogicCreeper extends FarmLogicPlasticNormal{

        public FarmLogicCreeper(IFarmHousing housing) throws Throwable{
            super(housing);
        }

        @Override
        protected Block getBlock(){
            return Blockss.creeperPlant;
        }

    }

    public static class FarmLogicSlime extends FarmLogicPlasticNormal{

        public FarmLogicSlime(IFarmHousing housing) throws Throwable{
            super(housing);
        }

        @Override
        protected Block getBlock(){
            return Blockss.slimePlant;
        }

    }

    public static class FarmLogicRain extends FarmLogicPlasticNormal{

        public FarmLogicRain(IFarmHousing housing) throws Throwable{
            super(housing);
        }

        @Override
        protected Block getBlock(){
            return Blockss.rainPlant;
        }

    }

    public static class FarmLogicEnder extends FarmLogicPlasticCustomEarth{
        public FarmLogicEnder(IFarmHousing housing) throws Throwable{
            super(housing);
        }

        @Override
        protected Block getBlock(){
            return Blockss.enderPlant;
        }

        @Override
        protected ItemStack getEarth(){
            return new ItemStack(Blocks.end_stone);
        }
    }

    public static class FarmLogicLightning extends FarmLogicPlasticNormal{

        public FarmLogicLightning(IFarmHousing housing) throws Throwable{
            super(housing);
        }

        @Override
        protected Block getBlock(){
            return Blockss.lightningPlant;
        }

    }

    public static class FarmLogicBurst extends FarmLogicPlasticNormal{

        public FarmLogicBurst(IFarmHousing housing) throws Throwable{
            super(housing);
        }

        @Override
        protected Block getBlock(){
            return Blockss.burstPlant;
        }

    }

    public static class FarmLogicPotion extends FarmLogicPlasticNormal{

        public FarmLogicPotion(IFarmHousing housing) throws Throwable{
            super(housing);
        }

        @Override
        protected Block getBlock(){
            return Blockss.potionPlant;
        }

    }

    public static class FarmLogicRepulsion extends FarmLogicPlasticNormal{

        public FarmLogicRepulsion(IFarmHousing housing) throws Throwable{
            super(housing);
        }

        @Override
        protected Block getBlock(){
            return Blockss.repulsionPlant;
        }

    }

    public static class FarmLogicChopper extends FarmLogicPlasticNormal{

        public FarmLogicChopper(IFarmHousing housing) throws Throwable{
            super(housing);
        }

        @Override
        protected Block getBlock(){
            return Blockss.chopperPlant;
        }

    }

    public static class FarmLogicPropulsion extends FarmLogicPlasticNormal{

        public FarmLogicPropulsion(IFarmHousing housing) throws Throwable{
            super(housing);
        }

        @Override
        protected Block getBlock(){
            return Blockss.propulsionPlant;
        }

    }

    public static class FarmLogicFlying extends FarmLogicPlasticNormal{

        public FarmLogicFlying(IFarmHousing housing) throws Throwable{
            super(housing);
        }

        @Override
        protected Block getBlock(){
            return Blockss.flyingFlower;
        }

    }

}
TOP

Related Classes of pneumaticCraft.common.thirdparty.forestry.Forestry$FarmLogicLightning

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.