Move some smelting and blasting recipes to data gen.

This commit is contained in:
modmuss50 2021-12-03 17:34:42 +00:00
parent 58423c560d
commit f7f8127ba0
29 changed files with 170 additions and 257 deletions

View file

@ -24,11 +24,11 @@
package reborncore.common.misc;
import net.fabricmc.fabric.api.tag.TagRegistry;
import net.fabricmc.fabric.api.tag.TagFactory;
import net.minecraft.item.Item;
import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier;
public class RebornCoreTags {
public static final Tag<Item> WATER_EXPLOSION_ITEM = TagRegistry.item(new Identifier("reborncore", "water_explosion"));
public static final Tag.Identified<Item> WATER_EXPLOSION_ITEM = TagFactory.ITEM.create(new Identifier("reborncore", "water_explosion"));
}

View file

@ -236,7 +236,7 @@ jar {
from { crowdin.getDidWork() ? fileTree('build/translations').matching{exclude "**/en_US.json"} : null}
dependsOn 'fixTranslations'
dependsOn 'compileRecipes'
dependsOn 'runDatagen'
}

View file

@ -2,10 +2,13 @@ package techreborn.datagen
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import techreborn.datagen.recipes.smelting.SmeltingRecipesProvider
import techreborn.datagen.tags.WaterExplosionTagProvider
class TechRebornDataGen implements DataGeneratorEntrypoint {
@Override
void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
// TODO generate data here
fabricDataGenerator.addProvider(WaterExplosionTagProvider.&new)
fabricDataGenerator.addProvider(SmeltingRecipesProvider.&new)
}
}

View file

@ -0,0 +1,56 @@
package techreborn.datagen.recipes.smelting
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import net.minecraft.data.server.recipe.CookingRecipeJsonFactory
import net.minecraft.item.ItemConvertible
import net.minecraft.item.Items
import net.minecraft.recipe.CookingRecipeSerializer
import net.minecraft.recipe.RecipeSerializer
import techreborn.datagen.tags.CommonTagsTrait
import techreborn.init.TRContent
class SmeltingRecipesProvider extends TechRebornRecipesProvider implements CommonTagsTrait {
SmeltingRecipesProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator)
}
@Override
void generateRecipes() {
// Add smelting and blasting recipes.
[
(TRContent.Ingots.MIXED_METAL): TRContent.Ingots.ADVANCED_ALLOY,
(cItem("brass_dusts")): TRContent.Ingots.BRASS,
(TRContent.Dusts.BRONZE): TRContent.Ingots.BRONZE,
(cItem("electrum_dusts")): TRContent.Ingots.ELECTRUM,
(TRContent.Dusts.INVAR): TRContent.Ingots.INVAR,
(cItem("lead_ores")): TRContent.Ingots.LEAD,
(cItem("raw_lead_ores")): TRContent.Ingots.LEAD,
(TRContent.Dusts.NICKEL): TRContent.Ingots.NICKEL,
(cItem("sheldonite_ores")): TRContent.Ingots.PLATINUM,
(cItem("platinum_dusts")): TRContent.Ingots.PLATINUM,
(Items.IRON_INGOT): TRContent.Ingots.REFINED_IRON,
(cItem("silver_ores")): TRContent.Ingots.SILVER,
(cItem("raw_silver_ores")): TRContent.Ingots.SILVER,
(cItem("tin_ores")): TRContent.Ingots.TIN,
(cItem("raw_tin_ores")): TRContent.Ingots.TIN,
(cItem("zinc_dusts")): TRContent.Ingots.ZINC
].each {input, output ->
offerSmelting(input, output)
offerBlasting(input, output)
}
}
def offerSmelting(def input, ItemConvertible output, float experience = 0.5f, int cookingTime = 200) {
offerCookingRecipe(input, output, experience, cookingTime, RecipeSerializer.SMELTING, "smelting/")
}
def offerBlasting(def input, ItemConvertible output, float experience = 0.5f, int cookingTime = 200) {
offerCookingRecipe(input, output, experience, cookingTime, RecipeSerializer.BLASTING, "blasting/")
}
def offerCookingRecipe(def input, ItemConvertible output, float experience, int cookingTime, CookingRecipeSerializer<?> serializer, String prefix = "") {
CookingRecipeJsonFactory.create(createIngredient(input), output, experience, cookingTime, serializer)
.criterion(getCriterionName(input), getCriterionConditions(input))
.offerTo(this.exporter, prefix + getInputPath(output) + "_from_" + getInputPath(input))
}
}

View file

@ -0,0 +1,72 @@
package techreborn.datagen.recipes.smelting
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipesProvider
import net.minecraft.advancement.criterion.CriterionConditions
import net.minecraft.data.server.recipe.RecipeJsonProvider
import net.minecraft.item.ItemConvertible
import net.minecraft.recipe.Ingredient
import net.minecraft.tag.Tag
import net.minecraft.util.Identifier
import java.util.function.Consumer
abstract class TechRebornRecipesProvider extends FabricRecipesProvider {
protected Consumer<RecipeJsonProvider> exporter
TechRebornRecipesProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator)
}
@Override
protected void generateRecipes(Consumer<RecipeJsonProvider> exporter) {
this.exporter = exporter
generateRecipes()
}
abstract void generateRecipes()
static Ingredient createIngredient(def input) {
if (input instanceof ItemConvertible) {
return Ingredient.ofItems(input)
} else if (input instanceof Tag.Identified) {
return Ingredient.fromTag(input)
}
throw new UnsupportedOperationException()
}
static String getCriterionName(def input) {
if (input instanceof ItemConvertible) {
return hasItem(input)
} else if (input instanceof Tag.Identified) {
return "has_tag_" + input.getId()
}
throw new UnsupportedOperationException()
}
static CriterionConditions getCriterionConditions(def input) {
if (input instanceof ItemConvertible) {
return conditionsFromItem(input)
} else if (input instanceof Tag.Identified) {
return conditionsFromTag(input)
}
throw new UnsupportedOperationException()
}
static String getInputPath(def input) {
if (input instanceof ItemConvertible) {
return getItemPath(input)
} else if (input instanceof Tag.Identified) {
return input.getId().toString().replace(":", "_")
}
throw new UnsupportedOperationException()
}
@Override
protected Identifier getRecipeIdentifier(Identifier identifier) {
return new Identifier("techreborn", super.getRecipeIdentifier(identifier).path)
}
}

View file

@ -0,0 +1,12 @@
package techreborn.datagen.tags
import net.fabricmc.fabric.api.tag.TagFactory
import net.minecraft.item.Item
import net.minecraft.tag.Tag
import net.minecraft.util.Identifier
trait CommonTagsTrait {
static Tag.Identified<Item> cItem(String path) {
return TagFactory.ITEM.create(new Identifier("c", path))
}
}

View file

@ -0,0 +1,18 @@
package techreborn.datagen.tags
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider
import reborncore.common.misc.RebornCoreTags
import techreborn.init.ModFluids
class WaterExplosionTagProvider extends FabricTagProvider.ItemTagProvider {
WaterExplosionTagProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator)
}
@Override
protected void generateTags() {
getOrCreateTagBuilder(RebornCoreTags.WATER_EXPLOSION_ITEM)
.add(ModFluids.SODIUM.getBucket())
}
}

View file

@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "techreborn-datagen",
"name": "TechReborn Gametest",
"name": "TechReborn Datagen",
"version": "1.0.0",
"environment": "*",
"entrypoints": {

View file

@ -122,4 +122,8 @@ public enum ModFluids {
public Identifier getIdentifier() {
return identifier;
}
public RebornBucketItem getBucket() {
return bucket;
}
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:sodium_bucket"
]
}

View file

@ -1,5 +0,0 @@
This directory is for vanilla Minecraft's blast furnace, not the blast furnace added by TechReborn.
!! DO NOT add recipes here unless they do not have a counterpart smelting recipe. !!
All of TechReborn's smelting recipes are automatically added to the (vanilla) blast furnace at build time using the "compileRecipes" Gradle task.

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"item": "techreborn:mixed_metal_ingot"
},
"result": "techreborn:advanced_alloy_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"tag": "c:brass_dusts"
},
"result": "techreborn:brass_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"item": "techreborn:bronze_dust"
},
"result": "techreborn:bronze_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"tag": "c:electrum_dusts"
},
"result": "techreborn:electrum_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"item": "techreborn:invar_dust"
},
"result": "techreborn:invar_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"tag": "c:lead_ores"
},
"result": "techreborn:lead_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"tag": "c:raw_lead_ores"
},
"result": "techreborn:lead_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"item": "techreborn:nickel_dust"
},
"result": "techreborn:nickel_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"tag": "c:sheldonite_ores"
},
"result": "techreborn:platinum_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"tag": "c:platinum_dusts"
},
"result": "techreborn:platinum_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"item": "minecraft:iron_ingot"
},
"result": "techreborn:refined_iron_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"tag": "c:silver_ores"
},
"result": "techreborn:silver_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"tag": "c:raw_silver_ores"
},
"result": "techreborn:silver_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"tag": "c:tin_ores"
},
"result": "techreborn:tin_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"tag": "c:raw_tin_ores"
},
"result": "techreborn:tin_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,9 +0,0 @@
{
"type": "minecraft:smelting",
"ingredient": {
"tag": "c:zinc_dusts"
},
"result": "techreborn:zinc_ingot",
"experience": 0.5,
"cookingtime": 200
}

View file

@ -1,92 +0,0 @@
//Warn that the sample script is running
log.warn("WARNING! The TechReborn tweaker sample script is running!");
log.warn("If you're seeing this and aren't in dev mode, please report it!");
var TRTweaker = libcd.require("techreborn.TRTweaker");
var TweakerUtils = libcd.require("libcd.util.TweakerUtils");
//Add an alloy smelter recipe that takes 8 coal and 2 obsidian -> 2 diamonds
TRTweaker.addAlloySmelter(["minecraft:coal@8", "minecraft:obsidian@2"], ["minecraft:diamond@2"], 6, 200);
//Add an assembling machine recipe that takes 3 diamonds and 2 sticks -> 1 diamond pickaxe
TRTweaker.addAssemblingMachine(["minecraft:diamond@3", "minecraft:stick@2"], ["minecraft:diamond_pickaxe"], 20, 200);
//Add a blast furnace recipe that takes 64 of any item in the minecraft:coals tag -> 8 diamonds
TRTweaker.addBlastFurnace(["#minecraft:coals@64"], ["minecraft:diamond@8"], 128, 200, 1300);
//Add a centrifuge recipe that takes any potion -> a water bottle
TRTweaker.addCentrifuge(["minecraft:potion"], [TweakerUtils.getSpecialStack("minecraft:potion->minecraft:water")], 5, 1000);
//Add a chemical reactor recipe that takes a water bottle and a can of methane -> a potion of fire resistance
//DISCLAIMER: do not try this at home
TRTweaker.addChemicalReactor(["minecraft:potion->minecraft:water", TRTweaker.createFluidIngredient("techreborn:methane", ["techreborn:cell"], -1)], [TweakerUtils.getSpecialStack("minecraft:potion->minecraft:fire_resistance")], 30, 800);
//Add a compressor recipe that takes 9 coal blocks -> 3 pieces of obsidian
TRTweaker.addCompressor(["minecraft:coal_ore@9"], ["minecraft:coal_block@3"], 10, 300);
//Add a distillation tower recipe that takes a potion of regneration -> a strong potion of regeneration
TRTweaker.addDistillationTower(["minecraft:potion->minecraft:regeneration"], [TweakerUtils.getSpecialStack("minecraft:potion->minecraft:strong_regeneration")], 20, 400);
//Add an extractor recipe that takes 4 coal -> 1 gunpowder
TRTweaker.addExtractor(["minecraft:coal@4"], ["minecraft:gunpowder"], 10, 300);
//Add a grinder recipe of 1 sugar cane -> 3 sugar
TRTweaker.addGrinder(["minecraft:sugar_cane"], ["minecraft:sugar@3"], 4, 270);
//Add an implosion compressor recipe of 32 coal and 16 flint -> 16 diamonds
TRTweaker.addImplosionCompressor(["minecraft:coal@32", "minecraft:flint@16"], ["minecraft:diamond@16"], 30, 2000);
//Add an industrial electrolyzer recipe of 1 skeleton skull -> 1 wither skeleton skull
TRTweaker.addIndustrialElectrolyzer(["minecraft:skeleton_skull"], ["minecraft:wither_skeleton_skull"], 50, 1400);
//Add an industrial electrolyzer recipe of 1 sea lantern -> 5 prismarine crystals and 4 prismarine shards
TRTweaker.addIndustrialGrinder(["minecraft:sea_lantern"], ["minecraft:prismarine_crystals@5", "minecraft:prismarine_shard@4"], 64, 100);
//Add an industrial electrolyzer recipe of 1 sea lantern and 1 bucket of electrolyzed water -> 9 prismarine crystals
TRTweaker.addIndustrialGrinder(["minecraft:sea_lantern"], ["minecraft:prismarine_crystals@9"], 64, 100, "techreborn:electrolyzed_water@1000");
//Add an industrial sawmill recipe of 3 sugar cane -> 18 paper
TRTweaker.addIndustrialSawmill(["minecraft:sugar_cane@3"], ["minecraft:paper@18"], 40, 200);
//Add an industrial sawmill recipe of 1 heart of the sea and 1/2 bucket of water -> 16 nautilus shells
TRTweaker.addIndustrialSawmill(["minecraft:heart_of_the_sea"], ["minecraft:nautilus_shell@16"], 40, 200, "minecraft:water@500");
//Add a recycler recipe of 1 water bucket -> 1 empty bucket
TRTweaker.addRecycler(["minecraft:water_bucket"], ["minecraft:bucket"], 5, 40);
//Add a scrapbox recipe of 1 scrap box -> 1 shulker box
TRTweaker.addScrapbox("minecraft:shulker_box", 10, 20);
//Add a scrapbox recipe of 1 cell of water -> 1 blue ice
TRTweaker.addVacuumFreezer([TRTweaker.createFluidIngredient("minecraft:water", ["techreborn:cell"], -1)], ["minecraft:blue_ice"], 60, 440);
//Add a fluid replicator recipe of 2 uu matter and 1 bucket of wulframium -> 2 buckets of wolframium
TRTweaker.addFluidReplicator(["techreborn:uu_matter@2"], 40, 100, "techreborn:wolframium@1000");
//Add a fusion reactor recipe of 3 wither skeleton skulls and 4 soul sand -> 1 nether star
TRTweaker.addFusionReactor(["minecraft:wither_skeleton_skull@3", "minecraft:soul_sand@4"], ["minecraft:nether_star"], -2048, 1024, 90000, 1);
//Add a rolling machine recipe for 5 popped chorus fruit in a helmet shape -> a shulker shell
var chorus = "minecraft:popped_chorus_fruit";
TRTweaker.addRollingMachine([[chorus, chorus, chorus], [chorus, "", chorus]], "minecraft:shulker_shell");
//Create a pattern/dictionary set for a shaped recipe
var pattern = [ '/ /',
'/_/',
'/ /'];
var dict = {
"/": "minecraft:stick",
"_": "#minecraft:wooden_slabs"
};
//Add a rolling machine recipe for sticks on the sides and any wooden slab in the middle -> six ladders
TRTweaker.addDictRollingMachine(pattern, dict, "minecraft:ladder@12");
//Add a solid canning machine recipe for 1 empty cell and 1 blue ice -> a cell full of water
TRTweaker.addSolidCanningMachine(["techreborn:cell{}", "minecraft:blue_ice"], [TweakerUtils.getSpecialStack("techreborn:cell->minecraft:water")], 1, 100);
//Add a wire mill recipe for 1 woll -> 4 string
TRTweaker.addWireMill(["#minecraft:wool"], ["minecraft:string@4"], 2, 200);
//Add a plasma fluid generator recipe for 1 mB of wolframium -> 300 EU
TRTweaker.addFluidGenerator("plasma", "techreborn:wolframium", 300);

View file

@ -1,5 +0,0 @@
{
"when": [
{ "libcd:dev_mode": true }
]
}