Skip to content

Commit

Permalink
Add recipe debugger for recipes with small variant of items
Browse files Browse the repository at this point in the history
  • Loading branch information
miozune committed Jan 25, 2023
1 parent d460ab1 commit a58923c
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ void initialize() {
diagramListMultimap.putAll(
GregTechRecipeDebugger.View.UNEQUAL_CELL_RECIPES,
buildRecipeDiagrams(recipeHandler.unequalCellRecipes));
diagramListMultimap.putAll(
GregTechRecipeDebugger.View.SMALL_VARIANT_RECIPES,
buildRecipeDiagrams(recipeHandler.smallVariantRecipes));

// This must be last, as it reads counts from diagramListMultimap.
menuDiagram = buildMenuDiagram();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -45,7 +48,12 @@ public enum View {
UNEQUAL_CELL_RECIPES(
"-unequal-cell-recipes",
GregTechOreDictUtil.getComponent(ItemList.Cell_Empty),
"unequalcellrecipesbutton");
"unequalcellrecipesbutton"),

SMALL_VARIANT_RECIPES(
"-small-variant-recipes",
ItemComponent.create(GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Salt, 1)),
"smallvariantrecipesbutton");

/** The suffix to append to the group ID, to get the custom behavior ID for this view. */
public final String suffix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class LayoutFactory {
.put(GregTechRecipeDebugger.View.COLLIDING_RECIPES, Grid.GRID.grid(6, 2))
.put(GregTechRecipeDebugger.View.VOIDING_RECIPES, Grid.GRID.grid(8, 2))
.put(GregTechRecipeDebugger.View.UNEQUAL_CELL_RECIPES, Grid.GRID.grid(10, 2))
.put(GregTechRecipeDebugger.View.SMALL_VARIANT_RECIPES, Grid.GRID.grid(12, 2))
.build();

static final class SlotGroupKeys {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.objects.ItemData;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe;
Expand Down Expand Up @@ -220,6 +222,7 @@ static Recipe create(RecipeMap recipeMap, GT_Recipe recipe) {
final Set<Recipe> collidingRecipes;
final List<Recipe> voidingRecipes;
final List<Recipe> unequalCellRecipes;
final List<Recipe> smallVariantRecipes;

RecipeHandler() {
this.allRecipes = new HashMap<>();
Expand All @@ -228,6 +231,7 @@ static Recipe create(RecipeMap recipeMap, GT_Recipe recipe) {
this.collidingRecipes = new LinkedHashSet<>();
this.voidingRecipes = new ArrayList<>();
this.unequalCellRecipes = new ArrayList<>();
this.smallVariantRecipes = new ArrayList<>();
}

/** This method must be called before any other methods are called. */
Expand Down Expand Up @@ -276,6 +280,10 @@ void initialize() {
if (unequalCellRecipe(recipe)) {
unequalCellRecipes.add(recipe);
}

if (SmallVariantRecipe(recipe)) {
smallVariantRecipes.add(recipe);
}
}
}
}
Expand Down Expand Up @@ -411,4 +419,53 @@ private static boolean unequalCellRecipe(Recipe recipe) {

return countCells(recipe.inputs()) != countCells(recipe.outputs());
}

private static boolean SmallVariantRecipe(Recipe recipe) {
if (recipe.recipeMap() == RecipeMap.PACKAGER
|| recipe.recipeMap() == RecipeMap.UNPACKAGER
|| recipe.recipeMap() == RecipeMap.MACERATOR
|| recipe.recipeMap() == RecipeMap.LATHE
|| recipe.recipeMap() == RecipeMap.FLUID_EXTRACTOR
|| recipe.recipeMap() == RecipeMap.IMPLOSION_COMPRESSOR
|| recipe.recipeMap() == RecipeMap.ALLOY_SMELTER) {
// These recipemaps are meant to have tiny / small dusts or nuggets.
return false;
}
if (recipe.recipeMap() == RecipeMap.ASSEMBLING_MACHINE) {
List<Component> components = new ArrayList<>(recipe.outputs().keySet());
if (components.size() > 0) {
Component component = components.get(0);
if (component.type() == Component.ComponentType.ITEM) {
ItemStack itemStack = ((ItemComponent) component).stack();
ItemData itemData = GT_OreDictUnificator.getAssociation(itemStack);
if (itemData != null
&& (itemData.mPrefix == OrePrefixes.cableGt01
|| itemData.mPrefix == OrePrefixes.cableGt02
|| itemData.mPrefix == OrePrefixes.cableGt04
|| itemData.mPrefix == OrePrefixes.cableGt08
|| itemData.mPrefix == OrePrefixes.cableGt12
|| itemData.mPrefix == OrePrefixes.cableGt16)) {
// Allow using small dusts for cable insulation.
return false;
}
}
}
}
return hasSmallVariant(recipe.inputs()) || hasSmallVariant(recipe.outputs());
}

private static boolean hasSmallVariant(Map<Component, Integer> componentMap) {
for (Component component : componentMap.keySet()) {
if (component.type() != Component.ComponentType.ITEM) continue;
ItemStack itemStack = ((ItemComponent) component).stack();
ItemData itemData = GT_OreDictUnificator.getAssociation(itemStack);
if (itemData == null) continue;
if (itemData.mPrefix == OrePrefixes.dustTiny
|| itemData.mPrefix == OrePrefixes.dustSmall
|| itemData.mPrefix == OrePrefixes.nugget) {
return true;
}
}
return false;
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/neicustomdiagram/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ neicustomdiagram.generators.gregtech5.recipedebugger.unnecessarycircuitrecipesbu
neicustomdiagram.generators.gregtech5.recipedebugger.collidingrecipesbutton=Recipes with colliding inputs
neicustomdiagram.generators.gregtech5.recipedebugger.voidingrecipesbutton=Recipes which void inputs
neicustomdiagram.generators.gregtech5.recipedebugger.unequalcellrecipesbutton=Recipes which output unequal cells
neicustomdiagram.generators.gregtech5.recipedebugger.smallvariantrecipesbutton=Recipes with tiny / small dusts or nuggets
neicustomdiagram.generators.gregtech5.recipedebugger.orewashingplantlabel=Ore Washing Plant recipe
neicustomdiagram.generators.gregtech5.recipedebugger.thermalcentrifugelabel=Thermal Centrifuge recipe
neicustomdiagram.generators.gregtech5.recipedebugger.compressorlabel=Compressor recipe
Expand Down

0 comments on commit a58923c

Please sign in to comment.