Skip to content

Commit

Permalink
v1.4.8
Browse files Browse the repository at this point in the history
Manual merge of:
 * GTNewHorizons#18
 * Add recipe debugger for recipes with small variant of items

Co-Authored-By: miozune <[email protected]>
  • Loading branch information
D-Cysteine and miozune committed Jan 26, 2023
1 parent b4980d8 commit cd5dd38
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
neiCustomDiagramVersion=1.4.7
neiCustomDiagramVersion=1.4.8

minecraftVersion=1.7.10
forgeVersion=10.13.4.1614
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,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,8 @@
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_Utility;
import net.minecraft.init.Items;

Expand Down Expand Up @@ -55,7 +57,13 @@ public enum View {
UNEQUAL_CELL_RECIPES(
"-unequal-cell-recipes",
GregTechOreDictUtil.getComponent(ItemList.Cell_Empty),
"unequalcellrecipesbutton");
"unequalcellrecipesbutton"),

SMALL_VARIANT_RECIPES(
"-small-variant-recipes",
GregTechOreDictUtil.getComponent(OrePrefixes.dustTiny, Materials.Salt).get(),
"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 @@ -29,6 +29,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,7 @@
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.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe;
Expand All @@ -22,10 +23,12 @@
import net.minecraftforge.fluids.FluidStack;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
Expand All @@ -45,6 +48,25 @@ class RecipeHandler {
.add(GregTechOreDictUtil.getComponent(ItemList.Schematic_Dust))
.build();

static final ImmutableSet<OrePrefixes> SMALL_VARIANT_ORE_PREFIXES =
ImmutableSet.of(OrePrefixes.dustTiny, OrePrefixes.dustSmall, OrePrefixes.nugget);
static final ImmutableSet<OrePrefixes> CABLE_ORE_PREFIXES = ImmutableSet.of(
OrePrefixes.cableGt01,
OrePrefixes.cableGt02,
OrePrefixes.cableGt04,
OrePrefixes.cableGt08,
OrePrefixes.cableGt12,
OrePrefixes.cableGt16);
static final ImmutableSet<RecipeMap> RECIPE_MAPS_TO_IGNORE_FOR_SMALL_VARIANT = ImmutableSet.of(
// These recipemaps are meant to have tiny / small dusts or nuggets.
RecipeMap.PACKAGER,
RecipeMap.UNPACKAGER,
RecipeMap.MACERATOR,
RecipeMap.LATHE,
RecipeMap.FLUID_EXTRACTOR,
RecipeMap.IMPLOSION_COMPRESSOR,
RecipeMap.ALLOY_SMELTER);

enum RecipeMap {
ORE_WASHING_PLANT(
GT_Recipe.GT_Recipe_Map.sOreWasherRecipes,
Expand Down Expand Up @@ -274,6 +296,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 @@ -282,6 +305,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 @@ -330,6 +354,10 @@ void initialize() {
if (unequalCellRecipe(recipe)) {
unequalCellRecipes.add(recipe);
}

if (smallVariantRecipe(recipe)) {
smallVariantRecipes.add(recipe);
}
}
}
}
Expand Down Expand Up @@ -467,4 +495,28 @@ private static boolean unequalCellRecipe(Recipe recipe) {

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

private static boolean smallVariantRecipe(Recipe recipe) {
if (RECIPE_MAPS_TO_IGNORE_FOR_SMALL_VARIANT.contains(recipe.recipeMap())) {
return false;
}

Set<OrePrefixes> orePrefixes = getOrePrefixes(recipe.outputs().keySet());
if (recipe.recipeMap() == RecipeMap.ASSEMBLING_MACHINE
&& Sets.intersection(orePrefixes, CABLE_ORE_PREFIXES).size() > 0) {
// Allow using small dusts for cable insulation.
return false;
} else {
orePrefixes.addAll(getOrePrefixes(recipe.inputs().keySet()));
return Sets.intersection(orePrefixes, SMALL_VARIANT_ORE_PREFIXES).size() > 0;
}
}

private static Set<OrePrefixes> getOrePrefixes(Set<Component> componentSet) {
return componentSet.stream()
.map(GregTechOreDictUtil::getItemData)
.filter(Optional::isPresent)
.map(itemData -> itemData.get().mPrefix)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(OrePrefixes.class)));
}
}
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
1 change: 1 addition & 0 deletions src/main/resources/assets/neicustomdiagram/lang/zh_CN.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=输入冲突的合成表
neicustomdiagram.generators.gregtech5.recipedebugger.voidingrecipesbutton=销毁输入的合成表
neicustomdiagram.generators.gregtech5.recipedebugger.unequalcellrecipesbutton=输出不等单元的合成表
neicustomdiagram.generators.gregtech5.recipedebugger.smallvariantrecipesbutton=Recipes with tiny / small dusts or nuggets
neicustomdiagram.generators.gregtech5.recipedebugger.orewashingplantlabel=洗矿机合成表
neicustomdiagram.generators.gregtech5.recipedebugger.thermalcentrifugelabel=热力离心机合成表
neicustomdiagram.generators.gregtech5.recipedebugger.compressorlabel=压缩机合成表
Expand Down

0 comments on commit cd5dd38

Please sign in to comment.