From d0363ed81c260228c2db3cf09b0cefbe0065e60e Mon Sep 17 00:00:00 2001 From: canitzp Date: Tue, 6 Oct 2020 09:01:56 +0200 Subject: [PATCH 1/5] Deleted deprecated recipe classes Signed-off-by: canitzp --- .../api/internal/IMethodHandler.java | 1 - .../api/recipe/BallOfFurReturn.java | 16 ------ .../api/recipe/CoffeeIngredient.java | 49 ------------------- .../api/recipe/CompostRecipe.java | 48 ------------------ .../api/recipe/CrusherRecipe.java | 45 ----------------- .../booklet/chapter/BookletChapterCoffee.java | 1 - .../chapter/BookletChapterCrusher.java | 1 - .../booklet/page/PageCoffeeMachine.java | 1 - .../booklet/page/PageCrusherRecipe.java | 1 - .../common/blocks/BlockCompost.java | 1 - .../common/crafting/CrusherCrafting.java | 1 - .../common/items/ItemCoffee.java | 1 - .../jei/JEIActuallyAdditionsPlugin.java | 3 -- .../coffee/CoffeeMachineRecipeWrapper.java | 1 - .../jei/compost/CompostRecipeWrapper.java | 1 - .../jei/crusher/CrusherRecipeWrapper.java | 1 - .../common/misc/apiimpl/MethodHandler.java | 1 - .../common/recipe/CrusherRecipeRegistry.java | 1 - .../common/tile/TileEntityCoffeeMachine.java | 1 - .../common/tile/TileEntityCompost.java | 1 - .../common/tile/TileEntityGrinder.java | 1 - .../common/util/RecipeUtil.java | 1 - 22 files changed, 178 deletions(-) delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/api/recipe/BallOfFurReturn.java delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/api/recipe/CoffeeIngredient.java delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/api/recipe/CrusherRecipe.java diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java index c899f56b5..d644115f4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java @@ -3,7 +3,6 @@ package de.ellpeck.actuallyadditions.api.internal; import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/BallOfFurReturn.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/BallOfFurReturn.java deleted file mode 100644 index 00861f0e2..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/BallOfFurReturn.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.ellpeck.actuallyadditions.api.recipe; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.WeightedRandom; - -@Deprecated -public class BallOfFurReturn extends WeightedRandom.Item { - - public final ItemStack returnItem; - - public BallOfFurReturn(ItemStack returnItem, int chance) { - super(chance); - this.returnItem = returnItem; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CoffeeIngredient.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CoffeeIngredient.java deleted file mode 100644 index 841fad154..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CoffeeIngredient.java +++ /dev/null @@ -1,49 +0,0 @@ -package de.ellpeck.actuallyadditions.api.recipe; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.potion.EffectInstance; - -@Deprecated -public class CoffeeIngredient { - - protected final Ingredient input; - protected final int maxAmplifier; - protected EffectInstance[] effects; - - @Deprecated - public CoffeeIngredient(ItemStack input, EffectInstance[] effects, int maxAmplifier) { - this(Ingredient.fromStacks(input), maxAmplifier, effects); - } - - public CoffeeIngredient(Ingredient input, int maxAmplifier, EffectInstance... effects) { - this.input = input; - this.effects = effects; - this.maxAmplifier = maxAmplifier; - } - - public boolean matches(ItemStack stack) { - return this.input.test(stack); - } - - public Ingredient getInput() { - return this.input; - } - - public EffectInstance[] getEffects() { - return this.effects; - } - - public boolean effect(ItemStack stack) { - return ActuallyAdditionsAPI.methodHandler.addEffectToStack(stack, this); - } - - public String getExtraText() { - return ""; - } - - public int getMaxAmplifier() { - return this.maxAmplifier; - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java deleted file mode 100644 index 7a50b80f1..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java +++ /dev/null @@ -1,48 +0,0 @@ -package de.ellpeck.actuallyadditions.api.recipe; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; - -@Deprecated -public class CompostRecipe { - - protected final Ingredient input; - protected final ItemStack output; - protected final BlockState inputDisplay; - protected final BlockState outputDisplay; - - @Deprecated - public CompostRecipe(ItemStack input, Block inputDisplay, ItemStack output, Block outputDisplay) { - this(Ingredient.fromStacks(input), inputDisplay.getDefaultState(), output, outputDisplay.getDefaultState()); - } - - public CompostRecipe(Ingredient input, BlockState inputDisplay, ItemStack output, BlockState outputDisplay) { - this.input = input; - this.output = output; - this.inputDisplay = inputDisplay; - this.outputDisplay = outputDisplay; - } - - public boolean matches(ItemStack stack) { - return this.input.test(stack); - } - - public Ingredient getInput() { - return this.input; - } - - public ItemStack getOutput() { - return this.output; - } - - public BlockState getInputDisplay() { - return this.inputDisplay; - } - - public BlockState getOutputDisplay() { - return this.outputDisplay; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CrusherRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CrusherRecipe.java deleted file mode 100644 index 812906468..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CrusherRecipe.java +++ /dev/null @@ -1,45 +0,0 @@ -package de.ellpeck.actuallyadditions.api.recipe; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; - -public class CrusherRecipe { - - protected Ingredient input; - protected ItemStack outputOne; - protected ItemStack outputTwo; - protected int outputChance; - - @Deprecated - public CrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputChance) { - this(Ingredient.fromStacks(input), outputOne, outputTwo, outputChance); - } - - public CrusherRecipe(Ingredient input, ItemStack outputOne, ItemStack outputTwo, int outputChance) { - this.input = input; - this.outputOne = outputOne; - this.outputTwo = outputTwo; - this.outputChance = outputChance; - } - - public boolean matches(ItemStack stack) { - return this.input.test(stack); - } - - public ItemStack getOutputOne() { - return this.outputOne; - } - - public ItemStack getOutputTwo() { - return this.outputTwo; - } - - public int getSecondChance() { - return this.outputChance; - } - - public Ingredient getInput() { - return this.input; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/booklet/chapter/BookletChapterCoffee.java b/src/main/java/de/ellpeck/actuallyadditions/booklet/chapter/BookletChapterCoffee.java index 4f5932856..255b6223c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/booklet/chapter/BookletChapterCoffee.java +++ b/src/main/java/de/ellpeck/actuallyadditions/booklet/chapter/BookletChapterCoffee.java @@ -7,7 +7,6 @@ import java.util.List; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.booklet.page.BookletPage; import de.ellpeck.actuallyadditions.booklet.page.PageCoffeeMachine; import de.ellpeck.actuallyadditions.common.items.ItemCoffee; diff --git a/src/main/java/de/ellpeck/actuallyadditions/booklet/chapter/BookletChapterCrusher.java b/src/main/java/de/ellpeck/actuallyadditions/booklet/chapter/BookletChapterCrusher.java index adaf39353..38bd7bc43 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/booklet/chapter/BookletChapterCrusher.java +++ b/src/main/java/de/ellpeck/actuallyadditions/booklet/chapter/BookletChapterCrusher.java @@ -6,7 +6,6 @@ import java.util.List; import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; import de.ellpeck.actuallyadditions.booklet.page.PageCrusherRecipe; import de.ellpeck.actuallyadditions.common.crafting.CrusherCrafting; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/booklet/page/PageCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/booklet/page/PageCoffeeMachine.java index 0f9ee3f45..ef5e8ec7b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/booklet/page/PageCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/booklet/page/PageCoffeeMachine.java @@ -4,7 +4,6 @@ import java.util.List; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.booklet.gui.GuiBooklet; import de.ellpeck.actuallyadditions.common.items.InitItems; import de.ellpeck.actuallyadditions.common.items.metalists.TheMiscItems; diff --git a/src/main/java/de/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java index c1ebbe3b0..be0084011 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java @@ -3,7 +3,6 @@ package de.ellpeck.actuallyadditions.booklet.page; import java.util.List; import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.booklet.gui.GuiBooklet; import de.ellpeck.actuallyadditions.common.util.StackUtil; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/blocks/BlockCompost.java b/src/main/java/de/ellpeck/actuallyadditions/common/blocks/BlockCompost.java index f007f884b..a40a738a0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/blocks/BlockCompost.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/blocks/BlockCompost.java @@ -1,6 +1,5 @@ package de.ellpeck.actuallyadditions.common.blocks; -import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; import de.ellpeck.actuallyadditions.common.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.common.tile.TileEntityCompost; import de.ellpeck.actuallyadditions.common.util.AssetUtil; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/crafting/CrusherCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/common/crafting/CrusherCrafting.java index 677334186..3cddbf1fa 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/crafting/CrusherCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/crafting/CrusherCrafting.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.List; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.common.items.InitItems; import de.ellpeck.actuallyadditions.common.items.metalists.TheDusts; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/items/ItemCoffee.java b/src/main/java/de/ellpeck/actuallyadditions/common/items/ItemCoffee.java index c61cc5d69..03a712c1a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/items/ItemCoffee.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/items/ItemCoffee.java @@ -6,7 +6,6 @@ import java.util.List; import javax.annotation.Nullable; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.common.items.base.ItemFoodBase; import de.ellpeck.actuallyadditions.common.items.metalists.TheMiscItems; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/jei/JEIActuallyAdditionsPlugin.java b/src/main/java/de/ellpeck/actuallyadditions/common/jei/JEIActuallyAdditionsPlugin.java index 387809613..ee652da9b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/jei/JEIActuallyAdditionsPlugin.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/jei/JEIActuallyAdditionsPlugin.java @@ -2,9 +2,6 @@ package de.ellpeck.actuallyadditions.common.jei; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; -import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; import de.ellpeck.actuallyadditions.common.blocks.InitBlocks; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/jei/coffee/CoffeeMachineRecipeWrapper.java b/src/main/java/de/ellpeck/actuallyadditions/common/jei/coffee/CoffeeMachineRecipeWrapper.java index b5673f2a9..1850b5246 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/jei/coffee/CoffeeMachineRecipeWrapper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/jei/coffee/CoffeeMachineRecipeWrapper.java @@ -7,7 +7,6 @@ import com.google.common.base.Strings; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.common.blocks.InitBlocks; import de.ellpeck.actuallyadditions.booklet.misc.BookletUtils; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/jei/compost/CompostRecipeWrapper.java b/src/main/java/de/ellpeck/actuallyadditions/common/jei/compost/CompostRecipeWrapper.java index 6c383ef77..64e51b41b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/jei/compost/CompostRecipeWrapper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/jei/compost/CompostRecipeWrapper.java @@ -3,7 +3,6 @@ package de.ellpeck.actuallyadditions.common.jei.compost; import java.util.Arrays; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; import de.ellpeck.actuallyadditions.common.blocks.InitBlocks; import de.ellpeck.actuallyadditions.booklet.misc.BookletUtils; import de.ellpeck.actuallyadditions.common.jei.RecipeWrapperWithButton; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/jei/crusher/CrusherRecipeWrapper.java b/src/main/java/de/ellpeck/actuallyadditions/common/jei/crusher/CrusherRecipeWrapper.java index ad8dedb52..4f5c5b587 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/jei/crusher/CrusherRecipeWrapper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/jei/crusher/CrusherRecipeWrapper.java @@ -5,7 +5,6 @@ import java.util.Arrays; import java.util.List; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; import de.ellpeck.actuallyadditions.common.blocks.InitBlocks; import de.ellpeck.actuallyadditions.booklet.misc.BookletUtils; import de.ellpeck.actuallyadditions.common.jei.RecipeWrapperWithButton; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/misc/apiimpl/MethodHandler.java b/src/main/java/de/ellpeck/actuallyadditions/common/misc/apiimpl/MethodHandler.java index 9d121a122..f26dae69f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/misc/apiimpl/MethodHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/misc/apiimpl/MethodHandler.java @@ -10,7 +10,6 @@ import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.internal.IMethodHandler; import de.ellpeck.actuallyadditions.api.lens.Lens; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; import de.ellpeck.actuallyadditions.common.blocks.BlockLaserRelay; import de.ellpeck.actuallyadditions.booklet.chapter.BookletChapter; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipe/CrusherRecipeRegistry.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipe/CrusherRecipeRegistry.java index aa0344522..0ad887a2c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/recipe/CrusherRecipeRegistry.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/recipe/CrusherRecipeRegistry.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.List; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.common.config.values.ConfigStringListValues; import de.ellpeck.actuallyadditions.common.util.StackUtil; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/tile/TileEntityCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/common/tile/TileEntityCoffeeMachine.java index a54f635f8..82137d638 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/tile/TileEntityCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/tile/TileEntityCoffeeMachine.java @@ -1,6 +1,5 @@ package de.ellpeck.actuallyadditions.common.tile; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.common.items.InitItems; import de.ellpeck.actuallyadditions.common.items.ItemCoffee; import de.ellpeck.actuallyadditions.common.items.metalists.TheMiscItems; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/tile/TileEntityCompost.java b/src/main/java/de/ellpeck/actuallyadditions/common/tile/TileEntityCompost.java index 75ee79fc8..af3509cee 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/tile/TileEntityCompost.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/tile/TileEntityCompost.java @@ -1,7 +1,6 @@ package de.ellpeck.actuallyadditions.common.tile; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; import de.ellpeck.actuallyadditions.common.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.common.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.common.util.ItemUtil; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/tile/TileEntityGrinder.java b/src/main/java/de/ellpeck/actuallyadditions/common/tile/TileEntityGrinder.java index e6500301f..0c8b3b0bd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/tile/TileEntityGrinder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/tile/TileEntityGrinder.java @@ -1,6 +1,5 @@ package de.ellpeck.actuallyadditions.common.tile; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; import de.ellpeck.actuallyadditions.common.blocks.BlockFurnaceDouble; import de.ellpeck.actuallyadditions.common.misc.SoundHandler; import de.ellpeck.actuallyadditions.common.network.gui.IButtonReactor; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/util/RecipeUtil.java b/src/main/java/de/ellpeck/actuallyadditions/common/util/RecipeUtil.java index 00bf93659..7d182bb86 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/util/RecipeUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/util/RecipeUtil.java @@ -3,7 +3,6 @@ package de.ellpeck.actuallyadditions.common.util; import java.util.List; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; import de.ellpeck.actuallyadditions.common.util.crafting.RecipeHandler; From 35ff26221ad76ba330db97f428050eb91e93e944 Mon Sep 17 00:00:00 2001 From: canitzp Date: Tue, 6 Oct 2020 09:04:43 +0200 Subject: [PATCH 2/5] Added CrusherRecipe and Factory Signed-off-by: canitzp --- .../common/recipes/CrusherRecipe.java | 66 +++++++++++++ .../common/recipes/CrusherRecipeFactory.java | 95 +++++++++++++++++++ .../actuallyadditions/recipes/_factories.json | 3 +- 3 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipeFactory.java diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java new file mode 100644 index 000000000..3128ec5fd --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java @@ -0,0 +1,66 @@ +package de.ellpeck.actuallyadditions.common.recipes; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipeSerializer; +import net.minecraft.item.crafting.IRecipeType; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; + +import javax.annotation.Nonnull; + +public class CrusherRecipe implements IDummyRecipe { + + public static final IRecipeType CRUSHER_RECIPE_TYPE = IRecipeType.register("actuallyadditions:crusher"); + + @Nonnull private final ResourceLocation recipeId; + + @Nonnull private final Ingredient input; + @Nonnull private final ItemStack output; + @Nonnull private final ItemStack secondaryOutput; + private final int outputChance; + + public CrusherRecipe(@Nonnull ResourceLocation recipeId, @Nonnull Ingredient input, @Nonnull ItemStack output, @Nonnull ItemStack secondaryOutput, int outputChance){ + this.recipeId = recipeId; + this.input = input; + this.output = output; + this.secondaryOutput = secondaryOutput; + this.outputChance = outputChance; + } + + @Nonnull + public Ingredient getInput(){ + return input; + } + + @Nonnull + public ItemStack getOutput(){ + return output; + } + + @Nonnull + public ItemStack getSecondaryOutput(){ + return secondaryOutput; + } + + public int getOutputChance(){ + return outputChance; + } + + @Nonnull + @Override + public ResourceLocation getId(){ + return this.recipeId; + } + + @Nonnull + @Override + public IRecipeSerializer getSerializer(){ + return CrusherRecipeFactory.INSTANCE; + } + + @Nonnull + @Override + public IRecipeType getType(){ + return CRUSHER_RECIPE_TYPE; + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipeFactory.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipeFactory.java new file mode 100644 index 000000000..908dbd68d --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipeFactory.java @@ -0,0 +1,95 @@ +package de.ellpeck.actuallyadditions.common.recipes; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSyntaxException; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipeSerializer; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.item.crafting.ShapedRecipe; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.registries.ForgeRegistryEntry; + +import javax.annotation.Nonnull; + +public class CrusherRecipeFactory extends ForgeRegistryEntry> implements IRecipeSerializer { + + public static final CrusherRecipeFactory INSTANCE = IRecipeSerializer.register("actuallyadditions:crusher", new CrusherRecipeFactory()); + + @Nonnull + @Override + public CrusherRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json){ + Ingredient input; + ItemStack firstOutput; + ItemStack secondOutput = ItemStack.EMPTY; + int secondaryOutputChance = 0; + + if(json.has("input")){ + input = Ingredient.deserialize(json.get("input")); + } else { + throw new JsonSyntaxException("Input is not given for the recipe!"); + } + + if(json.has("output")){ + JsonElement outputElement = json.get("output"); + if(outputElement.isJsonObject()){ + firstOutput = ShapedRecipe.deserializeItem(outputElement.getAsJsonObject()); + } else { + throw new JsonSyntaxException("Output is not valid!"); + } + } else { + throw new JsonSyntaxException("Output is not given for the recipe!"); + } + + if(json.has("secondary")){ // Optional + JsonElement secondaryElement = json.get("secondary"); + if(secondaryElement.isJsonObject()){ + JsonObject secondary = secondaryElement.getAsJsonObject(); + if(secondary.has("output")){ + JsonElement outputElement = json.get("output"); + if(outputElement.isJsonObject()){ + secondOutput = ShapedRecipe.deserializeItem(outputElement.getAsJsonObject()); + } else { + throw new JsonSyntaxException("Secondary output is not valid!"); + } + } else { + throw new JsonSyntaxException("Secondary output is not given for the recipe!"); + } + if(secondary.has("chance")){ + JsonElement chanceElement = secondary.get("chance"); + if(chanceElement.isJsonPrimitive()){ + secondaryOutputChance = chanceElement.getAsInt(); + } else { + throw new JsonSyntaxException("Secondary chance is not valid!"); + } + } else { + throw new JsonSyntaxException("Secondary chance is not given for the recipe!"); + } + } else { + throw new JsonSyntaxException("Secondary is not valid!"); + } + } + + return new CrusherRecipe(recipeId, input, firstOutput, secondOutput, secondaryOutputChance); + } + + @Nonnull + @Override + public CrusherRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer){ + Ingredient input = Ingredient.read(buffer); + ItemStack output = buffer.readItemStack(); + ItemStack secondaryOutput = buffer.readItemStack(); + int chance = buffer.readVarInt(); + + return new CrusherRecipe(recipeId, input, output, secondaryOutput, chance); + } + + @Override + public void write(@Nonnull PacketBuffer buffer, @Nonnull CrusherRecipe recipe){ + recipe.getInput().write(buffer); + buffer.writeItemStack(recipe.getOutput()); + buffer.writeItemStack(recipe.getSecondaryOutput()); + buffer.writeVarInt(recipe.getOutputChance()); + } +} diff --git a/src/main/resources/assets/actuallyadditions/recipes/_factories.json b/src/main/resources/assets/actuallyadditions/recipes/_factories.json index 1b1b86408..f589c7c26 100644 --- a/src/main/resources/assets/actuallyadditions/recipes/_factories.json +++ b/src/main/resources/assets/actuallyadditions/recipes/_factories.json @@ -3,6 +3,7 @@ "atomic_reconstructor": "de.ellpeck.actuallyadditions.common.recipes.AtomicReconstructorRecipeFactory", "ball_of_fur": "de.ellpeck.actuallyadditions.common.recipes.BallOfFurRecipeFactory", "coffee_machine_ingredient": "de.ellpeck.actuallyadditions.common.recipes.CoffeeMachineIngredientFactory", - "compost": "de.ellpeck.actuallyadditions.common.recipes.CompostRecipeFactory" + "compost": "de.ellpeck.actuallyadditions.common.recipes.CompostRecipeFactory", + "crusher": "de.eppleck.actuallyadditions.common.recipes.CrusherRecipeFactory" } } \ No newline at end of file From 395b6d0491d505c6dba55ac57a84767d7e3a2663 Mon Sep 17 00:00:00 2001 From: canitzp Date: Tue, 6 Oct 2020 12:10:09 +0200 Subject: [PATCH 3/5] Recipe Factory changes Signed-off-by: canitzp --- .../common/recipes/CrusherRecipe.java | 56 ++++++++++- .../common/recipes/CrusherRecipeFactory.java | 95 ------------------- .../common/recipes/RecipeFactoryBase.java | 82 ++++++++++++++++ .../actuallyadditions/recipes/_factories.json | 2 +- 4 files changed, 136 insertions(+), 99 deletions(-) delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipeFactory.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/common/recipes/RecipeFactoryBase.java diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java index 3128ec5fd..0365a18da 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java @@ -1,16 +1,21 @@ package de.ellpeck.actuallyadditions.common.recipes; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSyntaxException; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.IRecipeType; import net.minecraft.item.crafting.Ingredient; +import net.minecraft.network.PacketBuffer; import net.minecraft.util.ResourceLocation; import javax.annotation.Nonnull; public class CrusherRecipe implements IDummyRecipe { - public static final IRecipeType CRUSHER_RECIPE_TYPE = IRecipeType.register("actuallyadditions:crusher"); + public static final IRecipeType RECIPE_TYPE = IRecipeType.register("actuallyadditions:crusher"); + public static final CrusherRecipeFactory FACTORY = IRecipeSerializer.register("actuallyadditions:crusher", new CrusherRecipeFactory()); @Nonnull private final ResourceLocation recipeId; @@ -55,12 +60,57 @@ public class CrusherRecipe implements IDummyRecipe { @Nonnull @Override public IRecipeSerializer getSerializer(){ - return CrusherRecipeFactory.INSTANCE; + return FACTORY; } @Nonnull @Override public IRecipeType getType(){ - return CRUSHER_RECIPE_TYPE; + return RECIPE_TYPE; } + + static class CrusherRecipeFactory extends RecipeFactoryBase { + + @Nonnull + @Override + public CrusherRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json){ + Ingredient input = this.readIngredient(json, "input"); + ItemStack firstOutput = this.readItemStack(json, "output"); + ItemStack secondOutput = ItemStack.EMPTY; + int secondaryOutputChance = 0; + + if(json.has("secondary")){ // Optional + JsonElement secondaryElement = json.get("secondary"); + if(secondaryElement.isJsonObject()){ + JsonObject secondary = secondaryElement.getAsJsonObject(); + secondOutput = this.readItemStack(secondary, "output", ItemStack.EMPTY); + secondaryOutputChance = this.readInt(secondary, "chance", 0); + } else { + throw new JsonSyntaxException("Secondary is not valid!"); + } + } + + return new CrusherRecipe(recipeId, input, firstOutput, secondOutput, secondaryOutputChance); + } + + @Nonnull + @Override + public CrusherRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer){ + Ingredient input = Ingredient.read(buffer); + ItemStack output = buffer.readItemStack(); + ItemStack secondaryOutput = buffer.readItemStack(); + int chance = buffer.readVarInt(); + + return new CrusherRecipe(recipeId, input, output, secondaryOutput, chance); + } + + @Override + public void write(@Nonnull PacketBuffer buffer, @Nonnull CrusherRecipe recipe){ + recipe.getInput().write(buffer); + buffer.writeItemStack(recipe.getOutput()); + buffer.writeItemStack(recipe.getSecondaryOutput()); + buffer.writeVarInt(recipe.getOutputChance()); + } + } + } diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipeFactory.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipeFactory.java deleted file mode 100644 index 908dbd68d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipeFactory.java +++ /dev/null @@ -1,95 +0,0 @@ -package de.ellpeck.actuallyadditions.common.recipes; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonSyntaxException; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.ShapedRecipe; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.registries.ForgeRegistryEntry; - -import javax.annotation.Nonnull; - -public class CrusherRecipeFactory extends ForgeRegistryEntry> implements IRecipeSerializer { - - public static final CrusherRecipeFactory INSTANCE = IRecipeSerializer.register("actuallyadditions:crusher", new CrusherRecipeFactory()); - - @Nonnull - @Override - public CrusherRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json){ - Ingredient input; - ItemStack firstOutput; - ItemStack secondOutput = ItemStack.EMPTY; - int secondaryOutputChance = 0; - - if(json.has("input")){ - input = Ingredient.deserialize(json.get("input")); - } else { - throw new JsonSyntaxException("Input is not given for the recipe!"); - } - - if(json.has("output")){ - JsonElement outputElement = json.get("output"); - if(outputElement.isJsonObject()){ - firstOutput = ShapedRecipe.deserializeItem(outputElement.getAsJsonObject()); - } else { - throw new JsonSyntaxException("Output is not valid!"); - } - } else { - throw new JsonSyntaxException("Output is not given for the recipe!"); - } - - if(json.has("secondary")){ // Optional - JsonElement secondaryElement = json.get("secondary"); - if(secondaryElement.isJsonObject()){ - JsonObject secondary = secondaryElement.getAsJsonObject(); - if(secondary.has("output")){ - JsonElement outputElement = json.get("output"); - if(outputElement.isJsonObject()){ - secondOutput = ShapedRecipe.deserializeItem(outputElement.getAsJsonObject()); - } else { - throw new JsonSyntaxException("Secondary output is not valid!"); - } - } else { - throw new JsonSyntaxException("Secondary output is not given for the recipe!"); - } - if(secondary.has("chance")){ - JsonElement chanceElement = secondary.get("chance"); - if(chanceElement.isJsonPrimitive()){ - secondaryOutputChance = chanceElement.getAsInt(); - } else { - throw new JsonSyntaxException("Secondary chance is not valid!"); - } - } else { - throw new JsonSyntaxException("Secondary chance is not given for the recipe!"); - } - } else { - throw new JsonSyntaxException("Secondary is not valid!"); - } - } - - return new CrusherRecipe(recipeId, input, firstOutput, secondOutput, secondaryOutputChance); - } - - @Nonnull - @Override - public CrusherRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer){ - Ingredient input = Ingredient.read(buffer); - ItemStack output = buffer.readItemStack(); - ItemStack secondaryOutput = buffer.readItemStack(); - int chance = buffer.readVarInt(); - - return new CrusherRecipe(recipeId, input, output, secondaryOutput, chance); - } - - @Override - public void write(@Nonnull PacketBuffer buffer, @Nonnull CrusherRecipe recipe){ - recipe.getInput().write(buffer); - buffer.writeItemStack(recipe.getOutput()); - buffer.writeItemStack(recipe.getSecondaryOutput()); - buffer.writeVarInt(recipe.getOutputChance()); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/RecipeFactoryBase.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/RecipeFactoryBase.java new file mode 100644 index 000000000..56c3c8d30 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/RecipeFactoryBase.java @@ -0,0 +1,82 @@ +package de.ellpeck.actuallyadditions.common.recipes; + +import com.google.gson.JsonObject; +import com.google.gson.JsonSyntaxException; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipeSerializer; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.item.crafting.ShapedRecipe; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.ForgeRegistryEntry; + +public abstract class RecipeFactoryBase extends ForgeRegistryEntry> implements IRecipeSerializer { + + protected Ingredient readIngredient(JsonObject json, String key){ + if(json.has(key)){ + return Ingredient.deserialize(json.get(key)); + } else { + throw new JsonSyntaxException(String.format("Json element does not contain any element with the key: '%s'", key)); + } + } + + protected Ingredient readIngredient(JsonObject json, String key, Ingredient alternative){ + try{ + return this.readIngredient(json, key); + } catch(JsonSyntaxException e){ + return alternative; + } + } + + protected ItemStack readItemStack(JsonObject json, String key){ + if(json.has(key)){ + if(json.get(key).isJsonObject()){ + return ShapedRecipe.deserializeItem(json.get(key).getAsJsonObject()); + } else if(json.get(key).isJsonPrimitive()){ + ResourceLocation itemKey = new ResourceLocation(json.get(key).getAsString()); + if(ForgeRegistries.ITEMS.containsKey(itemKey)){ + return new ItemStack(ForgeRegistries.ITEMS.getValue(itemKey)); + } else { + throw new JsonSyntaxException(String.format("Item with the key: '%s' is not registered!", key)); + } + } else { + throw new JsonSyntaxException(String.format("Json element with the key: '%s' is neither a object nor a string!", key)); + } + } else { + throw new JsonSyntaxException(String.format("Json element does not contain any element with the key: '%s'!", key)); + } + } + + protected ItemStack readItemStack(JsonObject json, String key, ItemStack alternative){ + try{ + return this.readItemStack(json, key); + } catch(JsonSyntaxException e){ + return alternative; + } + } + + protected int readInt(JsonObject json, String key){ + if(json.has(key)){ + if(json.get(key).isJsonPrimitive()){ + try{ + return json.get(key).getAsJsonPrimitive().getAsInt(); + } catch(NumberFormatException e){ + throw new JsonSyntaxException(String.format("Json element '%s' is not a valid integer!", key), e); + } + } else { + throw new JsonSyntaxException(String.format("Json element '%s' is not a valid integer!", key)); + } + } else { + throw new JsonSyntaxException(String.format("Json element '%s' does not exist!", key)); + } + } + + protected int readInt(JsonObject json, String key, int alternative){ + try{ + return this.readInt(json, key); + } catch(Exception e){ + return alternative; + } + } + +} \ No newline at end of file diff --git a/src/main/resources/assets/actuallyadditions/recipes/_factories.json b/src/main/resources/assets/actuallyadditions/recipes/_factories.json index f589c7c26..ef0e56c52 100644 --- a/src/main/resources/assets/actuallyadditions/recipes/_factories.json +++ b/src/main/resources/assets/actuallyadditions/recipes/_factories.json @@ -4,6 +4,6 @@ "ball_of_fur": "de.ellpeck.actuallyadditions.common.recipes.BallOfFurRecipeFactory", "coffee_machine_ingredient": "de.ellpeck.actuallyadditions.common.recipes.CoffeeMachineIngredientFactory", "compost": "de.ellpeck.actuallyadditions.common.recipes.CompostRecipeFactory", - "crusher": "de.eppleck.actuallyadditions.common.recipes.CrusherRecipeFactory" + "crusher": "de.ellpeck.actuallyadditions.common.recipes.CrusherRecipe$CrusherRecipeFactory" } } \ No newline at end of file From 2c07ef0fa0625fa6072b3dec64980ce87fd9ea7c Mon Sep 17 00:00:00 2001 From: canitzp Date: Wed, 7 Oct 2020 08:25:54 +0200 Subject: [PATCH 4/5] Start to work on DataGenerator. Crusher Recipes should now be able to be serialized to json by its Factory. In general the serializing to json is handled by the RecipeFactoryBase class. Removed some Recipes after the decision to not port it or change it to loot tables in favor of recipes. A lot more @Nonnull annotations. Signed-off-by: canitzp --- .../AtomicReconstructorBlockRecipe.java | 9 +- .../AtomicReconstructorItemRecipe.java | 22 ++-- .../common/recipes/BallOfFurRecipe.java | 45 -------- .../recipes/BallOfFurRecipeFactory.java | 65 ----------- .../recipes/CoffeeMachineIngredient.java | 21 ++-- .../common/recipes/CompostRecipe.java | 59 ---------- .../common/recipes/CompostRecipeFactory.java | 101 ------------------ .../common/recipes/CrusherRecipe.java | 39 +++++-- .../common/recipes/IDummyRecipe.java | 43 +++++++- .../common/recipes/RecipeFactoryBase.java | 19 +++- .../data/AADataGenerator.java | 11 +- .../data/BlockStateGenerator.java | 28 +++++ .../data/recipes/CrusherRecipeGenerator.java | 26 +++++ .../actuallyadditions/recipes/_factories.json | 9 -- 14 files changed, 184 insertions(+), 313 deletions(-) delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/common/recipes/BallOfFurRecipe.java delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/common/recipes/BallOfFurRecipeFactory.java delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/common/recipes/CompostRecipe.java delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/common/recipes/CompostRecipeFactory.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/data/BlockStateGenerator.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/data/recipes/CrusherRecipeGenerator.java delete mode 100644 src/main/resources/assets/actuallyadditions/recipes/_factories.json diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/AtomicReconstructorBlockRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/AtomicReconstructorBlockRecipe.java index babad16c0..30d6b3c14 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/AtomicReconstructorBlockRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/AtomicReconstructorBlockRecipe.java @@ -6,10 +6,12 @@ import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.IRecipeType; import net.minecraft.util.ResourceLocation; +import javax.annotation.Nonnull; + /** * Recipe class for the AtomicReconstructor when hitting a items stack */ -public class AtomicReconstructorBlockRecipe implements IDummyRecipe { +public class AtomicReconstructorBlockRecipe implements IDummyRecipe { public static final IRecipeType ATOMIC_RECONSTRUCTOR_BLOCK_RECIPE_TYPE = IRecipeType.register("actuallyadditions:atomic_reconstructor_block"); @@ -44,16 +46,19 @@ public class AtomicReconstructorBlockRecipe implements IDummyRecipe { return energyConsumption; } + @Nonnull @Override public ResourceLocation getId(){ return this.recipeId; } + @Nonnull @Override - public IRecipeSerializer getSerializer(){ + public IRecipeSerializer getSerializer(){ return AtomicReconstructorBlockRecipeFactory.INSTANCE; } + @Nonnull @Override public IRecipeType getType(){ return ATOMIC_RECONSTRUCTOR_BLOCK_RECIPE_TYPE; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/AtomicReconstructorItemRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/AtomicReconstructorItemRecipe.java index 67626bf61..90dbe8130 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/AtomicReconstructorItemRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/AtomicReconstructorItemRecipe.java @@ -7,21 +7,23 @@ import net.minecraft.item.crafting.IRecipeType; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; +import javax.annotation.Nonnull; + /** * Recipe class for the AtomicReconstructor when hitting a items stack */ -public class AtomicReconstructorItemRecipe implements IDummyRecipe { +public class AtomicReconstructorItemRecipe implements IDummyRecipe { public static final IRecipeType ATOMIC_RECONSTRUCTOR_ITEM_RECIPE_TYPE = IRecipeType.register("actuallyadditions:atomic_reconstructor_item"); - private final ResourceLocation recipeId; + @Nonnull private final ResourceLocation recipeId; - private final Lens lens; - private final Ingredient input; - private final ItemStack output; + @Nonnull private final Lens lens; + @Nonnull private final Ingredient input; + @Nonnull private final ItemStack output; private final int energyConsumption; - public AtomicReconstructorItemRecipe(ResourceLocation recipeId, Lens lens, Ingredient input, ItemStack output, int energyConsumption){ + public AtomicReconstructorItemRecipe(@Nonnull ResourceLocation recipeId, @Nonnull Lens lens, @Nonnull Ingredient input, @Nonnull ItemStack output, int energyConsumption){ this.recipeId = recipeId; this.lens = lens; this.input = input; @@ -29,14 +31,17 @@ public class AtomicReconstructorItemRecipe implements IDummyRecipe { this.energyConsumption = energyConsumption; } + @Nonnull public Lens getLens(){ return lens; } + @Nonnull public Ingredient getInput(){ return input; } + @Nonnull public ItemStack getOutput(){ return output; } @@ -45,16 +50,19 @@ public class AtomicReconstructorItemRecipe implements IDummyRecipe { return energyConsumption; } + @Nonnull @Override public ResourceLocation getId(){ return this.recipeId; } + @Nonnull @Override - public IRecipeSerializer getSerializer(){ + public IRecipeSerializer getSerializer(){ return AtomicReconstructorItemRecipeFactory.INSTANCE; } + @Nonnull @Override public IRecipeType getType(){ return ATOMIC_RECONSTRUCTOR_ITEM_RECIPE_TYPE; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/BallOfFurRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/BallOfFurRecipe.java deleted file mode 100644 index c938bbcb7..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/BallOfFurRecipe.java +++ /dev/null @@ -1,45 +0,0 @@ -package de.ellpeck.actuallyadditions.common.recipes; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.util.ResourceLocation; - -public class BallOfFurRecipe implements IDummyRecipe { - - public static final IRecipeType BALL_OF_FUR_RECIPE_TYPE = IRecipeType.register("actuallyadditions:ball_of_fur"); - - private final ResourceLocation recipeId; - - private final ItemStack returnItem; - private final int chance; - - public BallOfFurRecipe(ResourceLocation recipeId, ItemStack returnItem, int chance){ - this.recipeId = recipeId; - this.returnItem = returnItem; - this.chance = chance; - } - - public ItemStack getReturnItem(){ - return this.returnItem; - } - - public int getChance(){ - return this.chance; - } - - @Override - public ResourceLocation getId(){ - return this.recipeId; - } - - @Override - public IRecipeSerializer getSerializer(){ - return BallOfFurRecipeFactory.INSTANCE; - } - - @Override - public IRecipeType getType(){ - return BALL_OF_FUR_RECIPE_TYPE; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/BallOfFurRecipeFactory.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/BallOfFurRecipeFactory.java deleted file mode 100644 index e713b5b33..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/BallOfFurRecipeFactory.java +++ /dev/null @@ -1,65 +0,0 @@ -package de.ellpeck.actuallyadditions.common.recipes; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.ShapedRecipe; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.registries.ForgeRegistryEntry; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class BallOfFurRecipeFactory extends ForgeRegistryEntry> implements IRecipeSerializer { - - public static final BallOfFurRecipeFactory INSTANCE = IRecipeSerializer.register("actuallyadditions:ball_of_fur", new BallOfFurRecipeFactory()); - - @Nonnull - @Override - public BallOfFurRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json){ - ItemStack stack; - int chance; - - if(json.has("stack")){ - JsonElement stackJsonElement = json.get("stack"); - if(stackJsonElement.isJsonObject()){ - stack = ShapedRecipe.deserializeItem(stackJsonElement.getAsJsonObject()); - } else { - throw new JsonParseException("BallOfFurRecipe stack has to be a json object!"); - } - } else { - throw new JsonParseException("BallOfFurRecipe has no json stack object!"); - } - - if(json.has("chance")){ - JsonElement chanceJsonElement = json.get("chance"); - if(chanceJsonElement.isJsonPrimitive()){ - chance = chanceJsonElement.getAsInt(); - } else { - throw new JsonParseException("BallOfFurRecipe chance is not a json integer!"); - } - } else { - throw new JsonParseException("BallOfFurRecipe has no chance integer!"); - } - - return new BallOfFurRecipe(recipeId, stack, chance); - } - - @Nullable - @Override - public BallOfFurRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer){ - ItemStack stack = buffer.readItemStack(); - int chance = buffer.readInt(); - return new BallOfFurRecipe(recipeId, stack, chance); - } - - @Override - public void write(@Nonnull PacketBuffer buffer, @Nonnull BallOfFurRecipe recipe){ - buffer.writeItemStack(recipe.getReturnItem()); - buffer.writeInt(recipe.getChance()); - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CoffeeMachineIngredient.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CoffeeMachineIngredient.java index fdc02d823..b8f607c46 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CoffeeMachineIngredient.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CoffeeMachineIngredient.java @@ -6,22 +6,25 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.potion.EffectInstance; import net.minecraft.util.ResourceLocation; -public class CoffeeMachineIngredient implements IDummyRecipe{ +import javax.annotation.Nonnull; + +public class CoffeeMachineIngredient implements IDummyRecipe { public static final IRecipeType COFFEE_MACHINE_RECIPE_TYPE = IRecipeType.register("actuallyadditions:coffee_machine"); - protected final ResourceLocation recipeId; - protected final Ingredient input; - protected final int maxAmplifier; - protected final EffectInstance[] effects; + @Nonnull private final ResourceLocation recipeId; + @Nonnull private final Ingredient input; + private final int maxAmplifier; + @Nonnull private final EffectInstance[] effects; - public CoffeeMachineIngredient(ResourceLocation recipeId, Ingredient input, int maxAmplifier, EffectInstance[] effects){ + public CoffeeMachineIngredient(@Nonnull ResourceLocation recipeId, @Nonnull Ingredient input, int maxAmplifier, @Nonnull EffectInstance[] effects){ this.recipeId = recipeId; this.input = input; this.maxAmplifier = maxAmplifier; this.effects = effects; } + @Nonnull public Ingredient getInput(){ return input; } @@ -30,20 +33,24 @@ public class CoffeeMachineIngredient implements IDummyRecipe{ return maxAmplifier; } + @Nonnull public EffectInstance[] getEffects(){ return effects; } + @Nonnull @Override public ResourceLocation getId(){ return this.recipeId; } + @Nonnull @Override - public IRecipeSerializer getSerializer(){ + public IRecipeSerializer getSerializer(){ return CoffeeMachineIngredientFactory.INSTANCE; } + @Nonnull @Override public IRecipeType getType(){ return COFFEE_MACHINE_RECIPE_TYPE; diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CompostRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CompostRecipe.java deleted file mode 100644 index cf158ceb0..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CompostRecipe.java +++ /dev/null @@ -1,59 +0,0 @@ -package de.ellpeck.actuallyadditions.common.recipes; - -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; - -public class CompostRecipe implements IDummyRecipe { - - public static final IRecipeType COMPOST_RECIPE_TYPE = IRecipeType.register("actuallyadditions:compost"); - - private final ResourceLocation recipeId; - - private final Ingredient input; - private final ItemStack output; - private final BlockState inputDisplay; - private final BlockState outputDisplay; - - public CompostRecipe(ResourceLocation recipeId, Ingredient input, ItemStack output, BlockState inputDisplay, BlockState outputDisplay){ - this.recipeId = recipeId; - this.input = input; - this.output = output; - this.inputDisplay = inputDisplay; - this.outputDisplay = outputDisplay; - } - - public Ingredient getInput(){ - return this.input; - } - - public ItemStack getOutput(){ - return this.output; - } - - public BlockState getInputDisplay(){ - return this.inputDisplay; - } - - public BlockState getOutputDisplay(){ - return this.outputDisplay; - } - - @Override - public ResourceLocation getId(){ - return this.recipeId; - } - - @Override - public IRecipeSerializer getSerializer(){ - return CompostRecipeFactory.INSTANCE; - } - - @Override - public IRecipeType getType(){ - return COMPOST_RECIPE_TYPE; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CompostRecipeFactory.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CompostRecipeFactory.java deleted file mode 100644 index fd33a176c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CompostRecipeFactory.java +++ /dev/null @@ -1,101 +0,0 @@ -package de.ellpeck.actuallyadditions.common.recipes; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.mojang.datafixers.Dynamic; -import com.mojang.datafixers.types.JsonOps; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.ShapedRecipe; -import net.minecraft.nbt.*; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.registries.ForgeRegistryEntry; - -import javax.annotation.Nullable; - -public class CompostRecipeFactory extends ForgeRegistryEntry> implements IRecipeSerializer { - - public static final CompostRecipeFactory INSTANCE = IRecipeSerializer.register("actuallyadditions:compost", new CompostRecipeFactory()); - - @Override - public CompostRecipe read(ResourceLocation recipeId, JsonObject json){ - Ingredient input; - ItemStack output; - BlockState inputDisplay; - BlockState outputDisplay; - - if(json.has("input")){ - input = Ingredient.deserialize(json.get("input")); - } else { - throw new JsonParseException("CompostRecipe needs a input ingredient json element!"); - } - - if(json.has("output")){ - JsonElement outputJsonElement = json.get("output"); - if(outputJsonElement.isJsonObject()){ - output = ShapedRecipe.deserializeItem(outputJsonElement.getAsJsonObject()); - } else { - throw new JsonParseException("CompostRecipe output element is not a json object!"); - } - } else { - throw new JsonParseException("CompostRecipe needs a output itemstack json object!"); - } - - if(json.has("display")){ - JsonElement displayJsonElement = json.get("display"); - if(displayJsonElement.isJsonObject()){ - JsonObject displayJsonObject = displayJsonElement.getAsJsonObject(); - if(displayJsonObject.has("input")){ - inputDisplay = BlockState.deserialize(new Dynamic<>(JsonOps.INSTANCE, displayJsonObject.get("input"))); - } else { - throw new JsonParseException("CompostRecipe display needs an input json element!"); - } - - if(displayJsonObject.has("output")){ - outputDisplay = BlockState.deserialize(new Dynamic<>(JsonOps.INSTANCE, displayJsonObject.get("output"))); - } else { - throw new JsonParseException("CompostRecipe display needs an output json element!"); - } - } else { - throw new JsonParseException("CompostRecipe display has to be a json object!"); - } - } else { - // no exception but default values - inputDisplay = Blocks.DIRT.getDefaultState(); - outputDisplay = Blocks.COARSE_DIRT.getDefaultState(); - } - - return new CompostRecipe(recipeId, input, output, inputDisplay, outputDisplay); - } - - @Nullable - @Override - public CompostRecipe read(ResourceLocation recipeId, PacketBuffer buffer){ - Ingredient input = Ingredient.read(buffer); - ItemStack output = buffer.readItemStack(); - CompoundNBT inputNBT = buffer.readCompoundTag(); - CompoundNBT outputNBT = buffer.readCompoundTag(); - - BlockState inputDisplay = BlockState.deserialize(new Dynamic<>(NBTDynamicOps.INSTANCE, inputNBT)); - BlockState outputDisplay = BlockState.deserialize(new Dynamic<>(NBTDynamicOps.INSTANCE, outputNBT)); - - return new CompostRecipe(recipeId, input, output, inputDisplay, outputDisplay); - } - - @Override - public void write(PacketBuffer buffer, CompostRecipe recipe){ - recipe.getInput().write(buffer); - buffer.writeItemStack(recipe.getOutput()); - - INBT inputNBT = BlockState.serialize(NBTDynamicOps.INSTANCE, recipe.getInputDisplay()).getValue(); - buffer.writeCompoundTag((CompoundNBT) inputNBT); // if it isn't a compound than something real big is wrong and a crash should be the best way to handle it - - INBT outputNBT = BlockState.serialize(NBTDynamicOps.INSTANCE, recipe.getOutputDisplay()).getValue(); - buffer.writeCompoundTag((CompoundNBT) outputNBT); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java index 0365a18da..d1dff27cb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java @@ -12,16 +12,20 @@ import net.minecraft.util.ResourceLocation; import javax.annotation.Nonnull; -public class CrusherRecipe implements IDummyRecipe { +public class CrusherRecipe implements IDummyRecipe { public static final IRecipeType RECIPE_TYPE = IRecipeType.register("actuallyadditions:crusher"); public static final CrusherRecipeFactory FACTORY = IRecipeSerializer.register("actuallyadditions:crusher", new CrusherRecipeFactory()); - @Nonnull private final ResourceLocation recipeId; + @Nonnull + private final ResourceLocation recipeId; - @Nonnull private final Ingredient input; - @Nonnull private final ItemStack output; - @Nonnull private final ItemStack secondaryOutput; + @Nonnull + private final Ingredient input; + @Nonnull + private final ItemStack output; + @Nonnull + private final ItemStack secondaryOutput; private final int outputChance; public CrusherRecipe(@Nonnull ResourceLocation recipeId, @Nonnull Ingredient input, @Nonnull ItemStack output, @Nonnull ItemStack secondaryOutput, int outputChance){ @@ -32,6 +36,10 @@ public class CrusherRecipe implements IDummyRecipe { this.outputChance = outputChance; } + public CrusherRecipe(@Nonnull ResourceLocation recipeId, @Nonnull Ingredient input, @Nonnull ItemStack output){ + this(recipeId, input, output, ItemStack.EMPTY, 0); + } + @Nonnull public Ingredient getInput(){ return input; @@ -59,7 +67,7 @@ public class CrusherRecipe implements IDummyRecipe { @Nonnull @Override - public IRecipeSerializer getSerializer(){ + public IRecipeSerializer getSerializer(){ return FACTORY; } @@ -89,10 +97,21 @@ public class CrusherRecipe implements IDummyRecipe { throw new JsonSyntaxException("Secondary is not valid!"); } } - + return new CrusherRecipe(recipeId, input, firstOutput, secondOutput, secondaryOutputChance); } - + + @Override + public void write(@Nonnull JsonObject json, @Nonnull CrusherRecipe recipe){ + json.add("input", recipe.getInput().serialize()); + json.add("output", this.writeItemStack(recipe.getOutput())); + if(!recipe.getSecondaryOutput().isEmpty() && recipe.getOutputChance() > 0){ + JsonObject secondary = new JsonObject(); + secondary.add("output", this.writeItemStack(recipe.getSecondaryOutput())); + secondary.addProperty("chance", recipe.getOutputChance()); + } + } + @Nonnull @Override public CrusherRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer){ @@ -100,10 +119,10 @@ public class CrusherRecipe implements IDummyRecipe { ItemStack output = buffer.readItemStack(); ItemStack secondaryOutput = buffer.readItemStack(); int chance = buffer.readVarInt(); - + return new CrusherRecipe(recipeId, input, output, secondaryOutput, chance); } - + @Override public void write(@Nonnull PacketBuffer buffer, @Nonnull CrusherRecipe recipe){ recipe.getInput().write(buffer); diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/IDummyRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/IDummyRecipe.java index e480a93b2..27fc1c639 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/IDummyRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/IDummyRecipe.java @@ -1,25 +1,37 @@ package de.ellpeck.actuallyadditions.common.recipes; +import com.google.gson.JsonObject; +import net.minecraft.data.IFinishedRecipe; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.IRecipeSerializer; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + /** * A dummy Recipe implementation, because the minecraft recipe system forces us to use IRecipe with all of it's methods, * but we don't need any of them. * Additionally the "isDynamic()" methods now returns true, because this indicates that the recipe book doesn't list * this recipe at all. */ -public interface IDummyRecipe extends IRecipe { +public interface IDummyRecipe> extends IRecipe, IFinishedRecipe { + + @Nonnull + @Override + IRecipeSerializer getSerializer(); @Override - default boolean matches(IInventory inv, World worldIn){ + default boolean matches(@Nonnull IInventory inv, @Nonnull World world){ return false; } + @Nonnull @Override - default ItemStack getCraftingResult(IInventory inv){ + default ItemStack getCraftingResult(@Nonnull IInventory inv){ return ItemStack.EMPTY; } @@ -28,6 +40,7 @@ public interface IDummyRecipe extends IRecipe { return false; } + @Nonnull @Override default ItemStack getRecipeOutput(){ return ItemStack.EMPTY; @@ -39,4 +52,28 @@ public interface IDummyRecipe extends IRecipe { return true; } + @Override + default void serialize(@Nonnull JsonObject json){ + if(this.getSerializer() instanceof RecipeFactoryBase){ + (((RecipeFactoryBase) this.getSerializer())).write(json, (T) this); + } + } + + @Nonnull + @Override + default ResourceLocation getID(){ + return this.getId(); + } + + @Nullable + @Override + default JsonObject getAdvancementJson(){ + return null; + } + + @Nullable + @Override + default ResourceLocation getAdvancementID(){ + return null; + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/RecipeFactoryBase.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/RecipeFactoryBase.java index 56c3c8d30..6d05f6168 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/RecipeFactoryBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/RecipeFactoryBase.java @@ -1,16 +1,19 @@ package de.ellpeck.actuallyadditions.common.recipes; import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.ShapedRecipe; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistryEntry; -public abstract class RecipeFactoryBase extends ForgeRegistryEntry> implements IRecipeSerializer { +public abstract class RecipeFactoryBase> extends ForgeRegistryEntry> implements IRecipeSerializer { + + public abstract void write(JsonObject json, T recipe); protected Ingredient readIngredient(JsonObject json, String key){ if(json.has(key)){ @@ -31,7 +34,7 @@ public abstract class RecipeFactoryBase extends ForgeReg protected ItemStack readItemStack(JsonObject json, String key){ if(json.has(key)){ if(json.get(key).isJsonObject()){ - return ShapedRecipe.deserializeItem(json.get(key).getAsJsonObject()); + return CraftingHelper.getItemStack(json.get(key).getAsJsonObject(), true); } else if(json.get(key).isJsonPrimitive()){ ResourceLocation itemKey = new ResourceLocation(json.get(key).getAsString()); if(ForgeRegistries.ITEMS.containsKey(itemKey)){ @@ -47,6 +50,16 @@ public abstract class RecipeFactoryBase extends ForgeReg } } + protected JsonObject writeItemStack(ItemStack stack){ + JsonObject json = new JsonObject(); + json.addProperty("item", stack.getItem().getRegistryName().toString()); + json.addProperty("count", stack.getCount()); + if(stack.hasTag()){ + json.add("nbt", new JsonParser().parse(stack.getTag().toString())); + } + return json; + } + protected ItemStack readItemStack(JsonObject json, String key, ItemStack alternative){ try{ return this.readItemStack(json, key); diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/AADataGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/AADataGenerator.java index 2c7c5f4cb..4d0a5a409 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/AADataGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/AADataGenerator.java @@ -1,6 +1,9 @@ package de.ellpeck.actuallyadditions.data; import de.ellpeck.actuallyadditions.common.ActuallyAdditions; +import de.ellpeck.actuallyadditions.data.recipes.CrusherRecipeGenerator; +import net.minecraft.data.DataGenerator; +import net.minecraftforge.client.model.generators.ExistingFileHelper; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; @@ -9,7 +12,11 @@ import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; public class AADataGenerator { @SubscribeEvent - public static void gatherData(GatherDataEvent event) { - + public static void gatherData(GatherDataEvent event){ + DataGenerator dataGenerator = event.getGenerator(); + ExistingFileHelper existingFileHelper = event.getExistingFileHelper(); + + dataGenerator.addProvider(new BlockStateGenerator(dataGenerator, existingFileHelper)); + dataGenerator.addProvider(new CrusherRecipeGenerator(dataGenerator)); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/BlockStateGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/BlockStateGenerator.java new file mode 100644 index 000000000..bcd7d746b --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/data/BlockStateGenerator.java @@ -0,0 +1,28 @@ +package de.ellpeck.actuallyadditions.data; + + +import de.ellpeck.actuallyadditions.common.ActuallyAdditions; +import de.ellpeck.actuallyadditions.common.blocks.InitBlocks; +import net.minecraft.block.Block; +import net.minecraft.data.DataGenerator; +import net.minecraftforge.client.model.generators.BlockStateProvider; +import net.minecraftforge.client.model.generators.ExistingFileHelper; +import net.minecraftforge.fml.RegistryObject; + +public class BlockStateGenerator extends BlockStateProvider { + + public BlockStateGenerator(DataGenerator dataGenerator, ExistingFileHelper existingFileHelper){ + super(dataGenerator, ActuallyAdditions.MODID, existingFileHelper); + } + + @Override + protected void registerStatesAndModels(){ + for(RegistryObject blockEntry : InitBlocks.BLOCKS.getEntries()){ + blockEntry.ifPresent(block -> { + // todo check if the blocks aren't "simple" and provide a different model, + // probably with the help of a interface the block implements, like naturesaura does + this.simpleBlock(block); + }); + } + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/recipes/CrusherRecipeGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/recipes/CrusherRecipeGenerator.java new file mode 100644 index 000000000..c99486805 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/data/recipes/CrusherRecipeGenerator.java @@ -0,0 +1,26 @@ +package de.ellpeck.actuallyadditions.data.recipes; + +import de.ellpeck.actuallyadditions.common.ActuallyAdditions; +import de.ellpeck.actuallyadditions.common.recipes.CrusherRecipe; +import net.minecraft.data.DataGenerator; +import net.minecraft.data.IFinishedRecipe; +import net.minecraft.data.RecipeProvider; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; + +import java.util.function.Consumer; + +public class CrusherRecipeGenerator extends RecipeProvider { + + public CrusherRecipeGenerator(DataGenerator dataGenerator){ + super(dataGenerator); + } + + @Override + protected void registerRecipes(Consumer consumer){ + super.registerRecipes(consumer); + consumer.accept(new CrusherRecipe(new ResourceLocation(ActuallyAdditions.MODID, "test"), Ingredient.fromItems(Items.DIAMOND), new ItemStack(Items.DIRT, 64))); + } +} diff --git a/src/main/resources/assets/actuallyadditions/recipes/_factories.json b/src/main/resources/assets/actuallyadditions/recipes/_factories.json deleted file mode 100644 index ef0e56c52..000000000 --- a/src/main/resources/assets/actuallyadditions/recipes/_factories.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "recipes": { - "atomic_reconstructor": "de.ellpeck.actuallyadditions.common.recipes.AtomicReconstructorRecipeFactory", - "ball_of_fur": "de.ellpeck.actuallyadditions.common.recipes.BallOfFurRecipeFactory", - "coffee_machine_ingredient": "de.ellpeck.actuallyadditions.common.recipes.CoffeeMachineIngredientFactory", - "compost": "de.ellpeck.actuallyadditions.common.recipes.CompostRecipeFactory", - "crusher": "de.ellpeck.actuallyadditions.common.recipes.CrusherRecipe$CrusherRecipeFactory" - } -} \ No newline at end of file From fb62b8663246e70e19d002e7e4057d44922610e1 Mon Sep 17 00:00:00 2001 From: canitzp Date: Wed, 7 Oct 2020 08:28:30 +0200 Subject: [PATCH 5/5] I knew I forgot something Signed-off-by: canitzp --- .../ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java index d1dff27cb..eee44109d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/recipes/CrusherRecipe.java @@ -109,6 +109,7 @@ public class CrusherRecipe implements IDummyRecipe { JsonObject secondary = new JsonObject(); secondary.add("output", this.writeItemStack(recipe.getSecondaryOutput())); secondary.addProperty("chance", recipe.getOutputChance()); + json.add("secondary", secondary); } }