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 8fc7ac7 commit 3005d78
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 4 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 @@ -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Ɔ",
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 @@ -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",
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 @@ -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": "自定义维度",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}
}
Expand Down
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.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<BlockAccessor> {
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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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"));
}
}
}
}
}

0 comments on commit 3005d78

Please sign in to comment.