diff --git a/Common/src/main/java/com/almostreliable/unified/api/ModConstants.java b/Common/src/main/java/com/almostreliable/unified/api/ModConstants.java index 39bd2c1..5ecae36 100644 --- a/Common/src/main/java/com/almostreliable/unified/api/ModConstants.java +++ b/Common/src/main/java/com/almostreliable/unified/api/ModConstants.java @@ -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"; diff --git a/Common/src/main/java/com/almostreliable/unified/compat/AppliedEnergisticsUnifier.java b/Common/src/main/java/com/almostreliable/unified/compat/AppliedEnergisticsUnifier.java new file mode 100644 index 0000000..d927866 --- /dev/null +++ b/Common/src/main/java/com/almostreliable/unified/compat/AppliedEnergisticsUnifier.java @@ -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; + } +} diff --git a/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java b/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java index 5c07663..acc3b44 100644 --- a/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java +++ b/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java @@ -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()); diff --git a/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java b/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java index 9bfb0cd..39b9c0d 100644 --- a/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java +++ b/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java @@ -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,