fix inconsistencies and formatting

This commit is contained in:
Relentless 2022-11-30 21:04:27 +01:00
parent bbb62b9e44
commit 668957e25b
No known key found for this signature in database
GPG key ID: 759D97B8C6F25265
8 changed files with 43 additions and 33 deletions

View file

@ -2,12 +2,14 @@ package com.almostreliable.unified.api;
@SuppressWarnings("SpellCheckingInspection") @SuppressWarnings("SpellCheckingInspection")
public final class ModConstants { public final class ModConstants {
// recipe viewers
public static final String JEI = "jei"; public static final String JEI = "jei";
public static final String REI = "roughlyenoughitems"; public static final String REI = "roughlyenoughitems";
public static final String IE = "immersiveengineering"; // custom unify handlers
public static final String AMETHYST_IMBUEMENT = "amethyst_imbuement";
public static final String AD_ASTRA = "ad_astra"; public static final String AD_ASTRA = "ad_astra";
public static final String AMETHYST_IMBUEMENT = "amethyst_imbuement";
public static final String IMMERSIVE_ENGINEERING = "immersiveengineering";
public static final String MEKANISM = "mekanism"; public static final String MEKANISM = "mekanism";
public static final String MODERN_INDUSTRIALIZATION = "modern_industrialization"; public static final String MODERN_INDUSTRIALIZATION = "modern_industrialization";

View file

@ -1,6 +1,7 @@
package com.almostreliable.unified.api.recipe; package com.almostreliable.unified.api.recipe;
public final class RecipeConstants { public final class RecipeConstants {
// common inputs
public static final String ITEM = "item"; public static final String ITEM = "item";
public static final String TAG = "tag"; public static final String TAG = "tag";
public static final String INPUT = "input"; public static final String INPUT = "input";
@ -8,21 +9,31 @@ public final class RecipeConstants {
public static final String INGREDIENT = "ingredient"; public static final String INGREDIENT = "ingredient";
public static final String INGREDIENTS = "ingredients"; public static final String INGREDIENTS = "ingredients";
public static final String INPUT_ITEMS = "inputItems"; public static final String INPUT_ITEMS = "inputItems";
// common outputs
public static final String OUTPUT = "output"; public static final String OUTPUT = "output";
public static final String RESULT = "result"; public static final String RESULT = "result";
public static final String RESULTS = "results"; public static final String RESULTS = "results";
public static final String OUTPUT_ITEMS = "outputItems"; public static final String OUTPUT_ITEMS = "outputItems";
// inner keys
public static final String VALUE = "value"; public static final String VALUE = "value";
public static final String INPUT_0 = "input0";
public static final String INPUT_1 = "input1"; // immersive engineering
public static final String ADDITIVES = "additives"; public static final String INPUT_0 = "input0";
public static final String SECONDARIES = "secondaries"; public static final String INPUT_1 = "input1";
public static final String SLAG = "slag"; public static final String ADDITIVES = "additives";
public static final String SECONDARIES = "secondaries";
public static final String SLAG = "slag";
// mekanism
public static final String MAIN_INPUT = "mainInput"; public static final String MAIN_INPUT = "mainInput";
public static final String MAIN_OUTPUT = "mainOutput"; public static final String MAIN_OUTPUT = "mainOutput";
public static final String SECONDARY_OUTPUT = "secondaryOutput"; public static final String SECONDARY_OUTPUT = "secondaryOutput";
public static final String ITEM_INPUTS = "item_inputs";
public static final String ITEM_OUTPUTS = "item_outputs";
private RecipeConstants() {} // modern industrialization
public static final String ITEM_INPUTS = "item_inputs";
public static final String ITEM_OUTPUTS = "item_outputs";
private RecipeConstants() {}
} }

View file

@ -22,7 +22,6 @@ public class RecipeContextImpl implements RecipeContext {
private final ReplacementMap replacementMap; private final ReplacementMap replacementMap;
private final JsonObject originalRecipe; private final JsonObject originalRecipe;
public RecipeContextImpl(JsonObject json, ReplacementMap replacementMap) { public RecipeContextImpl(JsonObject json, ReplacementMap replacementMap) {
this.originalRecipe = json; this.originalRecipe = json;
this.replacementMap = replacementMap; this.replacementMap = replacementMap;

View file

@ -51,8 +51,8 @@ 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.MODERN_INDUSTRIALIZATION, new ModernIndustrializationRecipeUnifier());
factory.registerForMod(ModConstants.AMETHYST_IMBUEMENT, new AmethystImbuementRecipeUnifier()); factory.registerForMod(ModConstants.AMETHYST_IMBUEMENT, new AmethystImbuementRecipeUnifier());
factory.registerForMod(ModConstants.MODERN_INDUSTRIALIZATION, new ModernIndustrializationRecipeUnifier());
} }
@Override @Override

View file

@ -5,7 +5,6 @@ import com.almostreliable.unified.api.recipe.RecipeUnifier;
import com.almostreliable.unified.api.recipe.RecipeUnifierBuilder; import com.almostreliable.unified.api.recipe.RecipeUnifierBuilder;
public class ModernIndustrializationRecipeUnifier implements RecipeUnifier { public class ModernIndustrializationRecipeUnifier implements RecipeUnifier {
@Override @Override
public void collectUnifier(RecipeUnifierBuilder builder) { public void collectUnifier(RecipeUnifierBuilder builder) {
builder.put(RecipeConstants.ITEM_INPUTS, (json, ctx) -> ctx.createIngredientReplacement(json)); builder.put(RecipeConstants.ITEM_INPUTS, (json, ctx) -> ctx.createIngredientReplacement(json));

View file

@ -2,7 +2,7 @@ package com.almostreliable.unified;
import com.almostreliable.unified.api.ModConstants; import com.almostreliable.unified.api.ModConstants;
import com.almostreliable.unified.compat.AdAstraRecipeUnifier; import com.almostreliable.unified.compat.AdAstraRecipeUnifier;
import com.almostreliable.unified.compat.IERecipeUnifier; import com.almostreliable.unified.compat.ImmersiveEngineeringRecipeUnifier;
import com.almostreliable.unified.compat.MekanismRecipeUnifier; import com.almostreliable.unified.compat.MekanismRecipeUnifier;
import com.almostreliable.unified.recipe.unifier.RecipeHandlerFactory; import com.almostreliable.unified.recipe.unifier.RecipeHandlerFactory;
import com.almostreliable.unified.utils.UnifyTag; import com.almostreliable.unified.utils.UnifyTag;
@ -60,8 +60,8 @@ public class AlmostUnifiedPlatformForge 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.IMMERSIVE_ENGINEERING, new ImmersiveEngineeringRecipeUnifier());
factory.registerForMod(ModConstants.MEKANISM, new MekanismRecipeUnifier()); factory.registerForMod(ModConstants.MEKANISM, new MekanismRecipeUnifier());
factory.registerForMod(ModConstants.IE, new IERecipeUnifier());
} }
@Override @Override

View file

@ -13,33 +13,33 @@ import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class IERecipeUnifier implements RecipeUnifier { public class ImmersiveEngineeringRecipeUnifier implements RecipeUnifier {
// sub keys
private static final String BASE_KEY = "base_ingredient";
// From IE
protected static final String BASE_KEY = "base_ingredient";
@Override @Override
public void collectUnifier(RecipeUnifierBuilder builder) { public void collectUnifier(RecipeUnifierBuilder builder) {
builder.put(RecipeConstants.INPUT_0, this::replaceIEIngredient); // alloy recipes, refinery builder.put(RecipeConstants.INPUT_0, this::createIngredientReplacement); // alloy recipes, refinery
builder.put(RecipeConstants.INPUT_1, this::replaceIEIngredient); // alloy recipes, refinery builder.put(RecipeConstants.INPUT_1, this::createIngredientReplacement); // alloy recipes, refinery
builder.put(RecipeConstants.INPUT, builder.put(RecipeConstants.INPUT,
this::replaceIEIngredient); // arc furnace, squeezer, cloche, coke oven, fermenter, fertilizer, metal_press this::createIngredientReplacement); // arc furnace, squeezer, cloche, coke oven, fermenter, fertilizer, metal_press
builder.put(RecipeConstants.ADDITIVES, this::replaceIEIngredient); // arc furnace builder.put(RecipeConstants.ADDITIVES, this::createIngredientReplacement); // arc furnace
builder.put(RecipeConstants.INPUTS, this::replaceIEIngredient); // blueprint, mixer builder.put(RecipeConstants.INPUTS, this::createIngredientReplacement); // blueprint, mixer
// alloy recipes, crusher // alloy recipes, crusher
builder.forEachObject(RecipeConstants.SECONDARIES, builder.forEachObject(RecipeConstants.SECONDARIES,
(jsonObject, context) -> (jsonObject, context) ->
replaceIEResult(jsonObject.get(RecipeConstants.OUTPUT), context) instanceof JsonObject createResultReplacement(jsonObject.get(RecipeConstants.OUTPUT), context) instanceof JsonObject
? jsonObject : null); ? jsonObject : null);
builder.put(RecipeConstants.RESULT, this::replaceIEResult); builder.put(RecipeConstants.RESULT, this::createResultReplacement);
builder.put(RecipeConstants.RESULTS, this::replaceIEResult); builder.put(RecipeConstants.RESULTS, this::createResultReplacement);
builder.put(RecipeConstants.SLAG, this::replaceIEResult); // arc furnace builder.put(RecipeConstants.SLAG, this::createResultReplacement); // arc furnace
} }
@Nullable @Nullable
protected JsonElement replaceIEResult(@Nullable JsonElement element, RecipeContext context) { private JsonElement createResultReplacement(@Nullable JsonElement element, RecipeContext context) {
if (element instanceof JsonArray array) { if (element instanceof JsonArray array) {
if (JsonUtils.replaceOn(array, e -> this.replaceIEResult(e, context))) { if (JsonUtils.replaceOn(array, e -> createResultReplacement(e, context))) {
return array; return array;
} }
} }
@ -63,7 +63,7 @@ public class IERecipeUnifier implements RecipeUnifier {
JsonElement base = object.get(BASE_KEY); JsonElement base = object.get(BASE_KEY);
if (base != null) { if (base != null) {
JsonElement baseResult = replaceIEResult(base, context); JsonElement baseResult = createResultReplacement(base, context);
if (baseResult != null) { if (baseResult != null) {
object.add(BASE_KEY, baseResult); object.add(BASE_KEY, baseResult);
return object; return object;
@ -75,7 +75,7 @@ public class IERecipeUnifier implements RecipeUnifier {
} }
@Nullable @Nullable
public JsonElement replaceIEIngredient(@Nullable JsonElement element, RecipeContext context) { private JsonElement createIngredientReplacement(@Nullable JsonElement element, RecipeContext context) {
if (element instanceof JsonObject json && json.has(BASE_KEY)) { if (element instanceof JsonObject json && json.has(BASE_KEY)) {
return context.createIngredientReplacement(json.get(BASE_KEY)); return context.createIngredientReplacement(json.get(BASE_KEY));
} }

View file

@ -5,7 +5,6 @@ import com.almostreliable.unified.api.recipe.RecipeUnifier;
import com.almostreliable.unified.api.recipe.RecipeUnifierBuilder; import com.almostreliable.unified.api.recipe.RecipeUnifierBuilder;
public class MekanismRecipeUnifier implements RecipeUnifier { public class MekanismRecipeUnifier implements RecipeUnifier {
@Override @Override
public void collectUnifier(RecipeUnifierBuilder builder) { public void collectUnifier(RecipeUnifierBuilder builder) {
builder.put(RecipeConstants.MAIN_INPUT, (json, ctx) -> ctx.createIngredientReplacement(json)); builder.put(RecipeConstants.MAIN_INPUT, (json, ctx) -> ctx.createIngredientReplacement(json));