Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from EpimorphicPioneers/machine-mode
Browse files Browse the repository at this point in the history
修改机器模式显示样式,按下shift显示所有模式
  • Loading branch information
qwer523 authored Jun 5, 2024
2 parents 0263187 + c03fc7b commit 8fc7ac7
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/generated/resources/assets/monazite/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -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ıɔǝᴚ"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/resources/assets/monazite/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/resources/assets/monazite/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "配方输出:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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", "排气口信息显示");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()))));
}
}
}

Expand All @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
)))
);
}
}
}
}
Expand Down

0 comments on commit 8fc7ac7

Please sign in to comment.