mirror of
https://github.com/AlmostReliable/almostunified.git
synced 2024-11-28 10:35:38 -05:00
Add support for alloy forgery
This commit is contained in:
parent
88b2b4fa67
commit
4ca001ddc7
3 changed files with 45 additions and 0 deletions
|
@ -9,6 +9,7 @@ public final class ModConstants {
|
||||||
// custom unify handlers
|
// custom unify handlers
|
||||||
public static final String AD_ASTRA = "ad_astra";
|
public static final String AD_ASTRA = "ad_astra";
|
||||||
public static final String APPLIED_ENERGISTICS = "ae2";
|
public static final String APPLIED_ENERGISTICS = "ae2";
|
||||||
|
public static final String ALLOY_FORGERY = "alloy_forgery";
|
||||||
public static final String AMETHYST_IMBUEMENT = "amethyst_imbuement";
|
public static final String AMETHYST_IMBUEMENT = "amethyst_imbuement";
|
||||||
public static final String ARS_CREO = "ars_creo";
|
public static final String ARS_CREO = "ars_creo";
|
||||||
public static final String ARS_ELEMENTAL = "ars_elemental";
|
public static final String ARS_ELEMENTAL = "ars_elemental";
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class AlmostUnifiedPlatformFabric implements AlmostUnifiedPlatform {
|
||||||
@Override
|
@Override
|
||||||
public void bindRecipeHandlers(RecipeHandlerFactory factory) {
|
public void bindRecipeHandlers(RecipeHandlerFactory factory) {
|
||||||
factory.registerForMod(ModConstants.AD_ASTRA, new AdAstraRecipeUnifier());
|
factory.registerForMod(ModConstants.AD_ASTRA, new AdAstraRecipeUnifier());
|
||||||
|
factory.registerForMod(ModConstants.ALLOY_FORGERY, new AlloyForgeryRecipeUnifier());
|
||||||
factory.registerForMod(ModConstants.APPLIED_ENERGISTICS, new AppliedEnergisticsUnifier());
|
factory.registerForMod(ModConstants.APPLIED_ENERGISTICS, new AppliedEnergisticsUnifier());
|
||||||
factory.registerForMod(ModConstants.AMETHYST_IMBUEMENT, new AmethystImbuementRecipeUnifier());
|
factory.registerForMod(ModConstants.AMETHYST_IMBUEMENT, new AmethystImbuementRecipeUnifier());
|
||||||
factory.registerForMod(ModConstants.GREGTECH_MODERN, new GregTechModernRecipeUnifier());
|
factory.registerForMod(ModConstants.GREGTECH_MODERN, new GregTechModernRecipeUnifier());
|
||||||
|
|
|
@ -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.almostreliable.unified.utils.Utils;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonPrimitive;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class AlloyForgeryRecipeUnifier implements RecipeUnifier {
|
||||||
|
@Override
|
||||||
|
public void collectUnifier(RecipeUnifierBuilder builder) {
|
||||||
|
builder.put(RecipeConstants.OUTPUT, this::replaceTagOutput);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private JsonElement replaceTagOutput(JsonElement element, RecipeContext ctx) {
|
||||||
|
if (!(element instanceof JsonObject json)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json.get("priority") instanceof JsonArray && json.get("default") instanceof JsonPrimitive primitive) {
|
||||||
|
ResourceLocation item = ctx.getPreferredItemForTag(Utils.toItemTag(primitive.getAsString()), $ -> true);
|
||||||
|
if (item != null) {
|
||||||
|
json.addProperty("id", item.toString());
|
||||||
|
json.remove("priority");
|
||||||
|
json.remove("default");
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.createResultReplacement(element, false, "id");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue