add Applied Energistics compat

This commit is contained in:
rlnt 2024-03-14 20:49:20 +01:00
parent 20472767e1
commit 09873d3d9b
No known key found for this signature in database
4 changed files with 53 additions and 4 deletions

View file

@ -8,6 +8,7 @@ public final class ModConstants {
// custom unify handlers
public static final String AD_ASTRA = "ad_astra";
public static final String APPLIED_ENERGISTICS = "ae2";
public static final String AMETHYST_IMBUEMENT = "amethyst_imbuement";
public static final String ARS_CREO = "ars_creo";
public static final String ARS_ELEMENTAL = "ars_elemental";

View file

@ -0,0 +1,49 @@
package com.almostreliable.unified.compat;
import com.almostreliable.unified.api.recipe.RecipeConstants;
import com.almostreliable.unified.api.recipe.RecipeContext;
import com.almostreliable.unified.api.recipe.RecipeUnifier;
import com.almostreliable.unified.api.recipe.RecipeUnifierBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import javax.annotation.Nullable;
public class AppliedEnergisticsUnifier implements RecipeUnifier {
public static final String DROPS = "drops";
public static final String TOP = "top";
public static final String MIDDLE = "middle";
public static final String BOTTOM = "bottom";
public static final String AMMO = "ammo";
@Override
public void collectUnifier(RecipeUnifierBuilder builder) {
// entropy
builder.put(RecipeConstants.OUTPUT, this::createOutputDropsReplacement);
// inscriber
builder.put(
RecipeConstants.INGREDIENTS,
(json, ctx) -> ctx.createIngredientReplacement(json, TOP, MIDDLE, BOTTOM)
);
// matter cannon
builder.put(AMMO, (json, ctx) -> ctx.createIngredientReplacement(json));
}
@Nullable
private JsonElement createOutputDropsReplacement(JsonElement json, RecipeContext ctx) {
if (json instanceof JsonObject jsonObject && jsonObject.has(DROPS)) {
JsonElement resultReplacement = ctx.createResultReplacement(
jsonObject.get(DROPS),
false,
RecipeConstants.ITEM
);
if (resultReplacement != null) {
jsonObject.add(DROPS, resultReplacement);
return jsonObject;
}
}
return null;
}
}

View file

@ -1,10 +1,7 @@
package com.almostreliable.unified;
import com.almostreliable.unified.api.ModConstants;
import com.almostreliable.unified.compat.AdAstraRecipeUnifier;
import com.almostreliable.unified.compat.AmethystImbuementRecipeUnifier;
import com.almostreliable.unified.compat.GregTechModernRecipeUnifier;
import com.almostreliable.unified.compat.ModernIndustrializationRecipeUnifier;
import com.almostreliable.unified.compat.*;
import com.almostreliable.unified.recipe.unifier.RecipeHandlerFactory;
import com.almostreliable.unified.utils.UnifyTag;
import com.google.auto.service.AutoService;
@ -47,6 +44,7 @@ public class AlmostUnifiedPlatformFabric implements AlmostUnifiedPlatform {
@Override
public void bindRecipeHandlers(RecipeHandlerFactory factory) {
factory.registerForMod(ModConstants.AD_ASTRA, new AdAstraRecipeUnifier());
factory.registerForMod(ModConstants.APPLIED_ENERGISTICS, new AppliedEnergisticsUnifier());
factory.registerForMod(ModConstants.AMETHYST_IMBUEMENT, new AmethystImbuementRecipeUnifier());
factory.registerForMod(ModConstants.GREGTECH_MODERN, new GregTechModernRecipeUnifier());
factory.registerForMod(ModConstants.MODERN_INDUSTRIALIZATION, new ModernIndustrializationRecipeUnifier());

View file

@ -53,6 +53,7 @@ public class AlmostUnifiedPlatformForge implements AlmostUnifiedPlatform {
@Override
public void bindRecipeHandlers(RecipeHandlerFactory factory) {
factory.registerForMod(ModConstants.AD_ASTRA, new AdAstraRecipeUnifier());
factory.registerForMod(ModConstants.APPLIED_ENERGISTICS, new AppliedEnergisticsUnifier());
List.of(
ModConstants.ARS_CREO,
ModConstants.ARS_ELEMENTAL,