From 668957e25b4c81df1b1e85b38ed3331eab522f26 Mon Sep 17 00:00:00 2001 From: Relentless Date: Wed, 30 Nov 2022 21:04:27 +0100 Subject: [PATCH] fix inconsistencies and formatting --- .../unified/api/ModConstants.java | 6 ++-- .../unified/api/recipe/RecipeConstants.java | 27 ++++++++++----- .../unified/recipe/RecipeContextImpl.java | 1 - .../unified/AlmostUnifiedPlatformFabric.java | 2 +- .../ModernIndustrializationRecipeUnifier.java | 1 - .../unified/AlmostUnifiedPlatformForge.java | 4 +-- ...=> ImmersiveEngineeringRecipeUnifier.java} | 34 +++++++++---------- .../unified/compat/MekanismRecipeUnifier.java | 1 - 8 files changed, 43 insertions(+), 33 deletions(-) rename Forge/src/main/java/com/almostreliable/unified/compat/{IERecipeUnifier.java => ImmersiveEngineeringRecipeUnifier.java} (62%) 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 64aaca1..b3a011f 100644 --- a/Common/src/main/java/com/almostreliable/unified/api/ModConstants.java +++ b/Common/src/main/java/com/almostreliable/unified/api/ModConstants.java @@ -2,12 +2,14 @@ package com.almostreliable.unified.api; @SuppressWarnings("SpellCheckingInspection") public final class ModConstants { + // recipe viewers public static final String JEI = "jei"; public static final String REI = "roughlyenoughitems"; - public static final String IE = "immersiveengineering"; - public static final String AMETHYST_IMBUEMENT = "amethyst_imbuement"; + // custom unify handlers 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 MODERN_INDUSTRIALIZATION = "modern_industrialization"; diff --git a/Common/src/main/java/com/almostreliable/unified/api/recipe/RecipeConstants.java b/Common/src/main/java/com/almostreliable/unified/api/recipe/RecipeConstants.java index 27b768c..8986407 100644 --- a/Common/src/main/java/com/almostreliable/unified/api/recipe/RecipeConstants.java +++ b/Common/src/main/java/com/almostreliable/unified/api/recipe/RecipeConstants.java @@ -1,6 +1,7 @@ package com.almostreliable.unified.api.recipe; public final class RecipeConstants { + // common inputs public static final String ITEM = "item"; public static final String TAG = "tag"; public static final String INPUT = "input"; @@ -8,21 +9,31 @@ public final class RecipeConstants { public static final String INGREDIENT = "ingredient"; public static final String INGREDIENTS = "ingredients"; public static final String INPUT_ITEMS = "inputItems"; + + // common outputs public static final String OUTPUT = "output"; public static final String RESULT = "result"; public static final String RESULTS = "results"; public static final String OUTPUT_ITEMS = "outputItems"; + + // inner keys public static final String VALUE = "value"; - public static final String INPUT_0 = "input0"; - public static final String INPUT_1 = "input1"; - public static final String ADDITIVES = "additives"; - public static final String SECONDARIES = "secondaries"; - public static final String SLAG = "slag"; + + // immersive engineering + public static final String INPUT_0 = "input0"; + public static final String INPUT_1 = "input1"; + 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_OUTPUT = "mainOutput"; 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() {} } diff --git a/Common/src/main/java/com/almostreliable/unified/recipe/RecipeContextImpl.java b/Common/src/main/java/com/almostreliable/unified/recipe/RecipeContextImpl.java index d1095f2..5c60f79 100644 --- a/Common/src/main/java/com/almostreliable/unified/recipe/RecipeContextImpl.java +++ b/Common/src/main/java/com/almostreliable/unified/recipe/RecipeContextImpl.java @@ -22,7 +22,6 @@ public class RecipeContextImpl implements RecipeContext { private final ReplacementMap replacementMap; private final JsonObject originalRecipe; - public RecipeContextImpl(JsonObject json, ReplacementMap replacementMap) { this.originalRecipe = json; this.replacementMap = replacementMap; diff --git a/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java b/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java index c0ab0d9..713a6df 100644 --- a/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java +++ b/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java @@ -51,8 +51,8 @@ public class AlmostUnifiedPlatformFabric implements AlmostUnifiedPlatform { @Override public void bindRecipeHandlers(RecipeHandlerFactory factory) { factory.registerForMod(ModConstants.AD_ASTRA, new AdAstraRecipeUnifier()); - factory.registerForMod(ModConstants.MODERN_INDUSTRIALIZATION, new ModernIndustrializationRecipeUnifier()); factory.registerForMod(ModConstants.AMETHYST_IMBUEMENT, new AmethystImbuementRecipeUnifier()); + factory.registerForMod(ModConstants.MODERN_INDUSTRIALIZATION, new ModernIndustrializationRecipeUnifier()); } @Override diff --git a/Fabric/src/main/java/com/almostreliable/unified/compat/ModernIndustrializationRecipeUnifier.java b/Fabric/src/main/java/com/almostreliable/unified/compat/ModernIndustrializationRecipeUnifier.java index b4f426a..1be11ae 100644 --- a/Fabric/src/main/java/com/almostreliable/unified/compat/ModernIndustrializationRecipeUnifier.java +++ b/Fabric/src/main/java/com/almostreliable/unified/compat/ModernIndustrializationRecipeUnifier.java @@ -5,7 +5,6 @@ import com.almostreliable.unified.api.recipe.RecipeUnifier; import com.almostreliable.unified.api.recipe.RecipeUnifierBuilder; public class ModernIndustrializationRecipeUnifier implements RecipeUnifier { - @Override public void collectUnifier(RecipeUnifierBuilder builder) { builder.put(RecipeConstants.ITEM_INPUTS, (json, ctx) -> ctx.createIngredientReplacement(json)); diff --git a/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java b/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java index 2da20d7..d429ac2 100644 --- a/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java +++ b/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java @@ -2,7 +2,7 @@ package com.almostreliable.unified; import com.almostreliable.unified.api.ModConstants; 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.recipe.unifier.RecipeHandlerFactory; import com.almostreliable.unified.utils.UnifyTag; @@ -60,8 +60,8 @@ public class AlmostUnifiedPlatformForge implements AlmostUnifiedPlatform { @Override public void bindRecipeHandlers(RecipeHandlerFactory factory) { factory.registerForMod(ModConstants.AD_ASTRA, new AdAstraRecipeUnifier()); + factory.registerForMod(ModConstants.IMMERSIVE_ENGINEERING, new ImmersiveEngineeringRecipeUnifier()); factory.registerForMod(ModConstants.MEKANISM, new MekanismRecipeUnifier()); - factory.registerForMod(ModConstants.IE, new IERecipeUnifier()); } @Override diff --git a/Forge/src/main/java/com/almostreliable/unified/compat/IERecipeUnifier.java b/Forge/src/main/java/com/almostreliable/unified/compat/ImmersiveEngineeringRecipeUnifier.java similarity index 62% rename from Forge/src/main/java/com/almostreliable/unified/compat/IERecipeUnifier.java rename to Forge/src/main/java/com/almostreliable/unified/compat/ImmersiveEngineeringRecipeUnifier.java index d357701..51f098d 100644 --- a/Forge/src/main/java/com/almostreliable/unified/compat/IERecipeUnifier.java +++ b/Forge/src/main/java/com/almostreliable/unified/compat/ImmersiveEngineeringRecipeUnifier.java @@ -13,33 +13,33 @@ import net.minecraft.resources.ResourceLocation; 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 public void collectUnifier(RecipeUnifierBuilder builder) { - builder.put(RecipeConstants.INPUT_0, this::replaceIEIngredient); // alloy recipes, refinery - builder.put(RecipeConstants.INPUT_1, this::replaceIEIngredient); // alloy recipes, refinery + builder.put(RecipeConstants.INPUT_0, this::createIngredientReplacement); // alloy recipes, refinery + builder.put(RecipeConstants.INPUT_1, this::createIngredientReplacement); // alloy recipes, refinery builder.put(RecipeConstants.INPUT, - this::replaceIEIngredient); // arc furnace, squeezer, cloche, coke oven, fermenter, fertilizer, metal_press - builder.put(RecipeConstants.ADDITIVES, this::replaceIEIngredient); // arc furnace - builder.put(RecipeConstants.INPUTS, this::replaceIEIngredient); // blueprint, mixer + this::createIngredientReplacement); // arc furnace, squeezer, cloche, coke oven, fermenter, fertilizer, metal_press + builder.put(RecipeConstants.ADDITIVES, this::createIngredientReplacement); // arc furnace + builder.put(RecipeConstants.INPUTS, this::createIngredientReplacement); // blueprint, mixer // alloy recipes, crusher builder.forEachObject(RecipeConstants.SECONDARIES, (jsonObject, context) -> - replaceIEResult(jsonObject.get(RecipeConstants.OUTPUT), context) instanceof JsonObject + createResultReplacement(jsonObject.get(RecipeConstants.OUTPUT), context) instanceof JsonObject ? jsonObject : null); - builder.put(RecipeConstants.RESULT, this::replaceIEResult); - builder.put(RecipeConstants.RESULTS, this::replaceIEResult); - builder.put(RecipeConstants.SLAG, this::replaceIEResult); // arc furnace + builder.put(RecipeConstants.RESULT, this::createResultReplacement); + builder.put(RecipeConstants.RESULTS, this::createResultReplacement); + builder.put(RecipeConstants.SLAG, this::createResultReplacement); // arc furnace } @Nullable - protected JsonElement replaceIEResult(@Nullable JsonElement element, RecipeContext context) { + private JsonElement createResultReplacement(@Nullable JsonElement element, RecipeContext context) { if (element instanceof JsonArray array) { - if (JsonUtils.replaceOn(array, e -> this.replaceIEResult(e, context))) { + if (JsonUtils.replaceOn(array, e -> createResultReplacement(e, context))) { return array; } } @@ -63,7 +63,7 @@ public class IERecipeUnifier implements RecipeUnifier { JsonElement base = object.get(BASE_KEY); if (base != null) { - JsonElement baseResult = replaceIEResult(base, context); + JsonElement baseResult = createResultReplacement(base, context); if (baseResult != null) { object.add(BASE_KEY, baseResult); return object; @@ -75,7 +75,7 @@ public class IERecipeUnifier implements RecipeUnifier { } @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)) { return context.createIngredientReplacement(json.get(BASE_KEY)); } diff --git a/Forge/src/main/java/com/almostreliable/unified/compat/MekanismRecipeUnifier.java b/Forge/src/main/java/com/almostreliable/unified/compat/MekanismRecipeUnifier.java index 31d5fc0..067ffc6 100644 --- a/Forge/src/main/java/com/almostreliable/unified/compat/MekanismRecipeUnifier.java +++ b/Forge/src/main/java/com/almostreliable/unified/compat/MekanismRecipeUnifier.java @@ -5,7 +5,6 @@ import com.almostreliable.unified.api.recipe.RecipeUnifier; import com.almostreliable.unified.api.recipe.RecipeUnifierBuilder; public class MekanismRecipeUnifier implements RecipeUnifier { - @Override public void collectUnifier(RecipeUnifierBuilder builder) { builder.put(RecipeConstants.MAIN_INPUT, (json, ctx) -> ctx.createIngredientReplacement(json));