From c6a616ba844181e63e5ab10961d80a927e67b15d Mon Sep 17 00:00:00 2001 From: DancingSnow <1121149616@qq.com> Date: Wed, 5 Jun 2024 23:58:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=B2=E6=9F=93=E8=89=B2?= =?UTF-8?q?=E6=96=B9=E5=9D=97=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/assets/monazite/lang/en_ud.json | 6 ++- .../resources/assets/monazite/lang/en_us.json | 6 ++- .../resources/assets/monazite/lang/zh_cn.json | 8 ++- .../monazite/config/MonaziteConfigHolder.java | 4 ++ .../monazite/data/lang/MoLangHandler.java | 10 +++- .../integration/jade/MonaziteJadePlugin.java | 8 +++ .../jade/provider/StainedColorProvider.java | 50 +++++++++++++++++++ .../integration/top/MonaziteTOPPlugin.java | 4 ++ .../top/provider/StainedColorProvider.java | 40 +++++++++++++++ 9 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/epimorphismmc/monazite/integration/jade/provider/StainedColorProvider.java create mode 100644 src/main/java/com/epimorphismmc/monazite/integration/top/provider/StainedColorProvider.java diff --git a/src/generated/resources/assets/monazite/lang/en_ud.json b/src/generated/resources/assets/monazite/lang/en_ud.json index 307465a..f9f7b21 100644 --- a/src/generated/resources/assets/monazite/lang/en_ud.json +++ b/src/generated/resources/assets/monazite/lang/en_ud.json @@ -9,6 +9,7 @@ "config.jade.plugin_monazite.maintenance_info": "ʎɐןdsıᗡ uoıʇɐɯɹoɟuI ǝɔuɐuǝʇuıɐW", "config.jade.plugin_monazite.multiblock_structure": "ʎɐןdsıᗡ ǝɹnʇɔnɹʇS ʞɔoןqıʇןnW", "config.jade.plugin_monazite.recipe_output_info": "ʎɐןdsıᗡ sʇndʇnO ǝdıɔǝᴚ", + "config.jade.plugin_monazite.stained_color": "ʎɐןdsıᗡ ɹoןoƆ pǝuıɐʇS", "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Ɐ", @@ -16,7 +17,9 @@ "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.displayMulitblockStructure": "ǝɹnʇɔnɹʇS ʞɔoןqʇıןnW ʎɐןdsıᗡ", "config.monazite.option.displayRecipeOutputs": "ʎɐןdsıᗡ sʇndʇnO ǝdıɔǝᴚ", + "config.monazite.option.displayStainedColor": "ɹoןoƆ pǝuıɐʇS ʎɐןdsıᗡ", "config.monazite.option.itemsPerLine": "ǝuıꞀ ɹǝԀ sɯǝʇI", "config.monazite.option.showDimensionTier": "ɹǝı⟘ uoısuǝɯıᗡ buıʍoɥS", "config.monazite.option.topInformation": "uoıʇɐɯɹoɟuI do⟘", @@ -35,5 +38,6 @@ "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ıɔǝᴚ" + "monazite.recipe.output": ":ʇndʇnO ǝdıɔǝᴚ", + "monazite.stained": "%s :pǝuıɐʇS" } \ No newline at end of file diff --git a/src/generated/resources/assets/monazite/lang/en_us.json b/src/generated/resources/assets/monazite/lang/en_us.json index 1d7f5dc..df99f09 100644 --- a/src/generated/resources/assets/monazite/lang/en_us.json +++ b/src/generated/resources/assets/monazite/lang/en_us.json @@ -9,6 +9,7 @@ "config.jade.plugin_monazite.maintenance_info": "Maintenance Information Display", "config.jade.plugin_monazite.multiblock_structure": "Multiblock Structure Display", "config.jade.plugin_monazite.recipe_output_info": "Recipe Outputs Display", + "config.jade.plugin_monazite.stained_color": "Stained Color Display", "config.monazite.option.conciseMode": "Concise Mode", "config.monazite.option.dimensions": "Custom Dimensions", "config.monazite.option.displayAutoOutputInfo": "Auto Output Information Display", @@ -16,7 +17,9 @@ "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.displayMulitblockStructure": "Display Mulitblock Structure", "config.monazite.option.displayRecipeOutputs": "Recipe Outputs Display", + "config.monazite.option.displayStainedColor": "Display Stained Color", "config.monazite.option.itemsPerLine": "Items Per Line", "config.monazite.option.showDimensionTier": "Showing Dimension Tier", "config.monazite.option.topInformation": "Top Information", @@ -35,5 +38,6 @@ "monazite.machine_mode": "Machine Mode: ", "monazite.maintenance.broken": "Needs Maintenance", "monazite.maintenance.fixed": "Maintenance Fine", - "monazite.recipe.output": "Recipe Output:" + "monazite.recipe.output": "Recipe Output:", + "monazite.stained": "Stained: %s" } \ No newline at end of file diff --git a/src/generated/resources/assets/monazite/lang/zh_cn.json b/src/generated/resources/assets/monazite/lang/zh_cn.json index 03cce38..9d8523a 100644 --- a/src/generated/resources/assets/monazite/lang/zh_cn.json +++ b/src/generated/resources/assets/monazite/lang/zh_cn.json @@ -9,6 +9,7 @@ "config.jade.plugin_monazite.maintenance_info": "维护信息显示", "config.jade.plugin_monazite.multiblock_structure": "多方块结构显示", "config.jade.plugin_monazite.recipe_output_info": "配方输出显示", + "config.jade.plugin_monazite.stained_color": "染色方块显示", "config.monazite.option.conciseMode": "简洁模式", "config.monazite.option.dimensions": "自定义维度", "config.monazite.option.displayAutoOutputInfo": "自动输出信息显示", @@ -16,7 +17,9 @@ "config.monazite.option.displayExhaustVentInfo": "排气口信息显示", "config.monazite.option.displayMachineMode": "显示机器模式", "config.monazite.option.displayMaintenanceInfo": "维护信息显示", + "config.monazite.option.displayMulitblockStructure": "显示多方块结构", "config.monazite.option.displayRecipeOutputs": "配方输出显示", + "config.monazite.option.displayStainedColor": "显示已染色方块", "config.monazite.option.itemsPerLine": "每行物品数", "config.monazite.option.oreVeinDisplay": "矿脉显示", "config.monazite.option.showDimensionTier": "显示维度层级", @@ -33,8 +36,9 @@ "monazite.cable.voltage": "电压: ", "monazite.exhaust_vent.blocked": "受阻", "monazite.exhaust_vent.direction": "排气口方向: %s", - "monazite.machine_mode": "机器模式:", + "monazite.machine_mode": "机器模式: ", "monazite.maintenance.broken": "需要维护", "monazite.maintenance.fixed": "无需维护", - "monazite.recipe.output": "配方输出:" + "monazite.recipe.output": "配方输出:", + "monazite.stained": "已染色: %s" } \ No newline at end of file diff --git a/src/main/java/com/epimorphismmc/monazite/config/MonaziteConfigHolder.java b/src/main/java/com/epimorphismmc/monazite/config/MonaziteConfigHolder.java index 80eaff2..59422ae 100644 --- a/src/main/java/com/epimorphismmc/monazite/config/MonaziteConfigHolder.java +++ b/src/main/java/com/epimorphismmc/monazite/config/MonaziteConfigHolder.java @@ -59,6 +59,10 @@ public static class TopInformationConfigs { @Configurable @Configurable.Comment({"If true, Display whether it is currently formed or not.", "Default: true"}) public boolean displayMulitblockStructure = true; + + @Configurable + @Configurable.Comment({"If true, Display stained color in pipe or other stain block", "Default: true"}) + public boolean displayStainedColor = true; } public static class OreVeinDisplayConfigs { 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 e109ee5..3da30cf 100644 --- a/src/main/java/com/epimorphismmc/monazite/data/lang/MoLangHandler.java +++ b/src/main/java/com/epimorphismmc/monazite/data/lang/MoLangHandler.java @@ -18,6 +18,7 @@ public static void init(RegistrateLangProvider provider) { provider.add("monazite.cable.voltage", "Voltage: "); provider.add("monazite.cable.amperage", "Amperage: "); provider.add("monazite.machine_mode", "Machine Mode: "); + provider.add("monazite.stained", "Stained: %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"); @@ -25,6 +26,7 @@ public static void init(RegistrateLangProvider provider) { provider.add("config.jade.plugin_monazite.cable_info", "Cable Information Display"); provider.add("config.jade.plugin_monazite.machine_mode", "Machine Mode Display"); provider.add("config.jade.plugin_monazite.multiblock_structure", "Multiblock Structure Display"); + provider.add("config.jade.plugin_monazite.stained_color", "Stained Color Display"); provider.add("key.categories.monazite", "Monazite"); provider.add("key.toggleConciseMode", "Toggle Concise Mode"); provider.add("config.screen.monazite", "Monazite"); @@ -40,6 +42,8 @@ public static void init(RegistrateLangProvider provider) { 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("config.monazite.option.displayMulitblockStructure", "Display Mulitblock Structure"); + provider.add("config.monazite.option.displayStainedColor", "Display Stained Color"); 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"); @@ -57,7 +61,8 @@ 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", "机器模式:"); + provider.add("monazite.machine_mode", "机器模式: "); + provider.add("monazite.stained", "已染色: %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", "排气口信息显示"); @@ -65,6 +70,7 @@ public static void init(RegistrateCNLangProvider provider) { provider.add("config.jade.plugin_monazite.cable_info", "线缆信息显示"); provider.add("config.jade.plugin_monazite.machine_mode", "机器模式显示"); provider.add("config.jade.plugin_monazite.multiblock_structure", "多方块结构显示"); + provider.add("config.jade.plugin_monazite.stained_color", "染色方块显示"); provider.add("key.categories.monazite", "Monazite"); provider.add("key.toggleConciseMode", "开/关简洁模式"); provider.add("config.screen.monazite", "Monazite"); @@ -81,6 +87,8 @@ public static void init(RegistrateCNLangProvider provider) { provider.add("config.monazite.option.showDimensionTier", "显示维度层级"); provider.add("config.monazite.option.dimensions", "自定义维度"); provider.add("config.monazite.option.displayMachineMode", "显示机器模式"); + provider.add("config.monazite.option.displayMulitblockStructure", "显示多方块结构"); + provider.add("config.monazite.option.displayStainedColor", "显示已染色方块"); 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", "末地"); diff --git a/src/main/java/com/epimorphismmc/monazite/integration/jade/MonaziteJadePlugin.java b/src/main/java/com/epimorphismmc/monazite/integration/jade/MonaziteJadePlugin.java index bb70447..eb73095 100644 --- a/src/main/java/com/epimorphismmc/monazite/integration/jade/MonaziteJadePlugin.java +++ b/src/main/java/com/epimorphismmc/monazite/integration/jade/MonaziteJadePlugin.java @@ -42,6 +42,10 @@ public void register(IWailaCommonRegistration registration) { if (MonaziteConfigHolder.INSTANCE.topInformation.displayMachineMode) { registration.registerBlockDataProvider(MachineModeProvider.INSTANCE, BlockEntity.class); } + + if (MonaziteConfigHolder.INSTANCE.topInformation.displayStainedColor) { + registration.registerBlockDataProvider(StainedColorProvider.INSTANCE, BlockEntity.class); + } } @Override @@ -73,6 +77,10 @@ public void registerClient(IWailaClientRegistration registration) { if (MonaziteConfigHolder.INSTANCE.topInformation.displayMachineMode) { registration.registerBlockComponent(MachineModeProvider.INSTANCE, Block.class); } + + if (MonaziteConfigHolder.INSTANCE.topInformation.displayStainedColor) { + registration.registerBlockComponent(StainedColorProvider.INSTANCE, Block.class); + } } } diff --git a/src/main/java/com/epimorphismmc/monazite/integration/jade/provider/StainedColorProvider.java b/src/main/java/com/epimorphismmc/monazite/integration/jade/provider/StainedColorProvider.java new file mode 100644 index 0000000..4262cf6 --- /dev/null +++ b/src/main/java/com/epimorphismmc/monazite/integration/jade/provider/StainedColorProvider.java @@ -0,0 +1,50 @@ +package com.epimorphismmc.monazite.integration.jade.provider; + +import com.epimorphismmc.monazite.Monazite; +import com.gregtechceu.gtceu.api.blockentity.PipeBlockEntity; +import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; +import com.gregtechceu.gtceu.api.machine.MetaMachine; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.Style; +import net.minecraft.resources.ResourceLocation; +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; + +import java.util.Locale; + +public enum StainedColorProvider implements IBlockComponentProvider, IServerDataProvider { + INSTANCE; + + @Override + public void appendTooltip(ITooltip iTooltip, BlockAccessor blockAccessor, IPluginConfig iPluginConfig) { + if (blockAccessor.getServerData().contains("StainedColor")) { + int paintingColor = blockAccessor.getServerData().getInt("StainedColor"); + if (paintingColor != -1) { + iTooltip.add(Component.translatable("monazite.stained", "#" + Integer.toHexString(paintingColor).toUpperCase(Locale.ROOT)).withStyle(Style.EMPTY.withColor(paintingColor))); + } + } + } + + @Override + public void appendServerData(CompoundTag compoundTag, BlockAccessor blockAccessor) { + if (blockAccessor.getBlockEntity() instanceof IMachineBlockEntity blockEntity) { + MetaMachine metaMachine = blockEntity.getMetaMachine(); + if (metaMachine != null) { + int paintingColor = metaMachine.getPaintingColor(); + compoundTag.putInt("StainedColor", paintingColor); + } + } else if (blockAccessor.getBlockEntity() instanceof PipeBlockEntity pipe) { + int paintingColor = pipe.getPaintingColor(); + compoundTag.putInt("StainedColor", paintingColor); + } + } + + @Override + public ResourceLocation getUid() { + return Monazite.id("stained_color"); + } +} diff --git a/src/main/java/com/epimorphismmc/monazite/integration/top/MonaziteTOPPlugin.java b/src/main/java/com/epimorphismmc/monazite/integration/top/MonaziteTOPPlugin.java index 6181897..cbaf667 100644 --- a/src/main/java/com/epimorphismmc/monazite/integration/top/MonaziteTOPPlugin.java +++ b/src/main/java/com/epimorphismmc/monazite/integration/top/MonaziteTOPPlugin.java @@ -52,6 +52,10 @@ public static void registerProvider(ITheOneProbe oneProbe) { if (MonaziteConfigHolder.INSTANCE.topInformation.displayMachineMode) { oneProbe.registerProvider(new MachineModeProvider()); } + + if (MonaziteConfigHolder.INSTANCE.topInformation.displayStainedColor) { + oneProbe.registerProvider(new StainedColorProvider()); + } } public static void registerElements(ITheOneProbe oneProbe) { diff --git a/src/main/java/com/epimorphismmc/monazite/integration/top/provider/StainedColorProvider.java b/src/main/java/com/epimorphismmc/monazite/integration/top/provider/StainedColorProvider.java new file mode 100644 index 0000000..a105bc0 --- /dev/null +++ b/src/main/java/com/epimorphismmc/monazite/integration/top/provider/StainedColorProvider.java @@ -0,0 +1,40 @@ +package com.epimorphismmc.monazite.integration.top.provider; + +import com.epimorphismmc.monazite.Monazite; +import com.gregtechceu.gtceu.api.blockentity.PipeBlockEntity; +import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; +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.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.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; + +import java.util.Locale; + +public class StainedColorProvider implements IProbeInfoProvider { + @Override + public ResourceLocation getID() { + return Monazite.id("stained_color"); + } + + @Override + public void addProbeInfo(ProbeMode probeMode, IProbeInfo iProbeInfo, Player player, Level level, BlockState blockState, IProbeHitData iProbeHitData) { + BlockEntity blockEntity = level.getBlockEntity(iProbeHitData.getPos()); + int paintingColor = -1; + if (blockEntity instanceof IMachineBlockEntity machineBlockEntity) { + paintingColor = machineBlockEntity.getMetaMachine().getPaintingColor(); + } else if (blockEntity instanceof PipeBlockEntity pipe) { + paintingColor = pipe.getPaintingColor(); + } + if (paintingColor != -1) { + IProbeInfo horizontal = iProbeInfo.horizontal(iProbeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)); + horizontal.mcText(Component.translatable("monazite.stained", "#" + Integer.toHexString(paintingColor).toUpperCase(Locale.ROOT))); + } + } +}