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

90 lines
3.8 KiB
Java
Raw Normal View History

2022-08-31 00:20:32 +02:00
package de.ellpeck.actuallyadditions.data;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
2022-08-31 00:20:32 +02:00
import de.ellpeck.actuallyadditions.mod.crafting.MiningLensRecipe;
2024-03-04 22:03:46 +01:00
import de.ellpeck.actuallyadditions.mod.util.NoAdvRecipeOutput;
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.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;
2024-03-04 20:21:48 +01:00
import net.neoforged.neoforge.common.Tags;
2022-08-31 00:20:32 +02:00
2024-03-04 22:03:46 +01:00
import javax.annotation.Nonnull;
2022-08-31 00:20:32 +02:00
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
}
2024-03-03 01:20:53 +01:00
@Override
2024-03-04 22:03:46 +01:00
protected void buildRecipes(@Nonnull RecipeOutput recipeOutput) {
buildMiningLens(new NoAdvRecipeOutput(recipeOutput));
2022-08-31 00:20:32 +02:00
}
2024-03-02 21:23:08 +01:00
// private String getItemName(ItemLike item) {
2024-03-04 20:21:48 +01:00
// return BuiltInRegistries.ITEM.getKey(item.asItem()).getPath();
2024-03-02 21:23:08 +01:00
// }
2022-08-31 00:20:32 +02:00
private ResourceLocation folderRecipe(String folder, String recipe) {
return new ResourceLocation(ActuallyAdditions.MODID, folder + "/" + recipe);
}
2024-03-04 20:21:48 +01:00
private void buildStoneOre(RecipeOutput consumer, int weight, ItemLike output) {
2022-08-31 00:20:32 +02:00
buildTagOre(consumer, Tags.Items.STONE, "stone", weight, output);
}
2024-03-04 20:21:48 +01:00
private void buildNetherOre(RecipeOutput consumer, int weight, ItemLike output) {
2022-08-31 00:20:32 +02:00
buildTagOre(consumer, Tags.Items.NETHERRACK, "nether", weight, output);
}
2024-03-14 22:41:45 +01:00
private void buildDeepSlateOre(RecipeOutput consumer, int weight, ItemLike output) {
consumer.accept(folderRecipe("mininglens", "deepslate_" + getItemName(output)), new MiningLensRecipe(
Ingredient.of(Items.DEEPSLATE),
weight,
output.asItem().getDefaultInstance()
), null);
}
2024-03-04 20:21:48 +01:00
private void buildTagOre(RecipeOutput consumer, TagKey<Item> tag, String prefix, int weight, ItemLike output) {
consumer.accept(folderRecipe("mininglens", prefix + "_" + getItemName(output)), new MiningLensRecipe(
2022-08-31 00:20:32 +02:00
Ingredient.of(tag),
weight,
2024-03-04 20:21:48 +01:00
output.asItem().getDefaultInstance()
), null);
2022-08-31 00:20:32 +02:00
}
2024-03-04 20:21:48 +01:00
private void buildMiningLens(RecipeOutput consumer) {
2022-08-31 00:20:32 +02:00
buildStoneOre(consumer, 5000, Items.COAL_ORE);
buildStoneOre(consumer, 5000, Items.COPPER_ORE);
2022-08-31 00:20:32 +02:00
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);
buildStoneOre(consumer, 3000, ActuallyBlocks.BLACK_QUARTZ_ORE.getItem());
2024-03-12 23:15:56 +01:00
buildNetherOre(consumer, 1, Items.ANCIENT_DEBRIS);
2024-03-14 22:41:45 +01:00
buildDeepSlateOre(consumer, 2000, Items.DEEPSLATE_COAL_ORE);
buildDeepSlateOre(consumer, 3000, Items.DEEPSLATE_IRON_ORE);
buildDeepSlateOre(consumer, 3000, Items.DEEPSLATE_COPPER_ORE);
2024-03-14 22:41:45 +01:00
buildDeepSlateOre(consumer, 500, Items.DEEPSLATE_GOLD_ORE);
buildDeepSlateOre(consumer, 50, Items.DEEPSLATE_DIAMOND_ORE);
buildDeepSlateOre(consumer, 250, Items.DEEPSLATE_LAPIS_ORE);
buildDeepSlateOre(consumer, 200, Items.DEEPSLATE_REDSTONE_ORE);
buildDeepSlateOre(consumer, 30, Items.DEEPSLATE_EMERALD_ORE);
2022-08-31 00:20:32 +02:00
}
}