Search in sources :

Example 1 with MoistenerFuel

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

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

the class TileMoistener method updateServerSide.

@Override
public void updateServerSide() {
    if (updateOnInterval(20)) {
        // Check if we have suitable water container waiting in the item slot
        FluidHelper.drainContainers(tankManager, this, InventoryMoistener.SLOT_PRODUCT);
    }
    // Let's get to work
    int lightvalue = world.getLightFromNeighbors(getPos().up());
    IErrorLogic errorLogic = getErrorLogic();
    // Not working in broad daylight
    boolean gloomy = lightvalue <= 11;
    if (errorLogic.setCondition(!gloomy, EnumErrorCode.NOT_DARK)) {
        return;
    }
    // The darker, the better
    int speed;
    if (lightvalue >= 9) {
        speed = 1;
    } else if (lightvalue >= 7) {
        speed = 2;
    } else if (lightvalue >= 5) {
        speed = 3;
    } else {
        speed = 4;
    }
    // Already running
    if (burnTime > 0 && pendingProduct == null) {
        // Not working if there is no water available.
        boolean hasLiquid = resourceTank.getFluidAmount() > 0;
        if (errorLogic.setCondition(!hasLiquid, EnumErrorCode.NO_RESOURCE_LIQUID)) {
            return;
        }
        checkRecipe();
        if (currentRecipe == null) {
            return;
        }
        resourceTank.drain(1, true);
        burnTime -= speed;
        productionTime -= speed;
        if (productionTime <= 0) {
            pendingProduct = currentProduct;
            decrStackSize(InventoryMoistener.SLOT_RESOURCE, 1);
            resetRecipe();
            tryAddPending();
        }
    } else if (pendingProduct != null) {
        tryAddPending();
    } else // Try to start process
    {
        // Make sure we have a new item in the working slot.
        if (rotateWorkingSlot()) {
            checkRecipe();
            // Let's see if we have a valid resource in the working slot
            if (getStackInSlot(InventoryMoistener.SLOT_WORKING).isEmpty()) {
                return;
            }
            if (FuelManager.moistenerResource.containsKey(getStackInSlot(InventoryMoistener.SLOT_WORKING))) {
                MoistenerFuel res = FuelManager.moistenerResource.get(getStackInSlot(InventoryMoistener.SLOT_WORKING));
                burnTime = totalTime = res.getMoistenerValue();
            }
        } else {
            rotateReservoir();
        }
    }
    errorLogic.setCondition(currentRecipe == null, EnumErrorCode.NO_RECIPE);
}
Also used : MoistenerFuel(forestry.api.fuels.MoistenerFuel) IErrorLogic(forestry.api.core.IErrorLogic)

Example 3 with MoistenerFuel

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

the class ModuleFactory method preInit.

@Override
public void preInit() {
    ItemRegistryCore coreItems = ModuleCore.getItems();
    // Set fuels and resources for the fermenter
    ItemStack fertilizerCompound = coreItems.fertilizerCompound.getItemStack();
    FuelManager.fermenterFuel.put(fertilizerCompound, new FermenterFuel(fertilizerCompound, ForestryAPI.activeMode.getIntegerSetting("fermenter.value.fertilizer"), ForestryAPI.activeMode.getIntegerSetting("fermenter.cycles.fertilizer")));
    int cyclesCompost = ForestryAPI.activeMode.getIntegerSetting("fermenter.cycles.compost");
    int valueCompost = ForestryAPI.activeMode.getIntegerSetting("fermenter.value.compost");
    ItemStack fertilizerBio = coreItems.compost.getItemStack();
    ItemStack mulch = coreItems.mulch.getItemStack();
    FuelManager.fermenterFuel.put(fertilizerBio, new FermenterFuel(fertilizerBio, valueCompost, cyclesCompost));
    FuelManager.fermenterFuel.put(mulch, new FermenterFuel(mulch, valueCompost, cyclesCompost));
    // Add moistener resources
    ItemStack wheat = new ItemStack(Items.WHEAT);
    ItemStack mouldyWheat = coreItems.mouldyWheat.getItemStack();
    ItemStack decayingWheat = coreItems.decayingWheat.getItemStack();
    FuelManager.moistenerResource.put(wheat, new MoistenerFuel(wheat, mouldyWheat, 0, 300));
    FuelManager.moistenerResource.put(mouldyWheat, new MoistenerFuel(mouldyWheat, decayingWheat, 1, 600));
    FuelManager.moistenerResource.put(decayingWheat, new MoistenerFuel(decayingWheat, mulch, 2, 900));
    // Set fuels for our own engines
    ItemStack peat = coreItems.peat.getItemStack();
    FuelManager.copperEngineFuel.put(peat, new EngineCopperFuel(peat, Constants.ENGINE_COPPER_FUEL_VALUE_PEAT, Constants.ENGINE_COPPER_CYCLE_DURATION_PEAT));
    ItemStack bituminousPeat = coreItems.bituminousPeat.getItemStack();
    FuelManager.copperEngineFuel.put(bituminousPeat, new EngineCopperFuel(bituminousPeat, Constants.ENGINE_COPPER_FUEL_VALUE_BITUMINOUS_PEAT, Constants.ENGINE_COPPER_CYCLE_DURATION_BITUMINOUS_PEAT));
    Fluid biomass = Fluids.BIOMASS.getFluid();
    if (biomass != null) {
        FuelManager.bronzeEngineFuel.put(biomass, new EngineBronzeFuel(biomass, Constants.ENGINE_FUEL_VALUE_BIOMASS, (int) (Constants.ENGINE_CYCLE_DURATION_BIOMASS * ForestryAPI.activeMode.getFloatSetting("fuel.biomass.biogas")), 1));
    }
    FuelManager.bronzeEngineFuel.put(FluidRegistry.WATER, new EngineBronzeFuel(FluidRegistry.WATER, Constants.ENGINE_FUEL_VALUE_WATER, Constants.ENGINE_CYCLE_DURATION_WATER, 3));
    Fluid milk = Fluids.MILK.getFluid();
    if (milk != null) {
        FuelManager.bronzeEngineFuel.put(milk, new EngineBronzeFuel(milk, Constants.ENGINE_FUEL_VALUE_MILK, Constants.ENGINE_CYCLE_DURATION_MILK, 3));
    }
    Fluid seedOil = Fluids.SEED_OIL.getFluid();
    if (seedOil != null) {
        FuelManager.bronzeEngineFuel.put(seedOil, new EngineBronzeFuel(seedOil, Constants.ENGINE_FUEL_VALUE_SEED_OIL, Constants.ENGINE_CYCLE_DURATION_SEED_OIL, 1));
    }
    Fluid honey = Fluids.FOR_HONEY.getFluid();
    if (honey != null) {
        FuelManager.bronzeEngineFuel.put(honey, new EngineBronzeFuel(honey, Constants.ENGINE_FUEL_VALUE_HONEY, Constants.ENGINE_CYCLE_DURATION_HONEY, 1));
    }
    Fluid juice = Fluids.JUICE.getFluid();
    if (juice != null) {
        FuelManager.bronzeEngineFuel.put(juice, new EngineBronzeFuel(juice, Constants.ENGINE_FUEL_VALUE_JUICE, Constants.ENGINE_CYCLE_DURATION_JUICE, 1));
    }
    // Set rain substrates
    ItemStack iodineCharge = coreItems.iodineCharge.getItemStack();
    ItemStack dissipationCharge = coreItems.craftingMaterial.getDissipationCharge();
    FuelManager.rainSubstrate.put(iodineCharge, new RainSubstrate(iodineCharge, Constants.RAINMAKER_RAIN_DURATION_IODINE, 0.01f));
    FuelManager.rainSubstrate.put(dissipationCharge, new RainSubstrate(dissipationCharge, 0.075f));
    ICircuitLayout layoutMachineUpgrade = new CircuitLayout("machine.upgrade", CircuitSocketType.MACHINE);
    ChipsetManager.circuitRegistry.registerLayout(layoutMachineUpgrade);
}
Also used : ICircuitLayout(forestry.api.circuits.ICircuitLayout) EngineCopperFuel(forestry.api.fuels.EngineCopperFuel) ItemRegistryCore(forestry.core.items.ItemRegistryCore) MoistenerFuel(forestry.api.fuels.MoistenerFuel) Fluid(net.minecraftforge.fluids.Fluid) FermenterFuel(forestry.api.fuels.FermenterFuel) EngineBronzeFuel(forestry.api.fuels.EngineBronzeFuel) RainSubstrate(forestry.api.fuels.RainSubstrate) ICircuitLayout(forestry.api.circuits.ICircuitLayout) CircuitLayout(forestry.core.circuits.CircuitLayout) ItemStack(net.minecraft.item.ItemStack)

Example 4 with MoistenerFuel

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

the class TileMoistener method getNextResourceSlot.

private int getNextResourceSlot(int startSlot, int endSlot) {
    // Let's look for a new resource to put into the working slot.
    int stage = -1;
    int resourceSlot = -1;
    IInventoryAdapter inventory = getInternalInventory();
    for (int i = startSlot; i < endSlot; i++) {
        ItemStack slotStack = inventory.getStackInSlot(i);
        if (slotStack.isEmpty()) {
            continue;
        }
        if (!FuelManager.moistenerResource.containsKey(slotStack)) {
            continue;
        }
        MoistenerFuel res = FuelManager.moistenerResource.get(slotStack);
        if (stage < 0 || res.getStage() < stage) {
            stage = res.getStage();
            resourceSlot = i;
        }
    }
    return resourceSlot;
}
Also used : MoistenerFuel(forestry.api.fuels.MoistenerFuel) IInventoryAdapter(forestry.core.inventory.IInventoryAdapter) ItemStack(net.minecraft.item.ItemStack)

Example 5 with MoistenerFuel

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

the class TileMoistener method hasFuelMin.

public boolean hasFuelMin(float percentage) {
    int max = 0;
    int avail = 0;
    IInventoryAdapter inventory = getInternalInventory();
    for (int i = InventoryMoistener.SLOT_STASH_1; i < InventoryMoistener.SLOT_RESERVOIR_1; i++) {
        if (inventory.getStackInSlot(i).isEmpty()) {
            max += 64;
            continue;
        }
        if (FuelManager.moistenerResource.containsKey(inventory.getStackInSlot(i))) {
            MoistenerFuel res = FuelManager.moistenerResource.get(inventory.getStackInSlot(i));
            if (res.getItem().isItemEqual(inventory.getStackInSlot(i))) {
                max += 64;
                avail += inventory.getStackInSlot(i).getCount();
            }
        }
    }
    return (float) avail / (float) max > percentage;
}
Also used : MoistenerFuel(forestry.api.fuels.MoistenerFuel) IInventoryAdapter(forestry.core.inventory.IInventoryAdapter)

Aggregations

MoistenerFuel (forestry.api.fuels.MoistenerFuel)7 ItemStack (net.minecraft.item.ItemStack)5 ItemRegistryCore (forestry.core.items.ItemRegistryCore)3 IErrorLogic (forestry.api.core.IErrorLogic)2 IInventoryAdapter (forestry.core.inventory.IInventoryAdapter)2 FarmableAgingCrop (forestry.farming.logic.farmables.FarmableAgingCrop)2 Block (net.minecraft.block.Block)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 ImmutableList (com.google.common.collect.ImmutableList)1 ICircuitLayout (forestry.api.circuits.ICircuitLayout)1 IFarmRegistry (forestry.api.farming.IFarmRegistry)1 EngineBronzeFuel (forestry.api.fuels.EngineBronzeFuel)1 EngineCopperFuel (forestry.api.fuels.EngineCopperFuel)1 FermenterFuel (forestry.api.fuels.FermenterFuel)1 RainSubstrate (forestry.api.fuels.RainSubstrate)1 CircuitLayout (forestry.core.circuits.CircuitLayout)1 IProperty (net.minecraft.block.properties.IProperty)1 PropertyInteger (net.minecraft.block.properties.PropertyInteger)1 Fluid (net.minecraftforge.fluids.Fluid)1