diff --git a/CHANGELOG.md b/CHANGELOG.md index acd466abc7..6c237ea8e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,3 +21,4 @@ Version: 1.3.1 - Rubber trees spawn chance config now works - Singleblock machines can no longer run a recipe beyond its tier - Fluid Hatch locking properly saves between world loads +- Color-changing tooltip now changes colors properly diff --git a/src/main/java/com/gregtechceu/gtceu/client/forge/ForgeClientEventListener.java b/src/main/java/com/gregtechceu/gtceu/client/forge/ForgeClientEventListener.java index 9ff36466af..1a7d80450b 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/forge/ForgeClientEventListener.java +++ b/src/main/java/com/gregtechceu/gtceu/client/forge/ForgeClientEventListener.java @@ -3,10 +3,10 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.client.EnvironmentalHazardClientHandler; -import com.gregtechceu.gtceu.client.TooltipHelper; import com.gregtechceu.gtceu.client.TooltipsHandler; import com.gregtechceu.gtceu.client.renderer.BlockHighLightRenderer; import com.gregtechceu.gtceu.client.renderer.MultiblockInWorldPreviewRenderer; +import com.gregtechceu.gtceu.client.util.TooltipHelper; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; diff --git a/src/main/java/com/gregtechceu/gtceu/client/TooltipHelper.java b/src/main/java/com/gregtechceu/gtceu/client/util/TooltipHelper.java similarity index 96% rename from src/main/java/com/gregtechceu/gtceu/client/TooltipHelper.java rename to src/main/java/com/gregtechceu/gtceu/client/util/TooltipHelper.java index dd8d2b9447..9bc861d585 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/TooltipHelper.java +++ b/src/main/java/com/gregtechceu/gtceu/client/util/TooltipHelper.java @@ -1,4 +1,4 @@ -package com.gregtechceu.gtceu.client; +package com.gregtechceu.gtceu.client.util; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; @@ -15,7 +15,7 @@ public class TooltipHelper { private static final List CODES = new ArrayList<>(); - /* Array of TextFormatting codes that are used to create a rainbow effect */ + /** Array of TextFormatting codes that are used to create a rainbow effect */ private static final ChatFormatting[] ALL_COLORS = new ChatFormatting[] { RED, GOLD, YELLOW, GREEN, AQUA, DARK_AQUA, DARK_BLUE, BLUE, DARK_PURPLE, LIGHT_PURPLE }; diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java index 2b71703781..d97a0ba2ef 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java @@ -32,8 +32,8 @@ import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; import com.gregtechceu.gtceu.api.registry.registrate.MultiblockMachineBuilder; -import com.gregtechceu.gtceu.client.TooltipHelper; import com.gregtechceu.gtceu.client.renderer.machine.*; +import com.gregtechceu.gtceu.client.util.TooltipHelper; import com.gregtechceu.gtceu.common.block.BoilerFireboxType; import com.gregtechceu.gtceu.common.data.machines.GCyMMachines; import com.gregtechceu.gtceu.common.data.machines.GTAEMachines; @@ -554,21 +554,29 @@ public class GTMachines { ////////////////////////////////////// // ********* Storage *********// ////////////////////////////////////// + + public static final BiConsumer> CREATIVE_TOOLTIPS = (stack, components) -> components + .add(Component.translatable("gtceu.creative_tooltip.1") + .append(Component.translatable("gtceu.creative_tooltip.2") + .withStyle(style -> style.withColor(TooltipHelper.RAINBOW_SLOW.getCurrent()))) + .append(Component.translatable("gtceu.creative_tooltip.3"))); + + public static BiConsumer> createCreativeTooltips(boolean share) { + return (stack, list) -> { + CREATIVE_TOOLTIPS.accept(stack, list); + list.add(Component.translatable("gtceu.universal.%s".formatted(share ? "enabled" : "disabled"))); + }; + } + public static final MachineDefinition CREATIVE_ENERGY = REGISTRATE .machine("creative_energy", CreativeEnergyContainerMachine::new) .rotationState(RotationState.NONE) - .tooltips(Component.translatable("gtceu.creative_tooltip.1"), - Component.translatable("gtceu.creative_tooltip.2") - .withStyle(style -> style.withColor(TooltipHelper.RAINBOW_SLOW.getCurrent())), - Component.translatable("gtceu.creative_tooltip.3")) + .tooltipBuilder(CREATIVE_TOOLTIPS) .compassNodeSelf() .register(); public static final MachineDefinition CREATIVE_FLUID = REGISTRATE.machine("creative_tank", CreativeTankMachine::new) .rotationState(RotationState.ALL) - .tooltips(Component.translatable("gtceu.creative_tooltip.1"), - Component.translatable("gtceu.creative_tooltip.2") - .withStyle(style -> style.withColor(TooltipHelper.RAINBOW_SLOW.getCurrent())), - Component.translatable("gtceu.creative_tooltip.3")) + .tooltipBuilder(CREATIVE_TOOLTIPS) .renderer(() -> new QuantumTankRenderer(MAX, GTCEu.id("block/machine/creative_tank"))) .hasTESR(true) .compassNodeSelf() @@ -576,10 +584,7 @@ public class GTMachines { public static final MachineDefinition CREATIVE_ITEM = REGISTRATE .machine("creative_chest", CreativeChestMachine::new) .rotationState(RotationState.ALL) - .tooltips(Component.translatable("gtceu.creative_tooltip.1"), - Component.translatable("gtceu.creative_tooltip.2") - .withStyle(style -> style.withColor(TooltipHelper.RAINBOW_SLOW.getCurrent())), - Component.translatable("gtceu.creative_tooltip.3")) + .tooltipBuilder(CREATIVE_TOOLTIPS) .renderer(() -> new QuantumChestRenderer(MAX, GTCEu.id("block/machine/creative_chest"))) .hasTESR(true) .compassNodeSelf() @@ -1988,10 +1993,12 @@ public static BiConsumer> createTankTooltips(String n .recipeType(GTRecipeTypes.DUMMY_RECIPES) .appearanceBlock(HIGH_POWER_CASING) .tooltips(Component.translatable("gtceu.machine.active_transformer.tooltip.0"), - Component.translatable("gtceu.machine.active_transformer.tooltip.1"), - Component.translatable("gtceu.machine.active_transformer.tooltip.2") - .append(Component.translatable("gtceu.machine.active_transformer.tooltip.3") - .withStyle(style -> style.withColor(TooltipHelper.RAINBOW_SLOW.getCurrent())))) + Component.translatable("gtceu.machine.active_transformer.tooltip.1")) + .tooltipBuilder( + (stack, + components) -> components.add(Component.translatable("gtceu.machine.active_transformer.tooltip.2") + .append(Component.translatable("gtceu.machine.active_transformer.tooltip.3") + .withStyle(style -> style.withColor(TooltipHelper.RAINBOW_SLOW.getCurrent()))))) .pattern((definition) -> FactoryBlockPattern.start() .aisle("XXX", "XXX", "XXX") .aisle("XXX", "XCX", "XXX") @@ -2015,10 +2022,12 @@ public static BiConsumer> createTankTooltips(String n PowerSubstationMachine.MAX_BATTERY_LAYERS), Component.translatable("gtceu.machine.power_substation.tooltip.3"), Component.translatable("gtceu.machine.power_substation.tooltip.4", - PowerSubstationMachine.PASSIVE_DRAIN_MAX_PER_STORAGE / 1000), - Component.translatable("gtceu.machine.power_substation.tooltip.5") - .append(Component.translatable("gtceu.machine.power_substation.tooltip.6") - .withStyle(style -> style.withColor(TooltipHelper.RAINBOW_SLOW.getCurrent())))) + PowerSubstationMachine.PASSIVE_DRAIN_MAX_PER_STORAGE / 1000)) + .tooltipBuilder( + (stack, + components) -> components.add(Component.translatable("gtceu.machine.power_substation.tooltip.5") + .append(Component.translatable("gtceu.machine.power_substation.tooltip.6") + .withStyle(style -> style.withColor(TooltipHelper.RAINBOW_SLOW.getCurrent()))))) .appearanceBlock(CASING_PALLADIUM_SUBSTATION) .pattern(definition -> FactoryBlockPattern.start(RIGHT, BACK, UP) .aisle("XXSXX", "XXXXX", "XXXXX", "XXXXX", "XXXXX") @@ -2314,7 +2323,7 @@ public static MultiblockMachineDefinition[] registerTieredMultis(String name, private static MachineDefinition registerTankValve( String name, String displayName, boolean isMetal, - BiConsumer rendererSetup) { + BiConsumer, ResourceLocation> rendererSetup) { MachineBuilder builder = REGISTRATE .machine(name, holder -> new TankValvePartMachine(holder, isMetal)) .langValue(displayName) diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTResearchMachines.java b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTResearchMachines.java index 0446cd3d28..784fd8dc0c 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTResearchMachines.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTResearchMachines.java @@ -11,9 +11,9 @@ import com.gregtechceu.gtceu.api.pattern.FactoryBlockPattern; import com.gregtechceu.gtceu.api.pattern.MultiblockShapeInfo; import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; -import com.gregtechceu.gtceu.client.TooltipHelper; import com.gregtechceu.gtceu.client.renderer.machine.HPCAPartRenderer; import com.gregtechceu.gtceu.client.renderer.machine.OverlayTieredActiveMachineRenderer; +import com.gregtechceu.gtceu.client.util.TooltipHelper; import com.gregtechceu.gtceu.common.data.GTMachines; import com.gregtechceu.gtceu.common.data.GTMaterials; import com.gregtechceu.gtceu.common.data.GTRecipeTypes; @@ -35,6 +35,7 @@ import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Blocks; import org.jetbrains.annotations.NotNull; @@ -42,11 +43,13 @@ import java.util.ArrayList; import java.util.List; +import java.util.function.BiConsumer; import java.util.function.Function; import static com.gregtechceu.gtceu.api.GTValues.*; import static com.gregtechceu.gtceu.api.pattern.Predicates.*; import static com.gregtechceu.gtceu.common.data.GTBlocks.*; +import static com.gregtechceu.gtceu.common.data.GTMachines.createCreativeTooltips; import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; @SuppressWarnings("unused") @@ -345,12 +348,8 @@ public class GTResearchMachines { .tier(MAX) .rotationState(RotationState.ALL) .abilities(PartAbility.DATA_ACCESS) - .tooltips(Component.translatable("gtceu.machine.data_access_hatch.tooltip.0"), - Component.translatable("gtceu.creative_tooltip.1") - .append(TooltipHelper.RAINBOW.toString()) - .append(Component.translatable("gtceu.creative_tooltip.2")) - .append(Component.translatable("gtceu.creative_tooltip.3")), - Component.translatable("gtceu.universal.enabled")) + .tooltips(Component.translatable("gtceu.machine.data_access_hatch.tooltip.0")) + .tooltipBuilder(createCreativeTooltips(true)) .overlayTieredHullRenderer("data_access_hatch_creative") .register(); @@ -358,6 +357,10 @@ public class GTResearchMachines { // *********** HPCA ***********// ////////////////////////////////////// + public static final BiConsumer> OVERHEAT_TOOLTIPS = (stack, components) -> components + .add(Component.translatable("gtceu.machine.hpca.component_type.damaged") + .withStyle(style -> style.withColor(TooltipHelper.BLINKING_ORANGE.getCurrent()))); + public static final MachineDefinition HPCA_EMPTY_COMPONENT = registerHPCAPart( "hpca_empty_component", "Empty HPCA Component", HPCAEmptyPartMachine::new, "empty", null, null, false).register(); @@ -368,9 +371,8 @@ public class GTResearchMachines { Component.translatable("gtceu.machine.hpca.component_general.upkeep_eut", GTValues.VA[GTValues.EV]), Component.translatable("gtceu.machine.hpca.component_general.max_eut", GTValues.VA[GTValues.LuV]), Component.translatable("gtceu.machine.hpca.component_type.computation_cwut", 4), - Component.translatable("gtceu.machine.hpca.component_type.computation_cooling", 2), - Component.literal(TooltipHelper.BLINKING_ORANGE.toString()) - .append(Component.translatable("gtceu.machine.hpca.component_type.damaged"))) + Component.translatable("gtceu.machine.hpca.component_type.computation_cooling", 2)) + .tooltipBuilder(OVERHEAT_TOOLTIPS) .register(); public static final MachineDefinition HPCA_ADVANCED_COMPUTATION_COMPONENT = registerHPCAPart( "hpca_advanced_computation_component", "HPCA Advanced Computation Component", @@ -379,9 +381,8 @@ public class GTResearchMachines { Component.translatable("gtceu.machine.hpca.component_general.upkeep_eut", GTValues.VA[GTValues.IV]), Component.translatable("gtceu.machine.hpca.component_general.max_eut", GTValues.VA[GTValues.ZPM]), Component.translatable("gtceu.machine.hpca.component_type.computation_cwut", 16), - Component.translatable("gtceu.machine.hpca.component_type.computation_cooling", 4), - Component.literal(TooltipHelper.BLINKING_ORANGE.toString()) - .append(Component.translatable("gtceu.machine.hpca.component_type.damaged"))) + Component.translatable("gtceu.machine.hpca.component_type.computation_cooling", 4)) + .tooltipBuilder(OVERHEAT_TOOLTIPS) .register(); public static final MachineDefinition HPCA_HEAT_SINK_COMPONENT = registerHPCAPart( "hpca_heat_sink_component", "HPCA Heat Sink Component",