Grinder datagen w/o toasts. -25 manual, +41 datagen recipes

Unified power/time for a couple of similar processings.
All storage blocks of items that could be grinded should be able to be grinded now, with some time save compared to the items themselves.
This commit is contained in:
Ayutac 2022-01-29 10:27:51 +01:00
parent 5b596aa5f8
commit 79715b89a1
28 changed files with 212 additions and 408 deletions

View file

@ -32,6 +32,7 @@ import net.minecraft.recipe.RecipeSerializer
import net.minecraft.tag.Tag
import net.minecraft.util.Identifier
import net.minecraft.util.registry.Registry
import org.jetbrains.annotations.NotNull
import reborncore.common.crafting.RebornRecipe
import reborncore.common.crafting.RebornRecipeType
import reborncore.common.crafting.ingredient.RebornIngredient
@ -46,6 +47,7 @@ class MachineRecipeJsonFactory<R extends RebornRecipe> {
private int power = -1
private int time = -1
private Identifier customId = null
private String source = null
protected MachineRecipeJsonFactory(RebornRecipeType<R> type) {
this.type = type
@ -120,6 +122,17 @@ class MachineRecipeJsonFactory<R extends RebornRecipe> {
return this
}
def source(String s) {
this.source = s
return this
}
@NotNull String getSourceAppendix() {
if (source == null)
return ""
return "_from_" + source
}
MachineRecipeJsonFactory id(String path) {
return id(new Identifier("techreborn", path))
}
@ -168,7 +181,7 @@ class MachineRecipeJsonFactory<R extends RebornRecipe> {
}
def outputId = Registry.ITEM.getId(outputs[0].item)
return new Identifier("techreborn", "${type.name().path}/${outputId.path}")
return new Identifier("techreborn", "${type.name().path}/${outputId.path}${getSourceAppendix()}")
}
static class MachineRecipeJsonProvider<R extends RebornRecipe> implements RecipeJsonProvider {

View file

@ -25,7 +25,11 @@
package techreborn.datagen.recipes.machine.grinder
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import net.fabricmc.fabric.api.tag.TagFactory
import net.minecraft.item.ItemStack
import net.minecraft.item.Items
import net.minecraft.util.Identifier
import techreborn.TechReborn
import techreborn.datagen.recipes.TechRebornRecipesProvider
import techreborn.init.TRContent
@ -36,11 +40,74 @@ class GrinderRecipesProvider extends TechRebornRecipesProvider {
@Override
void generateRecipes() {
// offerGrinderRecipe {
// ingredients TRContent.ORES_TAG, Items.ACACIA_BOAT
// outputs Items.DIAMOND
// power 5
// time 200
// }
// vanilla raw metals
[
(Items.RAW_IRON): (TagFactory.ITEM.create(new Identifier("c","iron_ores"))),
(Items.RAW_COPPER): (TagFactory.ITEM.create(new Identifier("c","copper_ores"))),
(Items.RAW_GOLD): (TagFactory.ITEM.create(new Identifier("c","gold_ores")))
].each{raw, oreTag ->
offerGrinderRecipe {
ingredients oreTag
outputs new ItemStack(raw, 2)
power 2
time 270
}
}
// TR raw metals
TRContent.RawMetals.getRM2OBMap().each{raw, ore ->
if (!ore.isIndustrial())
offerGrinderRecipe {
ingredients ore.asTag()
outputs new ItemStack(raw, 2)
power 2
time 270
}
}
// vanilla gems
// TODO vanilla gems + storage blocks (Redstone, glowstone, lapis, emerald, diamond)
// TR gems
TRContent.Gems.getG2DMap().each {gem, dust ->
offerGrinderRecipe {
ingredients gem.asTag()
outputs dust
power 2
time 200
}
if (gem.getOre() != null)
offerGrinderRecipe {
ingredients gem.getOre().asTag()
outputs new ItemStack(dust,2)
power 2
time 220
source "ore"
}
if (gem.getStorageBlock() != null)
offerGrinderRecipe {
ingredients gem.getStorageBlock().asTag()
outputs new ItemStack(dust,9)
power 2
time 1500
source "block"
}
}
// vanilla ingots
// TODO vanilla ingots + storage blocks (iron, copper, gold)
// TR ingots
TRContent.Ingots.getI2DMap().each {ingot, dust ->
offerGrinderRecipe {
ingredients ingot.asTag()
outputs dust
power 5
time 200
}
if (ingot.getStorageBlock() != null)
offerGrinderRecipe {
ingredients ingot.getStorageBlock().asTag()
outputs new ItemStack(dust,9)
power 5
time 1500
source "block"
}
}
}
}

View file

@ -408,7 +408,7 @@ public class TRContent {
BAUXITE(OreDistribution.BAUXITE),
CINNABAR(OreDistribution.CINNABAR),
GALENA(OreDistribution.GALENA),
IRIDIUM(OreDistribution.IRIDIUM),
IRIDIUM(OreDistribution.IRIDIUM, true),
LEAD(OreDistribution.LEAD),
PERIDOT(OreDistribution.PERIDOT),
PYRITE(OreDistribution.PYRITE),
@ -419,7 +419,7 @@ public class TRContent {
SODALITE(OreDistribution.SODALITE),
SPHALERITE(OreDistribution.SPHALERITE),
TIN(OreDistribution.TIN),
TUNGSTEN(OreDistribution.TUNGSTEN),
TUNGSTEN(OreDistribution.TUNGSTEN, true),
DEEPSLATE_BAUXITE(BAUXITE),
DEEPSLATE_GALENA(GALENA),
@ -437,9 +437,10 @@ public class TRContent {
public final String name;
public final Block block;
public final OreDistribution distribution;
private final boolean industrial;
private final Tag.Identified<Item> tag;
Ores(OreDistribution distribution, UniformIntProvider experienceDroppedFallback) {
Ores(OreDistribution distribution, UniformIntProvider experienceDroppedFallback, boolean industrial) {
name = this.toString().toLowerCase(Locale.ROOT);
block = new OreBlock(FabricBlockSettings.of(Material.STONE)
.requiresTool()
@ -447,18 +448,27 @@ public class TRContent {
.strength(2f, 2f),
distribution != null ? distribution.experienceDropped : experienceDroppedFallback
);
this.industrial = industrial;
InitUtils.setup(block, name + "_ore");
tag = TagFactory.ITEM.create(new Identifier("c",
(name.startsWith("deepslate_") ? name.substring(name.indexOf('_')+1): name) + "_ores"));
this.distribution = distribution;
}
Ores(OreDistribution distribution, UniformIntProvider experienceDroppedFallback) {
this(distribution, experienceDroppedFallback, false);
}
Ores(OreDistribution distribution, boolean industrial) {
this(distribution, null, industrial);
}
Ores(OreDistribution distribution) {
this(distribution, null);
this(distribution, false);
}
Ores(TRContent.Ores stoneOre) {
this(null, stoneOre.distribution != null ? stoneOre.distribution.experienceDropped : null);
this(null, stoneOre.distribution != null ? stoneOre.distribution.experienceDropped : null, stoneOre.industrial);
deepslateMap.put(stoneOre, this);
unDeepslateMap.put(this, stoneOre);
}
@ -468,6 +478,10 @@ public class TRContent {
return block.asItem();
}
public boolean isIndustrial() {
return industrial;
}
@Override
public Tag.Identified<Item> asTag() {
return tag;
@ -717,13 +731,22 @@ public class TRContent {
private final String name;
private final Item item;
private final ItemConvertible storageBlock;
private final Ores ore;
private final StorageBlocks storageBlock;
private final Tag.Identified<Item> tag;
RawMetals() {
name = this.toString().toLowerCase(Locale.ROOT);
item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP));
ItemConvertible blockVariant = null;
Ores oreVariant = null;
try {
oreVariant = Ores.valueOf(this.toString());
}
catch (IllegalArgumentException ex) {
TechReborn.LOGGER.warn("Raw metal {} has no ore block equivalent!", name);
}
ore = oreVariant;
StorageBlocks blockVariant = null;
try {
blockVariant = StorageBlocks.valueOf(this.toString());
}
@ -745,21 +768,37 @@ public class TRContent {
return tag;
}
public ItemConvertible getStorageBlock() {
public StorageBlocks getStorageBlock() {
return storageBlock;
}
public Ores getOre() {
return ore;
}
/**
* Returns a map that maps the raw metals to their storage block equivalent.
* @return A non {@code null} map mapping the raw metals to their storage block equivalent.
* If a storage block equivalent doesn't exist, the raw metal will not be in the keys of this map.
*/
public static @NotNull Map<RawMetals, ItemConvertible> getRM2SBMap() {
public static @NotNull Map<RawMetals, StorageBlocks> getRM2SBMap() {
return Arrays.stream(values())
.map(rawMetal -> new Pair<>(rawMetal, rawMetal.getStorageBlock()))
.filter(entry -> entry.getRight() != null) // ensure storage block equivalent exists
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
}
/**
* Returns a map that maps the raw metals to their ore block equivalent.
* @return A non {@code null} map mapping the raw metals to their ore block equivalent.
* If an ore block equivalent doesn't exist, the raw metal will not be in the keys of this map.
*/
public static @NotNull Map<RawMetals, Ores> getRM2OBMap() {
return Arrays.stream(values())
.map(rawMetal -> new Pair<>(rawMetal, rawMetal.getOre()))
.filter(entry -> entry.getRight() != null) // ensure ore block equivalent exists
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
}
}
public static final Tag.Identified<Item> SMALL_DUSTS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "small_dusts"));
@ -841,13 +880,31 @@ public class TRContent {
private final String name;
private final Item item;
private final ItemConvertible storageBlock;
private final Dusts dust;
private final Ores ore;
private final StorageBlocks storageBlock;
private final Tag.Identified<Item> tag;
Gems(String tagPlural) {
name = this.toString().toLowerCase(Locale.ROOT);
item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP));
ItemConvertible blockVariant = null;
Dusts dustVariant = null;
try {
dustVariant = Dusts.valueOf(this.toString());
}
catch (IllegalArgumentException ex) {
TechReborn.LOGGER.warn("Gem {} has no dust item equivalent!", name);
}
dust = dustVariant;
Ores oreVariant = null;
try {
oreVariant = Ores.valueOf(this.toString());
}
catch (IllegalArgumentException ex) {
TechReborn.LOGGER.info("Gem {} has no ore block equivalent.", name);
}
ore = oreVariant;
StorageBlocks blockVariant = null;
try {
blockVariant = StorageBlocks.valueOf(this.toString());
}
@ -881,16 +938,36 @@ public class TRContent {
return tag;
}
public ItemConvertible getStorageBlock() {
public Dusts getDust() {
return dust;
}
public Ores getOre() {
return ore;
}
public StorageBlocks getStorageBlock() {
return storageBlock;
}
/**
* Returns a map that maps the gems to their dust item equivalent.
* @return A non {@code null} map mapping the gems to their dust item equivalent.
* If a dust item equivalent doesn't exist, the gem will not be in the keys of this map.
*/
public static @NotNull Map<Gems, Dusts> getG2DMap() {
return Arrays.stream(values())
.map(gem -> new Pair<>(gem, gem.getDust()))
.filter(entry -> entry.getRight() != null) // ensure dust item equivalent exists
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
}
/**
* Returns a map that maps the gems to their storage block equivalent.
* @return A non {@code null} map mapping the gems to their storage block equivalent.
* If a storage block equivalent doesn't exist, the raw metal will not be in the keys of this map.
* If a storage block equivalent doesn't exist, the gem will not be in the keys of this map.
*/
public static @NotNull Map<Gems, ItemConvertible> getG2SBMap() {
public static @NotNull Map<Gems, StorageBlocks> getG2SBMap() {
return Arrays.stream(values())
.map(gem -> new Pair<>(gem, gem.getStorageBlock()))
.filter(entry -> entry.getRight() != null) // ensure storage block equivalent exists
@ -906,13 +983,28 @@ public class TRContent {
private final String name;
private final Item item;
private final ItemConvertible storageBlock;
private final Dusts dust;
private final StorageBlocks storageBlock;
private final Tag.Identified<Item> tag;
Ingots() {
name = this.toString().toLowerCase(Locale.ROOT);
item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP));
ItemConvertible blockVariant = null;
Dusts dustVariant = null;
try {
dustVariant = Dusts.valueOf(this.toString());
}
catch (IllegalArgumentException ex) {
try {
RawMetals.valueOf(this.toString());
TechReborn.LOGGER.info("Ingot {} has no dust item equivalent, but a raw metal.", name);
}
catch (IllegalArgumentException ex2) {
TechReborn.LOGGER.warn("Ingot {} has no dust item equivalent AND no raw metal!", name);
}
}
dust = dustVariant;
StorageBlocks blockVariant = null;
try {
blockVariant = StorageBlocks.valueOf(this.toString());
}
@ -942,10 +1034,26 @@ public class TRContent {
return tag;
}
public ItemConvertible getStorageBlock() {
public Dusts getDust() {
return dust;
}
public StorageBlocks getStorageBlock() {
return storageBlock;
}
/**
* Returns a map that maps the ingots to their dust item equivalent.
* @return A non {@code null} map mapping the ingots to their dust item equivalent.
* If a dust item equivalent doesn't exist, the ingot will not be in the keys of this map.
*/
public static @NotNull Map<Ingots, Dusts> getI2DMap() {
return Arrays.stream(values())
.map(gem -> new Pair<>(gem, gem.getDust()))
.filter(entry -> entry.getRight() != null) // ensure dust item equivalent exists
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
}
/**
* Returns a map that maps the ingots to their storage block equivalent.
* @return A non {@code null} map mapping the ingots to their storage block equivalent.

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 200,
"ingredients": [
{
"tag": "c:aluminum_ingots"
}
],
"results": [
{
"item": "techreborn:aluminum_dust"
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 5,
"time": 200,
"ingredients": [
{
"tag": "c:brass_ingots"
}
],
"results": [
{
"item": "techreborn:brass_dust"
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 5,
"time": 200,
"ingredients": [
{
"tag": "c:bronze_ingots"
}
],
"results": [
{
"item": "techreborn:bronze_dust"
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 6,
"time": 250,
"ingredients": [
{
"tag": "c:chrome_ingots"
}
],
"results": [
{
"item": "techreborn:chrome_dust"
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 6,
"time": 220,
"ingredients": [
{
"tag": "c:electrum_ingots"
}
],
"results": [
{
"item": "techreborn:electrum_dust"
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 200,
"ingredients": [
{
"item": "techreborn:invar_ingot"
}
],
"results": [
{
"item": "techreborn:invar_dust"
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 200,
"ingredients": [
{
"tag": "c:nickel_ingots"
}
],
"results": [
{
"item": "techreborn:nickel_dust"
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 200,
"ingredients": [
{
"item": "techreborn:peridot_gem"
}
],
"results": [
{
"item": "techreborn:peridot_dust"
}
]
}

View file

@ -1,16 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 270,
"ingredients": [
{
"tag": "c:peridot_ores"
}
],
"results": [
{
"item": "techreborn:peridot_dust",
"count": 2
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 4,
"time": 200,
"ingredients": [
{
"tag": "c:platinum_ingots"
}
],
"results": [
{
"item": "techreborn:platinum_dust"
}
]
}

View file

@ -1,16 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 270,
"ingredients": [
{
"tag": "c:copper_ores"
}
],
"results": [
{
"item": "minecraft:raw_copper",
"count": 2
}
]
}

View file

@ -1,16 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 270,
"ingredients": [
{
"tag": "c:gold_ores"
}
],
"results": [
{
"item": "minecraft:raw_gold",
"count": 2
}
]
}

View file

@ -1,16 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 270,
"ingredients": [
{
"tag": "c:iron_ores"
}
],
"results": [
{
"item": "minecraft:raw_iron",
"count": 2
}
]
}

View file

@ -1,16 +0,0 @@
{
"type": "techreborn:grinder",
"power": 4,
"time": 270,
"ingredients": [
{
"tag": "c:lead_ores"
}
],
"results": [
{
"item": "techreborn:raw_lead",
"count": 2
}
]
}

View file

@ -1,16 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 220,
"ingredients": [
{
"tag": "c:silver_ores"
}
],
"results": [
{
"item": "techreborn:raw_silver",
"count": 2
}
]
}

View file

@ -1,16 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 270,
"ingredients": [
{
"tag": "c:tin_ores"
}
],
"results": [
{
"item": "techreborn:raw_tin",
"count": 2
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 200,
"ingredients": [
{
"item": "techreborn:red_garnet_gem"
}
],
"results": [
{
"item": "techreborn:red_garnet_dust"
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 200,
"ingredients": [
{
"item": "techreborn:ruby_gem"
}
],
"results": [
{
"item": "techreborn:ruby_dust"
}
]
}

View file

@ -1,16 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 270,
"ingredients": [
{
"tag": "c:ruby_ores"
}
],
"results": [
{
"item": "techreborn:ruby_dust",
"count": 2
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 200,
"ingredients": [
{
"item": "techreborn:sapphire_gem"
}
],
"results": [
{
"item": "techreborn:sapphire_dust"
}
]
}

View file

@ -1,16 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 220,
"ingredients": [
{
"tag": "c:sapphire_ores"
}
],
"results": [
{
"item": "techreborn:sapphire_dust",
"count": 2
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 4,
"time": 240,
"ingredients": [
{
"tag": "c:steel_ingots"
}
],
"results": [
{
"item": "techreborn:steel_dust"
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 4,
"time": 220,
"ingredients": [
{
"tag": "c:titanium_ingots"
}
],
"results": [
{
"item": "techreborn:titanium_dust"
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 200,
"ingredients": [
{
"item": "techreborn:yellow_garnet_gem"
}
],
"results": [
{
"item": "techreborn:yellow_garnet_dust"
}
]
}

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 200,
"ingredients": [
{
"tag": "c:zinc_ingots"
}
],
"results": [
{
"item": "techreborn:zinc_dust"
}
]
}