Skip to content

Commit

Permalink
Rename of Replace Recipe Helper
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Jul 14, 2024
1 parent 436df00 commit 28838e4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Imports all static functions from the recycling section of the groovy helpers
import static com.nomiceu.nomilabs.groovy.GroovyHelpers.RecipeRecyclingHelpers.*
import static com.nomiceu.nomilabs.groovy.GroovyHelpers.RecyclingHelpers.*

// Crafting Recipe Recycling Helpers. Goes in Post Init.
// Recycling Helpers. Goes in Post Init.

// All Replace Recipes only works for replacing recipes where:
// output item, ignoring count, including meta, is the same as the old output item, ignoring count, including meta
// Also don't work recursively, each item that depends on these needs to be changed too

// All crafting recipe 'replacements' or 'creations' in this script also changes/adds recycling of the output!

// Change a recipe's output & input, replacing by name
replaceRecipeShaped("casing_assembly_control", item('gregtech:multiblock_casing', 3) * 1, [
[ore('circuitLuv'), metaitem('plate.high_power_integrated_circuit'), ore('circuitLuv')],
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/com/nomiceu/nomilabs/groovy/GroovyHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private static FluidStack toFluidStack(Fluid fluid) {
}
}

public static class RecipeRecyclingHelpers {
public static class RecyclingHelpers {

public static void replaceRecipeShaped(String name, ItemStack output, List<List<IIngredient>> inputs) {
if (name.contains(":"))
Expand All @@ -257,12 +257,12 @@ public static void replaceRecipeShaped(String name, ItemStack output, List<List<

public static void replaceRecipeShaped(ResourceLocation name, ItemStack output,
List<List<IIngredient>> inputs) {
ReplaceRecipe.replaceRecipeShaped(name, output, inputs);
RecyclingHelper.replaceRecipeShaped(name, output, inputs);
}

public static void replaceRecipeShaped(ItemStack oldOutput, ItemStack newOutput,
List<List<IIngredient>> inputs) {
ReplaceRecipe.replaceRecipeShaped(oldOutput, newOutput, inputs);
RecyclingHelper.replaceRecipeShaped(oldOutput, newOutput, inputs);
}

public static void replaceRecipeOutput(String name, ItemStack output) {
Expand All @@ -273,11 +273,11 @@ public static void replaceRecipeOutput(String name, ItemStack output) {
}

public static void replaceRecipeOutput(ResourceLocation name, ItemStack newOutput) {
ReplaceRecipe.replaceRecipeOutput(name, newOutput);
RecyclingHelper.replaceRecipeOutput(name, newOutput);
}

public static void replaceRecipeOutput(ItemStack oldOutput, ItemStack newOutput) {
ReplaceRecipe.replaceRecipeOutput(oldOutput, newOutput);
RecyclingHelper.replaceRecipeOutput(oldOutput, newOutput);
}

public static void replaceRecipeInput(String name, List<List<IIngredient>> inputs) {
Expand All @@ -288,27 +288,27 @@ public static void replaceRecipeInput(String name, List<List<IIngredient>> input
}

public static void replaceRecipeInput(ResourceLocation name, List<List<IIngredient>> newInputs) {
ReplaceRecipe.replaceRecipeInput(name, newInputs);
RecyclingHelper.replaceRecipeInput(name, newInputs);
}

public static void replaceRecipeInput(ItemStack oldOutput, List<List<IIngredient>> newInputs) {
ReplaceRecipe.replaceRecipeInput(oldOutput, newInputs);
RecyclingHelper.replaceRecipeInput(oldOutput, newInputs);
}

public static void createRecipe(String name, ItemStack output, List<List<IIngredient>> input) {
ReplaceRecipe.createRecipe(name, output, input);
RecyclingHelper.createRecipe(name, output, input);
}

public static void createRecipe(ItemStack output, List<List<IIngredient>> input) {
ReplaceRecipe.createRecipe(output, input);
RecyclingHelper.createRecipe(output, input);
}

public static void changeStackRecycling(ItemStack output, List<IIngredient> ingredients) {
ReplaceRecipe.changeStackRecycling(output, ingredients);
RecyclingHelper.changeStackRecycling(output, ingredients);
}

public static void removeStackRecycling(ItemStack output) {
ReplaceRecipe.changeStackRecycling(output, Collections.emptyList());
RecyclingHelper.changeStackRecycling(output, Collections.emptyList());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void onReload() {

@Override
public void afterScriptLoad() {
ReplaceRecipe.reloadRecyclingRecipes();
RecyclingHelper.reloadRecyclingRecipes();
needReloading.clear();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@
import gregtech.loaders.recipe.RecyclingRecipes;

@GroovyBlacklist
public class ReplaceRecipe {
public class RecyclingHelper {

private static boolean reloadingRecycling = false;

// Extractor
public static final Map<RecipeMap<?>, GTRecipeCategory> recyclingMaps = ImmutableMap.of(
RecipeMaps.ARC_FURNACE_RECIPES, RecipeCategories.ARC_FURNACE_RECYCLING,
RecipeMaps.MACERATOR_RECIPES, RecipeCategories.MACERATOR_RECYCLING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.nomiceu.nomilabs.gregtech.mixinhelper.AccessibleRecipeMap;
import com.nomiceu.nomilabs.gregtech.mixinhelper.OutputBranch;
import com.nomiceu.nomilabs.gregtech.mixinhelper.RecipeMapLogic;
import com.nomiceu.nomilabs.groovy.ReplaceRecipe;
import com.nomiceu.nomilabs.groovy.RecyclingHelper;

import gregtech.api.recipes.Recipe;
import gregtech.api.recipes.RecipeMap;
Expand All @@ -43,9 +43,9 @@ public abstract class RecipeMapMixin implements AccessibleRecipeMap {
@Inject(method = "addRecipe", at = @At("HEAD"), cancellable = true)
public void addRecipeInRecycling(@NotNull ValidationResult<Recipe> validationResult,
CallbackInfoReturnable<Boolean> cir) {
if (!ReplaceRecipe.isReloadingRecycling()) return;
if (!RecyclingHelper.isReloadingRecycling()) return;
// If not in the map returns null, which will never equal the recipe category of the recipe, which is never null
if (!Objects.equals(ReplaceRecipe.recyclingMaps.get((RecipeMap<?>) (Object) this),
if (!Objects.equals(RecyclingHelper.recyclingMaps.get((RecipeMap<?>) (Object) this),
validationResult.getResult().getRecipeCategory()))
cir.setReturnValue(false);
}
Expand Down

0 comments on commit 28838e4

Please sign in to comment.