diff --git a/gradle.properties b/gradle.properties index 737e5fafd..44e96bffd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,9 @@ curse_project_id=59751 tesla_version=1.0.60 tesla_mcversion=1.12 -jei_version=4.8.5.147 +jei_version=4.10.0.200 jei_mcversion=1.12.2 -ic2_version=2.8.24-ex112 +ic2_version=2.8.90-ex112 TR_mcversion=1.12.2 TR_version=2.13.2.561 buildcraft_version=7.99.17 diff --git a/src/main/java/forestry/api/farming/IFarmCircuit.java b/src/main/java/forestry/api/farming/IFarmCircuit.java new file mode 100644 index 000000000..50fcc907b --- /dev/null +++ b/src/main/java/forestry/api/farming/IFarmCircuit.java @@ -0,0 +1,8 @@ +package forestry.api.farming; + +import forestry.api.circuits.ICircuit; + +public interface IFarmCircuit extends ICircuit { + + IFarmLogic getFarmLogic(); +} diff --git a/src/main/java/forestry/api/farming/IFarmLogic.java b/src/main/java/forestry/api/farming/IFarmLogic.java index 7db1e3df5..d72a69bbf 100644 --- a/src/main/java/forestry/api/farming/IFarmLogic.java +++ b/src/main/java/forestry/api/farming/IFarmLogic.java @@ -100,9 +100,14 @@ public interface IFarmLogic { return ForestryAPI.farmRegistry.createFakeInstance(this); } + default boolean isManual(){ + return false; + } + /** * @deprecated Since Forestry 5.8 logic instances are created at the constructor of the {@link IFarmProperties} and - * have a immutable manual state. TODO Remove this method in 1.13 + * have a immutable manual state. + * TODO Remove this method in 1.13 */ @Deprecated default IFarmLogic setManual(boolean manual){ diff --git a/src/main/java/forestry/api/farming/IFarmProperties.java b/src/main/java/forestry/api/farming/IFarmProperties.java index 25c751f06..e141fcc90 100644 --- a/src/main/java/forestry/api/farming/IFarmProperties.java +++ b/src/main/java/forestry/api/farming/IFarmProperties.java @@ -22,6 +22,14 @@ public interface IFarmProperties { */ void registerSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData); + void addGermlings(ItemStack... germlings); + + void addGermlings(Collection germlings); + + void addProducts(ItemStack... products); + + void addProducts(Collection products); + /** * Adds the {@link IFarmable}s that where registered with the given identifier. */ @@ -41,6 +49,8 @@ public interface IFarmProperties { Collection getFarmables(); + Collection getFarmableInfo(); + /** * Returns the instance of the manual or managed {@link IFarmLogic}. */ diff --git a/src/main/java/forestry/api/farming/IFarmRegistry.java b/src/main/java/forestry/api/farming/IFarmRegistry.java index c8dad116f..e731cee45 100644 --- a/src/main/java/forestry/api/farming/IFarmRegistry.java +++ b/src/main/java/forestry/api/farming/IFarmRegistry.java @@ -48,6 +48,8 @@ public interface IFarmRegistry { void registerFarmables(String identifier, IFarmable... farmable); Collection getFarmables(String identifier); + + IFarmableInfo getFarmableInfo(String identifier); /** * Can be used to create a simple version of a farm logic, like the vanilla vegetable or wheat farm logic. diff --git a/src/main/java/forestry/api/farming/IFarmable.java b/src/main/java/forestry/api/farming/IFarmable.java index d13f09b47..40ad488df 100644 --- a/src/main/java/forestry/api/farming/IFarmable.java +++ b/src/main/java/forestry/api/farming/IFarmable.java @@ -45,6 +45,9 @@ public interface IFarmable { */ boolean isGermling(ItemStack itemstack); + default void addInformation(IFarmableInfo info){ + } + /** * @return true if the item is something that can drop from this type without actually being harvested as a crop. (Apples or sapling from decaying leaves.) */ diff --git a/src/main/java/forestry/api/farming/IFarmableInfo.java b/src/main/java/forestry/api/farming/IFarmableInfo.java new file mode 100644 index 000000000..b9143a2fe --- /dev/null +++ b/src/main/java/forestry/api/farming/IFarmableInfo.java @@ -0,0 +1,40 @@ +package forestry.api.farming; + +import java.util.Arrays; +import java.util.Collection; + +import net.minecraft.item.ItemStack; + +/** + * IFarmableInfo describes the valid germlings and possible products of an IFarmable. This is mainly used by the jei farming + * category to display the valid germlings and possible products. + */ +public interface IFarmableInfo { + + /*** + * @return The identifier of the IFarmable. + */ + String getIdentifier(); + + default void addGermlings(ItemStack... germlings){ + addGermlings(Arrays.asList(germlings)); + } + + void addGermlings(Collection germlings); + + /** + * @return a collection that contains all valid germlings of a farmable. + */ + Collection getGermlings(); + + default void addProducts(ItemStack... products){ + addProducts(Arrays.asList(products)); + } + + void addProducts(Collection products); + + /** + * @return a collection that contains all possible products of a farmable. + */ + Collection getProducts(); +} diff --git a/src/main/java/forestry/arboriculture/charcoal/jei/CharcoalPileWallCategory.java b/src/main/java/forestry/arboriculture/charcoal/jei/CharcoalPileWallCategory.java index efc118697..bd55c091a 100644 --- a/src/main/java/forestry/arboriculture/charcoal/jei/CharcoalPileWallCategory.java +++ b/src/main/java/forestry/arboriculture/charcoal/jei/CharcoalPileWallCategory.java @@ -26,8 +26,8 @@ public class CharcoalPileWallCategory extends ForestryRecipeCategory recipes = new ArrayList<>(); @@ -32,6 +35,10 @@ public class SolderManager implements ISolderManager { recipes.add(new CircuitRecipe(layout, resource, circuit)); } + public static Collection getRecipes() { + return recipes; + } + @Nullable public static ICircuit getCircuit(ICircuitLayout layout, ItemStack resource) { CircuitRecipe circuitRecipe = getMatchingRecipe(layout, resource); diff --git a/src/main/java/forestry/farming/DummyFarmRegistry.java b/src/main/java/forestry/farming/DummyFarmRegistry.java index faf1f6532..2dd717bb2 100644 --- a/src/main/java/forestry/farming/DummyFarmRegistry.java +++ b/src/main/java/forestry/farming/DummyFarmRegistry.java @@ -11,8 +11,10 @@ import forestry.api.farming.IFarmLogic; import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmRegistry; import forestry.api.farming.IFarmable; +import forestry.api.farming.IFarmableInfo; import forestry.api.farming.ISimpleFarmLogic; import forestry.farming.logic.FakeFarmProperties; +import forestry.farming.logic.farmables.FarmableInfo; public class DummyFarmRegistry implements IFarmRegistry { @@ -32,6 +34,11 @@ public class DummyFarmRegistry implements IFarmRegistry { return Collections.emptyList(); } + @Override + public IFarmableInfo getFarmableInfo(String identifier) { + return new FarmableInfo(identifier); + } + @Override public IFarmProperties registerLogic(String identifier, IFarmProperties farmInstance) { return null; diff --git a/src/main/java/forestry/farming/FarmRegistry.java b/src/main/java/forestry/farming/FarmRegistry.java index 1ccd1245c..f1ec0f4ee 100644 --- a/src/main/java/forestry/farming/FarmRegistry.java +++ b/src/main/java/forestry/farming/FarmRegistry.java @@ -27,6 +27,7 @@ import forestry.api.farming.IFarmLogic; import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmRegistry; import forestry.api.farming.IFarmable; +import forestry.api.farming.IFarmableInfo; import forestry.api.farming.ISimpleFarmLogic; import forestry.core.config.LocalizedConfiguration; import forestry.core.utils.ItemStackUtil; @@ -35,12 +36,14 @@ import forestry.core.utils.Translator; import forestry.farming.logic.FakeFarmProperties; import forestry.farming.logic.FarmLogicSimple; import forestry.farming.logic.FarmProperties; +import forestry.farming.logic.farmables.FarmableInfo; public final class FarmRegistry implements IFarmRegistry { private static final FarmRegistry INSTANCE = new FarmRegistry(); private final Multimap farmables = HashMultimap.create(); + private final Map farmableInfo = new LinkedHashMap<>(); private final Map fertilizers = new LinkedHashMap<>(); private final Map farmInstances = new HashMap<>(); private FertilizerConfig fertilizer = FertilizerConfig.DUMMY; @@ -56,6 +59,10 @@ public final class FarmRegistry implements IFarmRegistry { @Override public void registerFarmables(String identifier, IFarmable... farmablesArray) { + IFarmableInfo info = getFarmableInfo(identifier); + for(IFarmable farmable : farmablesArray){ + farmable.addInformation(info); + } farmables.putAll(identifier, Arrays.asList(farmablesArray)); } @@ -64,6 +71,11 @@ public final class FarmRegistry implements IFarmRegistry { return farmables.get(identifier); } + @Override + public IFarmableInfo getFarmableInfo(String identifier) { + return farmableInfo.computeIfAbsent(identifier, FarmableInfo::new); + } + @Override public IFarmLogic createCropLogic(IFarmProperties instance, boolean isManual, ISimpleFarmLogic simpleFarmLogic) { return new FarmLogicSimple(instance, isManual, simpleFarmLogic); @@ -97,7 +109,7 @@ public final class FarmRegistry implements IFarmRegistry { public IFarmProperties registerLogic(String identifier, BiFunction logicFactory, String... farmablesIdentifiers) { Set identifiers = new HashSet<>(Arrays.asList(farmablesIdentifiers)); identifiers.add(identifier); - IFarmProperties instance = new FarmProperties(logicFactory, identifiers); + IFarmProperties instance = new FarmProperties(logicFactory, identifiers, identifier); farmInstances.put(identifier, instance); return instance; } diff --git a/src/main/java/forestry/farming/ModuleFarming.java b/src/main/java/forestry/farming/ModuleFarming.java index 72f7528b7..2256c79e1 100644 --- a/src/main/java/forestry/farming/ModuleFarming.java +++ b/src/main/java/forestry/farming/ModuleFarming.java @@ -21,6 +21,8 @@ import net.minecraft.block.BlockBeetroot; import net.minecraft.block.BlockCrops; import net.minecraft.block.BlockDirt; import net.minecraft.block.BlockNetherWart; +import net.minecraft.block.BlockOldLog; +import net.minecraft.block.BlockPlanks; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -37,6 +39,11 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import forestry.Forestry; +import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.arboriculture.IFruitProvider; +import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.ITreeRoot; +import forestry.api.arboriculture.TreeManager; import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.CircuitSocketType; import forestry.api.circuits.ICircuitLayout; @@ -44,6 +51,7 @@ import forestry.api.core.ForestryAPI; import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmRegistry; import forestry.api.modules.ForestryModule; +import forestry.arboriculture.genetics.alleles.AlleleFruits; import forestry.core.ModuleCore; import forestry.core.blocks.BlockBogEarth; import forestry.core.blocks.BlockRegistryCore; @@ -136,10 +144,10 @@ public class ModuleFarming extends BlankForestryModule { } registry.registerFarmables(ForestryFarmIdentifier.CROPS, - new FarmableAgingCrop(new ItemStack(Items.WHEAT_SEEDS), Blocks.WHEAT, BlockCrops.AGE, 7, 0), - new FarmableAgingCrop(new ItemStack(Items.POTATO), Blocks.POTATOES, BlockCrops.AGE, 7, 0), - new FarmableAgingCrop(new ItemStack(Items.CARROT), Blocks.CARROTS, BlockCrops.AGE, 7, 0), - new FarmableAgingCrop(new ItemStack(Items.BEETROOT_SEEDS), Blocks.BEETROOTS, BlockBeetroot.BEETROOT_AGE, 3, 0)); + new FarmableAgingCrop(new ItemStack(Items.WHEAT_SEEDS), Blocks.WHEAT, new ItemStack(Items.WHEAT), BlockCrops.AGE, 7, 0), + new FarmableAgingCrop(new ItemStack(Items.POTATO), Blocks.POTATOES, new ItemStack(Items.POTATO), BlockCrops.AGE, 7, 0), + new FarmableAgingCrop(new ItemStack(Items.CARROT), Blocks.CARROTS, new ItemStack(Items.CARROT), BlockCrops.AGE, 7, 0), + new FarmableAgingCrop(new ItemStack(Items.BEETROOT_SEEDS), Blocks.BEETROOTS, new ItemStack(Items.BEETROOT), BlockBeetroot.BEETROOT_AGE, 3, 0)); IBlockState plantedBrownMushroom = blocks.mushroom.getDefaultState().withProperty(BlockMushroom.VARIANT, BlockMushroom.MushroomType.BROWN); registry.registerFarmables(ForestryFarmIdentifier.SHROOM, new FarmableVanillaMushroom(new ItemStack(Blocks.BROWN_MUSHROOM), plantedBrownMushroom, Blocks.BROWN_MUSHROOM_BLOCK)); @@ -192,6 +200,7 @@ public class ModuleFarming extends BlankForestryModule { IFarmRegistry registry = FarmRegistry.getInstance(); BlockRegistryCore coreBlocks = ModuleCore.getBlocks(); + ItemRegistryCore coreItems = ModuleCore.getItems(); IFarmProperties arborealFarm = registry.registerLogic(ForestryFarmIdentifier.ARBOREAL, FarmLogicArboreal::new); IFarmProperties cropsFarm = registry.registerLogic(ForestryFarmIdentifier.CROPS, FarmLogicCrops::new); @@ -209,6 +218,7 @@ public class ModuleFarming extends BlankForestryModule { Circuits.farmArborealManual = new CircuitFarmLogic("manualArboreal", arborealFarm, true); arborealFarm.registerSoil(new ItemStack(Blocks.DIRT), coreBlocks.humus.getDefaultState()); arborealFarm.registerSoil(new ItemStack(coreBlocks.humus), coreBlocks.humus.getDefaultState()); + arborealFarm.addProducts(new ItemStack(Blocks.SAND)); Circuits.farmShroomManaged = new CircuitFarmLogic("managedShroom", mushroomFarm, false); Circuits.farmShroomManual = new CircuitFarmLogic("manualShroom", mushroomFarm, true); @@ -219,6 +229,7 @@ public class ModuleFarming extends BlankForestryModule { Circuits.farmPeatManaged = new CircuitFarmLogic("managedPeat", peatFarm, false); Circuits.farmPeatManual = new CircuitFarmLogic("manualPeat", peatFarm, true); peatFarm.registerSoil(coreBlocks.bogEarth.get(BlockBogEarth.SoilType.BOG_EARTH, 1), coreBlocks.bogEarth.getDefaultState()); + peatFarm.addProducts(new ItemStack(coreItems.peat), new ItemStack(Blocks.DIRT)); Circuits.farmCropsManaged = new CircuitFarmLogic("managedCrops", cropsFarm, false); Circuits.farmCropsManual = new CircuitFarmLogic("manualCrops", cropsFarm, true); @@ -231,6 +242,14 @@ public class ModuleFarming extends BlankForestryModule { Circuits.farmOrchardManaged = new CircuitFarmLogic("managedOrchard", orchardFarm, false); Circuits.farmOrchardManual = new CircuitFarmLogic("manualOrchard", orchardFarm, true); + /*for(IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles(EnumTreeChromosome.FRUITS)){ + if(allele instanceof IAlleleFruit){ + IAlleleFruit alleleFruit = (IAlleleFruit) allele; + IFruitProvider fruitProvider = alleleFruit.getProvider(); + orchardFarm.addProducts(fruitProvider.getProducts().keySet()); + orchardFarm.addProducts(fruitProvider.getSpecialty().keySet()); + } + }*/ Circuits.farmSucculentManaged = new CircuitFarmLogic("managedSucculent", succulentFarm, false); Circuits.farmSucculentManual = new CircuitFarmLogic("manualSucculent", succulentFarm, true); @@ -246,6 +265,10 @@ public class ModuleFarming extends BlankForestryModule { Circuits.farmCocoaManaged = new CircuitFarmLogic("managedCocoa", cocoaFarm, false); Circuits.farmCocoaManual = new CircuitFarmLogic("manualCocoa", cocoaFarm, true); + cocoaFarm.registerSoil(new ItemStack(Blocks.LOG, 1, 3), + Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.JUNGLE)); + cocoaFarm.addGermlings(new ItemStack(Items.DYE, 1, 3)); + cocoaFarm.addProducts(new ItemStack(Items.DYE, 1, 3)); Circuits.farmEnderManaged = new CircuitFarmLogic("managedEnder", enderFarm, false); Circuits.farmEnderManual = new CircuitFarmLogic("manualEnder", enderFarm, true); @@ -346,6 +369,24 @@ public class ModuleFarming extends BlankForestryModule { ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.ENDER, 1), Circuits.farmEnderManual); } + @Override + public void postInit() { + IFarmProperties orchardFarm = FarmRegistry.getInstance().getProperties(ForestryFarmIdentifier.ORCHARD); + if(orchardFarm != null && ModuleHelper.isEnabled(ForestryModuleUids.ARBORICULTURE)) { + ITreeRoot treeRoot = TreeManager.treeRoot; + if (treeRoot != null) { + for (ITree tree : treeRoot.getIndividualTemplates()) { + IFruitProvider fruitProvider = tree.getGenome().getFruitProvider(); + if (fruitProvider != AlleleFruits.fruitNone.getProvider()) { + orchardFarm.addGermlings(treeRoot.getMemberStack(tree, EnumGermlingType.SAPLING)); + orchardFarm.addProducts(fruitProvider.getProducts().keySet()); + orchardFarm.addProducts(fruitProvider.getSpecialty().keySet()); + } + } + } + } + } + @Override public void getHiddenItems(List hiddenItems) { // mushrooms are a workaround for the farm and should not be obtainable diff --git a/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java b/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java index 7b21d0e55..a3e4e9715 100755 --- a/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java +++ b/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java @@ -13,12 +13,13 @@ package forestry.farming.circuits; import javax.annotation.Nullable; import forestry.api.farming.FarmDirection; +import forestry.api.farming.IFarmCircuit; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmLogic; import forestry.api.farming.IFarmProperties; import forestry.core.circuits.Circuit; -public class CircuitFarmLogic extends Circuit { +public class CircuitFarmLogic extends Circuit implements IFarmCircuit { private final IFarmLogic logic; private boolean isManual = false; @@ -44,10 +45,7 @@ public class CircuitFarmLogic extends Circuit { return logic.getName(); } - /** - * @deprecated TODO: Remove this method in 1.13 - */ - @Deprecated + @Override public IFarmLogic getFarmLogic() { return logic; } diff --git a/src/main/java/forestry/farming/compat/FarmingInfoRecipeCategory.java b/src/main/java/forestry/farming/compat/FarmingInfoRecipeCategory.java new file mode 100644 index 000000000..6cf20676a --- /dev/null +++ b/src/main/java/forestry/farming/compat/FarmingInfoRecipeCategory.java @@ -0,0 +1,101 @@ +package forestry.farming.compat; + +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import forestry.core.config.Constants; +import forestry.core.recipes.jei.ForestryRecipeCategory; + +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.ingredients.IIngredients; + +public class FarmingInfoRecipeCategory extends ForestryRecipeCategory { + public static final String UID = "forestry.farming"; + private final IDrawable slotDrawable; + private final IDrawable addition; + private final IDrawable arrow; + + public FarmingInfoRecipeCategory(IGuiHelper guiHelper) { + super(guiHelper.createBlankDrawable(144, 90), "for.jei.farming.name"); + this.slotDrawable = guiHelper.getSlotDrawable(); + ResourceLocation resourceLocation = new ResourceLocation(Constants.MOD_ID, "textures/gui/jei/recipes.png"); + addition = guiHelper.createDrawable(resourceLocation, 44, 0, 15, 15); + arrow = guiHelper.createDrawable(resourceLocation, 59, 0, 15, 15); + } + + @Override + public String getUid() { + return UID; + } + + @Override + public void drawExtras(Minecraft minecraft) { + slotDrawable.draw(minecraft, 63, 18); + for(int x = 0;x < 2;x++){ + for(int y = 0;y < 2;y++){ + slotDrawable.draw(minecraft, x * 18, 54 + y * 18); + } + } + + addition.draw(minecraft, 37, 64); + + for(int x = 0;x < 2;x++){ + for(int y = 0;y < 2;y++){ + slotDrawable.draw(minecraft, 54 + x * 18, 54 + y * 18); + } + } + + arrow.draw(minecraft, 91, 64); + + for(int x = 0;x < 2;x++){ + for(int y = 0;y < 2;y++){ + slotDrawable.draw(minecraft, 108 + x * 18, 54 + y * 18); + } + } + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, FarmingInfoRecipeWrapper recipeWrapper, IIngredients ingredients) { + IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); + List> inputs = ingredients.getInputs(ItemStack.class); + List> outputs = ingredients.getOutputs(ItemStack.class); + guiItemStacks.init(0, true, 63, 18); + guiItemStacks.set(0, inputs.get(0)); + for(int x = 0;x < 2;x++){ + for(int y = 0;y < 2;y++){ + int index = 1 + x + y * 2; + guiItemStacks.init(index, true, x * 18, 54 + y * 18); + if(inputs.size() > index) { + List stack = inputs.get(index); + guiItemStacks.set(index, stack); + } + } + } + for(int x = 0;x < 2;x++){ + for(int y = 0;y < 2;y++){ + int index = 5 + x + y * 2; + guiItemStacks.init(index, true, 54 +x * 18, 54 + y * 18); + if(inputs.size() > index) { + List stack = inputs.get(index); + guiItemStacks.set(index, stack); + } + } + } + for(int x = 0;x < 2;x++){ + for(int y = 0;y < 2;y++){ + int index = 9 + x + y * 2; + guiItemStacks.init(index, false, 108 +x * 18, 54 + y * 18); + if(outputs.size() > x + y * 2) { + List stack = outputs.get(x + y * 2); + guiItemStacks.set(index, stack); + } + } + } + } +} diff --git a/src/main/java/forestry/farming/compat/FarmingInfoRecipeMaker.java b/src/main/java/forestry/farming/compat/FarmingInfoRecipeMaker.java new file mode 100644 index 000000000..8c5ec6abe --- /dev/null +++ b/src/main/java/forestry/farming/compat/FarmingInfoRecipeMaker.java @@ -0,0 +1,33 @@ +package forestry.farming.compat; + +import java.util.ArrayList; +import java.util.List; + +import forestry.api.circuits.ICircuit; +import forestry.api.farming.IFarmCircuit; +import forestry.api.farming.IFarmLogic; +import forestry.api.farming.IFarmProperties; +import forestry.core.circuits.CircuitRecipe; +import forestry.core.circuits.SolderManager; + +public class FarmingInfoRecipeMaker { + + private FarmingInfoRecipeMaker() { + } + + public static List getRecipes() { + List recipes = new ArrayList<>(); + for(CircuitRecipe circuitRecipe : SolderManager.getRecipes()){ + ICircuit circuit = circuitRecipe.getCircuit(); + if(circuit instanceof IFarmCircuit){ + IFarmCircuit farmCircuit = (IFarmCircuit) circuit; + IFarmLogic logic = farmCircuit.getFarmLogic(); + if(logic.isManual()) { + IFarmProperties properties = logic.getProperties(); + recipes.add(new FarmingInfoRecipeWrapper(circuitRecipe.getResource(), properties, circuit)); + } + } + } + return recipes; + } +} diff --git a/src/main/java/forestry/farming/compat/FarmingInfoRecipeWrapper.java b/src/main/java/forestry/farming/compat/FarmingInfoRecipeWrapper.java new file mode 100644 index 000000000..78d6542bb --- /dev/null +++ b/src/main/java/forestry/farming/compat/FarmingInfoRecipeWrapper.java @@ -0,0 +1,102 @@ +package forestry.farming.compat; + +import javax.annotation.Nullable; +import java.awt.Color; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.item.ItemStack; + +import forestry.api.circuits.ICircuit; +import forestry.api.farming.IFarmProperties; +import forestry.api.farming.IFarmableInfo; +import forestry.api.farming.ISoil; +import forestry.core.utils.Translator; + +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; + +public class FarmingInfoRecipeWrapper implements IRecipeWrapper { + private final ItemStack tube; + private final IFarmProperties properties; + private final ICircuit circuit; + + public FarmingInfoRecipeWrapper(ItemStack tube, IFarmProperties properties, ICircuit circuit) { + this.tube = tube; + this.properties = properties; + this.circuit = circuit; + } + + @Override + public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { + FontRenderer fontRenderer = minecraft.fontRenderer; + String circuitName = Translator.translateToLocal(circuit.getUnlocalizedName()); + fontRenderer.drawString(circuitName, (recipeWidth - fontRenderer.getStringWidth(circuitName)) / 2, 3, Color.darkGray.getRGB()); + String soilName = Translator.translateToLocal("for.jei.farming.soil"); + fontRenderer.drawString(soilName, 18 - (fontRenderer.getStringWidth(soilName)) / 2, 45, Color.darkGray.getRGB()); + String germlingsName = Translator.translateToLocal("for.jei.farming.germlings"); + fontRenderer.drawString(germlingsName, (recipeWidth - fontRenderer.getStringWidth(germlingsName)) / 2, 45, Color.darkGray.getRGB()); + String productsName = Translator.translateToLocal("for.jei.farming.products"); + fontRenderer.drawString(productsName, 126 - (fontRenderer.getStringWidth(productsName)) / 2, 45, Color.darkGray.getRGB()); + } + + @Override + public void getIngredients(IIngredients ingredients) { + List> inputStacks = new ArrayList<>(9); + List> outputStacks = new ArrayList<>(4); + inputStacks.add(Collections.singletonList(tube)); + List soils = new ArrayList<>(properties.getSoils()); + splitItems(inputStacks, 1, soils, ISoil::getResource); + Collection farmableInfo = properties.getFarmableInfo(); + List germlings = farmableInfo.stream() + .map(IFarmableInfo::getGermlings) + .flatMap(Collection::stream) + .collect(Collectors.toList()); + splitItems(inputStacks, 5, germlings, item -> item); + List productions = farmableInfo.stream() + .map(IFarmableInfo::getProducts) + .flatMap(Collection::stream) + .collect(Collectors.toList()); + splitItems(outputStacks, 0, productions, item -> item); + ingredients.setInputLists(ItemStack.class, inputStacks); + ingredients.setOutputLists(ItemStack.class, outputStacks); + } + + private static void splitItems(List> items, int startIndex, List values, Function itemFunction){ + int count = values.size(); + if(count == 0 || count % 4 != 0) { + count += (4 - count % 4); + } + for(int i = 0;i < count;i++){ + int index = startIndex + i % 4; + ItemStack stack; + if(values.size() > i){ + stack = itemFunction.apply(values.get(i)); + }else{ + stack = null; + } + addItemToList(items, index, stack); + } + } + + private static void addItemToList(List> items, int index, @Nullable ItemStack stack){ + List itemList; + if(items.size() > index){ + itemList = items.get(index); + if(itemList == null){ + itemList = new ArrayList<>(); + items.set(index, itemList); + } + }else{ + itemList = new ArrayList<>(); + items.add(itemList); + } + itemList.add(stack); + } +} diff --git a/src/main/java/forestry/farming/compat/FarmingJeiPlugin.java b/src/main/java/forestry/farming/compat/FarmingJeiPlugin.java index 407ef8c10..4f1c64cf6 100644 --- a/src/main/java/forestry/farming/compat/FarmingJeiPlugin.java +++ b/src/main/java/forestry/farming/compat/FarmingJeiPlugin.java @@ -3,18 +3,45 @@ package forestry.farming.compat; import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; +import forestry.core.ModuleCore; +import forestry.core.circuits.EnumCircuitBoardType; import forestry.farming.ModuleFarming; import forestry.farming.blocks.BlockRegistryFarming; import forestry.farming.models.EnumFarmBlockTexture; import forestry.modules.ForestryModuleUids; import forestry.modules.ModuleHelper; +import mezz.jei.api.IGuiHelper; import mezz.jei.api.IModPlugin; +import mezz.jei.api.IModRegistry; import mezz.jei.api.ISubtypeRegistry; import mezz.jei.api.JEIPlugin; +import mezz.jei.api.recipe.IRecipeCategoryRegistration; @JEIPlugin public class FarmingJeiPlugin implements IModPlugin { + + @Override + public void register(IModRegistry registry) { + if (!ModuleHelper.isEnabled(ForestryModuleUids.FARMING)) { + return; + } + + registry.addRecipes(FarmingInfoRecipeMaker.getRecipes(), FarmingInfoRecipeCategory.UID); + + registry.addRecipeCatalyst(ModuleCore.getItems().circuitboards.get(EnumCircuitBoardType.INTRICATE), FarmingInfoRecipeCategory.UID); + } + + @Override + public void registerCategories(IRecipeCategoryRegistration registry) { + if (!ModuleHelper.isEnabled(ForestryModuleUids.FARMING)) { + return; + } + + IGuiHelper guiHelper = registry.getJeiHelpers().getGuiHelper(); + registry.addRecipeCategories(new FarmingInfoRecipeCategory(guiHelper)); + } + @Override public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) { if (!ModuleHelper.isEnabled(ForestryModuleUids.FARMING)) { diff --git a/src/main/java/forestry/farming/logic/FakeFarmProperties.java b/src/main/java/forestry/farming/logic/FakeFarmProperties.java index 6cf8aa652..5106df90d 100644 --- a/src/main/java/forestry/farming/logic/FakeFarmProperties.java +++ b/src/main/java/forestry/farming/logic/FakeFarmProperties.java @@ -9,6 +9,7 @@ import net.minecraft.item.ItemStack; import forestry.api.farming.IFarmLogic; import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmable; +import forestry.api.farming.IFarmableInfo; import forestry.api.farming.ISoil; public class FakeFarmProperties implements IFarmProperties { @@ -26,6 +27,26 @@ public class FakeFarmProperties implements IFarmProperties { public void registerSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { } + @Override + public void addGermlings(ItemStack... germlings) { + + } + + @Override + public void addGermlings(Collection germlings) { + + } + + @Override + public void addProducts(Collection products) { + + } + + @Override + public void addProducts(ItemStack... products) { + + } + @Override public boolean isAcceptedSoil(IBlockState blockState) { return false; @@ -46,6 +67,11 @@ public class FakeFarmProperties implements IFarmProperties { return Collections.emptySet(); } + @Override + public Collection getFarmableInfo() { + return Collections.emptySet(); + } + @Override public IFarmLogic getLogic(boolean manuel) { return logic; diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index 6593f21ba..9b099c7a8 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -67,6 +67,16 @@ public abstract class FarmLogic implements IFarmLogic { return this; } + @Override + public IFarmProperties getProperties() { + return properties; + } + + @Override + public boolean isManual() { + return isManual; + } + @Override public Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent) { Stack crops = new Stack<>(); diff --git a/src/main/java/forestry/farming/logic/FarmProperties.java b/src/main/java/forestry/farming/logic/FarmProperties.java index f83d02774..17888c66e 100644 --- a/src/main/java/forestry/farming/logic/FarmProperties.java +++ b/src/main/java/forestry/farming/logic/FarmProperties.java @@ -14,6 +14,7 @@ import net.minecraft.item.ItemStack; import forestry.api.farming.IFarmLogic; import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmable; +import forestry.api.farming.IFarmableInfo; import forestry.api.farming.ISoil; import forestry.farming.FarmRegistry; @@ -22,14 +23,17 @@ public final class FarmProperties implements IFarmProperties { private final Set farmablesIdentifiers; private final IFarmLogic manualLogic; private final IFarmLogic managedLogic; - + private final IFarmableInfo defaultInfo; @Nullable private Collection farmables; + @Nullable + private Collection farmableInfo; - public FarmProperties(BiFunction logicFactory, Set farmablesIdentifiers) { + public FarmProperties(BiFunction logicFactory, Set farmablesIdentifiers, String identifier) { this.farmablesIdentifiers = farmablesIdentifiers; this.manualLogic = logicFactory.apply(this, true); this.managedLogic = logicFactory.apply(this, false); + this.defaultInfo = FarmRegistry.getInstance().getFarmableInfo(identifier); } @Override @@ -48,6 +52,16 @@ public final class FarmProperties implements IFarmProperties { return farmables; } + @Override + public Collection getFarmableInfo() { + if(farmableInfo == null){ + farmableInfo = farmablesIdentifiers.stream() + .map(FarmRegistry.getInstance()::getFarmableInfo) + .collect(Collectors.toSet()); + } + return farmableInfo; + } + @Override public IFarmLogic getLogic(boolean manuel) { return manuel ? manualLogic : managedLogic; @@ -58,6 +72,26 @@ public final class FarmProperties implements IFarmProperties { soils.add(new Soil(resource, soilState, hasMetaData)); } + @Override + public void addGermlings(ItemStack... germlings) { + defaultInfo.addGermlings(germlings); + } + + @Override + public void addGermlings(Collection germlings) { + defaultInfo.addGermlings(germlings); + } + + @Override + public void addProducts(ItemStack... products) { + defaultInfo.addProducts(products); + } + + @Override + public void addProducts(Collection products) { + defaultInfo.addProducts(products); + } + @Override public boolean isAcceptedSoil(IBlockState ground) { for (ISoil soil : soils) { diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java b/src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java index ab1af6c98..aa20ba5c6 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java @@ -14,6 +14,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; +import forestry.api.farming.IFarmableInfo; import forestry.core.utils.BlockUtil; import forestry.farming.logic.crops.CropDestroy; @@ -27,21 +28,40 @@ public class FarmableAgingCrop implements IFarmable { protected final int minHarvestAge; @Nullable protected final Integer replantAge; + protected final ItemStack[] products; public FarmableAgingCrop(ItemStack germling, Block cropBlock, IProperty ageProperty, int minHarvestAge) { - this(germling, cropBlock, ageProperty, minHarvestAge, null); + this(germling, cropBlock, new ItemStack[0], ageProperty, minHarvestAge, null); } public FarmableAgingCrop(ItemStack germling, Block cropBlock, IProperty ageProperty, int minHarvestAge, @Nullable Integer replantAge) { + this(germling, cropBlock, new ItemStack[0], ageProperty, minHarvestAge, replantAge); + } + + public FarmableAgingCrop(ItemStack germling, Block cropBlock, ItemStack product, IProperty ageProperty, int minHarvestAge) { + this(germling, cropBlock, new ItemStack[]{product}, ageProperty, minHarvestAge, null); + } + + public FarmableAgingCrop(ItemStack germling, Block cropBlock, ItemStack product, IProperty ageProperty, int minHarvestAge, @Nullable Integer replantAge) { + this(germling, cropBlock, new ItemStack[]{product}, ageProperty, minHarvestAge, replantAge); + } + + public FarmableAgingCrop(ItemStack germling, Block cropBlock, ItemStack[] products, IProperty ageProperty, int minHarvestAge) { + this(germling, cropBlock, products, ageProperty, minHarvestAge, null); + } + + public FarmableAgingCrop(ItemStack germling, Block cropBlock, ItemStack[] products, IProperty ageProperty, int minHarvestAge, @Nullable Integer replantAge) { Preconditions.checkNotNull(germling); Preconditions.checkNotNull(cropBlock); Preconditions.checkNotNull(ageProperty); + Preconditions.checkNotNull(products); this.germling = germling; this.cropBlock = cropBlock; this.ageProperty = ageProperty; this.minHarvestAge = minHarvestAge; this.replantAge = replantAge; + this.products = products; } @Override @@ -77,6 +97,12 @@ public class FarmableAgingCrop implements IFarmable { return ItemStack.areItemsEqual(germling, itemstack); } + @Override + public void addInformation(IFarmableInfo info) { + info.addProducts(products); + info.addGermlings(germling); + } + @Override public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { IBlockState plantedState = cropBlock.getDefaultState().withProperty(ageProperty, 0); diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableBase.java b/src/main/java/forestry/farming/logic/farmables/FarmableBase.java index 857a34ac5..0f2c4238d 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableBase.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableBase.java @@ -8,6 +8,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; +import forestry.api.farming.IFarmableInfo; import forestry.core.utils.BlockUtil; import forestry.farming.logic.crops.CropDestroy; @@ -44,6 +45,11 @@ public abstract class FarmableBase implements IFarmable { return ItemStack.areItemsEqual(germling, itemstack); } + @Override + public void addInformation(IFarmableInfo info) { + info.addGermlings(germling); + } + @Override public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { return BlockUtil.setBlockWithPlaceSound(world, pos, plantedState); diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableChorus.java b/src/main/java/forestry/farming/logic/farmables/FarmableChorus.java index b68b874f4..3f125b7ec 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableChorus.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableChorus.java @@ -13,6 +13,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; +import forestry.api.farming.IFarmableInfo; import forestry.core.utils.BlockUtil; import forestry.farming.logic.crops.CropChorusFlower; @@ -51,6 +52,12 @@ public class FarmableChorus implements IFarmable { return ItemStack.areItemsEqual(germling, itemstack); } + @Override + public void addInformation(IFarmableInfo info) { + info.addGermlings(germling); + info.addProducts(germling, fruit); + } + @Override public boolean isWindfall(ItemStack itemstack) { return ItemStack.areItemsEqual(fruit, itemstack); diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableCocoa.java b/src/main/java/forestry/farming/logic/farmables/FarmableCocoa.java index 1c35f2788..d403e7d28 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableCocoa.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableCocoa.java @@ -27,7 +27,7 @@ public class FarmableCocoa extends FarmableAgingCrop { public static final int COCOA_META = 3; public FarmableCocoa() { - super(new ItemStack(COCOA_SEED, 1, COCOA_META), Blocks.COCOA, BlockCocoa.AGE, 2, null); + super(new ItemStack(COCOA_SEED, 1, COCOA_META), Blocks.COCOA, new ItemStack(COCOA_SEED, 1, COCOA_META), BlockCocoa.AGE, 2, null); } @Override diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableGourd.java b/src/main/java/forestry/farming/logic/farmables/FarmableGourd.java index c77d7a7c9..2470d7b23 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableGourd.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableGourd.java @@ -19,6 +19,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; +import forestry.api.farming.IFarmableInfo; import forestry.core.utils.BlockUtil; import forestry.farming.logic.crops.CropDestroy; @@ -53,6 +54,12 @@ public class FarmableGourd implements IFarmable { return ItemStack.areItemsEqual(itemstack, seed); } + @Override + public void addInformation(IFarmableInfo info) { + info.addGermlings(seed); + info.addProducts(new ItemStack(fruit)); + } + @Override public boolean isWindfall(ItemStack itemstack) { return false; diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableInfo.java b/src/main/java/forestry/farming/logic/farmables/FarmableInfo.java new file mode 100644 index 000000000..7424ca473 --- /dev/null +++ b/src/main/java/forestry/farming/logic/farmables/FarmableInfo.java @@ -0,0 +1,43 @@ +package forestry.farming.logic.farmables; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import forestry.api.farming.IFarmableInfo; + +public class FarmableInfo implements IFarmableInfo { + private final List germlings = new ArrayList<>(); + private final List products = new ArrayList<>(); + private final String identifier; + + public FarmableInfo(String identifier) { + this.identifier = identifier; + } + + public String getIdentifier() { + return identifier; + } + + @Override + public void addGermlings(Collection germlings){ + this.germlings.addAll(germlings); + } + + @Override + public Collection getGermlings() { + return germlings; + } + + @Override + public void addProducts(Collection products){ + this.products.addAll(products); + } + + @Override + public Collection getProducts() { + return products; + } +} diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java b/src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java index b615c47aa..e84f86577 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java @@ -10,6 +10,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; +import forestry.api.farming.IFarmableInfo; import forestry.core.network.packets.PacketFXSignal; import forestry.core.utils.NetworkUtil; import forestry.farming.logic.crops.CropDestroy; @@ -57,6 +58,12 @@ public class FarmableRusticSapling implements IFarmable { return germling == itemstack.getItem(); } + @Override + public void addInformation(IFarmableInfo info) { + info.addGermlings(new ItemStack(germling)); + info.addProducts(windfall); + } + @Override public boolean isWindfall(ItemStack itemstack) { for (ItemStack drop : windfall) { diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableSapling.java b/src/main/java/forestry/farming/logic/farmables/FarmableSapling.java index fed60f725..44f5055f6 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableSapling.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableSapling.java @@ -12,17 +12,21 @@ package forestry.farming.logic.farmables; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; +import forestry.api.farming.IFarmableInfo; import forestry.core.network.packets.PacketFXSignal; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.NetworkUtil; @@ -82,6 +86,23 @@ public class FarmableSapling implements IFarmable { return ItemStack.areItemsEqual(germling, itemstack); } + @Override + public void addInformation(IFarmableInfo info) { + NonNullList germlings = NonNullList.create(); + if(ignoreMetadata){ + Item germlingItem = germling.getItem(); + CreativeTabs tab = germlingItem.getCreativeTab(); + if(tab != null) { + germlingItem.getSubItems(tab, germlings); + } + } + if(germlings.isEmpty()){ + germlings.add(germling); + } + info.addGermlings(germlings); + info.addProducts(windfall); + } + @Override public boolean isWindfall(ItemStack itemstack) { for (ItemStack drop : windfall) { diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableStacked.java b/src/main/java/forestry/farming/logic/farmables/FarmableStacked.java index 6b0e6d8f6..e16607ffb 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableStacked.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableStacked.java @@ -19,6 +19,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; +import forestry.api.farming.IFarmableInfo; import forestry.core.utils.BlockUtil; import forestry.farming.logic.crops.CropDestroy; @@ -26,9 +27,15 @@ public class FarmableStacked implements IFarmable { protected final ItemStack germling; protected final Block cropBlock; protected final int matureHeight; + protected final ItemStack fruit; public FarmableStacked(ItemStack germling, Block cropBlock, int matureHeight) { + this(germling, germling, cropBlock, matureHeight); + } + + public FarmableStacked(ItemStack germling, ItemStack fruit, Block cropBlock, int matureHeight) { this.germling = germling; + this.fruit = fruit; this.cropBlock = cropBlock; this.matureHeight = matureHeight; } @@ -54,6 +61,12 @@ public class FarmableStacked implements IFarmable { return ItemStack.areItemsEqual(germling, itemstack); } + @Override + public void addInformation(IFarmableInfo info) { + info.addGermlings(germling); + info.addProducts(fruit); + } + @Override public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { return BlockUtil.setBlockWithPlaceSound(world, pos, cropBlock.getDefaultState()); diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableVanillaMushroom.java b/src/main/java/forestry/farming/logic/farmables/FarmableVanillaMushroom.java index fe8d6376a..b8be28b23 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableVanillaMushroom.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableVanillaMushroom.java @@ -18,6 +18,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmableInfo; import forestry.core.utils.BlockUtil; import forestry.farming.logic.crops.CropDestroy; @@ -45,4 +46,9 @@ public class FarmableVanillaMushroom extends FarmableBase { } return BlockUtil.setBlockWithPlaceSound(world, pos, plantedState); } + + @Override + public void addInformation(IFarmableInfo info) { + info.addProducts(germling); + } } diff --git a/src/main/java/forestry/farming/multiblock/FarmController.java b/src/main/java/forestry/farming/multiblock/FarmController.java index c5e78195c..704c292c7 100755 --- a/src/main/java/forestry/farming/multiblock/FarmController.java +++ b/src/main/java/forestry/farming/multiblock/FarmController.java @@ -679,6 +679,11 @@ public class FarmController extends RectangularMultiblockControllerBase implemen return CircuitSocketType.FARM; } + @Override + public boolean canPlantSoil(boolean manual) { + return true; + } + @Override public boolean isValidPlatform(World world, BlockPos pos) { IBlockState blockState = world.getBlockState(pos); diff --git a/src/main/java/forestry/plugins/PluginExtraUtilities.java b/src/main/java/forestry/plugins/PluginExtraUtilities.java index edae1c270..e9fe6ff7f 100644 --- a/src/main/java/forestry/plugins/PluginExtraUtilities.java +++ b/src/main/java/forestry/plugins/PluginExtraUtilities.java @@ -18,6 +18,7 @@ import java.util.Set; import net.minecraft.block.Block; import net.minecraft.block.properties.IProperty; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -58,7 +59,7 @@ public class PluginExtraUtilities extends CompatPlugin { if (Config.isExUtilRedOrchidEnabled() && redOrchid != null) { Item item = Item.getItemFromBlock(redOrchid); - registerFarmable(redOrchid, item, ForestryFarmIdentifier.ORCHID); + registerFarmable(redOrchid, item, new ItemStack(Items.REDSTONE), ForestryFarmIdentifier.ORCHID); IFarmProperties orchidFarm = FarmRegistry.getInstance().registerLogic(ForestryFarmIdentifier.ORCHID, FarmLogicRedOrchid::new); orchidFarm.registerSoil(new ItemStack(Blocks.REDSTONE_ORE), Blocks.REDSTONE_ORE.getDefaultState()); @@ -72,7 +73,7 @@ public class PluginExtraUtilities extends CompatPlugin { if (Config.isExUtilEnderLilyEnabled() && enderLilly != null) { Item item = Item.getItemFromBlock(enderLilly); - registerFarmable(enderLilly, item, ForestryFarmIdentifier.ENDER); + registerFarmable(enderLilly, item, new ItemStack(Items.ENDER_PEARL), ForestryFarmIdentifier.ENDER); } } @@ -94,7 +95,7 @@ public class PluginExtraUtilities extends CompatPlugin { } } - private void registerFarmable(Block plantBlock, Item plantItem, String identifier){ + private void registerFarmable(Block plantBlock, Item plantItem, ItemStack product, String identifier){ IProperty growthProperty = BlockUtil.getProperty(plantBlock, "growth", Integer.class); if (growthProperty == null) { Log.error("Could not find the growth property of {}.", plantBlock.getLocalizedName()); @@ -102,7 +103,7 @@ public class PluginExtraUtilities extends CompatPlugin { IFarmRegistry registry = FarmRegistry.getInstance(); int harvestAge = Collections.max(growthProperty.getAllowedValues()); int replantAge = plantBlock.getDefaultState().getValue(growthProperty); - registry.registerFarmables(identifier, new FarmableAgingCrop(new ItemStack(plantItem), plantBlock, growthProperty, harvestAge, replantAge)); + registry.registerFarmables(identifier, new FarmableAgingCrop(new ItemStack(plantItem), plantBlock, product, growthProperty, harvestAge, replantAge)); } } } diff --git a/src/main/java/forestry/plugins/PluginRoots.java b/src/main/java/forestry/plugins/PluginRoots.java index 87e3e1ce3..7c987e275 100644 --- a/src/main/java/forestry/plugins/PluginRoots.java +++ b/src/main/java/forestry/plugins/PluginRoots.java @@ -58,7 +58,7 @@ public class PluginRoots extends CompatPlugin { RecipeManagers.squeezerManager.addRecipe(10, fruit, Fluids.JUICE.getFluid(juiceAmount)); } if (seed != null && block != null) { - farmRegistry.registerFarmables(ForestryFarmIdentifier.CROPS, new FarmableAgingCrop(seed, block, BlockCrops.AGE, 7, 0)); + farmRegistry.registerFarmables(ForestryFarmIdentifier.CROPS, new FarmableAgingCrop(seed, block, fruit, BlockCrops.AGE, 7, 0)); } } } diff --git a/src/main/java/forestry/plugins/PluginRustic.java b/src/main/java/forestry/plugins/PluginRustic.java index a116018db..0851a26af 100644 --- a/src/main/java/forestry/plugins/PluginRustic.java +++ b/src/main/java/forestry/plugins/PluginRustic.java @@ -73,7 +73,7 @@ public class PluginRustic extends CompatPlugin { RecipeManagers.squeezerManager.addRecipe(10, fruit, Fluids.JUICE.getFluid(juiceAmount / 25)); } if (seeds != null && block != null) { - farmRegistry.registerFarmables(ForestryFarmIdentifier.ORCHARD, new FarmableAgingCrop(seeds, block, cropAge, 3, 2)); + farmRegistry.registerFarmables(ForestryFarmIdentifier.ORCHARD, new FarmableAgingCrop(seeds, block, fruit, cropAge, 3, 2)); } } } diff --git a/src/main/resources/assets/forestry/lang/de_de.lang b/src/main/resources/assets/forestry/lang/de_de.lang index 82e345971..d219efd52 100644 --- a/src/main/resources/assets/forestry/lang/de_de.lang +++ b/src/main/resources/assets/forestry/lang/de_de.lang @@ -1787,5 +1787,9 @@ for.jei.rainmaker.causes.rain=Sorgt für Regen for.jei.rainmaker.stops.rain=Stoppt Regen for.jei.rainmaker.speed=Geschw.: %s for.jei.rainmaker.duration=Dauer: %s ticks -tile.for.charcoal.pile.wall.name= Holzkohlehaufen +for.jei.farming.name=Farming +for.jei.farming.soil=Erdreich +for.jei.farming.germlings=Setzling +for.jei.farming.products=Produkte +for.jei.charcoal.pile.name=Holzkohlehaufen for.jei.chance=Chance: %s diff --git a/src/main/resources/assets/forestry/lang/en_us.lang b/src/main/resources/assets/forestry/lang/en_us.lang index 989d884cc..c2fabffdf 100644 --- a/src/main/resources/assets/forestry/lang/en_us.lang +++ b/src/main/resources/assets/forestry/lang/en_us.lang @@ -2031,6 +2031,10 @@ for.jei.rainmaker.causes.rain=Causes Rain for.jei.rainmaker.stops.rain=Stops Rain for.jei.rainmaker.speed=Speed: %s for.jei.rainmaker.duration=Duration: %s ticks -tile.for.charcoal.pile.wall.name=Charcoal Pile +for.jei.farming.name=Farming +for.jei.farming.soil=Soil +for.jei.farming.germlings=Germlings +for.jei.farming.products=Products +for.jei.charcoal.pile.name=Charcoal Pile for.jei.chance=Chance: %s for.jei.fortune=The amount of this item is affected by the fortune enchantment. diff --git a/src/main/resources/assets/forestry/textures/gui/jei/charcoal_pile_wall.png b/src/main/resources/assets/forestry/textures/gui/jei/recipes.png similarity index 55% rename from src/main/resources/assets/forestry/textures/gui/jei/charcoal_pile_wall.png rename to src/main/resources/assets/forestry/textures/gui/jei/recipes.png index 8ae9620de..a65f8b060 100644 Binary files a/src/main/resources/assets/forestry/textures/gui/jei/charcoal_pile_wall.png and b/src/main/resources/assets/forestry/textures/gui/jei/recipes.png differ