@@ -36,14 +36,15 @@ public static boolean applyItemBackgroundFromWizard() {
3636 return false ;
3737 }
3838
39+ // mapper returns null for "none" meaning "disable backgrounds"
3940 String style = mapToSkyblockerStyle (itemBackground );
4041 return applyItemBackgroundStyle (style );
4142 }
4243
4344 /**
44- * Applies a specific item background style.
45+ * Applies a specific item background style or disables backgrounds when style is null .
4546 *
46- * @param style the style enum name (CIRCULAR, SQUARE, or NONE)
47+ * @param style the style enum name (CIRCULAR, SQUARE) or null to disable rarity backgrounds
4748 * @return true if successfully applied, false otherwise
4849 */
4950 private static boolean applyItemBackgroundStyle (String style ) {
@@ -54,7 +55,7 @@ private static boolean applyItemBackgroundStyle(String style) {
5455 Consumer <Object > configUpdater = config -> updateItemBackgroundConfig (config , style );
5556 updateMethod .invoke (null , configUpdater );
5657
57- PackCore .LOGGER .info ("Successfully applied Skyblocker item background: {}" , style );
58+ PackCore .LOGGER .info ("Successfully applied Skyblocker item background change : {}" , style == null ? "DISABLE_BACKGROUNDS" : style );
5859 return true ;
5960
6061 } catch (ClassNotFoundException e ) {
@@ -72,8 +73,11 @@ private static boolean applyItemBackgroundStyle(String style) {
7273 /**
7374 * Updates the Skyblocker config object with the new item background settings.
7475 *
76+ * If *style* is null, this will disable item rarity backgrounds. Otherwise it will set the enum,
77+ * enable rarity backgrounds and set default opacity.
78+ *
7579 * @param config the Skyblocker config instance
76- * @param style the background style to apply
80+ * @param style the background style to apply, or null to disable backgrounds
7781 */
7882 private static void updateItemBackgroundConfig (Object config , String style ) {
7983 try {
@@ -84,22 +88,26 @@ private static void updateItemBackgroundConfig(Object config, String style) {
8488 Field itemInfoDisplayField = general .getClass ().getField ("itemInfoDisplay" );
8589 Object itemInfoDisplay = itemInfoDisplayField .get (general );
8690
87- // Set the background style enum
88- Class <?> styleEnum = Class . forName ( ITEM_BACKGROUND_ENUM_CLASS );
89- Object enumValue = Enum . valueOf (( Class < Enum >) styleEnum , style );
91+ // Toggle itemRarityBackgrounds based on whether we have a style or are disabling
92+ Field rarityBackgroundsField = itemInfoDisplay . getClass (). getField ( "itemRarityBackgrounds" );
93+ rarityBackgroundsField . setBoolean ( itemInfoDisplay , style != null );
9094
91- Field styleField = itemInfoDisplay .getClass ().getField ("itemBackgroundStyle" );
92- styleField .set (itemInfoDisplay , enumValue );
95+ if (style != null ) {
96+ // Set the background style enum
97+ Class <?> styleEnum = Class .forName (ITEM_BACKGROUND_ENUM_CLASS );
98+ Object enumValue = Enum .valueOf ((Class <Enum >) styleEnum , style );
9399
94- // Enable item rarity backgrounds (required for backgrounds to show)
95- Field rarityBackgroundsField = itemInfoDisplay .getClass ().getField ("itemRarityBackgrounds" );
96- rarityBackgroundsField .setBoolean (itemInfoDisplay , true );
100+ Field styleField = itemInfoDisplay .getClass ().getField ("itemBackgroundStyle" );
101+ styleField .set (itemInfoDisplay , enumValue );
97102
98- // Set default opacity
99- Field opacityField = itemInfoDisplay .getClass ().getField ("itemBackgroundOpacity" );
100- opacityField .setFloat (itemInfoDisplay , DEFAULT_OPACITY );
103+ // Set default opacity
104+ Field opacityField = itemInfoDisplay .getClass ().getField ("itemBackgroundOpacity" );
105+ opacityField .setFloat (itemInfoDisplay , DEFAULT_OPACITY );
101106
102- PackCore .LOGGER .debug ("Item background config updated: style={}, opacity={}" , style , DEFAULT_OPACITY );
107+ PackCore .LOGGER .debug ("Item background config updated: style={}, opacity={}" , style , DEFAULT_OPACITY );
108+ } else {
109+ PackCore .LOGGER .debug ("Item rarity backgrounds disabled via wizard selection" );
110+ }
103111
104112 } catch (NoSuchFieldException e ) {
105113 PackCore .LOGGER .error ("Required config field not found - Skyblocker structure may have changed: {}" , e .getMessage ());
@@ -115,13 +123,17 @@ private static void updateItemBackgroundConfig(Object config, String style) {
115123 /**
116124 * Maps wizard style names to Skyblocker enum values.
117125 *
126+ * Returns null for "none"/"no background" to indicate disabling backgrounds.
127+ *
118128 * @param wizardStyle the style name from the wizard
119- * @return the corresponding Skyblocker enum name
129+ * @return the corresponding Skyblocker enum name or null to disable backgrounds
120130 */
121131 private static String mapToSkyblockerStyle (String wizardStyle ) {
122- return switch (wizardStyle .toLowerCase ()) {
132+ if (wizardStyle == null ) return "SQUARE" ;
133+ return switch (wizardStyle .toLowerCase ().trim ()) {
123134 case "circular" -> "CIRCULAR" ;
124135 case "square" -> "SQUARE" ;
136+ case "no background" , "none" -> null ; // signal to disable itemRarityBackgrounds
125137 default -> {
126138 PackCore .LOGGER .warn ("Unknown item background style '{}', defaulting to SQUARE" , wizardStyle );
127139 yield "SQUARE" ;
@@ -131,9 +143,10 @@ private static String mapToSkyblockerStyle(String wizardStyle) {
131143
132144 /**
133145 * Checks if the application should be skipped.
146+ * Do not skip when the user explicitly chose "None" — that indicates they want to disable backgrounds.
134147 */
135148 private static boolean shouldSkipApplication (String itemBackground ) {
136- return itemBackground == null || itemBackground .isEmpty () || "None" . equalsIgnoreCase ( itemBackground ) ;
149+ return itemBackground == null || itemBackground .isEmpty ();
137150 }
138151
139152 /**
@@ -142,4 +155,4 @@ private static boolean shouldSkipApplication(String itemBackground) {
142155 private static boolean isSkyblockerLoaded () {
143156 return FabricLoader .getInstance ().isModLoaded (SKYBLOCKER_MOD_ID );
144157 }
145- }
158+ }
0 commit comments