--- a/net/minecraft/ChatFormatting.java
+++ b/net/minecraft/ChatFormatting.java
@@ -43,7 +_,7 @@
         .collect(Collectors.toMap(formatting -> cleanName(formatting.name), chatFormatter -> (ChatFormatting)chatFormatter));
     private static final Pattern STRIP_FORMATTING_PATTERN = Pattern.compile("(?i)§[0-9A-FK-OR]");
     private final String name;
-    private final char code;
+    public final char code;
     private final boolean isFormat;
     private final String toString;
     private final int id;
@@ -111,6 +_,19 @@
     public static ChatFormatting getByName(@Nullable String friendlyName) {
         return friendlyName == null ? null : FORMATTING_BY_NAME.get(cleanName(friendlyName));
     }
+
+    // Paper start - add method to get by hex value
+    @Nullable
+    public static ChatFormatting getByHexValue(int i) {
+        for (ChatFormatting value : values()) {
+            if (value.getColor() != null && value.getColor() == i) {
+                return value;
+            }
+        }
+
+        return null;
+    }
+    // Paper end - add method to get by hex value
 
     @Nullable
     public static ChatFormatting getById(int index) {
