mirror of
https://github.com/AlmostReliable/almostunified.git
synced 2024-11-14 19:25:13 -05:00
fix inconsistencies and formatting
This commit is contained in:
parent
bbb62b9e44
commit
668957e25b
8 changed files with 43 additions and 33 deletions
|
@ -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";
|
||||
|
||||
|
|
|
@ -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() {}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,33 +13,33 @@ import net.minecraft.resources.ResourceLocation;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class IERecipeUnifier implements RecipeUnifier {
|
||||
public class ImmersiveEngineeringRecipeUnifier implements RecipeUnifier {
|
||||
|
||||
// From IE
|
||||
protected static final String BASE_KEY = "base_ingredient";
|
||||
// sub keys
|
||||
private 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));
|
||||
}
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue