Added datagen: Concrete Grinder and some dying recipes. Thanks to Ayutac

* Added datagen: Concrete Grinder and some dying recipes

* fixed the bugs

* dont decrease efficiency of carpet...

* another bug leftover, whoops
This commit is contained in:
Ayutac 2022-03-30 11:23:05 +02:00 committed by GitHub
parent e28c9176e5
commit ccfeeb42b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 311 additions and 8 deletions

View file

@ -27,6 +27,7 @@ package techreborn.datagen
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import techreborn.datagen.recipes.machine.blast_furnace.BlastFurnaceRecipesProvider
import techreborn.datagen.recipes.machine.chemical_reactor.ChemicalReactorRecipesProvider
import techreborn.datagen.recipes.machine.compressor.CompressorRecipesProvider
import techreborn.datagen.recipes.machine.grinder.GrinderRecipesProvider
import techreborn.datagen.recipes.machine.industrial_sawmill.IndustrialSawmillRecipesProvider
@ -49,6 +50,7 @@ class TechRebornDataGen implements DataGeneratorEntrypoint {
fabricDataGenerator.addProvider(GrinderRecipesProvider.&new)
fabricDataGenerator.addProvider(CompressorRecipesProvider.&new)
fabricDataGenerator.addProvider(ChemicalReactorRecipesProvider.&new)
fabricDataGenerator.addProvider(BlastFurnaceRecipesProvider.&new)
fabricDataGenerator.addProvider(IndustrialSawmillRecipesProvider.&new)
}

View file

@ -131,6 +131,10 @@ abstract class TechRebornRecipesProvider extends FabricRecipeProvider {
MachineRecipeJsonFactory.create(ModRecipes.COMPRESSOR, closure).offerTo(exporter)
}
def offerChemicalReactorRecipe(@DelegatesTo(value = MachineRecipeJsonFactory.class, strategy = Closure.DELEGATE_FIRST) Closure closure) {
MachineRecipeJsonFactory.create(ModRecipes.CHEMICAL_REACTOR, closure).offerTo(exporter)
}
@Override
protected Identifier getRecipeIdentifier(Identifier identifier) {
return new Identifier("techreborn", super.getRecipeIdentifier(identifier).path)

View file

@ -49,11 +49,11 @@ class IngredientBuilder {
throw new IllegalStateException("Cannot have ingredient with tag and stack inputs")
}
return new TagIngredient(tag, getCount())
return new TagIngredient(tag, Optional.empty())
}
if (stacks.size() == 1) {
return new StackIngredient(stacks.get(0), getCount(), Optional.empty(), false)
return new StackIngredient(stacks.get(0), Optional.of(stacks.get(0).getCount()), Optional.empty(), false)
}
throw new IllegalStateException()
@ -72,9 +72,4 @@ class IngredientBuilder {
stacks.add(itemStack)
return this
}
private Optional<Integer> getCount() {
return Optional.empty()
}
}

View file

@ -78,8 +78,12 @@ class MachineRecipeJsonFactory<R extends RebornRecipe> {
ingredient {
tag object
}
} else if (object instanceof ItemStack) {
ingredient {
stack object
}
} else {
throw new UnsupportedOperationException()
throw new IllegalArgumentException()
}
}

View file

@ -0,0 +1,267 @@
/*
* 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.chemical_reactor
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import net.minecraft.item.ItemStack
import net.minecraft.item.Items
import techreborn.datagen.recipes.TechRebornRecipesProvider
class ChemicalReactorRecipesProvider extends TechRebornRecipesProvider {
public final int DYE_POWER = 25
public final int DYE_TIME = 250
ChemicalReactorRecipesProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator)
}
@Override
void generateRecipes() {
generateWoolFromWhite()
generateCarpetFromWhite()
generateConcretePowderFromWhite()
generateCandleFromNeutral()
generateGlassFromNeutral()
generateGlassPaneFromNeutral()
generateTerracottaFromNeutral()
}
void generateWoolFromWhite() {
[
(Items.BLACK_DYE): Items.BLACK_WOOL,
(Items.BLUE_DYE): Items.BLUE_WOOL,
(Items.BROWN_DYE): Items.BROWN_WOOL,
(Items.CYAN_DYE): Items.CYAN_WOOL,
(Items.GRAY_DYE): Items.GRAY_WOOL,
(Items.GREEN_DYE): Items.GREEN_WOOL,
(Items.LIGHT_BLUE_DYE): Items.LIGHT_BLUE_WOOL,
(Items.LIGHT_GRAY_DYE): Items.LIGHT_GRAY_WOOL,
(Items.LIME_DYE): Items.LIME_WOOL,
(Items.MAGENTA_DYE): Items.MAGENTA_WOOL,
(Items.ORANGE_DYE): Items.ORANGE_WOOL,
(Items.PINK_DYE): Items.PINK_WOOL,
(Items.PURPLE_DYE): Items.PURPLE_WOOL,
(Items.RED_DYE): Items.RED_WOOL,
// (Items.WHITE_DYE): Items.WHITE_WOOL, // white stays white
(Items.YELLOW_DYE): Items.YELLOW_WOOL
].each {dye, wool ->
offerChemicalReactorRecipe {
ingredients dye, new ItemStack(Items.WHITE_WOOL, 4)
output new ItemStack(wool, 4)
source "white_wool"
power DYE_POWER
time DYE_TIME
criterion getCriterionName(dye), getCriterionConditions(dye)
}
}
}
void generateCarpetFromWhite() {
[
(Items.BLACK_DYE): Items.BLACK_CARPET,
(Items.BLUE_DYE): Items.BLUE_CARPET,
(Items.BROWN_DYE): Items.BROWN_CARPET,
(Items.CYAN_DYE): Items.CYAN_CARPET,
(Items.GRAY_DYE): Items.GRAY_CARPET,
(Items.GREEN_DYE): Items.GREEN_CARPET,
(Items.LIGHT_BLUE_DYE): Items.LIGHT_BLUE_CARPET,
(Items.LIGHT_GRAY_DYE): Items.LIGHT_GRAY_CARPET,
(Items.LIME_DYE): Items.LIME_CARPET,
(Items.MAGENTA_DYE): Items.MAGENTA_CARPET,
(Items.ORANGE_DYE): Items.ORANGE_CARPET,
(Items.PINK_DYE): Items.PINK_CARPET,
(Items.PURPLE_DYE): Items.PURPLE_CARPET,
(Items.RED_DYE): Items.RED_CARPET,
// (Items.WHITE_DYE): Items.WHITE_CARPET, // white stays white
(Items.YELLOW_DYE): Items.YELLOW_CARPET
].each {dye, carpet ->
offerChemicalReactorRecipe {
ingredients dye, new ItemStack(Items.WHITE_CARPET, 8)
output new ItemStack(carpet, 8)
source "white_carpet"
power DYE_POWER
time DYE_TIME
criterion getCriterionName(dye), getCriterionConditions(dye)
}
}
}
void generateConcretePowderFromWhite() {
[
(Items.BLACK_DYE): Items.BLACK_CONCRETE_POWDER,
(Items.BLUE_DYE): Items.BLUE_CONCRETE_POWDER,
(Items.BROWN_DYE): Items.BROWN_CONCRETE_POWDER,
(Items.CYAN_DYE): Items.CYAN_CONCRETE_POWDER,
(Items.GRAY_DYE): Items.GRAY_CONCRETE_POWDER,
(Items.GREEN_DYE): Items.GREEN_CONCRETE_POWDER,
(Items.LIGHT_BLUE_DYE): Items.LIGHT_BLUE_CONCRETE_POWDER,
(Items.LIGHT_GRAY_DYE): Items.LIGHT_GRAY_CONCRETE_POWDER,
(Items.LIME_DYE): Items.LIME_CONCRETE_POWDER,
(Items.MAGENTA_DYE): Items.MAGENTA_CONCRETE_POWDER,
(Items.ORANGE_DYE): Items.ORANGE_CONCRETE_POWDER,
(Items.PINK_DYE): Items.PINK_CONCRETE_POWDER,
(Items.PURPLE_DYE): Items.PURPLE_CONCRETE_POWDER,
(Items.RED_DYE): Items.RED_CONCRETE_POWDER,
// (Items.WHITE_DYE): Items.WHITE_CONCRETE_POWDER, // white stays white
(Items.YELLOW_DYE): Items.YELLOW_CONCRETE_POWDER
].each {dye, concretePowder ->
offerChemicalReactorRecipe {
ingredients dye, new ItemStack(Items.WHITE_CONCRETE_POWDER, 8)
output new ItemStack(concretePowder, 8)
source "white_concrete_powder"
power DYE_POWER
time DYE_TIME
criterion getCriterionName(dye), getCriterionConditions(dye)
}
}
}
// explicitly no recipes for concrete, too thick a material, needs to be grinded back to powder first
void generateCandleFromNeutral() {
[
(Items.BLACK_DYE): Items.BLACK_CANDLE,
(Items.BLUE_DYE): Items.BLUE_CANDLE,
(Items.BROWN_DYE): Items.BROWN_CANDLE,
(Items.CYAN_DYE): Items.CYAN_CANDLE,
(Items.GRAY_DYE): Items.GRAY_CANDLE,
(Items.GREEN_DYE): Items.GREEN_CANDLE,
(Items.LIGHT_BLUE_DYE): Items.LIGHT_BLUE_CANDLE,
(Items.LIGHT_GRAY_DYE): Items.LIGHT_GRAY_CANDLE,
(Items.LIME_DYE): Items.LIME_CANDLE,
(Items.MAGENTA_DYE): Items.MAGENTA_CANDLE,
(Items.ORANGE_DYE): Items.ORANGE_CANDLE,
(Items.PINK_DYE): Items.PINK_CANDLE,
(Items.PURPLE_DYE): Items.PURPLE_CANDLE,
(Items.RED_DYE): Items.RED_CANDLE,
(Items.WHITE_DYE): Items.WHITE_CANDLE,
(Items.YELLOW_DYE): Items.YELLOW_CANDLE
].each {dye, candle ->
offerChemicalReactorRecipe {
ingredients dye, new ItemStack(Items.CANDLE, 2)
output new ItemStack(candle, 2)
source "candle"
power DYE_POWER
time DYE_TIME
criterion getCriterionName(dye), getCriterionConditions(dye)
}
}
}
void generateGlassFromNeutral() {
[
(Items.BLACK_DYE): Items.BLACK_STAINED_GLASS,
(Items.BLUE_DYE): Items.BLUE_STAINED_GLASS,
(Items.BROWN_DYE): Items.BROWN_STAINED_GLASS,
(Items.CYAN_DYE): Items.CYAN_STAINED_GLASS,
(Items.GRAY_DYE): Items.GRAY_STAINED_GLASS,
(Items.GREEN_DYE): Items.GREEN_STAINED_GLASS,
(Items.LIGHT_BLUE_DYE): Items.LIGHT_BLUE_STAINED_GLASS,
(Items.LIGHT_GRAY_DYE): Items.LIGHT_GRAY_STAINED_GLASS,
(Items.LIME_DYE): Items.LIME_STAINED_GLASS,
(Items.MAGENTA_DYE): Items.MAGENTA_STAINED_GLASS,
(Items.ORANGE_DYE): Items.ORANGE_STAINED_GLASS,
(Items.PINK_DYE): Items.PINK_STAINED_GLASS,
(Items.PURPLE_DYE): Items.PURPLE_STAINED_GLASS,
(Items.RED_DYE): Items.RED_STAINED_GLASS,
(Items.WHITE_DYE): Items.WHITE_STAINED_GLASS,
(Items.YELLOW_DYE): Items.YELLOW_STAINED_GLASS
].each {dye, glass ->
offerChemicalReactorRecipe {
ingredients dye, new ItemStack(Items.GLASS, 12)
output new ItemStack(glass, 12)
source "glass"
power DYE_POWER
time DYE_TIME
criterion getCriterionName(dye), getCriterionConditions(dye)
}
}
}
void generateGlassPaneFromNeutral() {
[
(Items.BLACK_DYE): Items.BLACK_STAINED_GLASS_PANE,
(Items.BLUE_DYE): Items.BLUE_STAINED_GLASS_PANE,
(Items.BROWN_DYE): Items.BROWN_STAINED_GLASS_PANE,
(Items.CYAN_DYE): Items.CYAN_STAINED_GLASS_PANE,
(Items.GRAY_DYE): Items.GRAY_STAINED_GLASS_PANE,
(Items.GREEN_DYE): Items.GREEN_STAINED_GLASS_PANE,
(Items.LIGHT_BLUE_DYE): Items.LIGHT_BLUE_STAINED_GLASS_PANE,
(Items.LIGHT_GRAY_DYE): Items.LIGHT_GRAY_STAINED_GLASS_PANE,
(Items.LIME_DYE): Items.LIME_STAINED_GLASS_PANE,
(Items.MAGENTA_DYE): Items.MAGENTA_STAINED_GLASS_PANE,
(Items.ORANGE_DYE): Items.ORANGE_STAINED_GLASS_PANE,
(Items.PINK_DYE): Items.PINK_STAINED_GLASS_PANE,
(Items.PURPLE_DYE): Items.PURPLE_STAINED_GLASS_PANE,
(Items.RED_DYE): Items.RED_STAINED_GLASS_PANE,
(Items.WHITE_DYE): Items.WHITE_STAINED_GLASS_PANE,
(Items.YELLOW_DYE): Items.YELLOW_STAINED_GLASS_PANE
].each {dye, glass_pane ->
offerChemicalReactorRecipe {
ingredients dye, new ItemStack(Items.GLASS_PANE, 16)
output new ItemStack(glass_pane, 16)
source "glass_pane"
power DYE_POWER
time DYE_TIME
criterion getCriterionName(dye), getCriterionConditions(dye)
}
}
}
void generateTerracottaFromNeutral() {
[
(Items.BLACK_DYE): Items.BLACK_TERRACOTTA,
(Items.BLUE_DYE): Items.BLUE_TERRACOTTA,
(Items.BROWN_DYE): Items.BROWN_TERRACOTTA,
(Items.CYAN_DYE): Items.CYAN_TERRACOTTA,
(Items.GRAY_DYE): Items.GRAY_TERRACOTTA,
(Items.GREEN_DYE): Items.GREEN_TERRACOTTA,
(Items.LIGHT_BLUE_DYE): Items.LIGHT_BLUE_TERRACOTTA,
(Items.LIGHT_GRAY_DYE): Items.LIGHT_GRAY_TERRACOTTA,
(Items.LIME_DYE): Items.LIME_TERRACOTTA,
(Items.MAGENTA_DYE): Items.MAGENTA_TERRACOTTA,
(Items.ORANGE_DYE): Items.ORANGE_TERRACOTTA,
(Items.PINK_DYE): Items.PINK_TERRACOTTA,
(Items.PURPLE_DYE): Items.PURPLE_TERRACOTTA,
(Items.RED_DYE): Items.RED_TERRACOTTA,
(Items.WHITE_DYE): Items.WHITE_TERRACOTTA,
(Items.YELLOW_DYE): Items.YELLOW_TERRACOTTA
].each {dye, terracotta ->
offerChemicalReactorRecipe {
ingredients dye, new ItemStack(Items.TERRACOTTA, 8)
output new ItemStack(terracotta, 8)
source "terracotta"
power DYE_POWER
time DYE_TIME
criterion getCriterionName(dye), getCriterionConditions(dye)
}
}
}
// no recipes for beds and banners since the chemical reactor cannot color partially
// and glazed terracotta is too special to be recolored
}

View file

@ -51,6 +51,7 @@ class GrinderRecipesProvider extends TechRebornRecipesProvider {
generateTRIngots()
generateSand()
generateRedSand()
generateConcretePowder()
}
void generateVanillaRawMetals() {
@ -180,4 +181,34 @@ class GrinderRecipesProvider extends TechRebornRecipesProvider {
}
}
}
void generateConcretePowder() {
[
(Items.BLACK_CONCRETE): Items.BLACK_CONCRETE_POWDER,
(Items.BLUE_CONCRETE): Items.BLUE_CONCRETE_POWDER,
(Items.BROWN_CONCRETE): Items.BROWN_CONCRETE_POWDER,
(Items.CYAN_CONCRETE): Items.CYAN_CONCRETE_POWDER,
(Items.GRAY_CONCRETE): Items.GRAY_CONCRETE_POWDER,
(Items.GREEN_CONCRETE): Items.GREEN_CONCRETE_POWDER,
(Items.LIGHT_BLUE_CONCRETE): Items.LIGHT_BLUE_CONCRETE_POWDER,
(Items.LIGHT_GRAY_CONCRETE): Items.LIGHT_GRAY_CONCRETE_POWDER,
(Items.LIME_CONCRETE): Items.LIME_CONCRETE_POWDER,
(Items.MAGENTA_CONCRETE): Items.MAGENTA_CONCRETE_POWDER,
(Items.ORANGE_CONCRETE): Items.ORANGE_CONCRETE_POWDER,
(Items.PINK_CONCRETE): Items.PINK_CONCRETE_POWDER,
(Items.PURPLE_CONCRETE): Items.PURPLE_CONCRETE_POWDER,
(Items.RED_CONCRETE): Items.RED_CONCRETE_POWDER,
(Items.WHITE_CONCRETE): Items.WHITE_CONCRETE_POWDER,
(Items.YELLOW_CONCRETE): Items.YELLOW_CONCRETE_POWDER
].each {concrete, concretePowder ->
offerGrinderRecipe {
ingredients concrete
outputs concretePowder
source "concrete"
power 4
time 200
criterion getCriterionName(concrete), getCriterionConditions(concrete)
}
}
}
}