样板上传时合成配方固定记录配方为crafting

This commit is contained in:
GaLi 2026-03-28 15:31:11 +08:00
parent c77e354abd
commit af35ee9d97
4 changed files with 50 additions and 16 deletions

View File

@ -282,6 +282,7 @@ public class CtrlQPatternKeyHandler {
// 10. 获取输出材料 // 10. 获取输出材料
List<ItemStack> selectedOutputs = convertOutputsToItemStacks(matchingRecipeInfo); List<ItemStack> selectedOutputs = convertOutputsToItemStacks(matchingRecipeInfo);
RecipeTypeNameConfig.presetCraftingProviderSearchKey();
// 11. 发送网络包创建样板并上传到装配矩阵 // 11. 发送网络包创建样板并上传到装配矩阵
ModNetwork.CHANNEL.sendToServer(new CreateAndUploadPatternC2SPacket( ModNetwork.CHANNEL.sendToServer(new CreateAndUploadPatternC2SPacket(

View File

@ -78,7 +78,7 @@ public class ProviderSelectScreen extends Screen {
// 缓存 Component JSON 解析 // 缓存 Component JSON 解析
private static final Map<String, String> componentCache = new HashMap<>(); private static final Map<String, String> componentCache = new HashMap<>();
private String lastLanguage = ""; // 当前语言版本 private String lastLanguage = ""; // 当前语言版本
private boolean autoUploadRequestedFromProcessingName = false; private boolean autoUploadRequestedFromPresetSearch = false;
private boolean autoUploadAttempted = false; private boolean autoUploadAttempted = false;
private int lastExactMatchCount = 0; private int lastExactMatchCount = 0;
private boolean lastFilterUsedFallback = false; private boolean lastFilterUsedFallback = false;
@ -89,14 +89,12 @@ public class ProviderSelectScreen extends Screen {
this.ids = ids; this.ids = ids;
this.names = names; this.names = names;
this.emptySlots = emptySlots; this.emptySlots = emptySlots;
// 如果有来自 JEI 的最近处理名称则作为初始查询 // 如果有来自最近一次写样板流程的预设搜索词则作为初始查询
try { try {
String recent = RecipeTypeNameConfig.lastProcessingName; String recent = RecipeTypeNameConfig.consumeLastProviderSearchKey();
if (recent != null && !recent.isBlank()) { if (recent != null && !recent.isBlank()) {
this.query = recent; this.query = recent;
this.autoUploadRequestedFromProcessingName = true; this.autoUploadRequestedFromPresetSearch = true;
// 用后即清空避免污染下次
RecipeTypeNameConfig.lastProcessingName = null;
} }
} catch (Throwable ignored) {} } catch (Throwable ignored) {}
buildGroups(); buildGroups();
@ -401,7 +399,7 @@ public class ProviderSelectScreen extends Screen {
} }
private void tryAutoUploadIfUniqueMatch() { private void tryAutoUploadIfUniqueMatch() {
if (!autoUploadRequestedFromProcessingName || autoUploadAttempted) { if (!autoUploadRequestedFromPresetSearch || autoUploadAttempted) {
return; return;
} }
autoUploadAttempted = true; autoUploadAttempted = true;

View File

@ -30,8 +30,10 @@ public abstract class EncodePatternTransferHandlerMixin {
if (!doTransfer) return; if (!doTransfer) return;
String name = null; String name = null;
if (recipeBase instanceof Recipe<?> recipe) { if (recipeBase instanceof Recipe<?> recipe) {
// 仅记录处理配方 3x3 合成 if (EncodingHelper.isSupportedCraftingRecipe(recipe)) {
if (EncodingHelper.isSupportedCraftingRecipe(recipe)) return; RecipeTypeNameConfig.presetCraftingProviderSearchKey();
return;
}
name = RecipeTypeNameConfig.mapRecipeTypeToSearchKey(recipe); name = RecipeTypeNameConfig.mapRecipeTypeToSearchKey(recipe);
} else if (recipeBase != null && } else if (recipeBase != null &&
"com.gregtechceu.gtceu.api.recipe.GTRecipe".equals(recipeBase.getClass().getName())) { "com.gregtechceu.gtceu.api.recipe.GTRecipe".equals(recipeBase.getClass().getName())) {

View File

@ -42,10 +42,32 @@ public final class RecipeTypeNameConfig {
private RecipeTypeNameConfig() {} private RecipeTypeNameConfig() {}
// 最近一次通过 JEI 填充到编码终端的处理配方的中文名称烧炼/高炉/烟熏... // 最近一次打开供应器选择界面时的预设搜索关键字
public static volatile String lastProcessingName = null; // 处理样板会写入映射后的配方类型关键字合成样板固定使用 crafting可通过映射改名
public static final String DEFAULT_CRAFTING_SEARCH_KEY = "crafting";
private static volatile String lastProviderSearchKey = null;
public static void setLastProcessingName(String name) { public static void setLastProcessingName(String name) {
lastProcessingName = name; setLastProviderSearchKey(name);
}
public static void setLastProviderSearchKey(String name) {
if (name == null) {
lastProviderSearchKey = null;
return;
}
String trimmed = name.trim();
lastProviderSearchKey = trimmed.isEmpty() ? null : trimmed;
}
public static void presetCraftingProviderSearchKey() {
setLastProviderSearchKey(resolveSearchKeyAlias(DEFAULT_CRAFTING_SEARCH_KEY));
}
public static String consumeLastProviderSearchKey() {
String searchKey = lastProviderSearchKey;
lastProviderSearchKey = null;
return searchKey;
} }
/** /**
@ -240,14 +262,25 @@ public final class RecipeTypeNameConfig {
* @param recipe 配方对象 * @param recipe 配方对象
* @return 搜索关键字自定义名称别名或类型路径 null 如果无效 * @return 搜索关键字自定义名称别名或类型路径 null 如果无效
*/ */
public static String resolveSearchKeyAlias(String rawKey) {
if (rawKey == null) return null;
String normalized = rawKey.trim();
if (normalized.isEmpty()) return null;
String alias = CUSTOM_ALIASES.get(normalized.toLowerCase());
return alias != null && !alias.isBlank() ? alias : normalized;
}
public static String mapRecipeTypeToSearchKey(Recipe<?> recipe) { public static String mapRecipeTypeToSearchKey(Recipe<?> recipe) {
if (recipe == null) return null; if (recipe == null) return null;
RecipeType<?> type = recipe.getType(); RecipeType<?> type = recipe.getType();
ResourceLocation key = BuiltInRegistries.RECIPE_TYPE.getKey(type); ResourceLocation key = BuiltInRegistries.RECIPE_TYPE.getKey(type);
if (key == null) return null; if (key == null) return null;
String path = key.getPath().toLowerCase(); String resolvedPath = resolveSearchKeyAlias(key.getPath());
// 优先查别名再查完整 ID最后用路径 if (resolvedPath != null) {
return CUSTOM_ALIASES.getOrDefault(path, CUSTOM_NAMES.getOrDefault(key, path)); return resolvedPath;
}
String custom = CUSTOM_NAMES.get(key);
return custom != null && !custom.isBlank() ? custom : key.getPath();
} }
/** /**
@ -269,7 +302,7 @@ public final class RecipeTypeNameConfig {
// 1) 别名优先使用 path 作为最终搜索关键字 // 1) 别名优先使用 path 作为最终搜索关键字
String path = rl.getPath(); String path = rl.getPath();
if (path != null) { if (path != null) {
String alias = CUSTOM_ALIASES.get(path.toLowerCase()); String alias = resolveSearchKeyAlias(path);
if (alias != null && !alias.isBlank()) return alias; if (alias != null && !alias.isBlank()) return alias;
} }
// 2) 再查完整ID映射 // 2) 再查完整ID映射