mirror of
https://github.com/AlmostReliable/almostunified.git
synced 2024-11-28 10:35:38 -05:00
add Integrated Dynamics compat
This commit is contained in:
parent
af1253cf97
commit
11427a6cc7
3 changed files with 45 additions and 0 deletions
|
@ -17,6 +17,7 @@ public final class ModConstants {
|
|||
public static final String ENDER_IO = "enderio";
|
||||
public static final String GREGTECH_MODERN = "gtceu";
|
||||
public static final String IMMERSIVE_ENGINEERING = "immersiveengineering";
|
||||
public static final String INTEGRATED_DYNAMICS = "integrateddynamics";
|
||||
public static final String MEKANISM = "mekanism";
|
||||
public static final String MODERN_INDUSTRIALIZATION = "modern_industrialization";
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ public class AlmostUnifiedPlatformForge implements AlmostUnifiedPlatform {
|
|||
factory.registerForMod(ModConstants.ENDER_IO, new EnderIORecipeUnifier());
|
||||
factory.registerForMod(ModConstants.GREGTECH_MODERN, new GregTechModernRecipeUnifier());
|
||||
factory.registerForMod(ModConstants.IMMERSIVE_ENGINEERING, new ImmersiveEngineeringRecipeUnifier());
|
||||
factory.registerForMod(ModConstants.INTEGRATED_DYNAMICS, new IntegratedDynamicsRecipeUnifier());
|
||||
factory.registerForMod(ModConstants.MEKANISM, new MekanismRecipeUnifier());
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
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.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class IntegratedDynamicsRecipeUnifier implements RecipeUnifier {
|
||||
|
||||
private static final String ITEMS = "items";
|
||||
|
||||
@Override
|
||||
public void collectUnifier(RecipeUnifierBuilder builder) {
|
||||
builder.put(RecipeConstants.ITEM, this::createItemReplacement);
|
||||
builder.put(RecipeConstants.RESULT, this::createResultReplacement);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private JsonElement createItemReplacement(@Nullable JsonElement json, RecipeContext ctx) {
|
||||
if (json instanceof JsonPrimitive jsonPrimitive) {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.add(RecipeConstants.ITEM, jsonPrimitive);
|
||||
return ctx.createIngredientReplacement(jsonObject);
|
||||
}
|
||||
|
||||
return ctx.createIngredientReplacement(json);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private JsonElement createResultReplacement(@Nullable JsonElement json, RecipeContext ctx) {
|
||||
if (json instanceof JsonObject jsonObject && jsonObject.get(ITEMS) instanceof JsonArray jsonArray) {
|
||||
ctx.createResultReplacement(jsonArray);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue