Skip to content

Commit

Permalink
Backport to 1.21.1: Add attributeAdvancedTooltipDebugInfo config opti…
Browse files Browse the repository at this point in the history
…on (#1902)

Co-authored-by: TelepathicGrunt <[email protected]>
  • Loading branch information
1 parent 0b5f50c commit 147d9f7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ public static class Server {
*/
public static class Common {
public final ModConfigSpec.EnumValue<TagConventionLogWarning.LogWarningMode> logUntranslatedItemTagWarnings;

public final ModConfigSpec.EnumValue<TagConventionLogWarning.LogWarningMode> logLegacyTagWarnings;

public final BooleanValue attributeAdvancedTooltipDebugInfo;

Common(ModConfigSpec.Builder builder) {
logUntranslatedItemTagWarnings = builder
.comment("A config option mainly for developers. Logs out modded item tags that do not have translations when running on integrated server. Format desired is tag.item.<namespace>.<path> for the translation key. Defaults to SILENCED.")
Expand All @@ -76,6 +79,11 @@ public static class Common {
.comment("A config option mainly for developers. Logs out modded tags that are using the 'forge' namespace when running on integrated server. Defaults to DEV_SHORT.")
.translation("neoforge.configgui.logLegacyTagWarnings")
.defineEnum("logLegacyTagWarnings", TagConventionLogWarning.LogWarningMode.DEV_SHORT);

attributeAdvancedTooltipDebugInfo = builder
.comment("Set this to true to enable showing debug information about attributes on an item when advanced tooltips is on.")
.translation("neoforge.configgui.attributeAdvancedTooltipDebugInfo")
.define("attributeAdvancedTooltipDebugInfo", true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.TooltipFlag;
import net.neoforged.neoforge.common.NeoForgeConfig;
import net.neoforged.neoforge.common.NeoForgeMod;
import net.neoforged.neoforge.common.util.AttributeUtil;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -83,7 +84,7 @@ default MutableComponent toComponent(AttributeModifier modif, TooltipFlag flag)
default Component getDebugInfo(AttributeModifier modif, TooltipFlag flag) {
Component debugInfo = CommonComponents.EMPTY;

if (flag.isAdvanced()) {
if (flag.isAdvanced() && NeoForgeConfig.COMMON.attributeAdvancedTooltipDebugInfo.get()) {
// Advanced Tooltips show the underlying operation and the "true" value. We offset MULTIPLY_TOTAL by 1 due to how the operation is calculated.
double advValue = (modif.operation() == Operation.ADD_MULTIPLIED_TOTAL ? 1 : 0) + modif.amount();
String valueStr = FORMAT.format(advValue);
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/neoforge/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@
"neoforge.configuration.section.neoforge.server.toml.title": "Server settings",
"neoforge.configgui.advertiseDedicatedServerToLan": "Advertise Dedicated Server To LAN",
"neoforge.configgui.advertiseDedicatedServerToLan.tooltip": "Set this to true to enable advertising the dedicated server to local LAN clients so that it shows up in the Multiplayer screen automatically.",
"neoforge.configgui.attributeAdvancedTooltipDebugInfo": "Additional Attribute Advanced Tooltips",
"neoforge.configgui.attributeAdvancedTooltipDebugInfo.tooltip": "Set this to true to enable additional information about attributes on an item when advanced tooltips is on.",
"neoforge.configgui.forgeLightPipelineEnabled": "NeoForge Light Pipeline",
"neoforge.configgui.forgeLightPipelineEnabled.tooltip": "Enable the NeoForge block rendering pipeline - fixes the lighting of custom models.",
"neoforge.configgui.fullBoundingBoxLadders": "Full Bounding Box Ladders",
Expand Down

0 comments on commit 147d9f7

Please sign in to comment.