1+ from pathlib import Path
12from OpenGL .GL import * # type: ignore
23from OpenGL .GLUT import * # type: ignore
34from OpenGL .GLU import * # type: ignore
@@ -133,6 +134,15 @@ def get_real_key(
133134 return value
134135 else :
135136 raise RenderError (f"Unknown texture type { type (value )} for key { key } " )
137+
138+ def get_missingno (self ) -> Image .Image :
139+ """Returns a missingno image for debugging purposes."""
140+ if self .getter .opts .transparent_missingno :
141+ return Image .new ("RGBA" , (16 , 16 ), (0 , 0 , 0 , 0 ))
142+ path = Path (__file__ ).parent .parent / "missingno.png"
143+ if not path .exists ():
144+ raise RenderError (f"Missingno image not found at { path } " )
145+ return Image .open (path ).convert ("RGBA" )
136146
137147 def load_textures (
138148 self , model : MinecraftModel
@@ -141,7 +151,7 @@ def load_textures(
141151 for key in model .textures .keys ():
142152 value = self .get_real_key (key , model .textures )
143153 if value is None :
144- res [key ] = (Image . new ( "RGBA" , ( 16 , 16 ), ( 0 , 0 , 0 , 0 ) ), "empty" )
154+ res [key ] = (self . get_missingno ( ), "empty" )
145155 log .warning (f"Texture { key } not found in model" )
146156 elif isinstance (value , Image .Image ):
147157 res [key ] = (value , "dynamic" )
@@ -157,7 +167,7 @@ def load_textures(
157167 texture = Texture (self .dynamic_textures [path ])
158168 img = texture .image
159169 else :
160- img = Image . new ( "RGBA" , ( 16 , 16 ), ( 0 , 0 , 0 , 0 ) )
170+ img = self . get_missingno ( )
161171 log .warning (f"Texture { key } not found at { path } " )
162172
163173 img = img .convert ("RGBA" )
@@ -172,7 +182,7 @@ def load_textures(
172182 texture = Texture (self .dynamic_textures [path ])
173183 img = texture .image
174184 else :
175- img = Image . new ( "RGBA" , ( 16 , 16 ), ( 0 , 0 , 0 , 0 ) )
185+ img = self . get_missingno ( )
176186 log .warning (f"Texture { key } not found at { path } " )
177187 img = img .convert ("RGBA" )
178188 res [key ] = (img , path )
0 commit comments