mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-28 15:36:18 +00:00
Merge branch 'Greenhouse' of https://github.com/ForestryMC/ForestryMC into mc-1.12
This commit is contained in:
commit
26bf69effc
413 files changed
+13569
-7506
No files matched your search
@@ -10,11 +10,17 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.recipes.ICarpenterManager;
|
||||
import forestry.api.recipes.ICarpenterRecipe;
|
||||
import forestry.api.recipes.ICentrifugeManager;
|
||||
@@ -33,9 +39,6 @@ import forestry.api.recipes.ISqueezerManager;
|
||||
import forestry.api.recipes.ISqueezerRecipe;
|
||||
import forestry.api.recipes.IStillManager;
|
||||
import forestry.api.recipes.IStillRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class DummyManagers {
|
||||
|
||||
@@ -110,6 +113,16 @@ public class DummyManagers {
|
||||
public void addRecipe(ItemStack resource, int fermentationValue, float modifier, FluidStack output) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(String resource, int fermentationValue, float modifier, FluidStack output, FluidStack liquid) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(String resource, int fermentationValue, float modifier, FluidStack output) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static class DummyMoistenerManager extends DummyCraftingProvider<IMoistenerRecipe> implements IMoistenerManager {
|
||||
|
||||
@@ -56,6 +56,7 @@ import forestry.core.items.ItemRegistryCore;
|
||||
import forestry.core.items.ItemRegistryFluids;
|
||||
import forestry.core.network.IPacketRegistry;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.utils.OreDictUtil;
|
||||
import forestry.core.utils.datastructures.FluidMap;
|
||||
import forestry.core.utils.datastructures.ItemStackMap;
|
||||
import forestry.factory.blocks.BlockRegistryFactory;
|
||||
@@ -383,14 +384,12 @@ public class PluginFactory extends BlankForestryPlugin {
|
||||
RecipeManagers.moistenerManager.addRecipe(new ItemStack(Blocks.LEAVES, 1, EnumType.SPRUCE.ordinal()), new ItemStack(Blocks.DIRT, 1, DirtType.PODZOL.ordinal()), 5000);
|
||||
|
||||
// FERMENTER
|
||||
for (int i = 0; i < 6; i++) {
|
||||
RecipeUtil.addFermenterRecipes(new ItemStack(Blocks.SAPLING, 1, i), ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS);
|
||||
}
|
||||
RecipeUtil.addFermenterRecipes(OreDictUtil.TREE_SAPLING, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS);
|
||||
|
||||
RecipeUtil.addFermenterRecipes(new ItemStack(Blocks.CACTUS), ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.cactus"), Fluids.BIOMASS);
|
||||
RecipeUtil.addFermenterRecipes(new ItemStack(Items.WHEAT), ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
|
||||
RecipeUtil.addFermenterRecipes(new ItemStack(Items.POTATO), 2 * ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
|
||||
RecipeUtil.addFermenterRecipes(new ItemStack(Items.REEDS), ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.cane"), Fluids.BIOMASS);
|
||||
RecipeUtil.addFermenterRecipes(OreDictUtil.BLOCK_CACTUS, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.cactus"), Fluids.BIOMASS);
|
||||
RecipeUtil.addFermenterRecipes(OreDictUtil.CROP_WHEAT, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
|
||||
RecipeUtil.addFermenterRecipes(OreDictUtil.CROP_POTATO, 2 * ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
|
||||
RecipeUtil.addFermenterRecipes(OreDictUtil.SUGARCANE, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.cane"), Fluids.BIOMASS);
|
||||
RecipeUtil.addFermenterRecipes(new ItemStack(Blocks.BROWN_MUSHROOM), ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.mushroom"), Fluids.BIOMASS);
|
||||
RecipeUtil.addFermenterRecipes(new ItemStack(Blocks.RED_MUSHROOM), ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.mushroom"), Fluids.BIOMASS);
|
||||
|
||||
|
||||
@@ -11,14 +11,20 @@
|
||||
package forestry.factory.recipes;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import forestry.api.recipes.IFermenterRecipe;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.recipes.IFermenterRecipe;
|
||||
|
||||
public class FermenterRecipe implements IFermenterRecipe {
|
||||
|
||||
private final ItemStack resource;
|
||||
private final String resourceOreName;
|
||||
private final int fermentationValue;
|
||||
private final float modifier;
|
||||
private final Fluid output;
|
||||
@@ -31,17 +37,39 @@ public class FermenterRecipe implements IFermenterRecipe {
|
||||
Preconditions.checkNotNull(fluidResource, "Fermenter Liquid cannot be null!");
|
||||
|
||||
this.resource = resource;
|
||||
this.resourceOreName = null;
|
||||
this.fermentationValue = fermentationValue;
|
||||
this.modifier = modifier;
|
||||
this.output = output;
|
||||
this.fluidResource = fluidResource;
|
||||
}
|
||||
|
||||
public FermenterRecipe(String resourceOreName, int fermentationValue, float modifier, Fluid output, FluidStack fluidResource) {
|
||||
Preconditions.checkNotNull(resourceOreName, "Fermenter Resource cannot be null!");
|
||||
Preconditions.checkArgument(!resourceOreName.isEmpty(), "Fermenter Resource ore name cannot be empty!");
|
||||
Preconditions.checkNotNull(output, "Fermenter Output cannot be null!");
|
||||
Preconditions.checkNotNull(fluidResource, "Fermenter Liquid cannot be null!");
|
||||
|
||||
this.resource = ItemStack.EMPTY;
|
||||
this.resourceOreName = resourceOreName;
|
||||
this.fermentationValue = fermentationValue;
|
||||
this.modifier = modifier;
|
||||
this.output = output;
|
||||
this.fluidResource = fluidResource;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getResourceOreName() {
|
||||
return resourceOreName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluidResource() {
|
||||
return fluidResource;
|
||||
@@ -61,4 +89,9 @@ public class FermenterRecipe implements IFermenterRecipe {
|
||||
public Fluid getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(IFermenterRecipe o) {
|
||||
return resource.isEmpty() ? 1 : 0;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -27,7 +28,7 @@ import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class FermenterRecipeManager implements IFermenterManager {
|
||||
|
||||
private static final Set<IFermenterRecipe> recipes = new HashSet<>();
|
||||
private static final Set<IFermenterRecipe> recipes = new TreeSet<>();
|
||||
public static final Set<Fluid> recipeFluidInputs = new HashSet<>();
|
||||
public static final Set<Fluid> recipeFluidOutputs = new HashSet<>();
|
||||
|
||||
@@ -42,6 +43,17 @@ public class FermenterRecipeManager implements IFermenterManager {
|
||||
addRecipe(resource, fermentationValue, modifier, output, new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(String resourceOreName, int fermentationValue, float modifier, FluidStack output, FluidStack liquid) {
|
||||
IFermenterRecipe recipe = new FermenterRecipe(resourceOreName, fermentationValue, modifier, output.getFluid(), liquid);
|
||||
addRecipe(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(String resourceOreName, int fermentationValue, float modifier, FluidStack output) {
|
||||
addRecipe(resourceOreName, fermentationValue, modifier, output, new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IFermenterRecipe findMatchingRecipe(ItemStack res, FluidStack liqu) {
|
||||
if(res.isEmpty()){
|
||||
@@ -57,7 +69,7 @@ public class FermenterRecipeManager implements IFermenterManager {
|
||||
|
||||
public static boolean matches(IFermenterRecipe recipe, ItemStack res, FluidStack liqu) {
|
||||
ItemStack resource = recipe.getResource();
|
||||
if (!ItemStackUtil.isCraftingEquivalent(resource, res)) {
|
||||
if (!ItemStackUtil.isCraftingEquivalent(resource, res, recipe.getResourceOreName(), false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -71,7 +83,7 @@ public class FermenterRecipeManager implements IFermenterManager {
|
||||
}
|
||||
|
||||
for (IFermenterRecipe recipe : recipes) {
|
||||
if (ItemStackUtil.isCraftingEquivalent(recipe.getResource(), resource)) {
|
||||
if (ItemStackUtil.isCraftingEquivalent(recipe.getResource(), resource, recipe.getResourceOreName(), false)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package forestry.factory.recipes.jei.bottler;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mezz.jei.api.ingredients.IIngredientRegistry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -13,6 +13,8 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
|
||||
import mezz.jei.api.ingredients.IIngredientRegistry;
|
||||
|
||||
public class BottlerRecipeMaker {
|
||||
|
||||
private BottlerRecipeMaker() {
|
||||
|
||||
@@ -3,12 +3,17 @@ package forestry.factory.recipes.jei.fermenter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.api.recipes.IFermenterRecipe;
|
||||
import forestry.api.recipes.IVariableFermentable;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.utils.Log;
|
||||
|
||||
import mezz.jei.api.recipe.IStackHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class FermenterRecipeMaker {
|
||||
|
||||
@@ -19,12 +24,13 @@ public class FermenterRecipeMaker {
|
||||
List<FermenterRecipeWrapper> recipes = new ArrayList<>();
|
||||
for (IFermenterRecipe recipe : RecipeManagers.fermenterManager.recipes()) {
|
||||
if (!recipe.getResource().isEmpty()) {
|
||||
if (recipe.getResource().getItem() instanceof IVariableFermentable) {
|
||||
for (ItemStack stack : stackHelper.getSubtypes(recipe.getResource())) {
|
||||
recipes.add(new FermenterRecipeWrapper(recipe, stack));
|
||||
addWrapperToList(stackHelper, recipe, recipe.getResource(), recipes);
|
||||
}else if(recipe.getResourceOreName() != null){
|
||||
NonNullList<ItemStack> itemStacks = OreDictionary.getOres(recipe.getResourceOreName());
|
||||
if(!itemStacks.isEmpty()){
|
||||
for(ItemStack resource : itemStacks){
|
||||
addWrapperToList(stackHelper, recipe, resource, recipes);
|
||||
}
|
||||
} else {
|
||||
recipes.add(new FermenterRecipeWrapper(recipe, recipe.getResource()));
|
||||
}
|
||||
} else {
|
||||
Log.error("Empty resource for recipe");
|
||||
@@ -33,4 +39,14 @@ public class FermenterRecipeMaker {
|
||||
return recipes;
|
||||
}
|
||||
|
||||
private static void addWrapperToList(IStackHelper stackHelper, IFermenterRecipe recipe, ItemStack resource, List<FermenterRecipeWrapper> recipes){
|
||||
if (resource.getItem() instanceof IVariableFermentable) {
|
||||
for (ItemStack stack : stackHelper.getSubtypes(resource)) {
|
||||
recipes.add(new FermenterRecipeWrapper(recipe, stack));
|
||||
}
|
||||
} else {
|
||||
recipes.add(new FermenterRecipeWrapper(recipe, resource));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user