Skip to content

Commit

Permalink
Config option to turn off colored tooltip borders
Browse files Browse the repository at this point in the history
  • Loading branch information
Davoleo committed Jul 6, 2023
1 parent ac72f7a commit 2b402cb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public class GeneralConfig {
@Config.Comment("Hides extra stats information that is usually displayed when you hold the shift key down when hovering over armor and tools")
public static boolean hideStatsTooltip = false;

@Config.Name("Metal Colored Tooltip Borders for metal items")
@Config.Comment("Disabling this option will prevent modification to tooltip borders for metal items (useful when the modpack has another system to modify tooltips that conflicts with Metallurgy or hinders the consistency of modpack tooltips).")
public static boolean metalColoredTooltipBorders = true;

//Handles Config Synchronization
public static class ChangeListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

package it.hurts.metallurgy_reforged.gui;

import it.hurts.metallurgy_reforged.config.GeneralConfig;
import it.hurts.metallurgy_reforged.material.Metal;
import it.hurts.metallurgy_reforged.util.ItemUtils;
import net.minecraft.item.Item;
Expand All @@ -18,17 +19,17 @@
public class TooltipRenderHandler {

@SubscribeEvent
public static void tooltipRenderColor(RenderTooltipEvent.Color event)
{
Item item = event.getStack().getItem();
Metal metal = ItemUtils.getMetalFromItem(item);
if (metal != null)
{
int color = metal.getStats().getColorHex();
//Move the alpha channel 6 digits (24 / 4) to the left and add the rgb color to it
int argb = (0xFF << 24) + color;
event.setBorderStart(argb);
event.setBorderEnd(argb);
public static void tooltipRenderColor(RenderTooltipEvent.Color event) {
if (GeneralConfig.metalColoredTooltipBorders) {
Item item = event.getStack().getItem();
Metal metal = ItemUtils.getMetalFromItem(item);
if (metal != null) {
int color = metal.getStats().getColorHex();
//Move the alpha channel 6 digits (24 / 4) to the left and add the rgb color to it
int argb = (0xFF << 24) + color;
event.setBorderStart(argb);
event.setBorderEnd(argb);
}
}
}

Expand Down

0 comments on commit 2b402cb

Please sign in to comment.