Search in sources :

Example 1 with GeneratorFuel

use of forestry.api.fuels.GeneratorFuel in project ForestryMC by ForestryMC.

the class ModuleFluids method doInit.

@Override
public void doInit() {
    if (RecipeManagers.squeezerManager != null) {
        ItemRegistryCore itemRegistryCore = ModuleCore.getItems();
        RecipeManagers.squeezerManager.addContainerRecipe(10, getItems().canEmpty.getItemStack(), itemRegistryCore.ingotTin.copy(), 0.05f);
        RecipeManagers.squeezerManager.addContainerRecipe(10, getItems().waxCapsuleEmpty.getItemStack(), itemRegistryCore.beeswax.getItemStack(), 0.10f);
        RecipeManagers.squeezerManager.addContainerRecipe(10, getItems().refractoryEmpty.getItemStack(), itemRegistryCore.refractoryWax.getItemStack(), 0.10f);
    }
    FluidStack ethanol = Fluids.BIO_ETHANOL.getFluid(1);
    GeneratorFuel ethanolFuel = new GeneratorFuel(ethanol, (int) (32 * ForestryAPI.activeMode.getFloatSetting("fuel.ethanol.generator")), 4);
    FuelManager.generatorFuel.put(ethanol.getFluid(), ethanolFuel);
    FluidStack biomass = Fluids.BIOMASS.getFluid(1);
    GeneratorFuel biomassFuel = new GeneratorFuel(biomass, (int) (8 * ForestryAPI.activeMode.getFloatSetting("fuel.biomass.generator")), 1);
    FuelManager.generatorFuel.put(biomass.getFluid(), biomassFuel);
}
Also used : GeneratorFuel(forestry.api.fuels.GeneratorFuel) ItemRegistryCore(forestry.core.items.ItemRegistryCore) FluidStack(net.minecraftforge.fluids.FluidStack)

Example 2 with GeneratorFuel

use of forestry.api.fuels.GeneratorFuel in project ForestryMC by ForestryMC.

the class TileEuGenerator method updateServerSide.

@Override
public void updateServerSide() {
    if (updateOnInterval(20)) {
        FluidHelper.drainContainers(tankManager, this, InventoryGenerator.SLOT_CAN);
    }
    IErrorLogic errorLogic = getErrorLogic();
    // No work to be done if IC2 is unavailable.
    if (errorLogic.setCondition(ic2EnergySource == null, EnumErrorCode.NO_ENERGY_NET)) {
        return;
    }
    ic2EnergySource.update();
    if (resourceTank.getFluidAmount() > 0) {
        GeneratorFuel fuel = FuelManager.generatorFuel.get(resourceTank.getFluid().getFluid());
        if (resourceTank.canDrainFluidType(fuel.getFuelConsumed()) && ic2EnergySource.getFreeCapacity() >= fuel.getEu()) {
            ic2EnergySource.addEnergy(fuel.getEu());
            this.tickCount++;
            if (tickCount >= fuel.getRate()) {
                tickCount = 0;
                resourceTank.drain(fuel.getFuelConsumed().amount, true);
            }
        }
    }
    boolean hasFuel = resourceTank.getFluidAmount() > 0;
    errorLogic.setCondition(!hasFuel, EnumErrorCode.NO_FUEL);
}
Also used : GeneratorFuel(forestry.api.fuels.GeneratorFuel) IErrorLogic(forestry.api.core.IErrorLogic)

Example 3 with GeneratorFuel

use of forestry.api.fuels.GeneratorFuel 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)

Aggregations

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