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

Commit

Permalink
Merge pull request #6 from EpimorphicPioneers/color
Browse files Browse the repository at this point in the history
添加已染色方块的显示
  • Loading branch information
qwer523 authored Jun 5, 2024
2 parents 31f70dd + c6a616b commit 6f8e672
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/generated/resources/assets/monazite/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
"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Ɐ",
"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.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⟘",
Expand All @@ -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"
}
6 changes: 5 additions & 1 deletion src/generated/resources/assets/monazite/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
"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",
"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.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",
Expand All @@ -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"
}
8 changes: 6 additions & 2 deletions src/generated/resources/assets/monazite/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
"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": "自动输出信息显示",
"config.monazite.option.displayCableInfo": "线缆信息显示",
"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": "显示维度层级",
Expand All @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ 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");
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("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");
Expand All @@ -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");
Expand All @@ -57,14 +61,16 @@ 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", "排气口信息显示");
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("config.jade.plugin_monazite.stained_color", "染色方块显示");
provider.add("key.categories.monazite", "Monazite");
provider.add("key.toggleConciseMode", "开/关简洁模式");
provider.add("config.screen.monazite", "Monazite");
Expand All @@ -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", "末地");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

}
Original file line number Diff line number Diff line change
@@ -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<BlockAccessor> {
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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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)));
}
}
}

0 comments on commit 6f8e672

Please sign in to comment.