Search in sources :

Example 6 with MoistenerFuel

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

the class TileMoistener method rotateWorkingSlot.

private boolean rotateWorkingSlot() {
    IErrorLogic errorLogic = getErrorLogic();
    // Put working slot contents into inventory if space is available
    if (!getStackInSlot(InventoryMoistener.SLOT_WORKING).isEmpty()) {
        // Get the result of the consumed item in the working slot
        ItemStack deposit;
        if (FuelManager.moistenerResource.containsKey(getStackInSlot(InventoryMoistener.SLOT_WORKING))) {
            MoistenerFuel res = FuelManager.moistenerResource.get(getStackInSlot(InventoryMoistener.SLOT_WORKING));
            deposit = res.getProduct().copy();
        } else {
            deposit = getStackInSlot(InventoryMoistener.SLOT_WORKING).copy();
        }
        int targetSlot = getFreeReservoirSlot(deposit);
        // We stop the whole thing, if we don't have any room anymore.
        if (errorLogic.setCondition(targetSlot < 0, EnumErrorCode.NO_SPACE_INVENTORY)) {
            return false;
        }
        if (getStackInSlot(targetSlot).isEmpty()) {
            setInventorySlotContents(targetSlot, deposit);
        } else {
            getStackInSlot(targetSlot).grow(1);
        }
        decrStackSize(InventoryMoistener.SLOT_WORKING, 1);
    }
    if (!getStackInSlot(InventoryMoistener.SLOT_WORKING).isEmpty()) {
        return true;
    }
    // Let's look for a new resource to put into the working slot.
    int resourceSlot = getNextResourceSlot(InventoryMoistener.SLOT_RESERVOIR_1, InventoryMoistener.SLOT_RESERVOIR_1 + InventoryMoistener.SLOT_RESERVOIR_COUNT);
    // Nothing found, stop.
    if (errorLogic.setCondition(resourceSlot < 0, EnumErrorCode.NO_RESOURCE)) {
        return false;
    }
    setInventorySlotContents(InventoryMoistener.SLOT_WORKING, decrStackSize(resourceSlot, 1));
    return true;
}
Also used : MoistenerFuel(forestry.api.fuels.MoistenerFuel) ItemStack(net.minecraft.item.ItemStack) IErrorLogic(forestry.api.core.IErrorLogic)

Example 7 with MoistenerFuel

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

the class PluginHarvestCraft method registerRecipes.

@Override
public void registerRecipes() {
    ImmutableList<String> berries = ImmutableList.of("cranberry", "blackberry", "blueberry", "raspberry", "strawberry");
    ImmutableList<String> fruits = ImmutableList.of("pineapple", "cactusfruit", "cantaloupe", "grape", "kiwi", "chilipepper");
    ImmutableList<String> treeFruits = ImmutableList.of("banana", "dragonfruit", "lemon", "lime", "mango", "orange", "papaya", "peach", "pear", "plum", "pomegranate", "starfruit", "apricot", "date", "fig", "grapefruit", "persimmon", "avocado", "coconut", "durian");
    ImmutableList<String> trees = ImmutableList.of("nutmeg", "olive", "peppercorn");
    ImmutableList<String> treesSpecial = ImmutableList.of("cinnamon", "maple", "paperbark", "vanillabean", // to prevent apples from getting double registered
    "apple");
    ImmutableList<String> herbs = ImmutableList.of("garlic");
    ImmutableList<String> spices = ImmutableList.of("ginger", "spiceleaf");
    ImmutableList<String> vegetables = ImmutableList.of("asparagus", "bean", "beet", "broccoli", "cauliflower", "celery", "leek", "lettuce", "onion", "parsnip", "radish", "rutabaga", "scallion", "soybean", "sweetpotato", "turnip", "whitemushroom", "artichoke", "bellpepper", "brusselsprout", "cabbage", "corn", "cucumber", "eggplant", "okra", "peas", "rhubarb", "seaweed", "tomato", "wintersquash", "zucchini", "bambooshoot", "spinach");
    ImmutableList<String> grains = ImmutableList.of("barley", "oats", "rye");
    ImmutableList<String> cropNuts = ImmutableList.of("peanut");
    ImmutableList<String> nuts = ImmutableList.of("walnut", "almond", "cashew", "chestnut", "pecan", "pistachio", // Cherries in forestry make seed oil
    "cherry");
    ImmutableList.Builder<String> genericCropsBuilder = ImmutableList.builder();
    genericCropsBuilder.add("cotton", "rice", "tealeaf", "coffeebean", "candleberry");
    genericCropsBuilder.addAll(herbs);
    genericCropsBuilder.addAll(spices);
    IFarmRegistry farmRegistry = ForestryAPI.farmRegistry;
    ImmutableList<String> genericCrops = genericCropsBuilder.build();
    ImmutableList.Builder<String> plants = ImmutableList.builder();
    int juiceAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple") / 25;
    int seedamount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed");
    int wheatamount = ForestryAPI.activeMode.getIntegerSetting("recipe.output.compost.wheat");
    PropertyInteger plantAGE = PropertyInteger.create("age", 0, 3);
    PropertyInteger fruitAGE = PropertyInteger.create("age", 0, 2);
    // Produce at least 1 mb of juice.
    juiceAmount = Math.max(juiceAmount, 1);
    for (String berryName : berries) {
        ItemStack berry = getItemStack(berryName + "item");
        ItemStack berrySeed = getItemStack(berryName + "seeditem");
        Block berryBlock = getBlock("pam" + berryName + "crop");
        if (berry != null) {
            RecipeManagers.squeezerManager.addRecipe(10, berry, Fluids.JUICE.getFluid(juiceAmount));
        }
        if (berrySeed != null) {
            RecipeManagers.squeezerManager.addRecipe(10, berrySeed, Fluids.SEED_OIL.getFluid(seedamount));
        }
        if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && berrySeed != null && berryBlock != null) {
            farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(berrySeed, berryBlock, plantAGE, 3, 0));
        }
        plants.add(berryName);
    }
    juiceAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple");
    for (String fruitName : fruits) {
        ItemStack fruit = getItemStack(fruitName + "item");
        ItemStack fruitSeed = getItemStack(fruitName + "seeditem");
        Block fruitBlock = getBlock("pam" + fruitName + "crop");
        if (fruit != null) {
            RecipeManagers.squeezerManager.addRecipe(10, fruit, Fluids.JUICE.getFluid(juiceAmount));
        }
        if (fruitSeed != null) {
            RecipeManagers.squeezerManager.addRecipe(10, fruitSeed, Fluids.SEED_OIL.getFluid(seedamount));
        }
        if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && fruitSeed != null && fruitBlock != null) {
            farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(fruitSeed, fruitBlock, plantAGE, 3, 0));
        }
        plants.add(fruitName);
    }
    // vegetables produce less juice
    juiceAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple") / 2;
    // Produce at least 1 mb of juice.
    juiceAmount = Math.max(juiceAmount, 1);
    for (String vegetableName : vegetables) {
        ItemStack vegetable = getItemStack(vegetableName + "item");
        ItemStack vegetableSeed = getItemStack(vegetableName + "seeditem");
        Block vegetableBlock = getBlock("pam" + vegetableName + "crop");
        if (vegetable != null) {
            RecipeManagers.squeezerManager.addRecipe(10, vegetable, Fluids.JUICE.getFluid(juiceAmount));
        }
        if (vegetableSeed != null) {
            RecipeManagers.squeezerManager.addRecipe(10, vegetableSeed, Fluids.SEED_OIL.getFluid(seedamount));
        }
        if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && vegetableSeed != null && vegetableBlock != null) {
            farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(vegetableSeed, vegetableBlock, plantAGE, 3, 0));
        }
        plants.add(vegetableName);
    }
    ItemRegistryCore coreItems = ModuleCore.getItems();
    for (String grainName : grains) {
        ItemStack grain = getItemStack(grainName + "item");
        ItemStack grainSeed = getItemStack(grainName + "seeditem");
        Block grainBlock = getBlock("pam" + grainName + "crop");
        if (grain != null && wheatamount > 0) {
            RecipeUtil.addRecipe("pam_compost_" + grainName, coreItems.compost.getItemStack(wheatamount), " X ", "X#X", " X ", '#', Blocks.DIRT, 'X', grain);
            FuelManager.moistenerResource.put(grain, new MoistenerFuel(grain, coreItems.mouldyWheat.getItemStack(), 0, 300));
        }
        if (grainSeed != null) {
            RecipeManagers.squeezerManager.addRecipe(10, grainSeed, Fluids.SEED_OIL.getFluid(seedamount));
            RecipeManagers.moistenerManager.addRecipe(grainSeed, new ItemStack(Blocks.MYCELIUM), 5000);
        }
        if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && grainSeed != null && grainBlock != null) {
            farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(grainSeed, grainBlock, plantAGE, 3, 0));
        }
        plants.add(grainName);
    }
    for (String treeFruitName : treeFruits) {
        ItemStack treeFruit = getItemStack(treeFruitName + "item");
        Block treeFruitBlock = getBlock("pam" + treeFruitName);
        if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && treeFruitBlock != null) {
            farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(ItemStack.EMPTY, treeFruitBlock, fruitAGE, 2, 0));
        }
        if (treeFruit != null) {
            RecipeManagers.squeezerManager.addRecipe(10, treeFruit, Fluids.JUICE.getFluid(juiceAmount));
        }
        plants.add(treeFruitName);
    }
    for (String treeName : trees) {
        Block fruitBlock = getBlock("pam" + treeName);
        if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && fruitBlock != null) {
            farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(ItemStack.EMPTY, fruitBlock, fruitAGE, 2, 0));
        }
        plants.add(treeName);
    }
    for (String treeName : treesSpecial) {
        Block fruitBlock = getBlock("pam" + treeName);
        if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && fruitBlock != null) {
            farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(ItemStack.EMPTY, fruitBlock, fruitAGE, 2, 0));
        }
    }
    for (String cropName : genericCrops) {
        String seedPrefix = cropName;
        if (seedPrefix.equals("tealeaf")) {
            seedPrefix = "tea";
        }
        if (seedPrefix.equals("coffeebean")) {
            seedPrefix = "coffee";
        }
        ItemStack genericCropSeed = getItemStack(seedPrefix + "seeditem");
        Block genericCropBlock = getBlock("pam" + cropName + "crop");
        if (genericCropSeed != null) {
            RecipeManagers.squeezerManager.addRecipe(10, genericCropSeed, Fluids.SEED_OIL.getFluid(seedamount));
        }
        if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && genericCropSeed != null && genericCropBlock != null) {
            farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(genericCropSeed, genericCropBlock, plantAGE, 3, 0));
        }
        plants.add(cropName);
    }
    ItemStack mustardCropSeed = getItemStack("mustard" + "seeditem");
    Block mustardCropBlock = getBlock("pam" + "mustardseeds" + "crop");
    ItemStack mustardFruit = getItemStack("mustard" + "seedsitem");
    if (mustardCropSeed != null) {
        RecipeManagers.squeezerManager.addRecipe(10, mustardCropSeed, Fluids.SEED_OIL.getFluid(seedamount));
    }
    if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && mustardCropSeed != null && mustardCropBlock != null) {
        farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(mustardCropSeed, mustardCropBlock, plantAGE, 3, 0));
    }
    if (mustardFruit != null) {
        RecipeUtil.addFermenterRecipes(mustardFruit, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
    }
    for (String plantName : plants.build()) {
        ItemStack plant = getItemStack(plantName + "item");
        if (plant != null) {
            RecipeUtil.addFermenterRecipes(plant, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
        }
    }
    for (String cropnutName : cropNuts) {
        ItemStack cropnut = getItemStack(cropnutName + "item");
        ItemStack cropnutSeed = getItemStack(cropnutName + "seeditem");
        Block cropnutBlock = getBlock("pam" + cropnutName + "crop");
        if (cropnutSeed != null) {
            RecipeManagers.squeezerManager.addRecipe(10, cropnutSeed, Fluids.SEED_OIL.getFluid(seedamount));
        }
        if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && cropnutSeed != null && cropnutBlock != null) {
            farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(cropnutSeed, cropnutBlock, plantAGE, 3, 0));
        }
        if (cropnut != null) {
            RecipeManagers.squeezerManager.addRecipe(20, cropnut, Fluids.SEED_OIL.getFluid(12 * seedamount));
        }
    }
    for (String nutName : nuts) {
        ItemStack nut = getItemStack(nutName + "item");
        Block nutBlock = getBlock("pam" + nutName);
        if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && nutBlock != null) {
            farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(ItemStack.EMPTY, nutBlock, fruitAGE, 2, 0));
        }
        if (nut != null) {
            RecipeManagers.squeezerManager.addRecipe(20, nut, Fluids.SEED_OIL.getFluid(15 * seedamount));
        }
    }
    if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.APICULTURE))) {
        ItemStack hcHoneyItem = getItemStack("honeyitem");
        if (hcHoneyItem != null) {
            RecipeManagers.squeezerManager.addRecipe(10, hcHoneyItem, Fluids.FOR_HONEY.getFluid(Constants.FLUID_PER_HONEY_DROP));
        }
        ItemStack hcBeeswaxItem = getItemStack("beeswaxitem");
        if (hcBeeswaxItem != null) {
            RecipeUtil.addRecipe("pam_wax_capsule", ModuleFluids.getItems().waxCapsuleEmpty.getItemStack(ForestryAPI.activeMode.getIntegerSetting("recipe.output.capsule")), "XXX ", 'X', hcBeeswaxItem);
        }
    }
}
Also used : PropertyInteger(net.minecraft.block.properties.PropertyInteger) ImmutableList(com.google.common.collect.ImmutableList) ItemRegistryCore(forestry.core.items.ItemRegistryCore) MoistenerFuel(forestry.api.fuels.MoistenerFuel) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) IFarmRegistry(forestry.api.farming.IFarmRegistry) ItemStack(net.minecraft.item.ItemStack) FarmableAgingCrop(forestry.farming.logic.farmables.FarmableAgingCrop)

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