2022-08-31 00:20:32 +02:00
|
|
|
package de.ellpeck.actuallyadditions.data;
|
|
|
|
|
|
|
|
import com.google.gson.JsonObject;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.crafting.MiningLensRecipe;
|
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.tags.TagKey;
|
|
|
|
import net.minecraft.world.item.Item;
|
|
|
|
import net.minecraft.world.item.Items;
|
|
|
|
import net.minecraft.world.item.crafting.Ingredient;
|
|
|
|
import net.minecraft.world.level.ItemLike;
|
2022-08-31 00:20:32 +02:00
|
|
|
import net.minecraftforge.common.Tags;
|
2024-03-03 01:20:53 +01:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2022-08-31 00:20:32 +02:00
|
|
|
|
2024-03-03 01:20:53 +01:00
|
|
|
import java.util.concurrent.CompletableFuture;
|
2022-08-31 00:20:32 +02:00
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
|
|
|
public class MiningLensGenerator extends RecipeProvider {
|
2024-03-03 01:20:53 +01:00
|
|
|
public MiningLensGenerator(PackOutput packOutput) {
|
|
|
|
super(packOutput);
|
2022-08-31 00:20:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2024-03-03 01:20:53 +01:00
|
|
|
public String getName() {
|
|
|
|
return "Mining Lens " + super.getName();
|
2022-08-31 00:20:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2024-03-03 01:20:53 +01:00
|
|
|
protected @Nullable CompletableFuture<?> saveAdvancement(CachedOutput output, FinishedRecipe finishedRecipe, JsonObject advancementJson) {
|
|
|
|
return null; //Nope...
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void buildRecipes(Consumer<FinishedRecipe> consumer) {
|
2022-08-31 00:20:32 +02:00
|
|
|
buildMiningLens(consumer);
|
|
|
|
}
|
|
|
|
|
2024-03-02 21:23:08 +01:00
|
|
|
// private String getItemName(ItemLike item) {
|
|
|
|
// return ForgeRegistries.ITEMS.getKey(item.asItem()).getPath();
|
|
|
|
// }
|
2022-08-31 00:20:32 +02:00
|
|
|
|
|
|
|
private ResourceLocation folderRecipe(String folder, String recipe) {
|
|
|
|
return new ResourceLocation(ActuallyAdditions.MODID, folder + "/" + recipe);
|
|
|
|
}
|
|
|
|
|
2024-03-02 21:23:08 +01:00
|
|
|
private void buildStoneOre(Consumer<FinishedRecipe> consumer, int weight, ItemLike output) {
|
2022-08-31 00:20:32 +02:00
|
|
|
buildTagOre(consumer, Tags.Items.STONE, "stone", weight, output);
|
|
|
|
}
|
2024-03-02 21:23:08 +01:00
|
|
|
private void buildNetherOre(Consumer<FinishedRecipe> consumer, int weight, ItemLike output) {
|
2022-08-31 00:20:32 +02:00
|
|
|
buildTagOre(consumer, Tags.Items.NETHERRACK, "nether", weight, output);
|
|
|
|
}
|
|
|
|
|
2024-03-02 21:23:08 +01:00
|
|
|
private void buildTagOre(Consumer<FinishedRecipe> consumer, TagKey<Item> tag, String prefix, int weight, ItemLike output) {
|
|
|
|
consumer.accept(new MiningLensRecipe.Result(
|
2022-08-31 00:20:32 +02:00
|
|
|
folderRecipe("mininglens", prefix + "_" + getItemName(output)),
|
|
|
|
Ingredient.of(tag),
|
|
|
|
weight,
|
|
|
|
output
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2024-03-02 21:23:08 +01:00
|
|
|
private void buildMiningLens(Consumer<FinishedRecipe> consumer) {
|
2022-08-31 00:20:32 +02:00
|
|
|
buildStoneOre(consumer, 5000, Items.COAL_ORE);
|
|
|
|
buildStoneOre(consumer, 3000, Items.IRON_ORE);
|
|
|
|
buildStoneOre(consumer, 500, Items.GOLD_ORE);
|
|
|
|
buildNetherOre(consumer, 500, Items.NETHER_GOLD_ORE);
|
|
|
|
buildStoneOre(consumer, 50, Items.DIAMOND_ORE);
|
|
|
|
buildStoneOre(consumer, 250, Items.LAPIS_ORE);
|
|
|
|
buildStoneOre(consumer, 200, Items.REDSTONE_ORE);
|
|
|
|
buildStoneOre(consumer, 30, Items.EMERALD_ORE);
|
|
|
|
buildNetherOre(consumer, 3000, Items.NETHER_QUARTZ_ORE);
|
|
|
|
}
|
|
|
|
}
|