Search in sources :

Example 1 with FarmableDoubleCrop

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

the class PluginImmersiveEngineering method postInit.

@Override
public void postInit() {
    IFarmRegistry farmRegistry = ForestryAPI.farmRegistry;
    ItemStack hempSeed = getItemStack("seed");
    Block hempCrop = getBlock("hemp");
    if (hempCrop != null) {
        int seedAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed");
        Stream<IProperty<?>> propertyStream = hempCrop.getBlockState().getProperties().stream();
        IProperty age = propertyStream.filter(p -> p.getName().equals("type")).findAny().orElseGet(null);
        if (hempSeed != null && hempCrop != Blocks.AIR && age != null) {
            Optional bottom0 = age.parseValue("bottom0");
            Optional bottom4 = age.parseValue("bottom4");
            Optional top0 = age.parseValue("top0");
            if (bottom0.isPresent() && top0.isPresent()) {
                IBlockState defaultState = hempCrop.getDefaultState();
                IBlockState planted = defaultState.withProperty(age, (Comparable) bottom0.get());
                IBlockState mature = defaultState.withProperty(age, (Comparable) bottom4.get());
                IBlockState topMature = defaultState.withProperty(age, (Comparable) top0.get());
                farmRegistry.registerFarmables("farmWheat", new FarmableDoubleCrop(hempSeed, planted, mature, topMature, false));
                farmRegistry.registerFarmables("farmOrchard", new FarmableDoubleCrop(hempSeed, planted, mature, topMature, true));
                RecipeManagers.squeezerManager.addRecipe(10, hempSeed, Fluids.SEED_OIL.getFluid(seedAmount));
            }
        }
    }
    Fluid ethanol = FluidRegistry.getFluid("ethanol");
    if (ethanol != null) {
        GeneratorFuel ethanolFuel = new GeneratorFuel(new FluidStack(ethanol, 1), (int) (32 * ForestryAPI.activeMode.getFloatSetting("fuel.ethanol.generator")), 4);
        FuelManager.generatorFuel.put(ethanol, ethanolFuel);
    }
}
Also used : GeneratorFuel(forestry.api.fuels.GeneratorFuel) IBlockState(net.minecraft.block.state.IBlockState) Optional(com.google.common.base.Optional) FarmableDoubleCrop(forestry.farming.logic.farmables.FarmableDoubleCrop) IProperty(net.minecraft.block.properties.IProperty) FluidStack(net.minecraftforge.fluids.FluidStack) Fluid(net.minecraftforge.fluids.Fluid) Block(net.minecraft.block.Block) IFarmRegistry(forestry.api.farming.IFarmRegistry) ItemStack(net.minecraft.item.ItemStack)

Example 2 with FarmableDoubleCrop

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

the class PluginBetterWithMods method registerRecipes.

@Override
public void registerRecipes() {
    IFarmRegistry farmRegistry = ForestryAPI.farmRegistry;
    int seedAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed");
    PropertyBool TOP = PropertyBool.create("top");
    PropertyInteger AGE = BlockCrops.AGE;
    ItemStack hempSeed = getItemStack("hemp");
    Block hempCrop = getBlock("hemp");
    if (hempSeed != null && hempCrop != null) {
        IBlockState defaultState = hempCrop.getDefaultState();
        IBlockState planted = defaultState.withProperty(AGE, 0).withProperty(TOP, false);
        IBlockState mature = defaultState.withProperty(AGE, 7).withProperty(TOP, false);
        IBlockState topMature = defaultState.withProperty(AGE, 7).withProperty(TOP, true);
        farmRegistry.registerFarmables("farmCrops", new FarmableDoubleCrop(hempSeed, planted, mature, topMature, true));
        RecipeManagers.squeezerManager.addRecipe(10, hempSeed, Fluids.SEED_OIL.getFluid(seedAmount));
    }
}
Also used : PropertyInteger(net.minecraft.block.properties.PropertyInteger) IBlockState(net.minecraft.block.state.IBlockState) PropertyBool(net.minecraft.block.properties.PropertyBool) FarmableDoubleCrop(forestry.farming.logic.farmables.FarmableDoubleCrop) Block(net.minecraft.block.Block) IFarmRegistry(forestry.api.farming.IFarmRegistry) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IFarmRegistry (forestry.api.farming.IFarmRegistry)2 FarmableDoubleCrop (forestry.farming.logic.farmables.FarmableDoubleCrop)2 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 ItemStack (net.minecraft.item.ItemStack)2 Optional (com.google.common.base.Optional)1 GeneratorFuel (forestry.api.fuels.GeneratorFuel)1 IProperty (net.minecraft.block.properties.IProperty)1 PropertyBool (net.minecraft.block.properties.PropertyBool)1 PropertyInteger (net.minecraft.block.properties.PropertyInteger)1 Fluid (net.minecraftforge.fluids.Fluid)1 FluidStack (net.minecraftforge.fluids.FluidStack)1