From ee17fe58d828d9714ba7db609468d80ac9138579 Mon Sep 17 00:00:00 2001 From: Ayutac Date: Thu, 10 Feb 2022 20:21:07 +0100 Subject: [PATCH] Added ind sawmill datagen --- .../reborncore/common/fluid/FluidValue.java | 2 +- .../datagen/TechRebornDataGen.groovy | 2 + .../IndustrialSawmillRecipeJsonFactory.groovy | 56 ++++++++++++++++ .../IndustrialSawmillRecipesProvider.groovy | 64 +++++++++++++++++++ src/main/java/techreborn/init/TRContent.java | 1 + .../auto/acacia_planks.json | 27 -------- .../auto/acacia_planks_1.json | 27 -------- .../industrial_sawmill/auto/birch_planks.json | 27 -------- .../auto/birch_planks_1.json | 27 -------- .../auto/dark_oak_planks.json | 27 -------- .../auto/dark_oak_planks_1.json | 27 -------- .../auto/jungle_planks.json | 27 -------- .../auto/jungle_planks_1.json | 27 -------- .../industrial_sawmill/auto/oak_planks.json | 27 -------- .../industrial_sawmill/auto/oak_planks_1.json | 27 -------- .../auto/rubber_planks.json | 27 -------- .../auto/spruce_planks.json | 27 -------- .../auto/spruce_planks_1.json | 27 -------- 18 files changed, 124 insertions(+), 352 deletions(-) create mode 100644 src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_sawmill/IndustrialSawmillRecipeJsonFactory.groovy create mode 100644 src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_sawmill/IndustrialSawmillRecipesProvider.groovy delete mode 100644 src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks.json delete mode 100644 src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks_1.json delete mode 100644 src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks.json delete mode 100644 src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks_1.json delete mode 100644 src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks.json delete mode 100644 src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks_1.json delete mode 100644 src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks.json delete mode 100644 src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks_1.json delete mode 100644 src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks.json delete mode 100644 src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks_1.json delete mode 100644 src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/rubber_planks.json delete mode 100644 src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks.json delete mode 100644 src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks_1.json diff --git a/RebornCore/src/main/java/reborncore/common/fluid/FluidValue.java b/RebornCore/src/main/java/reborncore/common/fluid/FluidValue.java index 1b26e2f9c..e5a998f59 100644 --- a/RebornCore/src/main/java/reborncore/common/fluid/FluidValue.java +++ b/RebornCore/src/main/java/reborncore/common/fluid/FluidValue.java @@ -40,7 +40,7 @@ public final class FluidValue { private final long rawValue; - private static FluidValue fromMillibuckets(long millibuckets) { + public static FluidValue fromMillibuckets(long millibuckets) { return new FluidValue(millibuckets * 81); } diff --git a/src/datagen/groovy/techreborn/datagen/TechRebornDataGen.groovy b/src/datagen/groovy/techreborn/datagen/TechRebornDataGen.groovy index 693cbe9b2..1870bb161 100644 --- a/src/datagen/groovy/techreborn/datagen/TechRebornDataGen.groovy +++ b/src/datagen/groovy/techreborn/datagen/TechRebornDataGen.groovy @@ -29,6 +29,7 @@ import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator import techreborn.datagen.recipes.machine.blast_furnace.BlastFurnaceRecipesProvider import techreborn.datagen.recipes.machine.compressor.CompressorRecipesProvider import techreborn.datagen.recipes.machine.grinder.GrinderRecipesProvider +import techreborn.datagen.recipes.machine.industrial_sawmill.IndustrialSawmillRecipesProvider import techreborn.datagen.recipes.smelting.SmeltingRecipesProvider import techreborn.datagen.recipes.crafting.CraftingRecipesProvider import techreborn.datagen.tags.TRItemTagProvider @@ -47,5 +48,6 @@ class TechRebornDataGen implements DataGeneratorEntrypoint { fabricDataGenerator.addProvider(GrinderRecipesProvider.&new) fabricDataGenerator.addProvider(CompressorRecipesProvider.&new) fabricDataGenerator.addProvider(BlastFurnaceRecipesProvider.&new) + fabricDataGenerator.addProvider(IndustrialSawmillRecipesProvider.&new) } } diff --git a/src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_sawmill/IndustrialSawmillRecipeJsonFactory.groovy b/src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_sawmill/IndustrialSawmillRecipeJsonFactory.groovy new file mode 100644 index 000000000..28f925018 --- /dev/null +++ b/src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_sawmill/IndustrialSawmillRecipeJsonFactory.groovy @@ -0,0 +1,56 @@ +package techreborn.datagen.recipes.machine.industrial_sawmill + +import net.minecraft.fluid.Fluid +import net.minecraft.fluid.Fluids +import net.minecraft.util.Identifier +import reborncore.common.fluid.FluidValue +import reborncore.common.fluid.container.FluidInstance +import techreborn.api.recipe.recipes.IndustrialSawmillRecipe +import techreborn.datagen.recipes.machine.MachineRecipeJsonFactory +import techreborn.init.ModRecipes + +class IndustrialSawmillRecipeJsonFactory extends MachineRecipeJsonFactory { + private Fluid fluid = Fluids.WATER // default + private long fluidAmount = -1 + + def fluid(Fluid fluid) { + this.fluid = fluid + return this + } + + def fluidAmount(int fluidAmount) { + this.fluidAmount = fluidAmount + return this + } + + protected IndustrialSawmillRecipeJsonFactory() { + super(ModRecipes.INDUSTRIAL_SAWMILL) + } + + static IndustrialSawmillRecipeJsonFactory create() { + return new IndustrialSawmillRecipeJsonFactory() + } + + static IndustrialSawmillRecipeJsonFactory create(@DelegatesTo(value = IndustrialSawmillRecipeJsonFactory.class, strategy = Closure.DELEGATE_FIRST) Closure closure) { + def factory = new IndustrialSawmillRecipeJsonFactory() + closure.setDelegate(factory) + closure.call(factory) + return factory + } + + @Override + protected IndustrialSawmillRecipe createRecipe(Identifier identifier) { + return new IndustrialSawmillRecipe(type, identifier, ingredients, outputs, power, time, new FluidInstance(fluid, FluidValue.fromMillibuckets(fluidAmount))) + } + + @Override + protected void validate() { + super.validate() + + if (fluidAmount < 0) { + throw new IllegalStateException("recipe has no valid fluid value specified") + } + if (fluid == null) + throw new IllegalStateException("recipe has no valid fluid type specified") + } +} \ No newline at end of file diff --git a/src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_sawmill/IndustrialSawmillRecipesProvider.groovy b/src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_sawmill/IndustrialSawmillRecipesProvider.groovy new file mode 100644 index 000000000..4e4d3c8c3 --- /dev/null +++ b/src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_sawmill/IndustrialSawmillRecipesProvider.groovy @@ -0,0 +1,64 @@ +/* + * This file is part of TechReborn, licensed under the MIT License (MIT). + * + * Copyright (c) 2020 TechReborn + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package techreborn.datagen.recipes.machine.industrial_sawmill + +import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.minecraft.item.ItemStack +import net.minecraft.item.Items +import net.minecraft.tag.ItemTags +import techreborn.datagen.recipes.TechRebornRecipesProvider +import techreborn.init.TRContent + +class IndustrialSawmillRecipesProvider extends TechRebornRecipesProvider { + + IndustrialSawmillRecipesProvider(FabricDataGenerator dataGenerator) { + super(dataGenerator) + } + + @Override + void generateRecipes() { + [ + (ItemTags.ACACIA_LOGS): Items.ACACIA_PLANKS, + (ItemTags.BIRCH_LOGS): Items.BIRCH_PLANKS, + (ItemTags.DARK_OAK_LOGS): Items.DARK_OAK_PLANKS, + (ItemTags.JUNGLE_LOGS): Items.JUNGLE_PLANKS, + (ItemTags.OAK_LOGS): Items.OAK_PLANKS, + (TRContent.RUBBER_LOGS): TRContent.RUBBER_PLANKS, + (ItemTags.SPRUCE_LOGS): Items.SPRUCE_PLANKS + ].each {logs, planks -> + offerIndustrialSawmillRecipe { + ingredients logs + outputs new ItemStack(planks,4), new ItemStack(TRContent.Dusts.SAW, 3) + power 40 + time 200 + fluidAmount 1000 // in millibuckets + } + } + } + + def offerIndustrialSawmillRecipe(@DelegatesTo(value = IndustrialSawmillRecipeJsonFactory.class, strategy = Closure.DELEGATE_FIRST) Closure closure) { + IndustrialSawmillRecipeJsonFactory.create(closure).offerTo(exporter) + } +} \ No newline at end of file diff --git a/src/main/java/techreborn/init/TRContent.java b/src/main/java/techreborn/init/TRContent.java index 7e6c04efe..84a20c124 100644 --- a/src/main/java/techreborn/init/TRContent.java +++ b/src/main/java/techreborn/init/TRContent.java @@ -110,6 +110,7 @@ public class TRContent { public static Block REINFORCED_GLASS; public static Block RUBBER_LEAVES; public static Block RUBBER_LOG; + public static Tag.Identified RUBBER_LOGS = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "rubber_logs")); public static Block RUBBER_PLANK_SLAB; public static Block RUBBER_PLANK_STAIR; public static Block RUBBER_PLANKS; diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks.json deleted file mode 100644 index 7c05a9459..000000000 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "techreborn:industrial_sawmill", - "power": 40, - "time": 200, - "tank" : { - "fluid": "minecraft:water", - "amount": 1000 - }, - "ingredients": [ - { - "item": "minecraft:acacia_log" - } - ], - "results": [ - { - "item": "minecraft:acacia_planks", - "count": 4 - }, - { - "item": "techreborn:saw_dust", - "count": 3 - }, - { - "item": "minecraft:paper" - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks_1.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks_1.json deleted file mode 100644 index af2bf41c3..000000000 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks_1.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "techreborn:industrial_sawmill", - "power": 40, - "time": 200, - "tank" : { - "fluid": "minecraft:water", - "amount": 1000 - }, - "ingredients": [ - { - "item": "minecraft:stripped_acacia_log" - } - ], - "results": [ - { - "item": "minecraft:acacia_planks", - "count": 4 - }, - { - "item": "techreborn:saw_dust", - "count": 3 - }, - { - "item": "minecraft:paper" - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks.json deleted file mode 100644 index bbeda3e36..000000000 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "techreborn:industrial_sawmill", - "power": 40, - "time": 200, - "tank" : { - "fluid": "minecraft:water", - "amount": 1000 - }, - "ingredients": [ - { - "item": "minecraft:birch_log" - } - ], - "results": [ - { - "item": "minecraft:birch_planks", - "count": 4 - }, - { - "item": "techreborn:saw_dust", - "count": 3 - }, - { - "item": "minecraft:paper" - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks_1.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks_1.json deleted file mode 100644 index 8c4c51553..000000000 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks_1.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "techreborn:industrial_sawmill", - "power": 40, - "time": 200, - "tank" : { - "fluid": "minecraft:water", - "amount": 1000 - }, - "ingredients": [ - { - "item": "minecraft:stripped_birch_log" - } - ], - "results": [ - { - "item": "minecraft:birch_planks", - "count": 4 - }, - { - "item": "techreborn:saw_dust", - "count": 3 - }, - { - "item": "minecraft:paper" - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks.json deleted file mode 100644 index 7f957cbc7..000000000 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "techreborn:industrial_sawmill", - "power": 40, - "time": 200, - "tank" : { - "fluid": "minecraft:water", - "amount": 1000 - }, - "ingredients": [ - { - "item": "minecraft:dark_oak_log" - } - ], - "results": [ - { - "item": "minecraft:dark_oak_planks", - "count": 4 - }, - { - "item": "techreborn:saw_dust", - "count": 3 - }, - { - "item": "minecraft:paper" - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks_1.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks_1.json deleted file mode 100644 index abbf30fc5..000000000 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks_1.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "techreborn:industrial_sawmill", - "power": 40, - "time": 200, - "tank" : { - "fluid": "minecraft:water", - "amount": 1000 - }, - "ingredients": [ - { - "item": "minecraft:stripped_dark_oak_log" - } - ], - "results": [ - { - "item": "minecraft:dark_oak_planks", - "count": 4 - }, - { - "item": "techreborn:saw_dust", - "count": 3 - }, - { - "item": "minecraft:paper" - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks.json deleted file mode 100644 index 32c7b91ed..000000000 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "techreborn:industrial_sawmill", - "power": 40, - "time": 200, - "tank" : { - "fluid": "minecraft:water", - "amount": 1000 - }, - "ingredients": [ - { - "item": "minecraft:jungle_log" - } - ], - "results": [ - { - "item": "minecraft:jungle_planks", - "count": 4 - }, - { - "item": "techreborn:saw_dust", - "count": 3 - }, - { - "item": "minecraft:paper" - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks_1.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks_1.json deleted file mode 100644 index 9890d16e1..000000000 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks_1.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "techreborn:industrial_sawmill", - "power": 40, - "time": 200, - "tank" : { - "fluid": "minecraft:water", - "amount": 1000 - }, - "ingredients": [ - { - "item": "minecraft:stripped_jungle_log" - } - ], - "results": [ - { - "item": "minecraft:jungle_planks", - "count": 4 - }, - { - "item": "techreborn:saw_dust", - "count": 3 - }, - { - "item": "minecraft:paper" - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks.json deleted file mode 100644 index cd71e6be0..000000000 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "techreborn:industrial_sawmill", - "power": 40, - "time": 200, - "tank" : { - "fluid": "minecraft:water", - "amount": 1000 - }, - "ingredients": [ - { - "item": "minecraft:oak_log" - } - ], - "results": [ - { - "item": "minecraft:oak_planks", - "count": 4 - }, - { - "item": "techreborn:saw_dust", - "count": 3 - }, - { - "item": "minecraft:paper" - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks_1.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks_1.json deleted file mode 100644 index 971727017..000000000 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks_1.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "techreborn:industrial_sawmill", - "power": 40, - "time": 200, - "tank" : { - "fluid": "minecraft:water", - "amount": 1000 - }, - "ingredients": [ - { - "item": "minecraft:stripped_oak_log" - } - ], - "results": [ - { - "item": "minecraft:oak_planks", - "count": 4 - }, - { - "item": "techreborn:saw_dust", - "count": 3 - }, - { - "item": "minecraft:paper" - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/rubber_planks.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/rubber_planks.json deleted file mode 100644 index 126e2d6bd..000000000 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/rubber_planks.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "techreborn:industrial_sawmill", - "power": 40, - "time": 200, - "tank" : { - "fluid": "minecraft:water", - "amount": 1000 - }, - "ingredients": [ - { - "tag": "techreborn:rubber_logs" - } - ], - "results": [ - { - "item": "techreborn:rubber_planks", - "count": 4 - }, - { - "item": "techreborn:saw_dust", - "count": 3 - }, - { - "item": "minecraft:paper" - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks.json deleted file mode 100644 index 4a4b3c51d..000000000 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "techreborn:industrial_sawmill", - "power": 40, - "time": 200, - "tank" : { - "fluid": "minecraft:water", - "amount": 1000 - }, - "ingredients": [ - { - "item": "minecraft:spruce_log" - } - ], - "results": [ - { - "item": "minecraft:spruce_planks", - "count": 4 - }, - { - "item": "techreborn:saw_dust", - "count": 3 - }, - { - "item": "minecraft:paper" - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks_1.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks_1.json deleted file mode 100644 index 0310a5f04..000000000 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks_1.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "techreborn:industrial_sawmill", - "power": 40, - "time": 200, - "tank" : { - "fluid": "minecraft:water", - "amount": 1000 - }, - "ingredients": [ - { - "item": "minecraft:stripped_spruce_log" - } - ], - "results": [ - { - "item": "minecraft:spruce_planks", - "count": 4 - }, - { - "item": "techreborn:saw_dust", - "count": 3 - }, - { - "item": "minecraft:paper" - } - ] -} \ No newline at end of file