Skip to content

Commit

Permalink
Add mod loaded condition to all AppBot recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Nov 27, 2023
1 parent 2884018 commit 6d19941
Show file tree
Hide file tree
Showing 13 changed files with 241 additions and 146 deletions.
9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ subprojects {
}
}

maven {
name = "BlameJared"
url = uri("https://maven.blamejared.com")
content {
includeGroup("vazkii.botania")
includeGroup("vazkii.patchouli")
}
}

maven {
name = "Modrinth Maven"
url = uri("https://api.modrinth.com/maven")
Expand Down
1 change: 1 addition & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ dependencies {
modCompileOnly(libs.cloth.fabric)
modCompileOnly(libs.ae2wtlib.fabric)
modCompileOnly(libs.appbot.fabric)
modCompileOnly(libs.botania.fabric) { isTransitive = false }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package gripe._90.megacells.datagen;

import java.util.function.Consumer;

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.PackOutput;
import net.minecraft.world.item.crafting.Ingredient;

import appeng.core.definitions.AEBlocks;
import appeng.core.definitions.AEItems;

import appbot.AppliedBotanics;

import gripe._90.megacells.MEGACells;
import gripe._90.megacells.core.Addons;
import gripe._90.megacells.integration.appbot.AppBotItems;

import vazkii.botania.common.block.block_entity.mana.ManaPoolBlockEntity;
import vazkii.botania.common.item.BotaniaItems;
import vazkii.botania.data.recipes.TerrestrialAgglomerationProvider;

public class AppBotHousingRecipeProvider extends TerrestrialAgglomerationProvider {
public AppBotHousingRecipeProvider(PackOutput packOutput) {
super(packOutput);
}

@Override
public void buildRecipes(Consumer<net.minecraft.data.recipes.FinishedRecipe> writer) {
var housing = AppBotItems.MEGA_MANA_CELL_HOUSING;
var id = MEGACells.makeId("cells/" + housing.id().getPath());
MEGACells.PLATFORM.addIntegrationRecipe(
writer,
new FinishedRecipe(
id,
ManaPoolBlockEntity.MAX_MANA * 2,
housing.stack(),
Ingredient.of(BuiltInRegistries.ITEM.get(AppliedBotanics.id("mana_cell_housing"))),
Ingredient.of(BotaniaItems.manaPearl),
Ingredient.of(BotaniaItems.manaDiamond),
Ingredient.of(AEItems.SKY_DUST),
Ingredient.of(AEBlocks.QUARTZ_VIBRANT_GLASS)),
Addons.APPBOT,
id);
}
}

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions common/src/main/java/gripe/_90/megacells/core/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

import net.minecraft.client.color.item.ItemColor;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeBuilder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike;
Expand Down Expand Up @@ -149,6 +153,12 @@ default void initUpgrades() {

void addVillagerTrade(ItemLike item, int cost, int quantity, int xp);

void addIntegrationRecipe(
Consumer<FinishedRecipe> writer, FinishedRecipe recipe, Addons addon, ResourceLocation id);

void addIntegrationRecipe(
Consumer<FinishedRecipe> writer, RecipeBuilder builder, Addons addon, ResourceLocation id);

interface Client {
void initScreens();

Expand Down

This file was deleted.

9 changes: 0 additions & 9 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ repositories {
}
}

maven {
name = "BlameJared"
url = uri("https://maven.blamejared.com")
content {
includeGroup("vazkii.botania")
includeGroup("vazkii.patchouli")
}
}

maven {
name = "TerraformersMC"
url = uri("https://maven.terraformersmc.com/")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package gripe._90.megacells.datagen;

import java.util.function.Consumer;

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.minecraft.data.recipes.FinishedRecipe;

public class FabricRecipeProvider extends net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider {
public FabricRecipeProvider(FabricDataOutput output) {
super(output);
}

@Override
public void buildRecipes(Consumer<FinishedRecipe> exporter) {
new CommonRecipeProvider(output).buildRecipes(exporter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public void onInitializeDataGenerator(FabricDataGenerator generator) {

pack.addProvider(CommonTagProvider.BlockTags::new);
pack.addProvider(CommonTagProvider.ItemTags::new);
pack.addProvider(FabricRecipeProvider::new);

pack.addProvider((FabricDataOutput output) -> new CommonLanguageProvider(output));
pack.addProvider((FabricDataOutput output) -> new CommonLootTableProvider(output));
pack.addProvider((FabricDataOutput output) -> new CommonRecipeProvider(output));
pack.addProvider((FabricDataOutput output) -> new CommonModelProvider(output));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
Expand All @@ -11,6 +12,9 @@
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper;
import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel;
import net.fabricmc.fabric.api.resource.conditions.v1.ConditionJsonProvider;
import net.fabricmc.fabric.api.resource.conditions.v1.DefaultResourceConditions;
import net.fabricmc.fabric.impl.datagen.FabricDataGenHelper;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.color.item.ItemColor;
Expand All @@ -20,6 +24,9 @@
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeBuilder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.npc.VillagerTrades;
import net.minecraft.world.item.CreativeModeTab;
Expand Down Expand Up @@ -112,6 +119,32 @@ public void addVillagerTrade(ItemLike item, int cost, int quantity, int xp) {
builder -> builder.add(new VillagerTrades.ItemsForEmeralds(item.asItem(), cost, quantity, xp)));
}

@SuppressWarnings("UnstableApiUsage")
@Override
public void addIntegrationRecipe(
Consumer<FinishedRecipe> writer, FinishedRecipe recipe, Addons addon, ResourceLocation id) {
Consumer<FinishedRecipe> withConditions = json -> {
FabricDataGenHelper.addConditions(
json, new ConditionJsonProvider[] {DefaultResourceConditions.allModsLoaded(addon.getModId())});
writer.accept(json);
};

withConditions.accept(recipe);
}

@SuppressWarnings("UnstableApiUsage")
@Override
public void addIntegrationRecipe(
Consumer<FinishedRecipe> writer, RecipeBuilder builder, Addons addon, ResourceLocation id) {
Consumer<FinishedRecipe> withConditions = json -> {
FabricDataGenHelper.addConditions(
json, new ConditionJsonProvider[] {DefaultResourceConditions.allModsLoaded(addon.getModId())});
writer.accept(json);
};

builder.save(withConditions, id);
}

public static class Client implements Platform.Client {
@Override
public void initScreens() {
Expand Down
9 changes: 0 additions & 9 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ repositories {
}
}

maven {
name = "BlameJared"
url = uri("https://maven.blamejared.com")
content {
includeGroup("vazkii.botania")
includeGroup("vazkii.patchouli")
}
}

maven {
name = "TheIllusiveC4"
url = uri("https://maven.theillusivec4.top/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
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 Down Expand Up @@ -133,9 +131,6 @@ private void chemPortable(Consumer<FinishedRecipe> consumer, ItemDefinition<?> c
}

private void appmekRecipe(Consumer<FinishedRecipe> consumer, ResourceLocation id, RecipeBuilder builder) {
ConditionalRecipe.builder()
.addCondition(new ModLoadedCondition(Addons.APPMEK.getModId()))
.addRecipe(builder::save)
.build(consumer, id);
MEGACells.PLATFORM.addIntegrationRecipe(consumer, builder, Addons.APPMEK, id);
}
}
24 changes: 24 additions & 0 deletions forge/src/main/java/gripe/_90/megacells/forge/ForgePlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

import org.apache.commons.lang3.ArrayUtils;
import org.jetbrains.annotations.NotNull;
Expand All @@ -19,6 +20,9 @@
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeBuilder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.npc.VillagerTrades;
import net.minecraft.world.item.CreativeModeTab;
Expand All @@ -33,6 +37,8 @@
import net.minecraftforge.client.event.RegisterColorHandlersEvent;
import net.minecraftforge.client.model.data.ModelData;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.crafting.ConditionalRecipe;
import net.minecraftforge.common.crafting.conditions.ModLoadedCondition;
import net.minecraftforge.event.OnDatapackSyncEvent;
import net.minecraftforge.event.server.ServerStartedEvent;
import net.minecraftforge.eventbus.api.IEventBus;
Expand Down Expand Up @@ -205,6 +211,24 @@ public void addVillagerTrade(ItemLike item, int cost, int quantity, int xp) {
offers.put(5, masterEntries);
}

@Override
public void addIntegrationRecipe(
Consumer<FinishedRecipe> writer, FinishedRecipe recipe, Addons addon, ResourceLocation id) {
ConditionalRecipe.builder()
.addCondition(new ModLoadedCondition(addon.getModId()))
.addRecipe(recipe)
.build(writer, id);
}

@Override
public void addIntegrationRecipe(
Consumer<FinishedRecipe> writer, RecipeBuilder builder, Addons addon, ResourceLocation id) {
ConditionalRecipe.builder()
.addCondition(new ModLoadedCondition(addon.getModId()))
.addRecipe(builder::save)
.build(writer, id);
}

public static class Client implements Platform.Client {
@Override
public void initScreens() {
Expand Down

0 comments on commit 6d19941

Please sign in to comment.