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

217 lines
13 KiB
Java
Raw Normal View History

2022-08-03 23:48:00 +02:00
package de.ellpeck.actuallyadditions.data;
import com.google.gson.JsonObject;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
2022-08-11 00:11:09 +02:00
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
2022-08-03 23:48:00 +02:00
import de.ellpeck.actuallyadditions.mod.crafting.ColorChangeRecipe;
2024-03-03 01:20:53 +01:00
import net.minecraft.data.CachedOutput;
import net.minecraft.data.PackOutput;
2024-03-02 21:23:08 +01:00
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.resources.ResourceLocation;
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-03 01:20:53 +01:00
import net.minecraftforge.registries.ForgeRegistries;
import org.jetbrains.annotations.Nullable;
2022-08-03 23:48:00 +02:00
import javax.annotation.Nonnull;
2024-03-03 01:20:53 +01:00
import java.util.concurrent.CompletableFuture;
2022-08-03 23:48:00 +02:00
import java.util.function.Consumer;
public class ColorChangeGenerator extends RecipeProvider {
2024-03-03 01:20:53 +01:00
public ColorChangeGenerator(PackOutput packOutput) {
super(packOutput);
2022-08-03 23:48:00 +02:00
}
2024-03-03 01:20:53 +01:00
@Override
public String getName() {
return "Color Change " + super.getName();
}
2022-08-03 23:48:00 +02:00
@Override
2024-03-03 01:20:53 +01:00
protected @Nullable CompletableFuture<?> saveAdvancement(CachedOutput output, FinishedRecipe finishedRecipe, JsonObject advancementJson) {
return null; //Nope...
2022-08-03 23:48:00 +02:00
}
@Override
2024-03-03 01:20:53 +01:00
protected void buildRecipes(@Nonnull Consumer<FinishedRecipe> consumer) {
2022-08-11 00:11:09 +02:00
buildWool(consumer);
buildStainedGlass(consumer);
buildStainedGlassPane(consumer);
buildTerracotta(consumer);
buildGlazedTerracotta(consumer);
buildCarpet(consumer);
buildLamps(consumer);
2022-08-11 00:33:07 +02:00
buildDye(consumer);
2022-08-11 00:11:09 +02:00
}
2024-03-02 21:23:08 +01:00
private void buildWool(@Nonnull Consumer<FinishedRecipe> c) {
2022-08-03 23:48:00 +02:00
//Wool
2022-08-11 00:11:09 +02:00
changeColor(c, Items.WHITE_WOOL, Items.BLACK_WOOL);
changeColor(c, Items.ORANGE_WOOL, Items.WHITE_WOOL);
changeColor(c, Items.MAGENTA_WOOL, Items.ORANGE_WOOL);
changeColor(c, Items.LIGHT_BLUE_WOOL, Items.MAGENTA_WOOL);
changeColor(c, Items.YELLOW_WOOL, Items.LIGHT_BLUE_WOOL);
changeColor(c, Items.LIME_WOOL, Items.YELLOW_WOOL);
changeColor(c, Items.PINK_WOOL, Items.LIME_WOOL);
changeColor(c, Items.GRAY_WOOL, Items.PINK_WOOL);
changeColor(c, Items.LIGHT_GRAY_WOOL, Items.GRAY_WOOL);
changeColor(c, Items.CYAN_WOOL, Items.LIGHT_GRAY_WOOL);
changeColor(c, Items.PURPLE_WOOL, Items.CYAN_WOOL);
changeColor(c, Items.BLUE_WOOL, Items.PURPLE_WOOL);
changeColor(c, Items.BROWN_WOOL, Items.BLUE_WOOL);
changeColor(c, Items.GREEN_WOOL, Items.BROWN_WOOL);
changeColor(c, Items.RED_WOOL, Items.GREEN_WOOL);
changeColor(c, Items.BLACK_WOOL, Items.RED_WOOL);
}
2024-03-02 21:23:08 +01:00
private void buildStainedGlass(@Nonnull Consumer<FinishedRecipe> c) {
2022-08-11 00:11:09 +02:00
changeColor(c, Items.WHITE_STAINED_GLASS, Items.BLACK_STAINED_GLASS);
changeColor(c, Items.ORANGE_STAINED_GLASS, Items.WHITE_STAINED_GLASS);
changeColor(c, Items.MAGENTA_STAINED_GLASS, Items.ORANGE_STAINED_GLASS);
changeColor(c, Items.LIGHT_BLUE_STAINED_GLASS, Items.MAGENTA_STAINED_GLASS);
changeColor(c, Items.YELLOW_STAINED_GLASS, Items.LIGHT_BLUE_STAINED_GLASS);
changeColor(c, Items.LIME_STAINED_GLASS, Items.YELLOW_STAINED_GLASS);
changeColor(c, Items.PINK_STAINED_GLASS, Items.LIME_STAINED_GLASS);
changeColor(c, Items.GRAY_STAINED_GLASS, Items.PINK_STAINED_GLASS);
changeColor(c, Items.LIGHT_GRAY_STAINED_GLASS, Items.GRAY_STAINED_GLASS);
changeColor(c, Items.CYAN_STAINED_GLASS, Items.LIGHT_GRAY_STAINED_GLASS);
changeColor(c, Items.PURPLE_STAINED_GLASS, Items.CYAN_STAINED_GLASS);
changeColor(c, Items.BLUE_STAINED_GLASS, Items.PURPLE_STAINED_GLASS);
changeColor(c, Items.BROWN_STAINED_GLASS, Items.BLUE_STAINED_GLASS);
changeColor(c, Items.GREEN_STAINED_GLASS, Items.BROWN_STAINED_GLASS);
changeColor(c, Items.RED_STAINED_GLASS, Items.GREEN_STAINED_GLASS);
changeColor(c, Items.BLACK_STAINED_GLASS, Items.RED_STAINED_GLASS);
}
2024-03-02 21:23:08 +01:00
private void buildStainedGlassPane(@Nonnull Consumer<FinishedRecipe> c) {
2022-08-11 00:11:09 +02:00
changeColor(c, Items.WHITE_STAINED_GLASS_PANE, Items.BLACK_STAINED_GLASS_PANE);
changeColor(c, Items.ORANGE_STAINED_GLASS_PANE, Items.WHITE_STAINED_GLASS_PANE);
changeColor(c, Items.MAGENTA_STAINED_GLASS_PANE, Items.ORANGE_STAINED_GLASS_PANE);
changeColor(c, Items.LIGHT_BLUE_STAINED_GLASS_PANE, Items.MAGENTA_STAINED_GLASS_PANE);
changeColor(c, Items.YELLOW_STAINED_GLASS_PANE, Items.LIGHT_BLUE_STAINED_GLASS_PANE);
changeColor(c, Items.LIME_STAINED_GLASS_PANE, Items.YELLOW_STAINED_GLASS_PANE);
changeColor(c, Items.PINK_STAINED_GLASS_PANE, Items.LIME_STAINED_GLASS_PANE);
changeColor(c, Items.GRAY_STAINED_GLASS_PANE, Items.PINK_STAINED_GLASS_PANE);
changeColor(c, Items.LIGHT_GRAY_STAINED_GLASS_PANE, Items.GRAY_STAINED_GLASS_PANE);
changeColor(c, Items.CYAN_STAINED_GLASS_PANE, Items.LIGHT_GRAY_STAINED_GLASS_PANE);
changeColor(c, Items.PURPLE_STAINED_GLASS_PANE, Items.CYAN_STAINED_GLASS_PANE);
changeColor(c, Items.BLUE_STAINED_GLASS_PANE, Items.PURPLE_STAINED_GLASS_PANE);
changeColor(c, Items.BROWN_STAINED_GLASS_PANE, Items.BLUE_STAINED_GLASS_PANE);
changeColor(c, Items.GREEN_STAINED_GLASS_PANE, Items.BROWN_STAINED_GLASS_PANE);
changeColor(c, Items.RED_STAINED_GLASS_PANE, Items.GREEN_STAINED_GLASS_PANE);
changeColor(c, Items.BLACK_STAINED_GLASS_PANE, Items.RED_STAINED_GLASS_PANE);
}
2024-03-02 21:23:08 +01:00
private void buildTerracotta(@Nonnull Consumer<FinishedRecipe> c) {
2022-08-11 00:11:09 +02:00
changeColor(c, Items.WHITE_TERRACOTTA, Items.BLACK_TERRACOTTA);
changeColor(c, Items.ORANGE_TERRACOTTA, Items.WHITE_TERRACOTTA);
changeColor(c, Items.MAGENTA_TERRACOTTA, Items.ORANGE_TERRACOTTA);
changeColor(c, Items.LIGHT_BLUE_TERRACOTTA, Items.MAGENTA_TERRACOTTA);
changeColor(c, Items.YELLOW_TERRACOTTA, Items.LIGHT_BLUE_TERRACOTTA);
changeColor(c, Items.LIME_TERRACOTTA, Items.YELLOW_TERRACOTTA);
changeColor(c, Items.PINK_TERRACOTTA, Items.LIME_TERRACOTTA);
changeColor(c, Items.GRAY_TERRACOTTA, Items.PINK_TERRACOTTA);
changeColor(c, Items.LIGHT_GRAY_TERRACOTTA, Items.GRAY_TERRACOTTA);
changeColor(c, Items.CYAN_TERRACOTTA, Items.LIGHT_GRAY_TERRACOTTA);
changeColor(c, Items.PURPLE_TERRACOTTA, Items.CYAN_TERRACOTTA);
changeColor(c, Items.BLUE_TERRACOTTA, Items.PURPLE_TERRACOTTA);
changeColor(c, Items.BROWN_TERRACOTTA, Items.BLUE_TERRACOTTA);
changeColor(c, Items.GREEN_TERRACOTTA, Items.BROWN_TERRACOTTA);
changeColor(c, Items.RED_TERRACOTTA, Items.GREEN_TERRACOTTA);
changeColor(c, Items.BLACK_TERRACOTTA, Items.RED_TERRACOTTA);
2022-08-03 23:48:00 +02:00
}
2024-03-02 21:23:08 +01:00
private void buildGlazedTerracotta(@Nonnull Consumer<FinishedRecipe> c) {
2022-08-11 00:11:09 +02:00
changeColor(c, Items.WHITE_GLAZED_TERRACOTTA, Items.BLACK_GLAZED_TERRACOTTA);
changeColor(c, Items.ORANGE_GLAZED_TERRACOTTA, Items.WHITE_GLAZED_TERRACOTTA);
changeColor(c, Items.MAGENTA_GLAZED_TERRACOTTA, Items.ORANGE_GLAZED_TERRACOTTA);
changeColor(c, Items.LIGHT_BLUE_GLAZED_TERRACOTTA, Items.MAGENTA_GLAZED_TERRACOTTA);
changeColor(c, Items.YELLOW_GLAZED_TERRACOTTA, Items.LIGHT_BLUE_GLAZED_TERRACOTTA);
changeColor(c, Items.LIME_GLAZED_TERRACOTTA, Items.YELLOW_GLAZED_TERRACOTTA);
changeColor(c, Items.PINK_GLAZED_TERRACOTTA, Items.LIME_GLAZED_TERRACOTTA);
changeColor(c, Items.GRAY_GLAZED_TERRACOTTA, Items.PINK_GLAZED_TERRACOTTA);
changeColor(c, Items.LIGHT_GRAY_GLAZED_TERRACOTTA, Items.GRAY_GLAZED_TERRACOTTA);
changeColor(c, Items.CYAN_GLAZED_TERRACOTTA, Items.LIGHT_GRAY_GLAZED_TERRACOTTA);
changeColor(c, Items.PURPLE_GLAZED_TERRACOTTA, Items.CYAN_GLAZED_TERRACOTTA);
changeColor(c, Items.BLUE_GLAZED_TERRACOTTA, Items.PURPLE_GLAZED_TERRACOTTA);
changeColor(c, Items.BROWN_GLAZED_TERRACOTTA, Items.BLUE_GLAZED_TERRACOTTA);
changeColor(c, Items.GREEN_GLAZED_TERRACOTTA, Items.BROWN_GLAZED_TERRACOTTA);
changeColor(c, Items.RED_GLAZED_TERRACOTTA, Items.GREEN_GLAZED_TERRACOTTA);
changeColor(c, Items.BLACK_GLAZED_TERRACOTTA, Items.RED_GLAZED_TERRACOTTA);
}
2024-03-02 21:23:08 +01:00
private void buildCarpet(@Nonnull Consumer<FinishedRecipe> c) {
2022-08-11 00:11:09 +02:00
changeColor(c, Items.WHITE_CARPET, Items.BLACK_CARPET);
changeColor(c, Items.ORANGE_CARPET, Items.WHITE_CARPET);
changeColor(c, Items.MAGENTA_CARPET, Items.ORANGE_CARPET);
changeColor(c, Items.LIGHT_BLUE_CARPET, Items.MAGENTA_CARPET);
changeColor(c, Items.YELLOW_CARPET, Items.LIGHT_BLUE_CARPET);
changeColor(c, Items.LIME_CARPET, Items.YELLOW_CARPET);
changeColor(c, Items.PINK_CARPET, Items.LIME_CARPET);
changeColor(c, Items.GRAY_CARPET, Items.PINK_CARPET);
changeColor(c, Items.LIGHT_GRAY_CARPET, Items.GRAY_CARPET);
changeColor(c, Items.CYAN_CARPET, Items.LIGHT_GRAY_CARPET);
changeColor(c, Items.PURPLE_CARPET, Items.CYAN_CARPET);
changeColor(c, Items.BLUE_CARPET, Items.PURPLE_CARPET);
changeColor(c, Items.BROWN_CARPET, Items.BLUE_CARPET);
changeColor(c, Items.GREEN_CARPET, Items.BROWN_CARPET);
changeColor(c, Items.RED_CARPET, Items.GREEN_CARPET);
changeColor(c, Items.BLACK_CARPET, Items.RED_CARPET);
}
2024-03-02 21:23:08 +01:00
private void buildLamps(@Nonnull Consumer<FinishedRecipe> c) {
2022-08-11 00:11:09 +02:00
changeColor(c, ActuallyBlocks.LAMP_WHITE.getItem(), ActuallyBlocks.LAMP_BLACK.getItem());
changeColor(c, ActuallyBlocks.LAMP_ORANGE.getItem(), ActuallyBlocks.LAMP_WHITE.getItem());
changeColor(c, ActuallyBlocks.LAMP_MAGENTA.getItem(), ActuallyBlocks.LAMP_ORANGE.getItem());
changeColor(c, ActuallyBlocks.LAMP_LIGHT_BLUE.getItem(), ActuallyBlocks.LAMP_MAGENTA.getItem());
changeColor(c, ActuallyBlocks.LAMP_YELLOW.getItem(), ActuallyBlocks.LAMP_LIGHT_BLUE.getItem());
changeColor(c, ActuallyBlocks.LAMP_LIME.getItem(), ActuallyBlocks.LAMP_YELLOW.getItem());
changeColor(c, ActuallyBlocks.LAMP_PINK.getItem(), ActuallyBlocks.LAMP_LIME.getItem());
changeColor(c, ActuallyBlocks.LAMP_GRAY.getItem(), ActuallyBlocks.LAMP_PINK.getItem());
changeColor(c, ActuallyBlocks.LAMP_LIGHT_GRAY.getItem(), ActuallyBlocks.LAMP_GRAY.getItem());
changeColor(c, ActuallyBlocks.LAMP_CYAN.getItem(), ActuallyBlocks.LAMP_LIGHT_GRAY.getItem());
changeColor(c, ActuallyBlocks.LAMP_PURPLE.getItem(), ActuallyBlocks.LAMP_CYAN.getItem());
changeColor(c, ActuallyBlocks.LAMP_BLUE.getItem(), ActuallyBlocks.LAMP_PURPLE.getItem());
changeColor(c, ActuallyBlocks.LAMP_BROWN.getItem(), ActuallyBlocks.LAMP_BLUE.getItem());
changeColor(c, ActuallyBlocks.LAMP_GREEN.getItem(), ActuallyBlocks.LAMP_BROWN.getItem());
changeColor(c, ActuallyBlocks.LAMP_RED.getItem(), ActuallyBlocks.LAMP_GREEN.getItem());
changeColor(c, ActuallyBlocks.LAMP_BLACK.getItem(), ActuallyBlocks.LAMP_RED.getItem());
}
2024-03-02 21:23:08 +01:00
private void buildDye(@Nonnull Consumer<FinishedRecipe> c) {
2022-08-11 00:33:07 +02:00
changeColor(c, Items.WHITE_DYE, Items.BLACK_DYE);
changeColor(c, Items.ORANGE_DYE, Items.WHITE_DYE);
changeColor(c, Items.MAGENTA_DYE, Items.ORANGE_DYE);
changeColor(c, Items.LIGHT_BLUE_DYE, Items.MAGENTA_DYE);
changeColor(c, Items.YELLOW_DYE, Items.LIGHT_BLUE_DYE);
changeColor(c, Items.LIME_DYE, Items.YELLOW_DYE);
changeColor(c, Items.PINK_DYE, Items.LIME_DYE);
changeColor(c, Items.GRAY_DYE, Items.PINK_DYE);
changeColor(c, Items.LIGHT_GRAY_DYE, Items.GRAY_DYE);
changeColor(c, Items.CYAN_DYE, Items.LIGHT_GRAY_DYE);
changeColor(c, Items.PURPLE_DYE, Items.CYAN_DYE);
changeColor(c, Items.BLUE_DYE, Items.PURPLE_DYE);
changeColor(c, Items.BROWN_DYE, Items.BLUE_DYE);
changeColor(c, Items.GREEN_DYE, Items.BROWN_DYE);
changeColor(c, Items.RED_DYE, Items.GREEN_DYE);
changeColor(c, Items.BLACK_DYE, Items.RED_DYE);
}
2022-08-11 00:11:09 +02:00
2024-03-02 21:23:08 +01:00
private void changeColor(Consumer<FinishedRecipe> consumer, ItemLike output, Ingredient input) {
2024-03-03 01:20:53 +01:00
consumer.accept(new ColorChangeRecipe.Result(new ResourceLocation(ActuallyAdditions.MODID, "colorchange/" + ForgeRegistries.ITEMS.getKey(output.asItem()).getPath()),
2022-08-03 23:48:00 +02:00
input, output));
}
2024-03-02 21:23:08 +01:00
private void changeColor(Consumer<FinishedRecipe> consumer, ItemLike output, ItemLike input) {
2024-03-03 01:20:53 +01:00
consumer.accept(new ColorChangeRecipe.Result(new ResourceLocation(ActuallyAdditions.MODID, "colorchange/" + ForgeRegistries.ITEMS.getKey(output.asItem()).getPath()),
2022-08-03 23:48:00 +02:00
Ingredient.of(input), output));
}
2024-03-02 21:23:08 +01:00
private void changeColor(Consumer<FinishedRecipe> consumer, ItemLike output, ItemStack input) {
2024-03-03 01:20:53 +01:00
consumer.accept(new ColorChangeRecipe.Result(new ResourceLocation(ActuallyAdditions.MODID, "colorchange/" + ForgeRegistries.ITEMS.getKey(output.asItem()).getPath()),
2022-08-03 23:48:00 +02:00
Ingredient.of(input), output));
}
}