Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/main/java/gregtech/api/recipes/RecipeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.ore.OrePrefix;
import gregtech.api.unification.stack.ItemMaterialInfo;
import gregtech.api.util.EnumValidationResult;
import gregtech.api.util.GTLog;
import gregtech.api.util.GTUtility;
Expand Down Expand Up @@ -93,6 +94,8 @@ public class RecipeBuilder<R extends RecipeBuilder<R>> {
protected boolean ignoreAllBuildActions = false;
protected Map<ResourceLocation, RecipeBuildAction<R>> ignoredBuildActions;

private boolean withItemRecycling;

protected RecipeBuilder() {
this.inputs = new ArrayList<>();
this.outputs = new ArrayList<>();
Expand Down Expand Up @@ -137,6 +140,7 @@ protected RecipeBuilder(RecipeBuilder<R> recipeBuilder) {
if (recipeBuilder.ignoredBuildActions != null) {
this.ignoredBuildActions = new Object2ObjectOpenHashMap<>(recipeBuilder.ignoredBuildActions);
}
this.withItemRecycling = recipeBuilder.hasItemRecycling();
}

public R cleanroom(@Nullable CleanroomType cleanroom) {
Expand Down Expand Up @@ -964,6 +968,14 @@ public R ignoreBuildAction(ResourceLocation buildActionName) {
return (R) this;
}

/**
* Generate Recycling Data based on this recipe's Items
*/
public R withRecycling() {
this.withItemRecycling = true;
return (R) this;
}

public ValidationResult<Recipe> build() {
EnumValidationResult result = recipePropertyStorageErrored ? EnumValidationResult.INVALID : validate();
return ValidationResult.newResult(result, new Recipe(inputs, outputs,
Expand Down Expand Up @@ -1071,6 +1083,15 @@ public void buildAndRegister() {
buildAction.getValue().accept((R) this);
}
}
if (hasItemRecycling()) {
// ignore input fluids for item-only recycling
ItemStack outputStack = getOutputs().get(0);
ItemMaterialInfo info = RecyclingHandler.getRecyclingIngredients(getInputs(), outputStack.getCount());
if (info != null) {
OreDictUnifier.registerOre(outputStack, info);
}
}

ValidationResult<Recipe> validationResult = build();
recipeMap.addRecipe(validationResult);
}
Expand Down Expand Up @@ -1151,6 +1172,10 @@ public boolean ignoresAllBuildActions() {
return ignoredBuildActions;
}

public boolean hasItemRecycling() {
return withItemRecycling;
}

@Override
public String toString() {
return new ToStringBuilder(this)
Expand Down
19 changes: 2 additions & 17 deletions src/main/java/gregtech/api/recipes/RecipeMaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import gregtech.api.gui.GuiTextures;
import gregtech.api.gui.widgets.ProgressWidget;
import gregtech.api.gui.widgets.ProgressWidget.MoveType;
import gregtech.api.recipes.builders.AssemblerRecipeBuilder;
import gregtech.api.recipes.builders.AssemblyLineRecipeBuilder;
import gregtech.api.recipes.builders.BlastRecipeBuilder;
import gregtech.api.recipes.builders.CircuitAssemblerRecipeBuilder;
Expand All @@ -29,15 +28,12 @@
import gregtech.api.recipes.ui.impl.DistillationTowerUI;
import gregtech.api.recipes.ui.impl.FormingPressUI;
import gregtech.api.recipes.ui.impl.ResearchStationUI;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Materials;
import gregtech.api.unification.stack.ItemMaterialInfo;
import gregtech.api.util.AssemblyLineManager;
import gregtech.api.util.GTUtility;
import gregtech.core.sound.GTSoundEvents;

import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;

import crafttweaker.annotations.ZenRegister;
import stanhebben.zenscript.annotations.ZenClass;
Expand Down Expand Up @@ -144,8 +140,8 @@ public final class RecipeMaps {
* </pre>
*/
@ZenProperty
public static final RecipeMap<AssemblerRecipeBuilder> ASSEMBLER_RECIPES = new RecipeMapBuilder<>("assembler",
new AssemblerRecipeBuilder())
public static final RecipeMap<SimpleRecipeBuilder> ASSEMBLER_RECIPES = new RecipeMapBuilder<>("assembler",
new SimpleRecipeBuilder())
.itemInputs(9)
.itemOutputs(1)
.fluidInputs(1)
Expand All @@ -162,17 +158,6 @@ public final class RecipeMaps {
.buildAndRegister();
}
})
.onBuild(gregtechId("assembler_recycling"), recipeBuilder -> {
if (recipeBuilder.isWithRecycling()) {
// ignore input fluids for recycling
ItemStack outputStack = recipeBuilder.getOutputs().get(0);
ItemMaterialInfo info = RecyclingHandler.getRecyclingIngredients(recipeBuilder.getInputs(),
outputStack.getCount());
if (info != null) {
OreDictUnifier.registerOre(outputStack, info);
}
}
})
.build();

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import gregtech.api.GTValues;
import gregtech.api.recipes.ModHandler;
import gregtech.api.recipes.builders.AssemblerRecipeBuilder;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.properties.PropertyKey;
Expand Down Expand Up @@ -118,7 +117,7 @@ public static void generateCableCovering(OrePrefix wirePrefix, Material material

// Rubber Recipe (ULV-EV cables)
if (voltageTier <= GTValues.EV) {
AssemblerRecipeBuilder builder = ASSEMBLER_RECIPES.recipeBuilder().EUt(VA[ULV]).duration(100)
var builder = ASSEMBLER_RECIPES.recipeBuilder().EUt(VA[ULV]).duration(100)
.input(wirePrefix, material)
.output(cablePrefix, material)
.fluidInputs(Rubber.getFluid(GTValues.L * insulationAmount));
Expand All @@ -130,7 +129,7 @@ public static void generateCableCovering(OrePrefix wirePrefix, Material material
}

// Silicone Rubber Recipe (all cables)
AssemblerRecipeBuilder builder = ASSEMBLER_RECIPES.recipeBuilder().EUt(VA[ULV]).duration(100)
var builder = ASSEMBLER_RECIPES.recipeBuilder().EUt(VA[ULV]).duration(100)
.input(wirePrefix, material)
.output(cablePrefix, material);

Expand Down
Loading