Go go mining lens recipes, part 1.

This commit is contained in:
Flanks255 2022-08-30 17:20:32 -05:00
parent a7ea216a03
commit 7251e3390c
17 changed files with 350 additions and 44 deletions

View file

@ -809,6 +809,15 @@ ec31df01057ad65de89068b01f96b3fb9f837bb4 data/actuallyadditions/recipes/lens.jso
0c908206a367aa9c04f751d1f69aa50d6d09ce3a data/actuallyadditions/recipes/liquid_fuel/crystallized_canola_oil.json 0c908206a367aa9c04f751d1f69aa50d6d09ce3a data/actuallyadditions/recipes/liquid_fuel/crystallized_canola_oil.json
901f642d13b3768f2a00fbbdd3482c7b4866867f data/actuallyadditions/recipes/liquid_fuel/empowered_canola_oil.json 901f642d13b3768f2a00fbbdd3482c7b4866867f data/actuallyadditions/recipes/liquid_fuel/empowered_canola_oil.json
cce14618f9e39666e2858bf09c3cc7197e758b1c data/actuallyadditions/recipes/liquid_fuel/refined_canola_oil.json cce14618f9e39666e2858bf09c3cc7197e758b1c data/actuallyadditions/recipes/liquid_fuel/refined_canola_oil.json
a37d681793afbdafb245885ab96713ce3cba988d data/actuallyadditions/recipes/mininglens/nether_nether_gold_ore.json
7da4bcc3730868f48aab438f9e8b7c430d73876e data/actuallyadditions/recipes/mininglens/nether_nether_quartz_ore.json
07ff82ce86dee38e569726c64a2c7a072d187834 data/actuallyadditions/recipes/mininglens/stone_coal_ore.json
67e1ce2380778c700a9325497c8be90fdf0eb66e data/actuallyadditions/recipes/mininglens/stone_diamond_ore.json
1c0b8bdef6f1d66b64c2a96fbfe558209ca8a46a data/actuallyadditions/recipes/mininglens/stone_emerald_ore.json
6f74e1702e1b6ce18e19045133f0209831e80d80 data/actuallyadditions/recipes/mininglens/stone_gold_ore.json
6e55e07cac5e069cbeeca8fd6232e58c9ce0214d data/actuallyadditions/recipes/mininglens/stone_iron_ore.json
ccdc4ab92dc7c0aae4de1566435ef5d701e14934 data/actuallyadditions/recipes/mininglens/stone_lapis_ore.json
7d99d73a12a25056891a68a73cc4b93ce622e46a data/actuallyadditions/recipes/mininglens/stone_redstone_ore.json
7821b149dc37caa85b587a0276307f1b5cefaa03 data/actuallyadditions/recipes/netherite_aiot.json 7821b149dc37caa85b587a0276307f1b5cefaa03 data/actuallyadditions/recipes/netherite_aiot.json
4590b472dcb90700ea525a3c6ac3f325458fab19 data/actuallyadditions/recipes/phantom_connector.json 4590b472dcb90700ea525a3c6ac3f325458fab19 data/actuallyadditions/recipes/phantom_connector.json
6a1050a9aaadea6d3961b7e77ee17880404a56e0 data/actuallyadditions/recipes/pressing/canola.json 6a1050a9aaadea6d3961b7e77ee17880404a56e0 data/actuallyadditions/recipes/pressing/canola.json

View file

@ -0,0 +1,10 @@
{
"type": "actuallyadditions:mining_lens",
"ingredient": {
"tag": "forge:netherrack"
},
"weight": 500,
"result": {
"item": "minecraft:nether_gold_ore"
}
}

View file

@ -0,0 +1,10 @@
{
"type": "actuallyadditions:mining_lens",
"ingredient": {
"tag": "forge:netherrack"
},
"weight": 3000,
"result": {
"item": "minecraft:nether_quartz_ore"
}
}

View file

@ -0,0 +1,10 @@
{
"type": "actuallyadditions:mining_lens",
"ingredient": {
"tag": "forge:stone"
},
"weight": 5000,
"result": {
"item": "minecraft:coal_ore"
}
}

View file

@ -0,0 +1,10 @@
{
"type": "actuallyadditions:mining_lens",
"ingredient": {
"tag": "forge:stone"
},
"weight": 50,
"result": {
"item": "minecraft:diamond_ore"
}
}

View file

@ -0,0 +1,10 @@
{
"type": "actuallyadditions:mining_lens",
"ingredient": {
"tag": "forge:stone"
},
"weight": 30,
"result": {
"item": "minecraft:emerald_ore"
}
}

View file

@ -0,0 +1,10 @@
{
"type": "actuallyadditions:mining_lens",
"ingredient": {
"tag": "forge:stone"
},
"weight": 500,
"result": {
"item": "minecraft:gold_ore"
}
}

View file

@ -0,0 +1,10 @@
{
"type": "actuallyadditions:mining_lens",
"ingredient": {
"tag": "forge:stone"
},
"weight": 3000,
"result": {
"item": "minecraft:iron_ore"
}
}

View file

@ -0,0 +1,10 @@
{
"type": "actuallyadditions:mining_lens",
"ingredient": {
"tag": "forge:stone"
},
"weight": 250,
"result": {
"item": "minecraft:lapis_ore"
}
}

View file

@ -0,0 +1,10 @@
{
"type": "actuallyadditions:mining_lens",
"ingredient": {
"tag": "forge:stone"
},
"weight": 200,
"result": {
"item": "minecraft:redstone_ore"
}
}

View file

@ -35,6 +35,7 @@ public class ActuallyAdditionsData {
generator.addProvider(new CrushingRecipeGenerator(generator)); generator.addProvider(new CrushingRecipeGenerator(generator));
generator.addProvider(new FuelRecipeGenerator(generator)); generator.addProvider(new FuelRecipeGenerator(generator));
generator.addProvider(new MiscMachineRecipeGenerator(generator)); generator.addProvider(new MiscMachineRecipeGenerator(generator));
generator.addProvider(new MiningLensGenerator(generator));
generator.addProvider(new SoundsGenerator(generator, helper)); generator.addProvider(new SoundsGenerator(generator, helper));
} }

View file

@ -0,0 +1,75 @@
package de.ellpeck.actuallyadditions.data;
import com.google.gson.JsonObject;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.crafting.FermentingRecipe;
import de.ellpeck.actuallyadditions.mod.crafting.MiningLensRecipe;
import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.data.RecipeProvider;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.tags.ITag;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.Tags;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.registries.ForgeRegistries;
import java.nio.file.Path;
import java.util.function.Consumer;
public class MiningLensGenerator extends RecipeProvider {
public MiningLensGenerator(DataGenerator pGenerator) {
super(pGenerator);
}
@Override
protected void saveAdvancement(DirectoryCache pCache, JsonObject pAdvancementJson, Path pPath) {
}
@Override
protected void buildShapelessRecipes(Consumer<IFinishedRecipe> consumer) {
buildMiningLens(consumer);
}
private String getItemName(IItemProvider item) {
return ForgeRegistries.ITEMS.getKey(item.asItem()).getPath();
}
private ResourceLocation folderRecipe(String folder, String recipe) {
return new ResourceLocation(ActuallyAdditions.MODID, folder + "/" + recipe);
}
private void buildStoneOre(Consumer<IFinishedRecipe> consumer, int weight, IItemProvider output) {
buildTagOre(consumer, Tags.Items.STONE, "stone", weight, output);
}
private void buildNetherOre(Consumer<IFinishedRecipe> consumer, int weight, IItemProvider output) {
buildTagOre(consumer, Tags.Items.NETHERRACK, "nether", weight, output);
}
private void buildTagOre(Consumer<IFinishedRecipe> consumer, ITag tag, String prefix, int weight, IItemProvider output) {
consumer.accept(new MiningLensRecipe.FinishedRecipe(
folderRecipe("mininglens", prefix + "_" + getItemName(output)),
Ingredient.of(tag),
weight,
output
));
}
private void buildMiningLens(Consumer<IFinishedRecipe> consumer) {
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);
}
}

View file

@ -3,6 +3,7 @@ package de.ellpeck.actuallyadditions.data;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.crafting.FermentingRecipe; import de.ellpeck.actuallyadditions.mod.crafting.FermentingRecipe;
import de.ellpeck.actuallyadditions.mod.crafting.MiningLensRecipe;
import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe; import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
@ -11,10 +12,15 @@ import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IFinishedRecipe; import net.minecraft.data.IFinishedRecipe;
import net.minecraft.data.RecipeProvider; import net.minecraft.data.RecipeProvider;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.Ingredient;
import net.minecraft.tags.ITag;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.registries.ForgeRegistries;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -37,6 +43,10 @@ public class MiscMachineRecipeGenerator extends RecipeProvider {
new FluidStack(InitFluids.CANOLA_OIL.get(), 80), new FluidStack(InitFluids.REFINED_CANOLA_OIL.get(), 80), 100)); new FluidStack(InitFluids.CANOLA_OIL.get(), 80), new FluidStack(InitFluids.REFINED_CANOLA_OIL.get(), 80), 100));
} }
private String getItemName(IItemProvider item) {
return ForgeRegistries.ITEMS.getKey(item.asItem()).getPath();
}
private ResourceLocation folderRecipe(String folder, String recipe) { private ResourceLocation folderRecipe(String folder, String recipe) {
return new ResourceLocation(ActuallyAdditions.MODID, folder + "/" + recipe); return new ResourceLocation(ActuallyAdditions.MODID, folder + "/" + recipe);
} }

View file

@ -133,7 +133,7 @@ public class ActuallyAdditions {
//AAWorldGen gen = new AAWorldGen(); //AAWorldGen gen = new AAWorldGen();
ItemCoffee.initIngredients(); ItemCoffee.initIngredients();
CrusherCrafting.init(); CrusherCrafting.init();
LensMining.init(); //LensMining.init();
} }
private void onConfigReload(ModConfig.ModConfigEvent event) { private void onConfigReload(ModConfig.ModConfigEvent event) {

View file

@ -24,6 +24,7 @@ public class ActuallyRecipes {
public static final RegistryObject<IRecipeSerializer<?>> PRESSING_RECIPE = SERIALIZERS.register(PressingRecipe.NAME, PressingRecipe.Serializer::new); public static final RegistryObject<IRecipeSerializer<?>> PRESSING_RECIPE = SERIALIZERS.register(PressingRecipe.NAME, PressingRecipe.Serializer::new);
public static final RegistryObject<IRecipeSerializer<?>> FERMENTING_RECIPE = SERIALIZERS.register(FermentingRecipe.NAME, FermentingRecipe.Serializer::new); public static final RegistryObject<IRecipeSerializer<?>> FERMENTING_RECIPE = SERIALIZERS.register(FermentingRecipe.NAME, FermentingRecipe.Serializer::new);
public static final RegistryObject<IRecipeSerializer<?>> COLOR_CHANGE_RECIPE = SERIALIZERS.register(ColorChangeRecipe.NAME, ColorChangeRecipe.Serializer::new); public static final RegistryObject<IRecipeSerializer<?>> COLOR_CHANGE_RECIPE = SERIALIZERS.register(ColorChangeRecipe.NAME, ColorChangeRecipe.Serializer::new);
public static final RegistryObject<IRecipeSerializer<?>> MINING_LENS_RECIPE = SERIALIZERS.register(MiningLensRecipe.NAME, MiningLensRecipe.Serializer::new);
@ -36,5 +37,6 @@ public class ActuallyRecipes {
public static final IRecipeType<PressingRecipe> PRESSING = IRecipeType.register(ActuallyAdditions.MODID + ":pressing"); public static final IRecipeType<PressingRecipe> PRESSING = IRecipeType.register(ActuallyAdditions.MODID + ":pressing");
public static final IRecipeType<FermentingRecipe> FERMENTING = IRecipeType.register(ActuallyAdditions.MODID + ":fermenting"); public static final IRecipeType<FermentingRecipe> FERMENTING = IRecipeType.register(ActuallyAdditions.MODID + ":fermenting");
public static final IRecipeType<ColorChangeRecipe> COLOR_CHANGE = IRecipeType.register(ActuallyAdditions.MODID + ":color_change"); public static final IRecipeType<ColorChangeRecipe> COLOR_CHANGE = IRecipeType.register(ActuallyAdditions.MODID + ":color_change");
public static final IRecipeType<MiningLensRecipe> MINING_LENS = IRecipeType.register(ActuallyAdditions.MODID + ":mining_lens");
} }
} }

View file

@ -0,0 +1,160 @@
package de.ellpeck.actuallyadditions.mod.crafting;
import com.google.gson.JsonObject;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.WeightedRandom;
import net.minecraft.world.World;
import net.minecraftforge.registries.ForgeRegistryEntry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class MiningLensRecipe extends WeightedRandom.Item implements IRecipe<IInventory> {
public static final String NAME = "mining_lens";
private final ResourceLocation id;
private final Ingredient input;
private final int weight;
private final ItemStack output;
public MiningLensRecipe(ResourceLocation id, Ingredient input, int weight, ItemStack output) {
super(weight);
this.input = input;
this.weight = weight;
this.output = output;
this.id = id;
}
public int getWeight() {
return weight;
}
public Ingredient getInput() {
return input;
}
public boolean matches(ItemStack test) {
return input.test(test);
}
@Override
public boolean matches(IInventory pInv, World pLevel) {
return false;
}
@Nonnull
@Override
public ItemStack assemble(IInventory pInv) {
return ItemStack.EMPTY;
}
@Override
public boolean canCraftInDimensions(int pWidth, int pHeight) {
return false;
}
@Override
public ItemStack getResultItem() {
return output.copy();
}
@Override
public ResourceLocation getId() {
return id;
}
@Override
public IRecipeSerializer<?> getSerializer() {
return ActuallyRecipes.MINING_LENS_RECIPE.get();
}
@Override
public IRecipeType<?> getType() {
return ActuallyRecipes.Types.MINING_LENS;
}
public static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<MiningLensRecipe> {
@Override
public MiningLensRecipe fromJson(@Nonnull ResourceLocation pRecipeId, @Nonnull JsonObject pJson) {
Ingredient ingredient = Ingredient.fromJson(JSONUtils.getAsJsonObject(pJson, "ingredient"));
int weight = JSONUtils.getAsInt(pJson, "weight");
JsonObject resultObject = JSONUtils.getAsJsonObject(pJson, "result");
ItemStack result = new ItemStack(JSONUtils.getAsItem(resultObject, "item"));
return new MiningLensRecipe(pRecipeId, ingredient, weight, result);
}
@Nullable
@Override
public MiningLensRecipe fromNetwork(@Nonnull ResourceLocation pRecipeId, @Nonnull PacketBuffer pBuffer) {
Ingredient ingredient = Ingredient.fromNetwork(pBuffer);
int weight = pBuffer.readInt();
ItemStack result = pBuffer.readItem();
return new MiningLensRecipe(pRecipeId, ingredient, weight, result);
}
@Override
public void toNetwork(@Nonnull PacketBuffer pBuffer, MiningLensRecipe pRecipe) {
pRecipe.input.toNetwork(pBuffer);
pBuffer.writeInt(pRecipe.weight);
pBuffer.writeItem(pRecipe.output);
}
}
public static class FinishedRecipe implements IFinishedRecipe {
private final ResourceLocation id;
private final Ingredient itemIngredient;
private final int weight;
private final IItemProvider output;
public FinishedRecipe(ResourceLocation id, Ingredient itemIngredient, int weight, IItemProvider output) {
this.id = id;
this.itemIngredient = itemIngredient;
this.weight = weight;
this.output = output;
}
@Override
public void serializeRecipeData(JsonObject pJson) {
pJson.add("ingredient", itemIngredient.toJson());
pJson.addProperty("weight", weight);
JsonObject resultObject = new JsonObject();
resultObject.addProperty("item", output.asItem().getRegistryName().toString());
pJson.add("result", resultObject);
}
@Override
public ResourceLocation getId() {
return id;
}
@Override
public IRecipeSerializer<?> getType() {
return ActuallyRecipes.MINING_LENS_RECIPE.get();
}
@Nullable
@Override
public JsonObject serializeAdvancement() {
return null;
}
@Nullable
@Override
public ResourceLocation getAdvancementId() {
return null;
}
}
}

View file

@ -28,22 +28,9 @@ import java.util.List;
public class LensMining extends Lens { public class LensMining extends Lens {
public static void init() { //TODO ohhh boy public static void init() {
ActuallyAdditionsAPI.addMiningLensStoneOre("oreCoal", 5000);
ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherCoal", 5000);
ActuallyAdditionsAPI.addMiningLensStoneOre("oreIron", 3000);
ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherIron", 3000);
ActuallyAdditionsAPI.addMiningLensStoneOre("oreGold", 500);
ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherGold", 500);
ActuallyAdditionsAPI.addMiningLensStoneOre("oreDiamond", 50);
ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherDiamond", 50);
ActuallyAdditionsAPI.addMiningLensStoneOre("oreLapis", 250);
ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherLapis", 250);
ActuallyAdditionsAPI.addMiningLensStoneOre("oreRedstone", 200);
ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherRedstone", 200);
ActuallyAdditionsAPI.addMiningLensStoneOre("oreEmerald", 30);
ActuallyAdditionsAPI.addMiningLensNetherOre("oreQuartz", 3000);
//These need to be moved to datagen conditionals if the appropriate mod is loaded.
ActuallyAdditionsAPI.addMiningLensStoneOre("oreCopper", 2000); ActuallyAdditionsAPI.addMiningLensStoneOre("oreCopper", 2000);
ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherCopper", 2000); ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherCopper", 2000);
ActuallyAdditionsAPI.addMiningLensStoneOre("oreTin", 1800); ActuallyAdditionsAPI.addMiningLensStoneOre("oreTin", 1800);
@ -79,36 +66,8 @@ public class LensMining extends Lens {
ActuallyAdditionsAPI.addMiningLensStoneOre("oreSalt", 2900); ActuallyAdditionsAPI.addMiningLensStoneOre("oreSalt", 2900);
ActuallyAdditionsAPI.addMiningLensStoneOre("oreDraconium", 5); ActuallyAdditionsAPI.addMiningLensStoneOre("oreDraconium", 5);
ActuallyAdditionsAPI.addMiningLensStoneOre("orePoorIron", 3000);
ActuallyAdditionsAPI.addMiningLensStoneOre("orePoorGold", 500);
ActuallyAdditionsAPI.addMiningLensStoneOre("orePoorCopper", 2000);
ActuallyAdditionsAPI.addMiningLensStoneOre("orePoorTin", 1800);
ActuallyAdditionsAPI.addMiningLensStoneOre("orePoorLead", 1500);
ActuallyAdditionsAPI.addMiningLensStoneOre("orePoorSilver", 1000);
ActuallyAdditionsAPI.addMiningLensNetherOre("oreCobalt", 50); ActuallyAdditionsAPI.addMiningLensNetherOre("oreCobalt", 50);
ActuallyAdditionsAPI.addMiningLensNetherOre("oreArdite", 50); ActuallyAdditionsAPI.addMiningLensNetherOre("oreArdite", 50);
// TODO: fix me
// for (String conf : ConfigStringListValues.MINING_LENS_EXTRA_WHITELIST.getValue()) {
// if (conf.contains("@")) {
// try {
// String[] split = conf.split("@");
//
// String ore = split[0];
// int weight = Integer.parseInt(split[1]);
// String dim = split[2];
//
// if ("n".equals(dim)) {
// ActuallyAdditionsAPI.addMiningLensNetherOre(ore, weight);
// } else if ("s".equals(dim)) {
// ActuallyAdditionsAPI.addMiningLensStoneOre(ore, weight);
// }
// } catch (Exception e) {
// ActuallyAdditions.LOGGER.warn("A config option appears to be incorrect: The entry " + conf + " can't be parsed!");
// }
// }
// }
} }
@Override @Override