Skip to content

Commit

Permalink
Various Recipe Builder Logging (#2497)
Browse files Browse the repository at this point in the history
  • Loading branch information
YoungOnionMC authored and screret committed Dec 27, 2024
1 parent 182375b commit 24b3432
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public class GTRecipeTypes {

public final static GTRecipeType MACERATOR_RECIPES = register("macerator", ELECTRIC).setMaxIOSize(1, 4, 0, 0)
.setEUIO(IO.IN)
.prepareBuilder(recipeBuilder -> recipeBuilder.duration(150).EUt(2))
.setSlotOverlay(false, false, GuiTextures.CRUSHED_ORE_OVERLAY)
.setSlotOverlay(true, false, GuiTextures.DUST_OVERLAY)
.setProgressBar(GuiTextures.PROGRESS_BAR_MACERATE, LEFT_TO_RIGHT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
import com.gregtechceu.gtceu.api.recipe.content.Content;
import com.gregtechceu.gtceu.api.recipe.ingredient.IntCircuitIngredient;
import com.gregtechceu.gtceu.api.recipe.ingredient.IntProviderIngredient;
import com.gregtechceu.gtceu.api.recipe.ingredient.SizedIngredient;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.common.data.GTRecipeCategories;
import com.gregtechceu.gtceu.common.data.GTRecipeTypes;
import com.gregtechceu.gtceu.common.recipe.condition.*;
import com.gregtechceu.gtceu.api.tag.TagPrefix;
import com.gregtechceu.gtceu.api.tag.TagUtil;
import com.gregtechceu.gtceu.common.item.behavior.IntCircuitBehaviour;
import com.gregtechceu.gtceu.common.recipe.*;
import com.gregtechceu.gtceu.config.ConfigHolder;
import com.gregtechceu.gtceu.data.recipe.GTRecipeTypes;
import com.gregtechceu.gtceu.utils.ResearchManager;
Expand Down Expand Up @@ -166,51 +165,91 @@ public GTRecipeBuilder copyFrom(GTRecipeBuilder builder) {
}

public <T> GTRecipeBuilder input(RecipeCapability<T> capability, T obj) {
(perTick ? tickInput : input).computeIfAbsent(capability, c -> new ArrayList<>())
var t = (perTick ? tickInput : input);
if (t.get(capability) != null && t.get(capability).size() >= recipeType.getMaxInputs(capability)) {
GTCEu.LOGGER.warn("Trying to add more inputs than RecipeType can support, id: {}, Max {}{}Inputs: {}",
id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxInputs(capability));
}
t.computeIfAbsent(capability, c -> new ArrayList<>())
.add(new Content(capability.of(obj), chance, maxChance, tierChanceBoost, slotName, uiName));
return this;
}

public <T> GTRecipeBuilder input(RecipeCapability<T> capability, T... obj) {
var t = (perTick ? tickInput : input);
if (t.get(capability) != null && t.get(capability).size() + obj.length > recipeType.getMaxInputs(capability)) {
GTCEu.LOGGER.warn("Trying to add more inputs than RecipeType can support, id: {}, Max {}{}Inputs: {}",
id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxInputs(capability));
}
(perTick ? tickInput : input).computeIfAbsent(capability, c -> new ArrayList<>()).addAll(Arrays.stream(obj)
.map(capability::of)
.map(o -> new Content(o, chance, maxChance, tierChanceBoost, slotName, uiName)).toList());
return this;
}

public <T> GTRecipeBuilder output(RecipeCapability<T> capability, T obj) {
var t = (perTick ? tickOutput : output);
if (t.get(capability) != null && t.get(capability).size() >= recipeType.getMaxOutputs(capability)) {
GTCEu.LOGGER.warn("Trying to add more outputs than RecipeType can support, id: {}, Max {}{}Outputs: {}",
id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxOutputs(capability));
}
(perTick ? tickOutput : output).computeIfAbsent(capability, c -> new ArrayList<>())
.add(new Content(capability.of(obj), chance, maxChance, tierChanceBoost, slotName, uiName));
return this;
}

public <T> GTRecipeBuilder output(RecipeCapability<T> capability, T... obj) {
var t = (perTick ? tickOutput : output);
if (t.get(capability) != null && t.get(capability).size() + obj.length > recipeType.getMaxOutputs(capability)) {
GTCEu.LOGGER.warn("Trying to add more outputs than RecipeType can support, id: {}, Max {}{}Outputs: {}",
id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxOutputs(capability));
}
(perTick ? tickOutput : output).computeIfAbsent(capability, c -> new ArrayList<>()).addAll(Arrays.stream(obj)
.map(capability::of)
.map(o -> new Content(o, chance, maxChance, tierChanceBoost, slotName, uiName)).toList());
return this;
}

public <T> GTRecipeBuilder inputs(RecipeCapability<T> capability, Object obj) {
var t = (perTick ? tickInput : input);
if (t.get(capability) != null && t.get(capability).size() >= recipeType.getMaxInputs(capability)) {
GTCEu.LOGGER.warn("Trying to add more inputs than RecipeType can support, id: {}, Max {}{}Inputs: {}",
id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxInputs(capability));
}
(perTick ? tickInput : input).computeIfAbsent(capability, c -> new ArrayList<>())
.add(new Content(capability.of(obj), chance, maxChance, tierChanceBoost, slotName, uiName));
return this;
}

public <T> GTRecipeBuilder inputs(RecipeCapability<T> capability, Object... obj) {
var t = (perTick ? tickInput : input);
if (t.get(capability) != null && t.get(capability).size() + obj.length > recipeType.getMaxInputs(capability)) {
GTCEu.LOGGER.warn("Trying to add more inputs than RecipeType can support, id: {}, Max {}{}Inputs: {}",
id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxInputs(capability));
}
(perTick ? tickInput : input).computeIfAbsent(capability, c -> new ArrayList<>()).addAll(Arrays.stream(obj)
.map(capability::of)
.map(o -> new Content(o, chance, maxChance, tierChanceBoost, slotName, uiName)).toList());
return this;
}

public <T> GTRecipeBuilder outputs(RecipeCapability<T> capability, Object obj) {
var t = (perTick ? tickOutput : output);
if (t.get(capability) != null && t.get(capability).size() >= recipeType.getMaxOutputs(capability)) {
GTCEu.LOGGER.warn("Trying to add more outputs than RecipeType can support, id: {}, Max {}{}Outputs: {}",
id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxOutputs(capability));
}
(perTick ? tickOutput : output).computeIfAbsent(capability, c -> new ArrayList<>())
.add(new Content(capability.of(obj), chance, maxChance, tierChanceBoost, slotName, uiName));
return this;
}

public <T> GTRecipeBuilder outputs(RecipeCapability<T> capability, Object... obj) {
var t = (perTick ? tickOutput : output);
if (t.get(capability) != null && t.get(capability).size() + obj.length > recipeType.getMaxOutputs(capability)) {
GTCEu.LOGGER.warn("Trying to add more outputs than RecipeType can support, id: {}, Max {}{}Outputs: {}",
id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxOutputs(capability));
}
(perTick ? tickOutput : output).computeIfAbsent(capability, c -> new ArrayList<>()).addAll(Arrays.stream(obj)
.map(capability::of)
.map(o -> new Content(o, chance, maxChance, tierChanceBoost, slotName, uiName)).toList());
Expand All @@ -227,6 +266,9 @@ public GTRecipeBuilder inputEU(long eu) {
}

public GTRecipeBuilder EUt(long eu) {
if (eu == 0) {
GTCEu.LOGGER.error("EUt can't be explicitly set to 0, id: {}", id);
}
var lastPerTick = perTick;
perTick = true;
if (eu > 0) {
Expand All @@ -249,6 +291,9 @@ public GTRecipeBuilder inputCWU(int cwu) {
}

public GTRecipeBuilder CWUt(int cwu) {
if (cwu == 0) {
GTCEu.LOGGER.error("CWUt can't be explicitly set to 0, id: {}", id);
}
var lastPerTick = perTick;
perTick = true;
if (cwu > 0) {
Expand Down Expand Up @@ -292,7 +337,7 @@ public GTRecipeBuilder inputItems(Object input) {
return inputItems(machine);
} else {
GTCEu.LOGGER.error(
"gt recipe {} input item is not one of: Item, Supplier<Item>, ItemStack, SizedIngredient, Ingredient, UnificationEntry, TagKey<Item>, MachineDefinition",
"Input item is not one of: Item, Supplier<Item>, ItemStack, Ingredient, UnificationEntry, TagKey<Item>, MachineDefinition, id: {}",
id);
return this;
}
Expand All @@ -317,7 +362,7 @@ public GTRecipeBuilder inputItems(Object input, int count) {
return inputItems(machine, count);
} else {
GTCEu.LOGGER.error(
"gt recipe {} input item is not one of: Item, Supplier<Item>, ItemStack, SizedIngredient, Ingredient, UnificationEntry, TagKey<Item>, MachineDefinition",
"Input item is not one of: Item, Supplier<Item>, ItemStack, Ingredient, UnificationEntry, TagKey<Item>, MachineDefinition, id: {}",
id);
return this;
}
Expand All @@ -342,7 +387,7 @@ public GTRecipeBuilder inputItems(Ingredient... inputs) {

public GTRecipeBuilder inputItems(ItemStack input) {
if (input.isEmpty()) {
GTCEu.LOGGER.error("gt recipe {} input items is empty", id);
GTCEu.LOGGER.error("Input items is empty, id: {}", id);
}
if (input.getComponentsPatch().isEmpty()) {
return input(ItemRecipeCapability.CAP, SizedIngredient.of(input.getItem(), input.getCount()));
Expand All @@ -355,7 +400,7 @@ public GTRecipeBuilder inputItems(ItemStack input) {
public GTRecipeBuilder inputItems(ItemStack... inputs) {
for (ItemStack itemStack : inputs) {
if (itemStack.isEmpty()) {
GTCEu.LOGGER.error("gt recipe {} input items is empty", id);
GTCEu.LOGGER.error("Input item is empty, id: {}", id);
}
}
return input(ItemRecipeCapability.CAP, Arrays.stream(inputs).map(stack -> {
Expand All @@ -368,6 +413,9 @@ public GTRecipeBuilder inputItems(ItemStack... inputs) {
}

public GTRecipeBuilder inputItems(TagKey<Item> tag, int amount) {
if (amount == 0) {
GTCEu.LOGGER.error("Item Count is 0, id: {}", id);
}
return inputItems(SizedIngredient.of(tag, amount));
}

Expand Down Expand Up @@ -396,17 +444,29 @@ public GTRecipeBuilder inputItems(TagPrefix orePrefix, Material material) {
}

public GTRecipeBuilder inputItems(UnificationEntry input) {
if (input.material == null) {
GTCEu.LOGGER.error("Unification Entry material is null, id: {}, TagPrefix: {}", id, input.tagPrefix);
}
return inputItems(input.tagPrefix, input.material, 1);
}

public GTRecipeBuilder inputItems(UnificationEntry input, int count) {
if (input.material == null) {
GTCEu.LOGGER.error("Unification Entry material is null, id: {}, TagPrefix: {}", id, input.tagPrefix);
}
return inputItems(input.tagPrefix, input.material, count);
}

public GTRecipeBuilder inputItems(TagPrefix orePrefix, Material material, int count) {
TagKey<Item> tag = ChemicalHelper.getTag(orePrefix, material);
if (tag == null) {
return inputItems(ChemicalHelper.get(orePrefix, material, count));
var item = ChemicalHelper.get(orePrefix, material, count);
if (item.isEmpty()) {
GTCEu.LOGGER.error(
"Tried to set input item stack that doesn't exist, id: {}, TagPrefix: {}, Material: {}, Count: {}",
id, orePrefix, material, count);
}
return inputItems(item);
}
return inputItems(tag, count);
}
Expand All @@ -432,7 +492,7 @@ public GTRecipeBuilder outputItems(Object input) {
return outputItems(machine);
} else {
GTCEu.LOGGER.error(
"gt recipe {} output item is not one of: Item, Supplier<Item>, ItemStack, Ingredient, UnificationEntry, TagKey<Item>, MachineDefinition",
"Output item is not one of: Item, Supplier<Item>, ItemStack, Ingredient, UnificationEntry, TagKey<Item>, MachineDefinition, id: {}",
id);
return this;
}
Expand All @@ -451,7 +511,7 @@ public GTRecipeBuilder outputItems(Object input, int count) {
return outputItems(machine, count);
} else {
GTCEu.LOGGER.error(
"gt recipe {} output item is not one of: Item, Supplier<Item>, ItemStack, Ingredient, UnificationEntry, TagKey<Item>, MachineDefinition",
"Output item is not one of: Item, Supplier<Item>, ItemStack, Ingredient, UnificationEntry, TagKey<Item>, MachineDefinition, id: {}",
id);
return this;
}
Expand All @@ -463,7 +523,7 @@ public GTRecipeBuilder outputItems(SizedIngredient... inputs) {

public GTRecipeBuilder outputItems(ItemStack output) {
if (output.isEmpty()) {
GTCEu.LOGGER.error("gt recipe {} output items is empty", id);
GTCEu.LOGGER.error("Output items is empty, id: {}", id);
}
return output(ItemRecipeCapability.CAP,
new SizedIngredient(DataComponentIngredient.of(true, output), output.getCount()));
Expand All @@ -472,7 +532,7 @@ public GTRecipeBuilder outputItems(ItemStack output) {
public GTRecipeBuilder outputItems(ItemStack... outputs) {
for (ItemStack itemStack : outputs) {
if (itemStack.isEmpty()) {
GTCEu.LOGGER.error("gt recipe {} output items is empty", id);
GTCEu.LOGGER.error("Output items is empty, id: {}", id);
}
}
return output(ItemRecipeCapability.CAP,
Expand Down Expand Up @@ -502,14 +562,25 @@ public GTRecipeBuilder outputItems(TagPrefix orePrefix, Material material) {
}

public GTRecipeBuilder outputItems(TagPrefix orePrefix, Material material, int count) {
return outputItems(ChemicalHelper.get(orePrefix, material, count));
var item = ChemicalHelper.get(orePrefix, material, count);
if (item.isEmpty()) {
GTCEu.LOGGER.error("Tried to set output item stack that doesn't exist, TagPrefix: {}, Material: {}",
orePrefix, material);
}
return outputItems(item);
}

public GTRecipeBuilder outputItems(UnificationEntry entry) {
if (entry.material == null) {
GTCEu.LOGGER.error("Unification Entry material is null, id: {}, TagPrefix: {}", id, entry.tagPrefix);
}
return outputItems(entry.tagPrefix, entry.material);
}

public GTRecipeBuilder outputItems(UnificationEntry entry, int count) {
if (entry.material == null) {
GTCEu.LOGGER.error("Unification Entry material is null, id: {}, TagPrefix: {}", id, entry.tagPrefix);
}
return outputItems(entry.tagPrefix, entry.material, count);
}

Expand All @@ -535,7 +606,12 @@ public GTRecipeBuilder outputItemsRanged(Supplier<? extends ItemLike> output, In
}

public GTRecipeBuilder outputItemsRanged(TagPrefix orePrefix, Material material, IntProvider intProvider) {
return outputItemsRanged(ChemicalHelper.get(orePrefix, material, 1), intProvider);
var item = ChemicalHelper.get(orePrefix, material, 1);
if (item.isEmpty()) {
GTCEu.LOGGER.error("Tried to set output ranged item stack that doesn't exist, TagPrefix: {}, Material: {}",
orePrefix, material);
}
return outputItemsRanged(item, intProvider);
}

public GTRecipeBuilder outputItemsRanged(MachineDefinition machine, IntProvider intProvider) {
Expand Down Expand Up @@ -604,6 +680,9 @@ public GTRecipeBuilder notConsumableFluid(SizedFluidIngredient ingredient) {
}

public GTRecipeBuilder circuitMeta(int configuration) {
if (configuration < 0 || configuration > IntCircuitBehaviour.CIRCUIT_MAX) {
GTCEu.LOGGER.error("Circuit configuration must be in the bounds 0 - 32");
}
return notConsumable(new SizedIngredient(IntCircuitIngredient.circuitInput(configuration).toVanilla(), 1));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,12 +812,6 @@ private static void redstoneRecipes(RecipeOutput provider) {
.inputItems(new ItemStack(Blocks.POLISHED_BLACKSTONE_SLAB))
.outputItems(new ItemStack(Blocks.POLISHED_BLACKSTONE_PRESSURE_PLATE, 8))
.duration(250).EUt(VA[ULV]).save(provider);

CUTTER_RECIPES.recipeBuilder("polished_blackstone_pressure_plate")
.inputItems(plate, Iron)
.outputItems(new ItemStack(Blocks.POLISHED_BLACKSTONE_PRESSURE_PLATE, 8))
.circuitMeta(10)
.duration(250).EUt(VA[ULV]).save(provider);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public static void init(RecipeOutput provider) {
.inputItems(dust, Charcoal)
.inputFluids(Nitrogen.getFluid(2000))
.outputItems(dust, ActivatedCarbon)
.chancedOutput(dust, Ash, 2000, 0)
.duration(640).EUt(64)
.save(provider);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static void init(RecipeOutput provider) {
.duration(400).EUt(VA[LV])
.save(provider);

CHEMICAL_RECIPES.recipeBuilder("iron_2_chloride")
LARGE_CHEMICAL_RECIPES.recipeBuilder("iron_2_chloride")
.inputFluids(Iron3Chloride.getFluid(2000))
.inputFluids(Chlorobenzene.getFluid(1000))
.outputFluids(Iron2Chloride.getFluid(2000))
Expand Down
Loading

0 comments on commit 24b3432

Please sign in to comment.