From c03fc7b9c62f43f6ea74c85c75f15105c187e1f1 Mon Sep 17 00:00:00 2001 From: DancingSnow <1121149616@qq.com> Date: Wed, 5 Jun 2024 22:06:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=BA=E5=99=A8=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E6=98=BE=E7=A4=BA=E6=A0=B7=E5=BC=8F=EF=BC=8C=E6=8C=89?= =?UTF-8?q?=E4=B8=8Bshift=E6=98=BE=E7=A4=BA=E6=89=80=E6=9C=89=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/assets/monazite/lang/en_ud.json | 2 +- .../resources/assets/monazite/lang/en_us.json | 2 +- .../resources/assets/monazite/lang/zh_cn.json | 2 +- .../monazite/data/lang/MoLangHandler.java | 4 +- .../jade/provider/MachineModeProvider.java | 40 +++++++++++++++++-- .../top/provider/MachineModeProvider.java | 27 ++++++++++++- 6 files changed, 66 insertions(+), 11 deletions(-) diff --git a/src/generated/resources/assets/monazite/lang/en_ud.json b/src/generated/resources/assets/monazite/lang/en_ud.json index 684bec2..15784ef 100644 --- a/src/generated/resources/assets/monazite/lang/en_ud.json +++ b/src/generated/resources/assets/monazite/lang/en_ud.json @@ -31,7 +31,7 @@ "monazite.cable.voltage": " :ǝbɐʇןoΛ", "monazite.exhaust_vent.blocked": "pǝʞɔoןᗺ", "monazite.exhaust_vent.direction": "%s :uoıʇɔǝɹıᗡ ʇuǝΛ ʇsnɐɥxƎ", - "monazite.machine_mode": "%s :ǝpoW ǝuıɥɔɐW", + "monazite.machine_mode": " :ǝpoW ǝuıɥɔɐW", "monazite.maintenance.broken": "ǝɔuɐuǝʇuıɐW spǝǝN", "monazite.maintenance.fixed": "ǝuıℲ ǝɔuɐuǝʇuıɐW", "monazite.recipe.output": ":ʇndʇnO ǝdıɔǝᴚ" diff --git a/src/generated/resources/assets/monazite/lang/en_us.json b/src/generated/resources/assets/monazite/lang/en_us.json index 77bf678..1a2eda1 100644 --- a/src/generated/resources/assets/monazite/lang/en_us.json +++ b/src/generated/resources/assets/monazite/lang/en_us.json @@ -31,7 +31,7 @@ "monazite.cable.voltage": "Voltage: ", "monazite.exhaust_vent.blocked": "Blocked", "monazite.exhaust_vent.direction": "Exhaust Vent Direction: %s", - "monazite.machine_mode": "Machine Mode: %s", + "monazite.machine_mode": "Machine Mode: ", "monazite.maintenance.broken": "Needs Maintenance", "monazite.maintenance.fixed": "Maintenance Fine", "monazite.recipe.output": "Recipe Output:" diff --git a/src/generated/resources/assets/monazite/lang/zh_cn.json b/src/generated/resources/assets/monazite/lang/zh_cn.json index 2cefd6e..622081c 100644 --- a/src/generated/resources/assets/monazite/lang/zh_cn.json +++ b/src/generated/resources/assets/monazite/lang/zh_cn.json @@ -32,7 +32,7 @@ "monazite.cable.voltage": "电压: ", "monazite.exhaust_vent.blocked": "受阻", "monazite.exhaust_vent.direction": "排气口方向: %s", - "monazite.machine_mode": "机器模式:%s", + "monazite.machine_mode": "机器模式:", "monazite.maintenance.broken": "需要维护", "monazite.maintenance.fixed": "无需维护", "monazite.recipe.output": "配方输出:" diff --git a/src/main/java/com/epimorphismmc/monazite/data/lang/MoLangHandler.java b/src/main/java/com/epimorphismmc/monazite/data/lang/MoLangHandler.java index b9640e1..dd79213 100644 --- a/src/main/java/com/epimorphismmc/monazite/data/lang/MoLangHandler.java +++ b/src/main/java/com/epimorphismmc/monazite/data/lang/MoLangHandler.java @@ -17,7 +17,7 @@ public static void init(RegistrateLangProvider provider) { provider.add("monazite.auto_output.allow_input", "Allows Input"); provider.add("monazite.cable.voltage", "Voltage: "); provider.add("monazite.cable.amperage", "Amperage: "); - provider.add("monazite.machine_mode", "Machine Mode: %s"); + provider.add("monazite.machine_mode", "Machine Mode: "); provider.add("config.jade.plugin_monazite.recipe_output_info", "Recipe Outputs Display"); provider.add("config.jade.plugin_monazite.maintenance_info", "Maintenance Information Display"); provider.add("config.jade.plugin_monazite.exhaust_vent_info", "Exhaust Vent Information Display"); @@ -56,7 +56,7 @@ public static void init(RegistrateCNLangProvider provider) { provider.add("monazite.auto_output.allow_input", "允许输入"); provider.add("monazite.cable.voltage", "电压: "); provider.add("monazite.cable.amperage", "电流: "); - provider.add("monazite.machine_mode", "机器模式:%s"); + provider.add("monazite.machine_mode", "机器模式:"); provider.add("config.jade.plugin_monazite.recipe_output_info", "配方输出显示"); provider.add("config.jade.plugin_monazite.maintenance_info", "维护信息显示"); provider.add("config.jade.plugin_monazite.exhaust_vent_info", "排气口信息显示"); diff --git a/src/main/java/com/epimorphismmc/monazite/integration/jade/provider/MachineModeProvider.java b/src/main/java/com/epimorphismmc/monazite/integration/jade/provider/MachineModeProvider.java index f5a1fab..5b2066e 100644 --- a/src/main/java/com/epimorphismmc/monazite/integration/jade/provider/MachineModeProvider.java +++ b/src/main/java/com/epimorphismmc/monazite/integration/jade/provider/MachineModeProvider.java @@ -4,8 +4,12 @@ import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; import com.gregtechceu.gtceu.api.machine.feature.IRecipeLogicMachine; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; +import net.minecraft.ChatFormatting; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.StringTag; import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.Nullable; import snownee.jade.api.BlockAccessor; @@ -19,9 +23,27 @@ public enum MachineModeProvider implements IBlockComponentProvider, IServerDataP @Override public void appendTooltip(ITooltip iTooltip, BlockAccessor blockAccessor, IPluginConfig iPluginConfig) { - if (blockAccessor.getServerData().contains("RecipeType")) { - ResourceLocation recipeType = new ResourceLocation(blockAccessor.getServerData().getString("RecipeType")); - iTooltip.add(Component.translatable("monazite.machine_mode", Component.translatable("%s.%s".formatted(recipeType.getNamespace(), recipeType.getPath())))); + CompoundTag serverData = blockAccessor.getServerData(); + if (serverData.contains("RecipeTypes") && serverData.contains("CurrentRecipeType")) { + int currentRecipeTypeIndex = serverData.getInt("CurrentRecipeType"); + ListTag recipeTypesTagList = serverData.getList("RecipeTypes", StringTag.TAG_STRING); + if (blockAccessor.showDetails()) { + iTooltip.add(Component.translatable("monazite.machine_mode")); + for (int i = 0; i < recipeTypesTagList.size(); i++) { + ResourceLocation recipeType = new ResourceLocation(recipeTypesTagList.getString(i)); + MutableComponent text; + if (currentRecipeTypeIndex == i) { + text = Component.literal(" > ").withStyle(ChatFormatting.BLUE); + } else { + text = Component.literal(" "); + } + text.append(Component.translatable("%s.%s".formatted(recipeType.getNamespace(), recipeType.getPath()))); + iTooltip.add(text); + } + } else { + ResourceLocation recipeType = new ResourceLocation(recipeTypesTagList.getString(currentRecipeTypeIndex)); + iTooltip.add(Component.translatable("monazite.machine_mode").append(Component.translatable("%s.%s".formatted(recipeType.getNamespace(), recipeType.getPath())))); + } } } @@ -31,7 +53,17 @@ public void appendServerData(CompoundTag compoundTag, BlockAccessor blockAccesso @Nullable GTRecipeType[] recipeTypes = blockEntity.getMetaMachine().getDefinition().getRecipeTypes(); if (recipeTypes.length > 1) { if (blockEntity.getMetaMachine() instanceof IRecipeLogicMachine recipeLogicMachine) { - compoundTag.putString("RecipeType", recipeLogicMachine.getRecipeType().registryName.toString()); + ListTag recipeTypesTagList = new ListTag(); + GTRecipeType currentRecipeType = recipeLogicMachine.getRecipeType(); + int currentRecipeTypeIndex = -1; + for (int i = 0; i < recipeTypes.length; i++) { + if (recipeTypes[i] == currentRecipeType) { + currentRecipeTypeIndex = i; + } + recipeTypesTagList.add(StringTag.valueOf(recipeTypes[i].registryName.toString())); + } + compoundTag.put("RecipeTypes", recipeTypesTagList); + compoundTag.putInt("CurrentRecipeType", currentRecipeTypeIndex); } } } diff --git a/src/main/java/com/epimorphismmc/monazite/integration/top/provider/MachineModeProvider.java b/src/main/java/com/epimorphismmc/monazite/integration/top/provider/MachineModeProvider.java index aa8e308..6c7b730 100644 --- a/src/main/java/com/epimorphismmc/monazite/integration/top/provider/MachineModeProvider.java +++ b/src/main/java/com/epimorphismmc/monazite/integration/top/provider/MachineModeProvider.java @@ -4,10 +4,13 @@ import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; import com.gregtechceu.gtceu.api.machine.feature.IRecipeLogicMachine; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; +import mcjty.theoneprobe.api.CompoundText; +import mcjty.theoneprobe.api.ElementAlignment; import mcjty.theoneprobe.api.IProbeHitData; import mcjty.theoneprobe.api.IProbeInfo; import mcjty.theoneprobe.api.IProbeInfoProvider; import mcjty.theoneprobe.api.ProbeMode; +import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Player; @@ -27,8 +30,28 @@ public void addProbeInfo(ProbeMode probeMode, IProbeInfo iProbeInfo, Player play @Nullable GTRecipeType[] recipeTypes = blockEntity.getMetaMachine().getDefinition().getRecipeTypes(); if (recipeTypes.length > 1) { if (blockEntity.getMetaMachine() instanceof IRecipeLogicMachine recipeLogicMachine) { - ResourceLocation recipeType = recipeLogicMachine.getRecipeType().registryName; - iProbeInfo.text(Component.translatable("monazite.machine_mode", Component.translatable("%s.%s".formatted(recipeType.getNamespace(), recipeType.getPath())))); + GTRecipeType currentRecipeType = recipeLogicMachine.getRecipeType(); + if (player.isShiftKeyDown()) { + iProbeInfo.text(Component.translatable("monazite.machine_mode")); + for (GTRecipeType recipeType : recipeTypes) { + IProbeInfo horizontalPane = iProbeInfo.horizontal(iProbeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)); + if (recipeType == currentRecipeType) { + horizontalPane.text(ChatFormatting.BLUE + " > "); + horizontalPane.text(CompoundText.create().important("%s.%s".formatted(recipeType.registryName.getNamespace(), recipeType.registryName.getPath()))); + } else { + horizontalPane.text(" "); + horizontalPane.text(CompoundText.create().label("%s.%s".formatted(recipeType.registryName.getNamespace(), recipeType.registryName.getPath()))); + } + } + } else { + iProbeInfo.text( + Component.translatable("monazite.machine_mode") + .append(Component.translatable("%s.%s".formatted( + currentRecipeType.registryName.getNamespace(), + currentRecipeType.registryName.getPath() + ))) + ); + } } } }