Skip to content

Commit

Permalink
Remove Fluids in Recycling
Browse files Browse the repository at this point in the history
Now its saved in git, we can always restore if implemented
  • Loading branch information
IntegerLimit committed Jan 25, 2024
1 parent e3c78a5 commit 85a801b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/main/groovy-tests/recipeRecyclingTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ createRecipe(metaitem('battery_buffer.uhv.8'), [
[null, metaitem('battery_buffer.uv.8'), null],
[null, null, null]])

// Add / Change recycling to a stack, including fluids, although fluids are not included in recycling calculations
changeStackRecycling(metaitem('battery_buffer.uhv.16'), [metaitem('battery_buffer.uv.16'), metaitem('charger.uv'), fluid('soldering_alloy') * 1152])
// Add / Change recycling to a stack
changeStackRecycling(metaitem('battery_buffer.uhv.16'), [metaitem('battery_buffer.uv.16'), metaitem('charger.uv')])
22 changes: 2 additions & 20 deletions src/main/java/com/nomiceu/nomilabs/groovy/ReplaceRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import gregtech.api.recipes.RecyclingHandler;
import gregtech.api.recipes.category.GTRecipeCategory;
import gregtech.api.recipes.category.RecipeCategories;
import gregtech.api.recipes.ingredients.GTRecipeFluidInput;
import gregtech.api.recipes.ingredients.GTRecipeInput;
import gregtech.api.recipes.ingredients.GTRecipeItemInput;
import gregtech.api.recipes.ingredients.GTRecipeOreInput;
Expand All @@ -24,12 +23,12 @@
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.crafting.IShapedRecipe;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -109,13 +108,7 @@ public static void createRecipe(ItemStack output, List<List<IIngredient>> input)


public static void changeStackRecycling(ItemStack output, List<IIngredient> ingredients) {
List<GTRecipeInput> gtInputs = new ArrayList<>();
for (var input : ingredients) {
var gtInput = ofGroovyIngredientIncludingFluids(input);
if (gtInput != null)
gtInputs.add(gtInput);
}
LabsVirtualizedRegistries.REPLACE_RECIPE_MANAGER.registerOre(output, RecyclingHandler.getRecyclingIngredients(gtInputs, output.getCount()));
registerRecycling(output, Collections.singletonList(ingredients));
}

private static IShapedRecipe validate(ResourceLocation name, ItemStack output, boolean validateOutput) {
Expand Down Expand Up @@ -186,17 +179,6 @@ private static GTRecipeInput ofGroovyIngredient(IIngredient ingredient) {
return null;
}

// TODO Remove? GTRecipeFluidInputs are not included in recycling calculations
@Nullable
private static GTRecipeInput ofGroovyIngredientIncludingFluids(IIngredient ingredient) {
var gtInput = ofGroovyIngredient(ingredient);
if (gtInput != null) return gtInput;
if ((Object) ingredient instanceof FluidStack stack) {
return new GTRecipeFluidInput(stack);
}
return null;
}

private static ResourceLocation getRecipeName(ItemStack oldOutput) {
ResourceLocation name = null;
for (IRecipe recipe : ForgeRegistries.RECIPES) {
Expand Down

0 comments on commit 85a801b

Please sign in to comment.