支持写完样板上传时自动填写处理方法名称
This commit is contained in:
parent
1d293d928a
commit
fba701131c
|
|
@ -52,6 +52,15 @@ 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 {
|
||||||
|
String recent = com.extendedae_plus.util.ExtendedAEPatternUploadUtil.lastProcessingName;
|
||||||
|
if (recent != null && !recent.isBlank()) {
|
||||||
|
this.query = recent;
|
||||||
|
// 用后即清空,避免污染下次
|
||||||
|
com.extendedae_plus.util.ExtendedAEPatternUploadUtil.lastProcessingName = null;
|
||||||
|
}
|
||||||
|
} catch (Throwable ignored) {}
|
||||||
buildGroups();
|
buildGroups();
|
||||||
applyFilter();
|
applyFilter();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.extendedae_plus.mixin.jei;
|
||||||
|
|
||||||
|
import appeng.integration.modules.jei.transfer.EncodePatternTransferHandler;
|
||||||
|
import appeng.integration.modules.jeirei.EncodingHelper;
|
||||||
|
import appeng.menu.me.items.PatternEncodingTermMenu;
|
||||||
|
import com.extendedae_plus.util.ExtendedAEPatternUploadUtil;
|
||||||
|
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
|
||||||
|
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.crafting.Recipe;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 捕获通过 JEI 点击 + 填充到样板编码终端的处理配方,并记录其工艺名称(如“烧炼”)。
|
||||||
|
*/
|
||||||
|
@Mixin(value = EncodePatternTransferHandler.class, remap = false)
|
||||||
|
public abstract class EncodePatternTransferHandlerMixin {
|
||||||
|
|
||||||
|
@Inject(method = "transferRecipe", at = @At("HEAD"), require = 0)
|
||||||
|
private void extendedae_plus$captureProcessingName(PatternEncodingTermMenu menu,
|
||||||
|
Object recipeBase,
|
||||||
|
IRecipeSlotsView slotsView,
|
||||||
|
Player player,
|
||||||
|
boolean maxTransfer,
|
||||||
|
boolean doTransfer,
|
||||||
|
CallbackInfoReturnable<IRecipeTransferError> cir) {
|
||||||
|
if (!doTransfer) return;
|
||||||
|
if (!(recipeBase instanceof Recipe<?> recipe)) return;
|
||||||
|
// 仅记录处理配方(非 3x3 合成)
|
||||||
|
if (EncodingHelper.isSupportedCraftingRecipe(recipe)) return;
|
||||||
|
String name = ExtendedAEPatternUploadUtil.mapRecipeTypeToCn(recipe);
|
||||||
|
if (name != null && !name.isBlank()) {
|
||||||
|
ExtendedAEPatternUploadUtil.setLastProcessingName(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -26,12 +26,47 @@ import com.glodblock.github.extendedae.common.tileentities.matrix.TileAssemblerM
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.item.crafting.Recipe;
|
||||||
|
import net.minecraft.world.item.crafting.RecipeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ExtendedAE扩展样板管理终端专用的样板上传工具类
|
* ExtendedAE扩展样板管理终端专用的样板上传工具类
|
||||||
* 兼容ExtendedAE的ContainerExPatternTerminal和原版AE2的PatternAccessTermMenu
|
* 兼容ExtendedAE的ContainerExPatternTerminal和原版AE2的PatternAccessTermMenu
|
||||||
*/
|
*/
|
||||||
public class ExtendedAEPatternUploadUtil {
|
public class ExtendedAEPatternUploadUtil {
|
||||||
|
|
||||||
|
// 最近一次通过 JEI 填充到编码终端的“处理配方”的中文名称(如:烧炼/高炉/烟熏...)
|
||||||
|
public static volatile String lastProcessingName = null;
|
||||||
|
|
||||||
|
public static void setLastProcessingName(String name) {
|
||||||
|
lastProcessingName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String mapRecipeTypeToCn(Recipe<?> recipe) {
|
||||||
|
if (recipe == null) return null;
|
||||||
|
RecipeType<?> type = recipe.getType();
|
||||||
|
ResourceLocation key = BuiltInRegistries.RECIPE_TYPE.getKey(type);
|
||||||
|
if (key == null) return null;
|
||||||
|
String id = key.toString();
|
||||||
|
String path = key.getPath();
|
||||||
|
// 常见原版类型映射
|
||||||
|
switch (path) {
|
||||||
|
case "smelting":
|
||||||
|
return "烧炼"; // 熔炉
|
||||||
|
case "blasting":
|
||||||
|
return "高炉";
|
||||||
|
case "smoking":
|
||||||
|
return "烟熏";
|
||||||
|
case "campfire_cooking":
|
||||||
|
return "营火烹饪";
|
||||||
|
default:
|
||||||
|
// 其他模组类型,返回路径名,必要时可再做表扩展
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取玩家当前的样板访问终端菜单(支持ExtendedAE和原版AE2)
|
* 获取玩家当前的样板访问终端菜单(支持ExtendedAE和原版AE2)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@
|
||||||
"GuiExPatternTerminalMixin",
|
"GuiExPatternTerminalMixin",
|
||||||
"HighlightButtonMixin",
|
"HighlightButtonMixin",
|
||||||
"PickFromWirelessMixin",
|
"PickFromWirelessMixin",
|
||||||
"PatternEncodingTermScreenMixin"
|
"PatternEncodingTermScreenMixin",
|
||||||
|
"jei.EncodePatternTransferHandlerMixin"
|
||||||
],
|
],
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"ContainerExPatternProviderMixin",
|
"ContainerExPatternProviderMixin",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user