ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/data/EmpoweringRecipeGenerator.java

171 lines
9.2 KiB
Java
Raw Normal View History

package de.ellpeck.actuallyadditions.data;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.Crystals;
2024-03-04 22:03:46 +01:00
import de.ellpeck.actuallyadditions.mod.util.NoAdvRecipeOutput;
2024-03-04 20:21:48 +01:00
import net.minecraft.core.NonNullList;
import net.minecraft.core.registries.BuiltInRegistries;
2024-03-03 01:20:53 +01:00
import net.minecraft.data.PackOutput;
2024-03-04 20:21:48 +01:00
import net.minecraft.data.recipes.RecipeOutput;
2024-03-02 21:23:08 +01:00
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags;
2024-03-02 21:23:08 +01:00
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.ItemLike;
2024-03-04 20:21:48 +01:00
import net.neoforged.neoforge.common.Tags;
2021-10-23 20:17:04 +02:00
public class EmpoweringRecipeGenerator extends RecipeProvider {
2024-03-03 01:20:53 +01:00
public EmpoweringRecipeGenerator(PackOutput packOutput) {
super(packOutput);
}
@Override
2024-03-03 01:20:53 +01:00
public String getName() {
return "Empowering " + super.getName();
}
2024-03-03 01:20:53 +01:00
@Override
2024-03-04 22:03:46 +01:00
protected void buildRecipes(RecipeOutput output) {
var recipeOutput = new NoAdvRecipeOutput(output);
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_RESTONIA_CRYSTAL.get(), ActuallyItems.RESTONIA_CRYSTAL.get(), 5000, 50, Crystals.REDSTONE.conversionColorParticles)
2021-11-13 20:09:55 +01:00
.addModifier(Tags.Items.DYES_RED)
.addModifier(Items.NETHER_BRICK)
.addModifier(Tags.Items.DUSTS_REDSTONE)
2024-03-04 22:03:46 +01:00
.addModifier(Items.BRICK).save(recipeOutput, "restonia");
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_RESTONIA_CRYSTAL.get(), ActuallyBlocks.RESTONIA_CRYSTAL.get(), 50000, 500, Crystals.REDSTONE.conversionColorParticles)
2021-11-13 20:09:55 +01:00
.addModifier(Tags.Items.DYES_RED)
.addModifier(Items.NETHER_BRICK)
.addModifier(Tags.Items.DUSTS_REDSTONE)
2024-03-04 22:03:46 +01:00
.addModifier(Items.BRICK).save(recipeOutput, "restonia_block");
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_PALIS_CRYSTAL.get(), ActuallyItems.PALIS_CRYSTAL.get(), 5000, 50, Crystals.LAPIS.conversionColorParticles)
2021-11-13 20:09:55 +01:00
.addModifier(Tags.Items.DYES_CYAN)
.addModifier(Items.PRISMARINE_SHARD)
.addModifier(Items.PRISMARINE_SHARD)
2024-03-04 22:03:46 +01:00
.addModifier(Items.PRISMARINE_SHARD).save(recipeOutput, "palis");
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_PALIS_CRYSTAL.get(), ActuallyBlocks.PALIS_CRYSTAL.get(), 50000, 500, Crystals.LAPIS.conversionColorParticles)
2021-11-13 20:09:55 +01:00
.addModifier(Tags.Items.DYES_CYAN)
.addModifier(Items.PRISMARINE_SHARD)
.addModifier(Items.PRISMARINE_SHARD)
2024-03-04 22:03:46 +01:00
.addModifier(Items.PRISMARINE_SHARD).save(recipeOutput, "palis_block");
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_DIAMATINE_CRYSTAL.get(), ActuallyItems.DIAMATINE_CRYSTAL.get(), 5000, 50, Crystals.DIAMOND.conversionColorParticles)
2021-11-13 20:09:55 +01:00
.addModifier(Tags.Items.DYES_LIGHT_BLUE)
.addModifier(Items.CLAY_BALL)
.addModifier(Items.CLAY_BALL)
2024-03-04 22:03:46 +01:00
.addModifier(Items.CLAY).save(recipeOutput, "diamatine");
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_DIAMATINE_CRYSTAL.get(), ActuallyBlocks.DIAMATINE_CRYSTAL.get(), 50000, 500, Crystals.DIAMOND.conversionColorParticles)
2021-11-13 20:09:55 +01:00
.addModifier(Tags.Items.DYES_LIGHT_BLUE)
.addModifier(Items.CLAY_BALL)
.addModifier(Items.CLAY_BALL)
2024-03-04 22:03:46 +01:00
.addModifier(Items.CLAY).save(recipeOutput, "diamatine_block");
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_ENORI_CRYSTAL.get(), ActuallyItems.ENORI_CRYSTAL.get(), 5000, 50, Crystals.IRON.conversionColorParticles)
2021-11-13 20:09:55 +01:00
.addModifier(Tags.Items.DYES_GRAY)
.addModifier(Items.SNOWBALL)
.addModifier(Items.STONE_BUTTON)
2024-03-04 22:03:46 +01:00
.addModifier(Tags.Items.COBBLESTONE).save(recipeOutput, "enori");
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_ENORI_CRYSTAL.get(), ActuallyBlocks.ENORI_CRYSTAL.get(), 50000, 500, Crystals.IRON.conversionColorParticles)
2021-11-13 20:09:55 +01:00
.addModifier(Tags.Items.DYES_GRAY)
.addModifier(Items.SNOWBALL)
.addModifier(Items.STONE_BUTTON)
2024-03-04 22:03:46 +01:00
.addModifier(Tags.Items.COBBLESTONE).save(recipeOutput, "enori_block");
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_VOID_CRYSTAL.get(), ActuallyItems.VOID_CRYSTAL.get(), 5000, 50, Crystals.COAL.conversionColorParticles)
2021-11-13 20:09:55 +01:00
.addModifier(Tags.Items.DYES_BLACK)
.addModifier(ItemTags.COALS)
.addModifier(Items.FLINT)
2024-03-04 22:03:46 +01:00
.addModifier(Tags.Items.STONE).save(recipeOutput, "void");
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_VOID_CRYSTAL.get(), ActuallyBlocks.VOID_CRYSTAL.get(), 50000, 500, Crystals.COAL.conversionColorParticles)
2021-11-13 20:09:55 +01:00
.addModifier(Tags.Items.DYES_BLACK)
.addModifier(ItemTags.COALS)
.addModifier(Items.FLINT)
2024-03-04 22:03:46 +01:00
.addModifier(Tags.Items.STONE).save(recipeOutput, "void_block");
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_EMERADIC_CRYSTAL.get(), ActuallyItems.EMERADIC_CRYSTAL.get(), 5000, 50, Crystals.EMERALD.conversionColorParticles)
2021-11-13 20:09:55 +01:00
.addModifier(Tags.Items.DYES_LIME)
.addModifier(Items.TALL_GRASS)
.addModifier(ItemTags.SAPLINGS)
2024-03-04 22:03:46 +01:00
.addModifier(Tags.Items.SLIMEBALLS).save(recipeOutput, "emeradic");
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_EMERADIC_CRYSTAL.get(), ActuallyBlocks.EMERADIC_CRYSTAL.get(), 50000, 500, Crystals.EMERALD.conversionColorParticles)
2021-11-13 20:09:55 +01:00
.addModifier(Tags.Items.DYES_LIME)
.addModifier(Items.TALL_GRASS)
.addModifier(ItemTags.SAPLINGS)
2024-03-04 22:03:46 +01:00
.addModifier(Tags.Items.SLIMEBALLS).save(recipeOutput, "emeradic_block");
2022-04-02 00:51:55 +02:00
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_CANOLA_SEED.get(), ActuallyItems.CRYSTALLIZED_CANOLA_SEED.get(), 1000, 30, 0xFF5B4C)
2021-11-24 17:57:31 +01:00
.addModifier(ActuallyItems.CANOLA_SEEDS.get())
.addModifier(ActuallyItems.CANOLA_SEEDS.get())
.addModifier(ActuallyItems.CANOLA_SEEDS.get())
2024-03-04 22:03:46 +01:00
.addModifier(ActuallyItems.CANOLA_SEEDS.get()).save(recipeOutput, "empowered_canola");
}
public static class EmpoweringBuilder {
private final Item result;
private final Ingredient base;
private final int energy;
private final int time;
private final int color;
2024-03-04 20:21:48 +01:00
private final NonNullList<Ingredient> modifiers = NonNullList.create();
2024-03-02 21:23:08 +01:00
public EmpoweringBuilder(ItemLike resultIn, Ingredient baseIn, int energyIn, int timeIn, int colorIn) {
result = resultIn.asItem();
base = baseIn;
energy = energyIn;
time = timeIn;
color = colorIn;
}
2024-03-02 21:23:08 +01:00
public static EmpoweringBuilder builder(ItemLike resultIn, ItemLike base, int energyIn, int timeIn, int colorIn) {
return new EmpoweringBuilder(resultIn, Ingredient.of(base), energyIn, timeIn, colorIn);
}
2024-03-02 21:23:08 +01:00
public EmpoweringBuilder addModifier(ItemLike input) {
if (modifiers.size() >= 4)
2024-03-04 20:21:48 +01:00
throw new IllegalStateException("too many modifiers for empowering recipe, input: " + BuiltInRegistries.ITEM.getKey(input.asItem()));
modifiers.add(Ingredient.of(input));
return this;
}
2021-11-13 20:09:55 +01:00
public EmpoweringBuilder addModifier(ItemStack input) {
if (modifiers.size() >= 4)
2024-03-04 20:21:48 +01:00
throw new IllegalStateException("too many modifiers for empowering recipe, input: " + BuiltInRegistries.ITEM.getKey(input.getItem()));
modifiers.add(Ingredient.of(input));
return this;
}
2021-11-13 20:09:55 +01:00
2024-03-02 21:23:08 +01:00
public EmpoweringBuilder addModifier(TagKey<Item> input) {
if (modifiers.size() >= 4)
2021-11-14 00:20:29 +01:00
throw new IllegalStateException("too many modifiers for empowering recipe, input: " + input.toString());
modifiers.add(Ingredient.of(input));
return this;
}
2024-03-04 20:21:48 +01:00
public void save(RecipeOutput consumer, ResourceLocation name) {
if (modifiers.size() != 4)
2021-11-14 00:20:29 +01:00
throw new IllegalStateException("invalid modifier count: " + modifiers.size() + ", recipe: " + name.toString());
2024-03-04 20:21:48 +01:00
EmpowererRecipe recipe = new EmpowererRecipe(result.getDefaultInstance(), base, modifiers, energy, color, time);
consumer.accept(name, recipe, null);
}
2021-11-13 20:09:55 +01:00
2024-03-04 20:21:48 +01:00
public void save(RecipeOutput consumer, String name) {
ResourceLocation res = new ResourceLocation(ActuallyAdditions.MODID, "empowering/" + name);
if (modifiers.size() != 4)
2021-11-14 00:20:29 +01:00
throw new IllegalStateException("invalid modifier count: " + modifiers.size() + ", recipe: " + res);
2024-03-04 20:21:48 +01:00
EmpowererRecipe recipe = new EmpowererRecipe(result.getDefaultInstance(), base, modifiers, energy, color, time);
consumer.accept(res, recipe, null);
}
}
}