Skip to content

Commit

Permalink
Add modLoaded conditions to AppMek integration recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Oct 4, 2023
1 parent fd926d5 commit db81bb2
Showing 1 changed file with 79 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeBuilder;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.data.recipes.ShapedRecipeBuilder;
Expand All @@ -14,6 +15,8 @@
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraftforge.common.crafting.ConditionalRecipe;
import net.minecraftforge.common.crafting.conditions.ModLoadedCondition;

import appeng.core.definitions.AEBlocks;
import appeng.core.definitions.AEItems;
Expand All @@ -38,15 +41,17 @@ public ForgeRecipeProvider(PackOutput output) {
@Override
protected void buildRecipes(@NotNull Consumer<FinishedRecipe> consumer) {
if (MEGACells.PLATFORM.isAddonLoaded(Addons.APPMEK)) {
ShapedRecipeBuilder.shaped(RecipeCategory.MISC, AppMekItems.MEGA_CHEMICAL_CELL_HOUSING)
.pattern("aba")
.pattern("b b")
.pattern("ddd")
.define('a', AEBlocks.QUARTZ_VIBRANT_GLASS)
.define('b', AEItems.SKY_DUST)
.define('d', OSMIUM)
.unlockedBy("has_dusts/sky_stone", has(AEItems.SKY_DUST))
.save(consumer, MEGACells.makeId("cells/has_mega_chemical_cell_housing"));
appmekRecipe(
consumer,
MEGACells.makeId("cells/mega_chemical_cell_housing"),
ShapedRecipeBuilder.shaped(RecipeCategory.MISC, AppMekItems.MEGA_CHEMICAL_CELL_HOUSING)
.pattern("aba")
.pattern("b b")
.pattern("ddd")
.define('a', AEBlocks.QUARTZ_VIBRANT_GLASS)
.define('b', AEItems.SKY_DUST)
.define('d', OSMIUM)
.unlockedBy("has_dusts/sky_stone", has(AEItems.SKY_DUST)));

chemCell(consumer, AppMekItems.CHEMICAL_CELL_1M, MEGAItems.CELL_COMPONENT_1M);
chemCell(consumer, AppMekItems.CHEMICAL_CELL_4M, MEGAItems.CELL_COMPONENT_4M);
Expand All @@ -60,61 +65,77 @@ protected void buildRecipes(@NotNull Consumer<FinishedRecipe> consumer) {
chemPortable(consumer, AppMekItems.PORTABLE_CHEMICAL_CELL_64M, MEGAItems.CELL_COMPONENT_64M);
chemPortable(consumer, AppMekItems.PORTABLE_CHEMICAL_CELL_256M, MEGAItems.CELL_COMPONENT_256M);

ShapedRecipeBuilder.shaped(RecipeCategory.MISC, AppMekItems.RADIOACTIVE_CELL_COMPONENT)
.pattern("aba")
.pattern("cdc")
.pattern("aea")
.define('a', AEItems.SKY_DUST)
.define('b', MEGAItems.ACCUMULATION_PROCESSOR)
.define('c', MekanismBlocks.RADIOACTIVE_WASTE_BARREL)
.define('d', AEBlocks.QUARTZ_VIBRANT_GLASS)
.define('e', AEItems.CELL_COMPONENT_256K)
.unlockedBy("has_cell_component_256k", has(AEItems.CELL_COMPONENT_256K))
.unlockedBy("has_waste_barrel", has(MekanismBlocks.RADIOACTIVE_WASTE_BARREL))
.save(consumer, MEGACells.makeId("crafting/radioactive_cell_component"));
ShapedRecipeBuilder.shaped(RecipeCategory.MISC, AppMekItems.RADIOACTIVE_CHEMICAL_CELL)
.pattern("aba")
.pattern("bcb")
.pattern("ded")
.define('a', GeneratorsBlocks.REACTOR_GLASS)
.define('b', AEItems.SKY_DUST)
.define('c', AppMekItems.RADIOACTIVE_CELL_COMPONENT)
.define('d', MekanismItems.HDPE_SHEET)
.define('e', MekanismItems.POLONIUM_PELLET)
.unlockedBy("has_radioactive_cell_component", has(AppMekItems.RADIOACTIVE_CELL_COMPONENT))
.save(consumer, MEGACells.makeId("cells/standard/radioactive_chemical_cell"));
appmekRecipe(
consumer,
MEGACells.makeId("crafting/radioactive_cell_component"),
ShapedRecipeBuilder.shaped(RecipeCategory.MISC, AppMekItems.RADIOACTIVE_CELL_COMPONENT)
.pattern("aba")
.pattern("cdc")
.pattern("aea")
.define('a', AEItems.SKY_DUST)
.define('b', MEGAItems.ACCUMULATION_PROCESSOR)
.define('c', MekanismBlocks.RADIOACTIVE_WASTE_BARREL)
.define('d', AEBlocks.QUARTZ_VIBRANT_GLASS)
.define('e', AEItems.CELL_COMPONENT_256K)
.unlockedBy("has_cell_component_256k", has(AEItems.CELL_COMPONENT_256K))
.unlockedBy("has_waste_barrel", has(MekanismBlocks.RADIOACTIVE_WASTE_BARREL)));
appmekRecipe(
consumer,
MEGACells.makeId("cells/standard/radioactive_chemical_cell"),
ShapedRecipeBuilder.shaped(RecipeCategory.MISC, AppMekItems.RADIOACTIVE_CHEMICAL_CELL)
.pattern("aba")
.pattern("bcb")
.pattern("ded")
.define('a', GeneratorsBlocks.REACTOR_GLASS)
.define('b', AEItems.SKY_DUST)
.define('c', AppMekItems.RADIOACTIVE_CELL_COMPONENT)
.define('d', MekanismItems.HDPE_SHEET)
.define('e', MekanismItems.POLONIUM_PELLET)
.unlockedBy("has_radioactive_cell_component", has(AppMekItems.RADIOACTIVE_CELL_COMPONENT)));
}
}

private void chemCell(Consumer<FinishedRecipe> consumer, ItemDefinition<?> cell, ItemDefinition<?> component) {
ShapedRecipeBuilder.shaped(RecipeCategory.MISC, cell)
.pattern("aba")
.pattern("bcb")
.pattern("ddd")
.define('a', AEBlocks.QUARTZ_VIBRANT_GLASS)
.define('b', AEItems.SKY_DUST)
.define('c', component)
.define('d', OSMIUM)
.unlockedBy("has_" + component.id().getPath(), has(component))
.save(consumer, MEGACells.makeId("cells/standard/" + cell.id().getPath()));

ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, cell)
.requires(AppMekItems.MEGA_CHEMICAL_CELL_HOUSING)
.requires(component)
.unlockedBy("has_" + component.id().getPath(), has(component))
.unlockedBy("has_mega_chemical_cell_housing", has(AppMekItems.MEGA_CHEMICAL_CELL_HOUSING))
.save(consumer, MEGACells.makeId("cells/standard/" + cell.id().getPath() + "_with_housing"));
appmekRecipe(
consumer,
MEGACells.makeId("cells/standard/" + cell.id().getPath()),
ShapedRecipeBuilder.shaped(RecipeCategory.MISC, cell)
.pattern("aba")
.pattern("bcb")
.pattern("ddd")
.define('a', AEBlocks.QUARTZ_VIBRANT_GLASS)
.define('b', AEItems.SKY_DUST)
.define('c', component)
.define('d', OSMIUM)
.unlockedBy("has_" + component.id().getPath(), has(component)));
appmekRecipe(
consumer,
MEGACells.makeId("cells/standard/" + cell.id().getPath() + "_with_housing"),
ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, cell)
.requires(AppMekItems.MEGA_CHEMICAL_CELL_HOUSING)
.requires(component)
.unlockedBy("has_" + component.id().getPath(), has(component))
.unlockedBy("has_mega_chemical_cell_housing", has(AppMekItems.MEGA_CHEMICAL_CELL_HOUSING)));
}

private void chemPortable(Consumer<FinishedRecipe> consumer, ItemDefinition<?> cell, ItemDefinition<?> component) {
ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, cell)
.requires(AEBlocks.CHEST)
.requires(component)
.requires(AEBlocks.DENSE_ENERGY_CELL)
.requires(AppMekItems.MEGA_CHEMICAL_CELL_HOUSING)
.unlockedBy("has_mega_chemical_cell_housing", has(AppMekItems.MEGA_CHEMICAL_CELL_HOUSING))
.unlockedBy("has_" + component.id().getPath(), has(component))
.unlockedBy("has_dense_energy_cell", has(AEBlocks.DENSE_ENERGY_CELL))
.save(consumer, MEGACells.makeId("cells/portable/" + cell.id().getPath()));
appmekRecipe(
consumer,
MEGACells.makeId("cells/portable/" + cell.id().getPath()),
ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, cell)
.requires(AEBlocks.CHEST)
.requires(component)
.requires(AEBlocks.DENSE_ENERGY_CELL)
.requires(AppMekItems.MEGA_CHEMICAL_CELL_HOUSING)
.unlockedBy("has_mega_chemical_cell_housing", has(AppMekItems.MEGA_CHEMICAL_CELL_HOUSING))
.unlockedBy("has_" + component.id().getPath(), has(component))
.unlockedBy("has_dense_energy_cell", has(AEBlocks.DENSE_ENERGY_CELL)));
}

private void appmekRecipe(Consumer<FinishedRecipe> consumer, ResourceLocation id, RecipeBuilder builder) {
ConditionalRecipe.builder()
.addCondition(new ModLoadedCondition(Addons.APPMEK.getModId()))
.addRecipe(builder::save)
.build(consumer, id);
}
}

0 comments on commit db81bb2

Please sign in to comment.