Search in sources :

Example 1 with IFarmRegistry

use of forestry.api.farming.IFarmRegistry in project ForestryMC by ForestryMC.

the class PluginNatura method postInit.

/* 
	 * Register soils required by Natura trees. Must run in postInit(), after core PluginFarming has registered FarmingLogic instances
	 */
@Override
public void postInit() {
    IFarmRegistry registry = FarmRegistry.getInstance();
    IFarmProperties mushroomFarm = registry.getProperties("farmShroom");
    IFarmProperties farmArboreal = registry.getProperties("farmArboreal");
    if (farmArboreal != null) {
        farmArboreal.registerSoil(new ItemStack(Blocks.NETHERRACK), Blocks.NETHERRACK.getDefaultState());
    }
    if (mushroomFarm != null) {
        mushroomFarm.registerSoil(new ItemStack(Blocks.NETHERRACK), Blocks.NETHERRACK.getDefaultState());
        mushroomFarm.registerSoil(new ItemStack(Blocks.SOUL_SAND), Blocks.SOUL_SAND.getDefaultState());
    }
}
Also used : IFarmProperties(forestry.api.farming.IFarmProperties) IFarmRegistry(forestry.api.farming.IFarmRegistry) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IFarmRegistry

use of forestry.api.farming.IFarmRegistry in project ForestryMC by ForestryMC.

the class PluginRoots method registerRecipes.

@Override
public void registerRecipes() {
    ImmutableList<String> crops = ImmutableList.of("moonglow", "terra_moss", "aubergine");
    ImmutableList<String> seeds = ImmutableList.of("moontinged_seed", "terra_moss_spore", "aubergine_seeds");
    ImmutableList<String> fruits = ImmutableList.of("moonglow_leaf", "terra_moss_ball", "aubergine_item");
    IFarmRegistry farmRegistry = ForestryAPI.farmRegistry;
    int seedAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed");
    int juiceAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple") / 25;
    for (int i = 0; i < fruits.size(); i++) {
        ItemStack seed = getItemStack(seeds.get(i));
        Block block = getBlock(crops.get(i));
        ItemStack fruit = getItemStack(fruits.get(i));
        if (seed != null && i != 1) {
            RecipeManagers.squeezerManager.addRecipe(10, seed, Fluids.SEED_OIL.getFluid(seedAmount));
        }
        if (fruit != null && i == 2) {
            RecipeManagers.squeezerManager.addRecipe(10, fruit, Fluids.JUICE.getFluid(juiceAmount));
        }
        if (seed != null && block != null) {
            farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(seed, block, BlockCrops.AGE, 7, 0));
        }
    }
}
Also used : Block(net.minecraft.block.Block) IFarmRegistry(forestry.api.farming.IFarmRegistry) ItemStack(net.minecraft.item.ItemStack) FarmableAgingCrop(forestry.farming.logic.farmables.FarmableAgingCrop)

Example 3 with IFarmRegistry

use of forestry.api.farming.IFarmRegistry in project ForestryMC by ForestryMC.

the class ModuleFarming method preInit.

@Override
public void preInit() {
    ItemRegistryCore coreItems = ModuleCore.getItems();
    BlockRegistryFarming blocks = getBlocks();
    MinecraftForge.EVENT_BUS.register(this);
    IFarmRegistry registry = ForestryAPI.farmRegistry;
    registry.registerFarmables("farmArboreal", new FarmableVanillaSapling());
    if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.ARBORICULTURE))) {
        registry.registerFarmables("farmArboreal", new FarmableGE());
    }
    registry.registerFarmables("farmCrops", new FarmableAgingCrop(new ItemStack(Items.WHEAT_SEEDS), Blocks.WHEAT, BlockCrops.AGE, 7, 0), new FarmableAgingCrop(new ItemStack(Items.POTATO), Blocks.POTATOES, BlockCrops.AGE, 7, 0), new FarmableAgingCrop(new ItemStack(Items.CARROT), Blocks.CARROTS, BlockCrops.AGE, 7, 0), new FarmableAgingCrop(new ItemStack(Items.BEETROOT_SEEDS), Blocks.BEETROOTS, BlockBeetroot.BEETROOT_AGE, 3, 0));
    IBlockState plantedBrownMushroom = blocks.mushroom.getDefaultState().withProperty(BlockMushroom.VARIANT, BlockMushroom.MushroomType.BROWN);
    registry.registerFarmables("farmShroom", new FarmableVanillaMushroom(new ItemStack(Blocks.BROWN_MUSHROOM), plantedBrownMushroom, Blocks.BROWN_MUSHROOM_BLOCK));
    IBlockState plantedRedMushroom = blocks.mushroom.getDefaultState().withProperty(BlockMushroom.VARIANT, BlockMushroom.MushroomType.RED);
    registry.registerFarmables("farmShroom", new FarmableVanillaMushroom(new ItemStack(Blocks.RED_MUSHROOM), plantedRedMushroom, Blocks.RED_MUSHROOM_BLOCK));
    registry.registerFarmables("farmGourd", new FarmableGourd(new ItemStack(Items.PUMPKIN_SEEDS), Blocks.PUMPKIN_STEM, Blocks.PUMPKIN));
    registry.registerFarmables("farmGourd", new FarmableGourd(new ItemStack(Items.MELON_SEEDS), Blocks.MELON_STEM, Blocks.MELON_BLOCK));
    registry.registerFarmables("farmInfernal", new FarmableAgingCrop(new ItemStack(Items.NETHER_WART), Blocks.NETHER_WART, BlockNetherWart.AGE, 3));
    registry.registerFarmables("farmPoales", new FarmableStacked(new ItemStack(Items.REEDS), Blocks.REEDS, 3));
    registry.registerFarmables("farmSucculentes", new FarmableStacked(new ItemStack(Blocks.CACTUS), Blocks.CACTUS, 3));
    registry.registerFarmables("farmEnder", FarmableChorus.INSTANCE);
    // Forestry fertilizer
    registry.registerFertilizer(new ItemStack(coreItems.fertilizerCompound, 1, OreDictionary.WILDCARD_VALUE), 500);
    proxy.initializeModels();
    // Layouts
    ICircuitLayout layoutManaged = new CircuitLayout("farms.managed", CircuitSocketType.FARM);
    ChipsetManager.circuitRegistry.registerLayout(layoutManaged);
    ICircuitLayout layoutManual = new CircuitLayout("farms.manual", CircuitSocketType.FARM);
    ChipsetManager.circuitRegistry.registerLayout(layoutManual);
}
Also used : BlockRegistryFarming(forestry.farming.blocks.BlockRegistryFarming) FarmableGE(forestry.farming.logic.farmables.FarmableGE) IBlockState(net.minecraft.block.state.IBlockState) FarmableVanillaSapling(forestry.farming.logic.farmables.FarmableVanillaSapling) ICircuitLayout(forestry.api.circuits.ICircuitLayout) CircuitLayout(forestry.core.circuits.CircuitLayout) FarmableStacked(forestry.farming.logic.farmables.FarmableStacked) FarmableVanillaMushroom(forestry.farming.logic.farmables.FarmableVanillaMushroom) ICircuitLayout(forestry.api.circuits.ICircuitLayout) ItemRegistryCore(forestry.core.items.ItemRegistryCore) ResourceLocation(net.minecraft.util.ResourceLocation) FarmableGourd(forestry.farming.logic.farmables.FarmableGourd) IFarmRegistry(forestry.api.farming.IFarmRegistry) FarmableAgingCrop(forestry.farming.logic.farmables.FarmableAgingCrop) ItemStack(net.minecraft.item.ItemStack)

Example 4 with IFarmRegistry

use of forestry.api.farming.IFarmRegistry in project ForestryMC by ForestryMC.

the class ModuleFarming method doInit.

@Override
public void doInit() {
    // Load config
    File configFile = new File(Forestry.instance.getConfigFolder(), Config.CATEGORY_FARM + ".cfg");
    LocalizedConfiguration config = new LocalizedConfiguration(configFile, "1.0.0");
    FarmRegistry.getInstance().loadConfig(config);
    config.save();
    GameRegistry.registerTileEntity(TileFarmPlain.class, "forestry.Farm");
    GameRegistry.registerTileEntity(TileFarmGearbox.class, "forestry.FarmGearbox");
    GameRegistry.registerTileEntity(TileFarmHatch.class, "forestry.FarmHatch");
    GameRegistry.registerTileEntity(TileFarmValve.class, "forestry.FarmValve");
    GameRegistry.registerTileEntity(TileFarmControl.class, "forestry.FarmControl");
    IFarmRegistry registry = FarmRegistry.getInstance();
    BlockRegistryCore coreBlocks = ModuleCore.getBlocks();
    IFarmProperties arborealFarm = registry.registerLogic("farmArboreal", FarmLogicArboreal::new);
    IFarmProperties cropsFarm = registry.registerLogic("farmCrops", FarmLogicCrops::new);
    IFarmProperties mushroomFarm = registry.registerLogic("farmShroom", FarmLogicMushroom::new);
    IFarmProperties succulentFarm = registry.registerLogic("farmSucculentes", FarmLogicSucculent::new);
    IFarmProperties peatFarm = registry.registerLogic("farmPeat", FarmLogicPeat::new);
    IFarmProperties infernalFarm = registry.registerLogic("farmInfernal", FarmLogicInfernal::new);
    IFarmProperties poalesFarm = registry.registerLogic("farmPoales", FarmLogicReeds::new);
    IFarmProperties orchardFarm = registry.registerLogic("farmOrchard", FarmLogicOrchard::new);
    IFarmProperties gourdFarm = registry.registerLogic("farmGourd", FarmLogicGourd::new);
    IFarmProperties cocoaFarm = registry.registerLogic("farmCocoa", FarmLogicCocoa::new);
    IFarmProperties enderFarm = registry.registerLogic("farmEnder", FarmLogicEnder::new);
    Circuits.farmArborealManaged = new CircuitFarmLogic("managedArboreal", arborealFarm, false);
    Circuits.farmArborealManual = new CircuitFarmLogic("manualArboreal", arborealFarm, true);
    arborealFarm.registerSoil(new ItemStack(Blocks.DIRT), coreBlocks.humus.getDefaultState());
    arborealFarm.registerSoil(new ItemStack(coreBlocks.humus), coreBlocks.humus.getDefaultState());
    Circuits.farmShroomManaged = new CircuitFarmLogic("managedShroom", mushroomFarm, false);
    Circuits.farmShroomManual = new CircuitFarmLogic("manualShroom", mushroomFarm, true);
    mushroomFarm.registerSoil(new ItemStack(Blocks.MYCELIUM), Blocks.MYCELIUM.getDefaultState());
    mushroomFarm.registerSoil(new ItemStack(Blocks.DIRT, 1, 2), Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL), true);
    Circuits.farmPeatManaged = new CircuitFarmLogic("managedPeat", peatFarm, false);
    Circuits.farmPeatManual = new CircuitFarmLogic("manualPeat", peatFarm, true);
    peatFarm.registerSoil(coreBlocks.bogEarth.get(BlockBogEarth.SoilType.BOG_EARTH, 1), coreBlocks.bogEarth.getDefaultState());
    Circuits.farmCropsManaged = new CircuitFarmLogic("managedCrops", cropsFarm, false);
    Circuits.farmCropsManual = new CircuitFarmLogic("manualCrops", cropsFarm, true);
    cropsFarm.registerSoil(new ItemStack(Blocks.DIRT), Blocks.FARMLAND.getDefaultState());
    cocoaFarm.registerFarmables("farmWheat");
    Circuits.farmInfernalManaged = new CircuitFarmLogic("managedInfernal", infernalFarm, false);
    Circuits.farmInfernalManual = new CircuitFarmLogic("manualInfernal", infernalFarm, true);
    infernalFarm.registerSoil(new ItemStack(Blocks.SOUL_SAND), Blocks.SOUL_SAND.getDefaultState());
    Circuits.farmOrchardManaged = new CircuitFarmLogic("managedOrchard", orchardFarm, false);
    Circuits.farmOrchardManual = new CircuitFarmLogic("manualOrchard", orchardFarm, true);
    Circuits.farmSucculentManaged = new CircuitFarmLogic("managedSucculent", succulentFarm, false);
    Circuits.farmSucculentManual = new CircuitFarmLogic("manualSucculent", succulentFarm, true);
    succulentFarm.registerSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(), true);
    Circuits.farmPoalesManaged = new CircuitFarmLogic("managedPoales", poalesFarm, false);
    Circuits.farmPoalesManual = new CircuitFarmLogic("manualPoales", poalesFarm, true);
    poalesFarm.registerSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(), true);
    poalesFarm.registerSoil(new ItemStack(Blocks.DIRT), Blocks.DIRT.getDefaultState(), false);
    Circuits.farmGourdManaged = new CircuitFarmLogic("managedGourd", gourdFarm, false);
    Circuits.farmGourdManual = new CircuitFarmLogic("manualGourd", gourdFarm, true);
    Circuits.farmCocoaManaged = new CircuitFarmLogic("managedCocoa", cocoaFarm, false);
    Circuits.farmCocoaManual = new CircuitFarmLogic("manualCocoa", cocoaFarm, true);
    Circuits.farmEnderManaged = new CircuitFarmLogic("managedEnder", enderFarm, false);
    Circuits.farmEnderManual = new CircuitFarmLogic("manualEnder", enderFarm, true);
    enderFarm.registerSoil(new ItemStack(Blocks.END_STONE), Blocks.END_STONE.getDefaultState());
}
Also used : BlockRegistryCore(forestry.core.blocks.BlockRegistryCore) FarmLogicMushroom(forestry.farming.logic.FarmLogicMushroom) FarmLogicGourd(forestry.farming.logic.FarmLogicGourd) IFarmProperties(forestry.api.farming.IFarmProperties) FarmLogicArboreal(forestry.farming.logic.FarmLogicArboreal) FarmLogicSucculent(forestry.farming.logic.FarmLogicSucculent) FarmLogicOrchard(forestry.farming.logic.FarmLogicOrchard) FarmLogicCrops(forestry.farming.logic.FarmLogicCrops) FarmLogicInfernal(forestry.farming.logic.FarmLogicInfernal) FarmLogicPeat(forestry.farming.logic.FarmLogicPeat) CircuitFarmLogic(forestry.farming.circuits.CircuitFarmLogic) FarmLogicReeds(forestry.farming.logic.FarmLogicReeds) LocalizedConfiguration(forestry.core.config.LocalizedConfiguration) FarmLogicEnder(forestry.farming.logic.FarmLogicEnder) IFarmRegistry(forestry.api.farming.IFarmRegistry) FarmLogicCocoa(forestry.farming.logic.FarmLogicCocoa) ItemStack(net.minecraft.item.ItemStack) File(java.io.File)

Example 5 with IFarmRegistry

use of forestry.api.farming.IFarmRegistry in project ForestryMC by ForestryMC.

the class PluginExtraUtilities method registerFarmable.

private void registerFarmable(Block plantBlock, Item plantItem, String identifier) {
    IProperty<Integer> growthProperty = BlockUtil.getProperty(plantBlock, "growth", Integer.class);
    if (growthProperty == null) {
        Log.error("Could not find the growth property of {}.", plantBlock.getLocalizedName());
    } else {
        IFarmRegistry registry = FarmRegistry.getInstance();
        int harvestAge = Collections.max(growthProperty.getAllowedValues());
        int replantAge = plantBlock.getDefaultState().getValue(growthProperty);
        registry.registerFarmables(identifier, new FarmableAgingCrop(new ItemStack(plantItem), plantBlock, growthProperty, harvestAge, replantAge));
    }
}
Also used : IFarmRegistry(forestry.api.farming.IFarmRegistry) FarmableAgingCrop(forestry.farming.logic.farmables.FarmableAgingCrop) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IFarmRegistry (forestry.api.farming.IFarmRegistry)10 ItemStack (net.minecraft.item.ItemStack)10 FarmableAgingCrop (forestry.farming.logic.farmables.FarmableAgingCrop)6 Block (net.minecraft.block.Block)6 PropertyInteger (net.minecraft.block.properties.PropertyInteger)3 IBlockState (net.minecraft.block.state.IBlockState)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 IFarmProperties (forestry.api.farming.IFarmProperties)2 ItemRegistryCore (forestry.core.items.ItemRegistryCore)2 FarmableDoubleCrop (forestry.farming.logic.farmables.FarmableDoubleCrop)2 Optional (com.google.common.base.Optional)1 ImmutableList (com.google.common.collect.ImmutableList)1 ICircuitLayout (forestry.api.circuits.ICircuitLayout)1 GeneratorFuel (forestry.api.fuels.GeneratorFuel)1 MoistenerFuel (forestry.api.fuels.MoistenerFuel)1 BlockRegistryCore (forestry.core.blocks.BlockRegistryCore)1 CircuitLayout (forestry.core.circuits.CircuitLayout)1 LocalizedConfiguration (forestry.core.config.LocalizedConfiguration)1 BlockRegistryFarming (forestry.farming.blocks.BlockRegistryFarming)1 CircuitFarmLogic (forestry.farming.circuits.CircuitFarmLogic)1