1- package com .spellarchives .render ;
1+ package com .spellarchives .client ;
22
33import java .awt .image .BufferedImage ;
44import java .io .IOException ;
1515import net .minecraft .client .resources .IResourceManager ;
1616import net .minecraft .util .ResourceLocation ;
1717
18- import com .spellarchives .gui . GuiStyle ;
18+ import com .spellarchives .config . ClientConfig ;
1919import com .spellarchives .util .TextUtils ;
2020
2121
2222/**
2323 * Centralized factory for dynamic textures used by the GUI. Caches textures and invalidates
24- * them automatically when relevant configuration changes (tracked via GuiStyle .CONFIG_REVISION).
24+ * them automatically when relevant configuration changes (tracked via ClientConfig .CONFIG_REVISION).
2525 */
2626public final class DynamicTextureFactory {
2727 private DynamicTextureFactory () {}
@@ -31,15 +31,15 @@ private DynamicTextureFactory() {}
3131 private static int cacheRevision = -1 ;
3232
3333 private static void checkRevision () {
34- if (cacheRevision != GuiStyle .CONFIG_REVISION ) {
34+ if (cacheRevision != ClientConfig .CONFIG_REVISION ) {
3535 // Attempt to delete previously registered dynamic textures from the texture manager
3636 TextureManager tm = Minecraft .getMinecraft ().getTextureManager ();
3737 for (ResourceLocation rl : spineCache .values ()) tm .deleteTexture (rl );
3838 for (ResourceLocation rl : bgCache .values ()) tm .deleteTexture (rl );
3939
4040 spineCache .clear ();
4141 bgCache .clear ();
42- cacheRevision = GuiStyle .CONFIG_REVISION ;
42+ cacheRevision = ClientConfig .CONFIG_REVISION ;
4343 }
4444 }
4545
@@ -56,7 +56,7 @@ private static void checkRevision() {
5656 */
5757 public static ResourceLocation getOrCreateSpineTexture (int baseRgb , int w , int h , ResourceLocation iconRl , int iconSize ) {
5858 checkRevision ();
59- String key = baseRgb + "_" + w + "x" + h + (iconRl != null && GuiStyle .SPINE_EMBED_ICON ? ("|icon=" + iconRl .toString () + "|s=" + iconSize ) : "" );
59+ String key = baseRgb + "_" + w + "x" + h + (iconRl != null && ClientConfig .SPINE_EMBED_ICON ? ("|icon=" + iconRl .toString () + "|s=" + iconSize ) : "" );
6060 ResourceLocation existing = spineCache .get (key );
6161 if (existing != null ) return existing ;
6262 // Full generator: curvature, vertical shading, deterministic noise, optional bands and icon embedding
@@ -89,17 +89,17 @@ public static ResourceLocation getOrCreateSpineTexture(int baseRgb, int w, int h
8989 // Off-center bias for spine curvature
9090 float centerBias = 0.5f + (rf .apply (s1 ) - 0.5f ) * 0.18f ; // 0.32..0.68
9191 centerBias = Math .max (0.3f , Math .min (0.7f , centerBias ));
92- float asymTilt = GuiStyle .SPINE_ENABLE_TILT ? (rf .apply (s2 ) - 0.5f ) * 0.12f : 0f ; // -0.06..0.06
93- float noiseAmp = GuiStyle .SPINE_ENABLE_NOISE ? GuiStyle .SPINE_NOISE_AMPLITUDE : 0f ; // +/- percentage noise
92+ float asymTilt = ClientConfig .SPINE_ENABLE_TILT ? (rf .apply (s2 ) - 0.5f ) * 0.12f : 0f ; // -0.06..0.06
93+ float noiseAmp = ClientConfig .SPINE_ENABLE_NOISE ? ClientConfig .SPINE_NOISE_AMPLITUDE : 0f ; // +/- percentage noise
9494
9595 // Two horizontal bands near the top of available area above icon reserve
96- int iconReserve = GuiStyle .SPINE_ICON_SIZE + GuiStyle .SPINE_ICON_BOTTOM_MARGIN ; // reserve for bottom icon area
96+ int iconReserve = ClientConfig .SPINE_ICON_SIZE + ClientConfig .SPINE_ICON_BOTTOM_MARGIN ; // reserve for bottom icon area
9797 int available = Math .max (0 , h - iconReserve );
98- int bandThickness = GuiStyle .SPINE_BAND_THICKNESS ;
99- int bandGap = GuiStyle .SPINE_BAND_GAP ;
98+ int bandThickness = ClientConfig .SPINE_BAND_THICKNESS ;
99+ int bandGap = ClientConfig .SPINE_BAND_GAP ;
100100
101101 // Place bands starting at top with a small top space
102- int band1 = available > 0 ? Math .min (available - bandThickness , GuiStyle .SPINE_BAND_TOP_SPACE ) : -1 ;
102+ int band1 = available > 0 ? Math .min (available - bandThickness , ClientConfig .SPINE_BAND_TOP_SPACE ) : -1 ;
103103 int band2 = band1 >= 0 ? Math .min (available - bandThickness , band1 + bandThickness + bandGap ) : -1 ;
104104
105105 for (int y = 0 ; y < h ; y ++) {
@@ -109,15 +109,15 @@ public static ResourceLocation getOrCreateSpineTexture(int baseRgb, int w, int h
109109 float dist = Math .abs (nx - centerBias ) * 2f ; // 0 center -> ~1 edges
110110 float side = Math .signum (nx - centerBias );
111111 dist *= (1f + asymTilt * side );
112- float shade = GuiStyle .SPINE_ENABLE_CURVATURE
113- ? (GuiStyle .SPINE_CENTER_BRIGHTEN - GuiStyle .SPINE_EDGE_FACTOR * dist )
112+ float shade = ClientConfig .SPINE_ENABLE_CURVATURE
113+ ? (ClientConfig .SPINE_CENTER_BRIGHTEN - ClientConfig .SPINE_EDGE_FACTOR * dist )
114114 : 1.0f ;
115115 int rgb = TextUtils .darkenColor (baseRgb , shade );
116116
117117 // Subtle horizontal roll-off towards top/bottom
118118 float ny = (y + 0.5f ) / h ;
119119 float edgeY = Math .min (ny , 1f - ny ) * 2f ; // 0 at edges, 1 at center
120- float vshade = GuiStyle .SPINE_VSHADE_BASE + GuiStyle .SPINE_VSHADE_RANGE * edgeY ; // darker near top/bottom
120+ float vshade = ClientConfig .SPINE_VSHADE_BASE + ClientConfig .SPINE_VSHADE_RANGE * edgeY ; // darker near top/bottom
121121 rgb = TextUtils .darkenColor (rgb , vshade );
122122
123123 // Per-pixel noise to break uniformity (deterministic)
@@ -131,36 +131,36 @@ public static ResourceLocation getOrCreateSpineTexture(int baseRgb, int w, int h
131131 }
132132
133133 // Apply horizontal bands post-pass for clean thin lines (darken slightly)
134- if (GuiStyle .SPINE_ENABLE_BANDS && band1 >= 0 ) {
134+ if (ClientConfig .SPINE_ENABLE_BANDS && band1 >= 0 ) {
135135 for (int x = 0 ; x < w ; x ++) {
136136 for (int dy = 0 ; dy < bandThickness ; dy ++) { // 2px thickness
137137 int yy = band1 + dy ;
138138 if (yy >= 0 && yy < h ) {
139139 int idx = yy * w + x ;
140140 int rgb = pixels [idx ] & 0xFFFFFF ;
141- pixels [idx ] = 0xFF000000 | (TextUtils .darkenColor (rgb , GuiStyle .SPINE_BAND1_DARKEN ) & 0xFFFFFF );
141+ pixels [idx ] = 0xFF000000 | (TextUtils .darkenColor (rgb , ClientConfig .SPINE_BAND1_DARKEN ) & 0xFFFFFF );
142142 }
143143 }
144144 }
145145 }
146146
147- if (GuiStyle .SPINE_ENABLE_BANDS && band2 >= 0 ) {
147+ if (ClientConfig .SPINE_ENABLE_BANDS && band2 >= 0 ) {
148148 for (int x = 0 ; x < w ; x ++) {
149149 for (int dy = 0 ; dy < bandThickness ; dy ++) {
150150 int yy = band2 + dy ;
151151 if (yy >= 0 && yy < h ) {
152152 int idx = yy * w + x ;
153153 int rgb = pixels [idx ] & 0xFFFFFF ;
154- pixels [idx ] = 0xFF000000 | (TextUtils .darkenColor (rgb , GuiStyle .SPINE_BAND2_DARKEN ) & 0xFFFFFF );
154+ pixels [idx ] = 0xFF000000 | (TextUtils .darkenColor (rgb , ClientConfig .SPINE_BAND2_DARKEN ) & 0xFFFFFF );
155155 }
156156 }
157157 }
158158 }
159159
160160 // Optionally embed the element icon into the spine texture (bottom-centered)
161- if (GuiStyle .SPINE_EMBED_ICON && iconRl != null && iconSize > 0 ) {
161+ if (ClientConfig .SPINE_EMBED_ICON && iconRl != null && iconSize > 0 ) {
162162 int ix = (w - iconSize ) / 2 ;
163- int iy = (h - iconSize - GuiStyle .SPINE_ICON_BOTTOM_MARGIN ) + GuiStyle .SPINE_ICON_Y_OFFSET ;
163+ int iy = (h - iconSize - ClientConfig .SPINE_ICON_BOTTOM_MARGIN ) + ClientConfig .SPINE_ICON_Y_OFFSET ;
164164
165165 if (ix >= 0 && iy >= 0 && ix + iconSize <= w && iy + iconSize <= h ) {
166166 try {
@@ -228,12 +228,12 @@ public static ResourceLocation getOrCreateSpineTexture(int baseRgb, int w, int h
228228 public static ResourceLocation getOrCreatePanelBg (int w , int h ) {
229229 checkRevision ();
230230
231- String key = "bg_" + w + "x" + h + "_rev" + GuiStyle .CONFIG_REVISION ;
231+ String key = "bg_" + w + "x" + h + "_rev" + ClientConfig .CONFIG_REVISION ;
232232 ResourceLocation existing = bgCache .get (key );
233233 if (existing != null ) return existing ;
234234
235- int topColor = GuiStyle .BACKGROUND_FILL ;
236- int bottomColor = GuiStyle .BACKGROUND_BORDER ;
235+ int topColor = ClientConfig .BACKGROUND_FILL ;
236+ int bottomColor = ClientConfig .BACKGROUND_BORDER ;
237237 int [] pixels = new int [w * h ];
238238 for (int y = 0 ; y < h ; y ++) {
239239 float t = y / (float )Math .max (1 , h - 1 );
0 commit comments