Search in sources :

Example 1 with FarmableAgingCrop

use of forestry.farming.logic.farmables.FarmableAgingCrop in project ForestryMC by ForestryMC.

the class PluginNatura method registerRecipes.

@Override
public void registerRecipes() {
    int amount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed");
    for (ItemStack seed : seeds) {
        RecipeManagers.squeezerManager.addRecipe(10, NonNullList.from(seed, seed), Fluids.SEED_OIL.getFluid(amount));
        RecipeManagers.moistenerManager.addRecipe(seed, new ItemStack(Blocks.MYCELIUM), 5000);
    }
    if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING))) {
        cropBlocks.forEach(itemStack -> {
            Block block = ItemStackUtil.getBlock(itemStack);
            ItemStack seedItem;
            int maxAge;
            try {
                maxAge = (int) block.getClass().getDeclaredMethod("getMaxAge").invoke(block);
                seedItem = block.getPickBlock(block.getBlockState().getBaseState(), null, null, null, null);
            } catch (Exception ignored) {
                return;
            }
            Log.info("[PluginNatura] Addding crop '{}'", itemStack);
            if (seedItem.isEmpty()) {
                return;
            }
            FarmRegistry.getInstance().registerFarmables("farmCrops", new FarmableAgingCrop(seedItem, block, (IProperty<Integer>) block.getBlockState().getProperty("age"), maxAge));
        });
    }
    ItemRegistryCore coreItems = ModuleCore.getItems();
    amount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple") / 2;
    // Produce at least 1 mb of juice.
    final int juiceAmount = Math.max(amount, 1);
    ItemStack mulch = coreItems.mulch.getItemStack();
    fruits.forEach(fruit -> RecipeManagers.squeezerManager.addRecipe(10, NonNullList.from(fruit, fruit), Fluids.JUICE.getFluid(juiceAmount), mulch, ForestryAPI.activeMode.getIntegerSetting("squeezer.mulch.apple")));
    amount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple") / 25;
    // Produce at least 1 mb of juice.
    amount = Math.max(amount, 1);
    for (ItemStack berry : berries) {
        RecipeManagers.squeezerManager.addRecipe(3, NonNullList.from(berry, berry), Fluids.JUICE.getFluid(amount));
    }
    crops.forEach(crop -> {
        RecipeUtil.addFermenterRecipes(crop, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
        if (crop.getUnlocalizedName().matches("^.*cotton$")) {
            return;
        }
        int compostWheatAmount = ForestryAPI.activeMode.getIntegerSetting("recipe.output.compost.wheat");
        if (compostWheatAmount > 0) {
            ItemStack compostWheat = coreItems.fertilizerCompound.getItemStack(compostWheatAmount);
            RecipeUtil.addRecipe(compostWheat.getUnlocalizedName(), compostWheat, " X ", "X#X", " X ", '#', Blocks.DIRT, 'X', crop);
        }
        FuelManager.moistenerResource.put(crop, new MoistenerFuel(crop, coreItems.mouldyWheat.getItemStack(), 0, 300));
    });
}
Also used : IProperty(net.minecraft.block.properties.IProperty) ItemRegistryCore(forestry.core.items.ItemRegistryCore) MoistenerFuel(forestry.api.fuels.MoistenerFuel) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) FarmableAgingCrop(forestry.farming.logic.farmables.FarmableAgingCrop)

Example 2 with FarmableAgingCrop

use of forestry.farming.logic.farmables.FarmableAgingCrop 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 FarmableAgingCrop

use of forestry.farming.logic.farmables.FarmableAgingCrop in project ForestryMC by ForestryMC.

the class PluginActuallyAdditions method registerSeedPlant.

private void registerSeedPlant(@Nullable Item seedItem, String blockName) {
    if (seedItem != null) {
        Block plantBlock = getBlock(blockName);
        if (plantBlock != null) {
            FarmableAgingCrop crop = new FarmableAgingCrop(new ItemStack(seedItem), plantBlock, BlockCrops.AGE, 7, 0);
            ForestryAPI.farmRegistry.registerFarmables("farmCrops", crop);
        }
    }
}
Also used : Block(net.minecraft.block.Block) FarmableAgingCrop(forestry.farming.logic.farmables.FarmableAgingCrop) ItemStack(net.minecraft.item.ItemStack)

Example 4 with FarmableAgingCrop

use of forestry.farming.logic.farmables.FarmableAgingCrop 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 5 with FarmableAgingCrop

use of forestry.farming.logic.farmables.FarmableAgingCrop 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

FarmableAgingCrop (forestry.farming.logic.farmables.FarmableAgingCrop)8 ItemStack (net.minecraft.item.ItemStack)8 IFarmRegistry (forestry.api.farming.IFarmRegistry)6 Block (net.minecraft.block.Block)6 ResourceLocation (net.minecraft.util.ResourceLocation)4 ItemRegistryCore (forestry.core.items.ItemRegistryCore)3 MoistenerFuel (forestry.api.fuels.MoistenerFuel)2 PropertyInteger (net.minecraft.block.properties.PropertyInteger)2 ImmutableList (com.google.common.collect.ImmutableList)1 ICircuitLayout (forestry.api.circuits.ICircuitLayout)1 CircuitLayout (forestry.core.circuits.CircuitLayout)1 BlockRegistryFarming (forestry.farming.blocks.BlockRegistryFarming)1 FarmableGE (forestry.farming.logic.farmables.FarmableGE)1 FarmableGourd (forestry.farming.logic.farmables.FarmableGourd)1 FarmableRusticGrape (forestry.farming.logic.farmables.FarmableRusticGrape)1 FarmableRusticSapling (forestry.farming.logic.farmables.FarmableRusticSapling)1 FarmableStacked (forestry.farming.logic.farmables.FarmableStacked)1 FarmableVanillaMushroom (forestry.farming.logic.farmables.FarmableVanillaMushroom)1 FarmableVanillaSapling (forestry.farming.logic.farmables.FarmableVanillaSapling)1 IProperty (net.minecraft.block.properties.IProperty)1