Search in sources :

Example 1 with ICircuitLayout

use of forestry.api.circuits.ICircuitLayout in project PneumaticCraft by MineMaarten.

the class Forestry method preInit.

@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?");
          }*/
}
Also used : Field(java.lang.reflect.Field) ICircuitLayout(forestry.api.circuits.ICircuitLayout) Constructor(java.lang.reflect.Constructor) Collection(java.util.Collection) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) HashSet(java.util.HashSet)

Aggregations

ICircuitLayout (forestry.api.circuits.ICircuitLayout)1 Constructor (java.lang.reflect.Constructor)1 Field (java.lang.reflect.Field)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Block (net.minecraft.block.Block)1 ItemStack (net.minecraft.item.ItemStack)1