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 9, 2024
1 parent 6f8e672 commit 2cc679e
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/generated/resources/assets/monazite/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"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.parallel": "ʎɐןdsıᗡ ןǝןןɐɹɐԀ",
"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Ɔ",
Expand Down
1 change: 1 addition & 0 deletions src/generated/resources/assets/monazite/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"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.parallel": "Parallel 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",
Expand Down
1 change: 1 addition & 0 deletions src/generated/resources/assets/monazite/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"config.jade.plugin_monazite.machine_mode": "机器模式显示",
"config.jade.plugin_monazite.maintenance_info": "维护信息显示",
"config.jade.plugin_monazite.multiblock_structure": "多方块结构显示",
"config.jade.plugin_monazite.parallel": "并行显示",
"config.jade.plugin_monazite.recipe_output_info": "配方输出显示",
"config.jade.plugin_monazite.stained_color": "染色方块显示",
"config.monazite.option.conciseMode": "简洁模式",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public static class TopInformationConfigs {
@Configurable
@Configurable.Comment({"If true, Display stained color in pipe or other stain block", "Default: true"})
public boolean displayStainedColor = true;

@Configurable
@Configurable.Comment({"If true, Display parallel of the machine or hatch", "Default: true"})
public boolean displayParallel = true;
}

public static class OreVeinDisplayConfigs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static void init(RegistrateLangProvider provider) {
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("config.jade.plugin_monazite.parallel", "Parallel Display");
provider.add("key.categories.monazite", "Monazite");
provider.add("key.toggleConciseMode", "Toggle Concise Mode");
provider.add("config.screen.monazite", "Monazite");
Expand All @@ -44,6 +45,7 @@ public static void init(RegistrateLangProvider provider) {
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("config.monazite.option.displayParallel", "Display Parallel");
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 Down Expand Up @@ -71,6 +73,7 @@ public static void init(RegistrateCNLangProvider provider) {
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("config.jade.plugin_monazite.parallel", "并行显示");
provider.add("key.categories.monazite", "Monazite");
provider.add("key.toggleConciseMode", "开/关简洁模式");
provider.add("config.screen.monazite", "Monazite");
Expand All @@ -89,6 +92,7 @@ public static void init(RegistrateCNLangProvider provider) {
provider.add("config.monazite.option.displayMachineMode", "显示机器模式");
provider.add("config.monazite.option.displayMulitblockStructure", "显示多方块结构");
provider.add("config.monazite.option.displayStainedColor", "显示已染色方块");
provider.add("config.monazite.option.displayParallel", "显示并行");
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 @@ -43,6 +43,10 @@ public void register(IWailaCommonRegistration registration) {
registration.registerBlockDataProvider(MachineModeProvider.INSTANCE, BlockEntity.class);
}

if (MonaziteConfigHolder.INSTANCE.topInformation.displayParallel) {
registration.registerBlockDataProvider(ParallelProvider.INSTANCE, BlockEntity.class);
}

if (MonaziteConfigHolder.INSTANCE.topInformation.displayStainedColor) {
registration.registerBlockDataProvider(StainedColorProvider.INSTANCE, BlockEntity.class);
}
Expand Down Expand Up @@ -78,6 +82,10 @@ public void registerClient(IWailaClientRegistration registration) {
registration.registerBlockComponent(MachineModeProvider.INSTANCE, Block.class);
}

if (MonaziteConfigHolder.INSTANCE.topInformation.displayParallel) {
registration.registerBlockComponent(ParallelProvider.INSTANCE, Block.class);
}

if (MonaziteConfigHolder.INSTANCE.topInformation.displayStainedColor) {
registration.registerBlockComponent(StainedColorProvider.INSTANCE, Block.class);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.epimorphismmc.monazite.integration.jade.provider;

import com.epimorphismmc.monazite.Monazite;
import com.epimorphismmc.monazite.utils.FormattingUtils;
import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity;
import com.gregtechceu.gtceu.api.capability.IParallelHatch;
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;

import java.util.Optional;

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

@Override
public void appendTooltip(ITooltip iTooltip, BlockAccessor blockAccessor, IPluginConfig iPluginConfig) {
if (blockAccessor.getServerData().contains("parallel")) {
int parallel = blockAccessor.getServerData().getInt("parallel");
if (parallel > 0) {
iTooltip.add(Component.translatable(
"gtceu.multiblock.parallel",
Component.literal(FormattingUtils.abbreviate0F(parallel)).withStyle(ChatFormatting.DARK_PURPLE)
));
}
}
}

@Override
public void appendServerData(CompoundTag compoundTag, BlockAccessor blockAccessor) {
if (blockAccessor.getBlockEntity() instanceof MetaMachineBlockEntity blockEntity) {
if (blockEntity.getMetaMachine() instanceof IParallelHatch parallelHatch) {
compoundTag.putInt("parallel", parallelHatch.getCurrentParallel());
} else if (blockEntity.getMetaMachine() instanceof IMultiController controller) {
Optional<IParallelHatch> parallelHatch = controller.getParts().stream()
.filter(IParallelHatch.class::isInstance)
.map(IParallelHatch.class::cast)
.findAny();
parallelHatch.ifPresent(iParallelHatch -> compoundTag.putInt("parallel", iParallelHatch.getCurrentParallel()));
}
}
}

@Override
public ResourceLocation getUid() {
return Monazite.id("parallel");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public static void registerProvider(ITheOneProbe oneProbe) {
oneProbe.registerProvider(new MachineModeProvider());
}

if (MonaziteConfigHolder.INSTANCE.topInformation.displayParallel) {
oneProbe.registerProvider(new ParallelProvider());
}

if (MonaziteConfigHolder.INSTANCE.topInformation.displayStainedColor) {
oneProbe.registerProvider(new StainedColorProvider());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.epimorphismmc.monazite.integration.top.provider;

import com.epimorphismmc.monazite.Monazite;
import com.epimorphismmc.monazite.utils.FormattingUtils;
import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity;
import com.gregtechceu.gtceu.api.capability.IParallelHatch;
import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiController;
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;
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.Optional;

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

@Override
public void addProbeInfo(ProbeMode probeMode, IProbeInfo iProbeInfo, Player player, Level level, BlockState blockState, IProbeHitData iProbeHitData) {
BlockEntity blockEntity = level.getBlockEntity(iProbeHitData.getPos());
if (blockEntity instanceof MetaMachineBlockEntity machineBlockEntity) {
int parallel = 0;
if (machineBlockEntity.getMetaMachine() instanceof IParallelHatch parallelHatch) {
parallel = parallelHatch.getCurrentParallel();
} else if (machineBlockEntity.getMetaMachine() instanceof IMultiController controller) {
Optional<IParallelHatch> parallelHatch = controller.getParts().stream()
.filter(IParallelHatch.class::isInstance)
.map(IParallelHatch.class::cast)
.findAny();
if (parallelHatch.isPresent()) {
parallel = parallelHatch.get().getCurrentParallel();
}
}
if (parallel > 0) {
iProbeInfo.text(Component.translatable(
"gtceu.multiblock.parallel",
Component.literal(FormattingUtils.abbreviate0F(parallel)).withStyle(ChatFormatting.DARK_PURPLE)
));
}
}
}
}

0 comments on commit 2cc679e

Please sign in to comment.