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

Commit

Permalink
添加机器模式显示
Browse files Browse the repository at this point in the history
  • Loading branch information
DancingSnow0517 committed Jun 5, 2024
1 parent 20f52c9 commit e172ffb
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/generated/resources/assets/monazite/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
"config.jade.plugin_monazite.auto_output_info": "ʎɐןdsıᗡ uoıʇɐɯɹoɟuI ʇndʇnO oʇnⱯ",
"config.jade.plugin_monazite.cable_info": "ʎɐןdsıᗡ uoıʇɐɯɹoɟuI ǝןqɐƆ",
"config.jade.plugin_monazite.exhaust_vent_info": "ʎɐןdsıᗡ uoıʇɐɯɹoɟuI ʇuǝΛ ʇsnɐɥxƎ",
"config.jade.plugin_monazite.machine_mode": "ʎɐןdsıᗡ ǝpoW ǝuıɥɔɐW",
"config.jade.plugin_monazite.maintenance_info": "ʎɐןdsıᗡ uoıʇɐɯɹoɟuI ǝɔuɐuǝʇuıɐW",
"config.jade.plugin_monazite.recipe_output_info": "ʎɐןdsıᗡ sʇndʇnO ǝdıɔǝᴚ",
"config.monazite.option.conciseMode": "ǝpoW ǝsıɔuoƆ",
"config.monazite.option.dimensions": "suoısuǝɯıᗡ ɯoʇsnƆ",
"config.monazite.option.displayAutoOutputInfo": "ʎɐןdsıᗡ uoıʇɐɯɹoɟuI ʇndʇnO oʇnⱯ",
"config.monazite.option.displayCableInfo": "ʎɐןdsıᗡ uoıʇɐɯɹoɟuI ǝןqɐƆ",
"config.monazite.option.displayExhaustVentInfo": "ʎɐןdsıᗡ uoıʇɐɯɹoɟuI ʇuǝΛ ʇsnɐɥxƎ",
"config.monazite.option.displayMachineMode": "ǝpoW ǝuıɥɔɐW ʎɐןdsıᗡ",
"config.monazite.option.displayMaintenanceInfo": "ʎɐןdsıᗡ uoıʇɐɯɹoɟuI ǝɔuɐuǝʇuıɐW",
"config.monazite.option.displayRecipeOutputs": "ʎɐןdsıᗡ sʇndʇnO ǝdıɔǝᴚ",
"config.monazite.option.itemsPerLine": "ǝuıꞀ ɹǝԀ sɯǝʇI",
Expand All @@ -29,6 +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.maintenance.broken": "ǝɔuɐuǝʇuıɐW spǝǝN",
"monazite.maintenance.fixed": "ǝuıℲ ǝɔuɐuǝʇuıɐW",
"monazite.recipe.output": ":ʇndʇnO ǝdıɔǝᴚ"
Expand Down
3 changes: 3 additions & 0 deletions src/generated/resources/assets/monazite/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
"config.jade.plugin_monazite.auto_output_info": "Auto Output Information Display",
"config.jade.plugin_monazite.cable_info": "Cable Information Display",
"config.jade.plugin_monazite.exhaust_vent_info": "Exhaust Vent Information Display",
"config.jade.plugin_monazite.machine_mode": "Machine Mode Display",
"config.jade.plugin_monazite.maintenance_info": "Maintenance Information Display",
"config.jade.plugin_monazite.recipe_output_info": "Recipe Outputs Display",
"config.monazite.option.conciseMode": "Concise Mode",
"config.monazite.option.dimensions": "Custom Dimensions",
"config.monazite.option.displayAutoOutputInfo": "Auto Output Information Display",
"config.monazite.option.displayCableInfo": "Cable Information Display",
"config.monazite.option.displayExhaustVentInfo": "Exhaust Vent Information Display",
"config.monazite.option.displayMachineMode": "Display Machine Mode",
"config.monazite.option.displayMaintenanceInfo": "Maintenance Information Display",
"config.monazite.option.displayRecipeOutputs": "Recipe Outputs Display",
"config.monazite.option.itemsPerLine": "Items Per Line",
Expand All @@ -29,6 +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.maintenance.broken": "Needs Maintenance",
"monazite.maintenance.fixed": "Maintenance Fine",
"monazite.recipe.output": "Recipe Output:"
Expand Down
3 changes: 3 additions & 0 deletions src/generated/resources/assets/monazite/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
"config.jade.plugin_monazite.auto_output_info": "自动输出信息显示",
"config.jade.plugin_monazite.cable_info": "线缆信息显示",
"config.jade.plugin_monazite.exhaust_vent_info": "排气口信息显示",
"config.jade.plugin_monazite.machine_mode": "机器模式显示",
"config.jade.plugin_monazite.maintenance_info": "维护信息显示",
"config.jade.plugin_monazite.recipe_output_info": "配方输出显示",
"config.monazite.option.conciseMode": "简洁模式",
"config.monazite.option.dimensions": "自定义维度",
"config.monazite.option.displayAutoOutputInfo": "自动输出信息显示",
"config.monazite.option.displayCableInfo": "线缆信息显示",
"config.monazite.option.displayExhaustVentInfo": "排气口信息显示",
"config.monazite.option.displayMachineMode": "显示机器模式",
"config.monazite.option.displayMaintenanceInfo": "维护信息显示",
"config.monazite.option.displayRecipeOutputs": "配方输出显示",
"config.monazite.option.itemsPerLine": "每行物品数",
Expand All @@ -30,6 +32,7 @@
"monazite.cable.voltage": "电压: ",
"monazite.exhaust_vent.blocked": "受阻",
"monazite.exhaust_vent.direction": "排气口方向: %s",
"monazite.machine_mode": "机器模式:%s",
"monazite.maintenance.broken": "需要维护",
"monazite.maintenance.fixed": "无需维护",
"monazite.recipe.output": "配方输出:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public static class TopInformationConfigs {
@Configurable
@Configurable.Comment({"If true, the voltage and amperage of the current cable will be displayed.", "Default: true"})
public boolean displayCableInfo = true; // default true

@Configurable
@Configurable.Comment({"If true, The current mode of the machine will be displayed.", "Default: true"})
public boolean displayMachineMode = true; // default true
}

public static class OreVeinDisplayConfigs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ 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("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");
provider.add("config.jade.plugin_monazite.auto_output_info", "Auto Output Information Display");
provider.add("config.jade.plugin_monazite.cable_info", "Cable Information Display");
provider.add("config.jade.plugin_monazite.machine_mode", "Machine Mode Display");
provider.add("key.categories.monazite", "Monazite");
provider.add("key.toggleConciseMode", "Toggle Concise Mode");
provider.add("config.screen.monazite", "Monazite");
Expand All @@ -36,6 +38,7 @@ public static void init(RegistrateLangProvider provider) {
provider.add("config.monazite.option.useNHDimensionDisplay", "Using NH-style Dimension Display");
provider.add("config.monazite.option.showDimensionTier", "Showing Dimension Tier");
provider.add("config.monazite.option.dimensions", "Custom Dimensions");
provider.add("config.monazite.option.displayMachineMode", "Display Machine Mode");
provider.add("block.monazite.dimension_display.minecraft.overworld", "Overworld");
provider.add("block.monazite.dimension_display.minecraft.the_nether", "The Nether");
provider.add("block.monazite.dimension_display.minecraft.the_end", "The End");
Expand All @@ -53,11 +56,13 @@ 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("config.jade.plugin_monazite.recipe_output_info", "配方输出显示");
provider.add("config.jade.plugin_monazite.maintenance_info", "维护信息显示");
provider.add("config.jade.plugin_monazite.exhaust_vent_info", "排气口信息显示");
provider.add("config.jade.plugin_monazite.auto_output_info", "自动输出信息显示");
provider.add("config.jade.plugin_monazite.cable_info", "线缆信息显示");
provider.add("config.jade.plugin_monazite.machine_mode", "机器模式显示");
provider.add("key.categories.monazite", "Monazite");
provider.add("key.toggleConciseMode", "开/关简洁模式");
provider.add("config.screen.monazite", "Monazite");
Expand All @@ -73,6 +78,7 @@ public static void init(RegistrateCNLangProvider provider) {
provider.add("config.monazite.option.useNHDimensionDisplay", "使用NH样式的维度显示");
provider.add("config.monazite.option.showDimensionTier", "显示维度层级");
provider.add("config.monazite.option.dimensions", "自定义维度");
provider.add("config.monazite.option.displayMachineMode", "显示机器模式");
provider.add("block.monazite.dimension_display.minecraft.overworld", "主世界");
provider.add("block.monazite.dimension_display.minecraft.the_nether", "下界");
provider.add("block.monazite.dimension_display.minecraft.the_end", "末地");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public void register(IWailaCommonRegistration registration) {
if (MonaziteConfigHolder.INSTANCE.topInformation.displayCableInfo) {
registration.registerBlockDataProvider(CableBlockProvider.INSTANCE, BlockEntity.class);
}

if (MonaziteConfigHolder.INSTANCE.topInformation.displayMachineMode) {
registration.registerBlockDataProvider(MachineModeProvider.INSTANCE, BlockEntity.class);
}
}

@Override
Expand All @@ -57,6 +61,10 @@ public void registerClient(IWailaClientRegistration registration) {
if (MonaziteConfigHolder.INSTANCE.topInformation.displayCableInfo) {
registration.registerBlockComponent(CableBlockProvider.INSTANCE, Block.class);
}

if (MonaziteConfigHolder.INSTANCE.topInformation.displayMachineMode) {
registration.registerBlockComponent(MachineModeProvider.INSTANCE, Block.class);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.epimorphismmc.monazite.integration.jade.provider;

import com.epimorphismmc.monazite.Monazite;
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.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;
import snownee.jade.api.BlockAccessor;
import snownee.jade.api.IBlockComponentProvider;
import snownee.jade.api.IServerDataProvider;
import snownee.jade.api.ITooltip;
import snownee.jade.api.config.IPluginConfig;

public enum MachineModeProvider implements IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
INSTANCE;

@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()))));
}
}

@Override
public void appendServerData(CompoundTag compoundTag, BlockAccessor blockAccessor) {
if (blockAccessor.getBlockEntity() instanceof MetaMachineBlockEntity blockEntity) {
@Nullable GTRecipeType[] recipeTypes = blockEntity.getMetaMachine().getDefinition().getRecipeTypes();
if (recipeTypes.length > 1) {
if (blockEntity.getMetaMachine() instanceof IRecipeLogicMachine recipeLogicMachine) {
compoundTag.putString("RecipeType", recipeLogicMachine.getRecipeType().registryName.toString());
}
}
}
}

@Override
public ResourceLocation getUid() {
return Monazite.id("machine_mode");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public static void registerProvider(ITheOneProbe oneProbe) {
if (MonaziteConfigHolder.INSTANCE.topInformation.displayCableInfo) {
oneProbe.registerProvider(new CableInfoProvider());
}

if (MonaziteConfigHolder.INSTANCE.topInformation.displayMachineMode) {
oneProbe.registerProvider(new MachineModeProvider());
}
}

public static void registerElements(ITheOneProbe oneProbe) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.epimorphismmc.monazite.integration.top.provider;

import com.epimorphismmc.monazite.Monazite;
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.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.IProbeInfoProvider;
import mcjty.theoneprobe.api.ProbeMode;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;

public class MachineModeProvider implements IProbeInfoProvider {
@Override
public ResourceLocation getID() {
return Monazite.id("machine_mode");
}

@Override
public void addProbeInfo(ProbeMode probeMode, IProbeInfo iProbeInfo, Player player, Level level, BlockState blockState, IProbeHitData iProbeHitData) {
if (level.getBlockEntity(iProbeHitData.getPos()) instanceof MetaMachineBlockEntity blockEntity) {
@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()))));
}
}
}
}
}

0 comments on commit e172ffb

Please sign in to comment.