From 3005d78985f9ea1cecc40021cf2f93d4853806a7 Mon Sep 17 00:00:00 2001 From: DancingSnow <1121149616@qq.com> Date: Wed, 5 Jun 2024 23:01:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=9A=E6=96=B9=E5=9D=97?= =?UTF-8?q?=E6=9C=BA=E5=99=A8=E6=98=AF=E5=90=A6=E6=88=90=E5=9E=8B=E6=98=BE?= =?UTF-8?q?=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 | 1 + .../resources/assets/monazite/lang/en_us.json | 1 + .../resources/assets/monazite/lang/zh_cn.json | 1 + .../monazite/config/MonaziteConfigHolder.java | 4 ++ .../monazite/data/lang/MoLangHandler.java | 2 + .../integration/jade/MonaziteJadePlugin.java | 8 ++++ .../jade/provider/MachineModeProvider.java | 2 +- .../provider/MaintenanceBlockProvider.java | 5 ++- .../provider/MulitblockStructureProvider.java | 44 +++++++++++++++++++ .../integration/top/MonaziteTOPPlugin.java | 4 ++ .../top/provider/MachineModeProvider.java | 2 +- .../provider/MulitblockStructureProvider.java | 34 ++++++++++++++ 12 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/epimorphismmc/monazite/integration/jade/provider/MulitblockStructureProvider.java create mode 100644 src/main/java/com/epimorphismmc/monazite/integration/top/provider/MulitblockStructureProvider.java diff --git a/src/generated/resources/assets/monazite/lang/en_ud.json b/src/generated/resources/assets/monazite/lang/en_ud.json index 15784ef..307465a 100644 --- a/src/generated/resources/assets/monazite/lang/en_ud.json +++ b/src/generated/resources/assets/monazite/lang/en_ud.json @@ -7,6 +7,7 @@ "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.multiblock_structure": "ʎɐןdsıᗡ ǝɹnʇɔnɹʇS ʞɔoןqıʇןnW", "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Ɔ", diff --git a/src/generated/resources/assets/monazite/lang/en_us.json b/src/generated/resources/assets/monazite/lang/en_us.json index 1a2eda1..1d7f5dc 100644 --- a/src/generated/resources/assets/monazite/lang/en_us.json +++ b/src/generated/resources/assets/monazite/lang/en_us.json @@ -7,6 +7,7 @@ "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.multiblock_structure": "Multiblock Structure Display", "config.jade.plugin_monazite.recipe_output_info": "Recipe Outputs Display", "config.monazite.option.conciseMode": "Concise Mode", "config.monazite.option.dimensions": "Custom Dimensions", diff --git a/src/generated/resources/assets/monazite/lang/zh_cn.json b/src/generated/resources/assets/monazite/lang/zh_cn.json index 622081c..03cce38 100644 --- a/src/generated/resources/assets/monazite/lang/zh_cn.json +++ b/src/generated/resources/assets/monazite/lang/zh_cn.json @@ -7,6 +7,7 @@ "config.jade.plugin_monazite.exhaust_vent_info": "排气口信息显示", "config.jade.plugin_monazite.machine_mode": "机器模式显示", "config.jade.plugin_monazite.maintenance_info": "维护信息显示", + "config.jade.plugin_monazite.multiblock_structure": "多方块结构显示", "config.jade.plugin_monazite.recipe_output_info": "配方输出显示", "config.monazite.option.conciseMode": "简洁模式", "config.monazite.option.dimensions": "自定义维度", diff --git a/src/main/java/com/epimorphismmc/monazite/config/MonaziteConfigHolder.java b/src/main/java/com/epimorphismmc/monazite/config/MonaziteConfigHolder.java index 199cda7..80eaff2 100644 --- a/src/main/java/com/epimorphismmc/monazite/config/MonaziteConfigHolder.java +++ b/src/main/java/com/epimorphismmc/monazite/config/MonaziteConfigHolder.java @@ -55,6 +55,10 @@ public static class TopInformationConfigs { @Configurable @Configurable.Comment({"If true, The current mode of the machine will be displayed.", "Default: true"}) public boolean displayMachineMode = true; // default true + + @Configurable + @Configurable.Comment({"If true, Display whether it is currently formed or not.", "Default: true"}) + public boolean displayMulitblockStructure = 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 dd79213..e109ee5 100644 --- a/src/main/java/com/epimorphismmc/monazite/data/lang/MoLangHandler.java +++ b/src/main/java/com/epimorphismmc/monazite/data/lang/MoLangHandler.java @@ -24,6 +24,7 @@ public static void init(RegistrateLangProvider provider) { 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("config.jade.plugin_monazite.multiblock_structure", "Multiblock Structure Display"); provider.add("key.categories.monazite", "Monazite"); provider.add("key.toggleConciseMode", "Toggle Concise Mode"); provider.add("config.screen.monazite", "Monazite"); @@ -63,6 +64,7 @@ public static void init(RegistrateCNLangProvider provider) { 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("config.jade.plugin_monazite.multiblock_structure", "多方块结构显示"); provider.add("key.categories.monazite", "Monazite"); provider.add("key.toggleConciseMode", "开/关简洁模式"); provider.add("config.screen.monazite", "Monazite"); 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 454b4bc..bb70447 100644 --- a/src/main/java/com/epimorphismmc/monazite/integration/jade/MonaziteJadePlugin.java +++ b/src/main/java/com/epimorphismmc/monazite/integration/jade/MonaziteJadePlugin.java @@ -19,6 +19,10 @@ public void register(IWailaCommonRegistration registration) { registration.registerBlockDataProvider(RecipeOutputProvider.INSTANCE, BlockEntity.class); } + if (MonaziteConfigHolder.INSTANCE.topInformation.displayMulitblockStructure) { + registration.registerBlockDataProvider(MulitblockStructureProvider.INSTANCE, BlockEntity.class); + } + if (ConfigHolder.INSTANCE.machines.enableMaintenance && MonaziteConfigHolder.INSTANCE.topInformation.displayMaintenanceInfo) { registration.registerBlockDataProvider(MaintenanceBlockProvider.INSTANCE, BlockEntity.class); } @@ -46,6 +50,10 @@ public void registerClient(IWailaClientRegistration registration) { registration.registerBlockComponent(RecipeOutputProvider.INSTANCE, Block.class); } + if (MonaziteConfigHolder.INSTANCE.topInformation.displayMulitblockStructure) { + registration.registerBlockComponent(MulitblockStructureProvider.INSTANCE, Block.class); + } + if (ConfigHolder.INSTANCE.machines.enableMaintenance && MonaziteConfigHolder.INSTANCE.topInformation.displayMaintenanceInfo) { registration.registerBlockComponent(MaintenanceBlockProvider.INSTANCE, Block.class); } 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 5b2066e..a46a5d1 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 @@ -51,7 +51,7 @@ public void appendTooltip(ITooltip iTooltip, BlockAccessor blockAccessor, IPlugi 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 (recipeTypes != null && recipeTypes.length > 1) { if (blockEntity.getMetaMachine() instanceof IRecipeLogicMachine recipeLogicMachine) { ListTag recipeTypesTagList = new ListTag(); GTRecipeType currentRecipeType = recipeLogicMachine.getRecipeType(); diff --git a/src/main/java/com/epimorphismmc/monazite/integration/jade/provider/MaintenanceBlockProvider.java b/src/main/java/com/epimorphismmc/monazite/integration/jade/provider/MaintenanceBlockProvider.java index 024141c..380cd15 100644 --- a/src/main/java/com/epimorphismmc/monazite/integration/jade/provider/MaintenanceBlockProvider.java +++ b/src/main/java/com/epimorphismmc/monazite/integration/jade/provider/MaintenanceBlockProvider.java @@ -7,6 +7,7 @@ import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMaintenanceMachine; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.integration.jade.provider.CapabilityBlockProvider; +import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; @@ -63,10 +64,10 @@ protected void addTooltip(CompoundTag compoundTag, ITooltip iTooltip, Player pla } } } else { - iTooltip.add(Component.translatable("monazite.maintenance.broken")); + iTooltip.add(Component.translatable("monazite.maintenance.broken").withStyle(ChatFormatting.RED)); } } else { - iTooltip.add(Component.translatable("monazite.maintenance.fixed")); + iTooltip.add(Component.translatable("monazite.maintenance.fixed").withStyle(ChatFormatting.GREEN)); } } } diff --git a/src/main/java/com/epimorphismmc/monazite/integration/jade/provider/MulitblockStructureProvider.java b/src/main/java/com/epimorphismmc/monazite/integration/jade/provider/MulitblockStructureProvider.java new file mode 100644 index 0000000..5db532a --- /dev/null +++ b/src/main/java/com/epimorphismmc/monazite/integration/jade/provider/MulitblockStructureProvider.java @@ -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.multiblock.IMultiController; +import net.minecraft.ChatFormatting; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +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; + +public enum MulitblockStructureProvider implements IBlockComponentProvider, IServerDataProvider { + INSTANCE; + + @Override + public void appendTooltip(ITooltip iTooltip, BlockAccessor blockAccessor, IPluginConfig iPluginConfig) { + if (blockAccessor.getServerData().contains("hasError")) { + boolean hasError = blockAccessor.getServerData().getBoolean("hasError"); + if (hasError) { + iTooltip.add(Component.translatable("gtceu.top.invalid_structure").withStyle(ChatFormatting.RED)); + } else { + iTooltip.add(Component.translatable("gtceu.top.valid_structure").withStyle(ChatFormatting.GREEN)); + } + } + } + + @Override + public void appendServerData(CompoundTag compoundTag, BlockAccessor blockAccessor) { + if (blockAccessor.getBlockEntity() instanceof MetaMachineBlockEntity blockEntity) { + if (blockEntity.getMetaMachine() instanceof IMultiController controller) { + compoundTag.putBoolean("hasError", controller.getMultiblockState().hasError()); + } + } + } + + @Override + public ResourceLocation getUid() { + return Monazite.id("multiblock_structure"); + } +} 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 dc4ee44..6181897 100644 --- a/src/main/java/com/epimorphismmc/monazite/integration/top/MonaziteTOPPlugin.java +++ b/src/main/java/com/epimorphismmc/monazite/integration/top/MonaziteTOPPlugin.java @@ -29,6 +29,10 @@ public static void registerProvider(ITheOneProbe oneProbe) { oneProbe.registerProvider(new RecipeOutputInfoProvider()); } + if (MonaziteConfigHolder.INSTANCE.topInformation.displayMulitblockStructure) { + oneProbe.registerProvider(new MulitblockStructureProvider()); + } + if (ConfigHolder.INSTANCE.machines.enableMaintenance && MonaziteConfigHolder.INSTANCE.topInformation.displayMaintenanceInfo) { oneProbe.registerProvider(new MaintenanceInfoProvider()); } 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 6c7b730..40e8120 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 @@ -28,7 +28,7 @@ public ResourceLocation getID() { 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 (recipeTypes != null && recipeTypes.length > 1) { if (blockEntity.getMetaMachine() instanceof IRecipeLogicMachine recipeLogicMachine) { GTRecipeType currentRecipeType = recipeLogicMachine.getRecipeType(); if (player.isShiftKeyDown()) { diff --git a/src/main/java/com/epimorphismmc/monazite/integration/top/provider/MulitblockStructureProvider.java b/src/main/java/com/epimorphismmc/monazite/integration/top/provider/MulitblockStructureProvider.java new file mode 100644 index 0000000..8847f34 --- /dev/null +++ b/src/main/java/com/epimorphismmc/monazite/integration/top/provider/MulitblockStructureProvider.java @@ -0,0 +1,34 @@ +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.multiblock.IMultiController; +import mcjty.theoneprobe.api.CompoundText; +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; +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; + +public class MulitblockStructureProvider implements IProbeInfoProvider { + @Override + public ResourceLocation getID() { + return Monazite.id("multiblock_structure"); + } + + @Override + public void addProbeInfo(ProbeMode probeMode, IProbeInfo iProbeInfo, Player player, Level level, BlockState blockState, IProbeHitData iProbeHitData) { + if (level.getBlockEntity(iProbeHitData.getPos()) instanceof MetaMachineBlockEntity blockEntity) { + if (blockEntity.getMetaMachine() instanceof IMultiController controller) { + if (controller.getMultiblockState().hasError()) { + iProbeInfo.text(CompoundText.create().error("gtceu.top.invalid_structure")); + } else { + iProbeInfo.text(CompoundText.create().ok("gtceu.top.valid_structure")); + } + } + } + } +}