Skip to content

Commit

Permalink
Revert "Crafting Component Refactor (#2652)" (#2708)
Browse files Browse the repository at this point in the history
  • Loading branch information
krossgg authored Jan 10, 2025
1 parent 9ca23ca commit 242ff2f
Show file tree
Hide file tree
Showing 10 changed files with 1,087 additions and 953 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/gregtechceu/gtceu/api/GTValues.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.gregtechceu.gtceu.api;

import com.gregtechceu.gtceu.data.recipe.CraftingComponent;

import net.minecraft.util.RandomSource;

import java.time.LocalDate;
Expand All @@ -13,6 +15,12 @@
*/
public class GTValues {

/**
* Default fallback value used for Map keys.
* Currently only used in {@link CraftingComponent}.
*/
public static final int FALLBACK = -1;

/**
* <p/>
* This is worth exactly one normal Item.
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/com/gregtechceu/gtceu/common/data/GTRecipes.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.gregtechceu.gtceu.common.data;

import com.gregtechceu.gtceu.api.addon.AddonFinder;
import com.gregtechceu.gtceu.api.data.chemical.material.properties.BlastProperty;
import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient;
import com.gregtechceu.gtceu.data.recipe.MaterialInfoLoader;
import com.gregtechceu.gtceu.data.recipe.configurable.RecipeAddition;
import com.gregtechceu.gtceu.data.recipe.configurable.RecipeRemoval;
Expand All @@ -16,24 +14,11 @@

import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;

import java.util.EnumMap;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;

public class GTRecipes {

public static final Map<BlastProperty.GasTier, FluidIngredient> EBF_GASES = new EnumMap<>(
BlastProperty.GasTier.class);

static {
EBF_GASES.put(BlastProperty.GasTier.LOW, FluidIngredient.of(GTMaterials.Nitrogen.getFluidTag(), 1000));
EBF_GASES.put(BlastProperty.GasTier.MID, FluidIngredient.of(GTMaterials.Helium.getFluidTag(), 100));
EBF_GASES.put(BlastProperty.GasTier.HIGH, FluidIngredient.of(GTMaterials.Argon.getFluidTag(), 50));
EBF_GASES.put(BlastProperty.GasTier.HIGHER, FluidIngredient.of(GTMaterials.Neon.getFluidTag(), 25));
EBF_GASES.put(BlastProperty.GasTier.HIGHEST, FluidIngredient.of(GTMaterials.Krypton.getFluidTag(), 10));
}

public static final Set<ResourceLocation> RECIPE_FILTERS = new ObjectOpenHashSet<>();

/*
Expand Down
982 changes: 950 additions & 32 deletions src/main/java/com/gregtechceu/gtceu/data/recipe/CraftingComponent.java

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient;
import com.gregtechceu.gtceu.common.data.*;
import com.gregtechceu.gtceu.config.ConfigHolder;
import com.gregtechceu.gtceu.data.recipe.CraftingComponent;
import com.gregtechceu.gtceu.data.recipe.VanillaRecipeHelper;
import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder;
import com.gregtechceu.gtceu.utils.FormattingUtil;
Expand All @@ -33,7 +34,6 @@
import static com.gregtechceu.gtceu.api.data.tag.TagPrefix.*;
import static com.gregtechceu.gtceu.common.data.GTMaterials.*;
import static com.gregtechceu.gtceu.common.data.GTRecipeTypes.*;
import static com.gregtechceu.gtceu.common.data.GTRecipes.EBF_GASES;

public class MaterialRecipeHandler {

Expand Down Expand Up @@ -194,7 +194,7 @@ private static void processEBFRecipe(Material material, BlastProperty property,
.EUt(EUt);

if (gasTier != null) {
FluidIngredient gas = EBF_GASES.get(gasTier).copy();
FluidIngredient gas = CraftingComponent.EBF_GASES.get(gasTier).copy();

blastBuilder.copy("blast_" + material.getName())
.circuitMeta(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.gregtechceu.gtceu.common.data.machines.GTMachineUtils;
import com.gregtechceu.gtceu.common.data.machines.GTMultiMachines;
import com.gregtechceu.gtceu.config.ConfigHolder;
import com.gregtechceu.gtceu.data.recipe.CraftingComponent;
import com.gregtechceu.gtceu.data.recipe.CustomTags;
import com.gregtechceu.gtceu.data.recipe.VanillaRecipeHelper;

Expand All @@ -30,9 +29,9 @@
import java.util.function.Consumer;

import static com.gregtechceu.gtceu.api.GTValues.*;
import static com.gregtechceu.gtceu.data.recipe.GTCraftingComponents.*;
import static com.gregtechceu.gtceu.data.recipe.GTCraftingComponents.HULL;
import static com.gregtechceu.gtceu.data.recipe.GTCraftingComponents.PUMP;
import static com.gregtechceu.gtceu.data.recipe.CraftingComponent.*;
import static com.gregtechceu.gtceu.data.recipe.CraftingComponent.HULL;
import static com.gregtechceu.gtceu.data.recipe.CraftingComponent.PUMP;

public class MetaTileEntityLoader {

Expand Down Expand Up @@ -393,16 +392,16 @@ public static void init(Consumer<FinishedRecipe> provider) {
"dwx", "hHc", "fsr", 'H', GTMachines.HULL[GTValues.LV].asStack());
VanillaRecipeHelper.addShapedRecipe(provider, true, "maintenance_hatch_configurable",
GTMachines.CONFIGURABLE_MAINTENANCE_HATCH.asStack(), " ", "CMC", "VHV", 'C',
CIRCUIT.get(HV), 'M', GTMachines.MAINTENANCE_HATCH.asStack(), 'V', CONVEYOR.get(HV),
CIRCUIT.getIngredient(HV), 'M', GTMachines.MAINTENANCE_HATCH.asStack(), 'V', CONVEYOR.getIngredient(HV),
'H', GTMachines.HULL[HV].asStack());
VanillaRecipeHelper.addShapedRecipe(provider, true, "maintenance_hatch_automatic",
GTMachines.AUTO_MAINTENANCE_HATCH.asStack(), "CMC", "RHR", "CMC", 'C', CIRCUIT.get(HV), 'M',
GTMachines.MAINTENANCE_HATCH.asStack(), 'R', ROBOT_ARM.get(HV), 'H',
GTMachines.AUTO_MAINTENANCE_HATCH.asStack(), "CMC", "RHR", "CMC", 'C', CIRCUIT.getIngredient(HV), 'M',
GTMachines.MAINTENANCE_HATCH.asStack(), 'R', ROBOT_ARM.getIngredient(HV), 'H',
GTMachines.HULL[HV].asStack());
VanillaRecipeHelper.addShapedRecipe(provider, true, "maintenance_hatch_cleaning",
GTMachines.CLEANING_MAINTENANCE_HATCH.asStack(), "CMC", "RHR", "WCW", 'C',
CIRCUIT.get(GTValues.UV), 'M', GTMachines.AUTO_MAINTENANCE_HATCH.asStack(), 'R',
ROBOT_ARM.get(GTValues.UV), 'H', GTMachines.HULL[GTValues.UV].asStack(), 'W',
CIRCUIT.getIngredient(GTValues.UV), 'M', GTMachines.AUTO_MAINTENANCE_HATCH.asStack(), 'R',
ROBOT_ARM.getIngredient(GTValues.UV), 'H', GTMachines.HULL[GTValues.UV].asStack(), 'W',
new UnificationEntry(TagPrefix.cableGtSingle, GTMaterials.YttriumBariumCuprate));

// TODO Access Interface
Expand Down Expand Up @@ -910,8 +909,8 @@ public static void init(Consumer<FinishedRecipe> provider) {
int fluidAmount = GTValues.L * 2 * (tier + 1);
GTRecipeTypes.ASSEMBLER_RECIPES
.recipeBuilder("fluid_hatch_" + VN[tier].toLowerCase() + "_" + fluidMap[j].getName())
.inputItems(HULL.get(tier))
.inputItems(DRUM.get(tier))
.inputItems(HULL.getIngredient(tier))
.inputItems(DRUM.getIngredient(tier))
.circuitMeta(1)
.inputFluids(fluidMap[j].getFluid(fluidAmount >> j))
.outputItems(machine)
Expand All @@ -929,8 +928,8 @@ public static void init(Consumer<FinishedRecipe> provider) {
int fluidAmount = GTValues.L * 2 * (tier + 1);
GTRecipeTypes.ASSEMBLER_RECIPES
.recipeBuilder("fluid_export_hatch_" + VN[tier].toLowerCase() + "_" + fluidMap[j].getName())
.inputItems(HULL.get(tier))
.inputItems(DRUM.get(tier))
.inputItems(HULL.getIngredient(tier))
.inputItems(DRUM.getIngredient(tier))
.circuitMeta(2)
.inputFluids(fluidMap[j].getFluid(fluidAmount >> j))
.outputItems(machine)
Expand All @@ -948,8 +947,8 @@ public static void init(Consumer<FinishedRecipe> provider) {
int fluidAmount = GTValues.L * 2 * (tier + 1);
GTRecipeTypes.ASSEMBLER_RECIPES
.recipeBuilder("item_import_bus_" + VN[tier].toLowerCase() + "_" + fluidMap[j].getName())
.inputItems(HULL.get(tier))
.inputItems(CRATE.get(tier))
.inputItems(HULL.getIngredient(tier))
.inputItems(CRATE.getIngredient(tier))
.circuitMeta(1)
.inputFluids(fluidMap[j].getFluid(fluidAmount >> j))
.outputItems(machine)
Expand All @@ -967,8 +966,8 @@ public static void init(Consumer<FinishedRecipe> provider) {
int fluidAmount = GTValues.L * 2 * (tier + 1);
GTRecipeTypes.ASSEMBLER_RECIPES
.recipeBuilder("item_export_bus_" + VN[tier].toLowerCase() + "_" + fluidMap[j].getName())
.inputItems(HULL.get(tier))
.inputItems(CRATE.get(tier))
.inputItems(HULL.getIngredient(tier))
.inputItems(CRATE.getIngredient(tier))
.circuitMeta(2)
.inputFluids(fluidMap[j].getFluid(fluidAmount >> j))
.outputItems(machine)
Expand All @@ -988,8 +987,8 @@ public static void init(Consumer<FinishedRecipe> provider) {
.recipeBuilder("dual_import_bus_" + VN[tier].toLowerCase() + "_" + fluidMap[j].getName())
.inputItems(GTMachines.ITEM_IMPORT_BUS[tier])
.inputItems(GTMachines.FLUID_IMPORT_HATCH[tier])
.inputItems(PIPE_NONUPLE.get(tier))
.inputItems(FRAME.get(tier), 3)
.inputItems(PIPE_NONUPLE.getIngredient(tier))
.inputItems(FRAME.getIngredient(tier), 3)
.circuitMeta(1)
.inputFluids(fluidMap[j].getFluid(fluidAmount >> j))
.outputItems(machine)
Expand All @@ -1009,8 +1008,8 @@ public static void init(Consumer<FinishedRecipe> provider) {
.recipeBuilder("dual_export_bus_" + VN[tier].toLowerCase() + "_" + fluidMap[j].getName())
.inputItems(GTMachines.ITEM_IMPORT_BUS[tier])
.inputItems(GTMachines.FLUID_IMPORT_HATCH[tier])
.inputItems(PIPE_NONUPLE.get(tier))
.inputItems(FRAME.get(tier), 3)
.inputItems(PIPE_NONUPLE.getIngredient(tier))
.inputItems(FRAME.getIngredient(tier), 3)
.circuitMeta(2)
.inputFluids(fluidMap[j].getFluid(fluidAmount >> j))
.outputItems(machine)
Expand Down Expand Up @@ -1183,7 +1182,7 @@ public static void init(Consumer<FinishedRecipe> provider) {
VanillaRecipeHelper.addShapedRecipe(provider, true, "cleanroom", GTMultiMachines.CLEANROOM.asStack(), "FFF",
"RHR",
"MCM", 'F', GTItems.ITEM_FILTER.asStack(), 'R',
new UnificationEntry(TagPrefix.rotor, GTMaterials.StainlessSteel), 'H', HULL.get(HV), 'M',
new UnificationEntry(TagPrefix.rotor, GTMaterials.StainlessSteel), 'H', HULL.getIngredient(HV), 'M',
GTItems.ELECTRIC_MOTOR_HV.asStack(), 'C', CustomTags.HV_CIRCUITS);

if (ConfigHolder.INSTANCE.compat.energy.enableFEConverters) {
Expand Down Expand Up @@ -1231,8 +1230,11 @@ public static void registerMachineRecipe(Consumer<FinishedRecipe> provider, Mach

private static Object[] prepareRecipe(int tier, Object... recipe) {
for (int i = 3; i < recipe.length; i++) {
if (recipe[i] instanceof CraftingComponent) {
Object component = ((CraftingComponent) recipe[i]).get(tier);
if (recipe[i] instanceof Component) {
Object component = ((Component) recipe[i]).getIngredient(tier);
if (component == null) {
return null;
}
recipe[i] = component;
} else if (recipe[i] instanceof Item item) {
recipe[i] = new ItemStack(item);
Expand Down
Loading

0 comments on commit 242ff2f

Please sign in to comment.