Skip to content

Commit

Permalink
Update SplashProgress make it implements Closeable
Browse files Browse the repository at this point in the history
  • Loading branch information
Ecdcaeb authored Aug 30, 2024
1 parent df88d63 commit 89dbd6b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/main/java/net/minecraftforge/fml/client/SplashProgress.java
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ private static IResourcePack createResourcePack(File file)
private static final IntBuffer buf = BufferUtils.createIntBuffer(4 * 1024 * 1024);

@SuppressWarnings("unused")
private static class Texture
private static class Texture implements Closeable
{
private final ResourceLocation location;
private final int name;
Expand Down Expand Up @@ -893,9 +893,14 @@ public void texCoord(int frame, float u, float v)
{
glTexCoord2f(getU(frame, u), getV(frame, v));
}

@Override
public void close(){
this.delete();
}
}

public static class SplashFontRenderer extends FontRenderer
public static class SplashFontRenderer extends FontRenderer implements Closeable
{
public HashMap<ResourceLocation, Texture> cachedImages;
public SplashFontRenderer(boolean isForcedUnicode)
Expand All @@ -921,6 +926,7 @@ protected IResource getResource(@Nonnull ResourceLocation location) throws IOExc
DefaultResourcePack pack = Minecraft.getMinecraft().defaultResourcePack;
return new SimpleResource(pack.getPackName(), location, pack.getInputStream(location), null, null);
}

public void clear(){
if(cachedImages != null){
for(Texture texture : cachedImages.values()){
Expand All @@ -930,6 +936,11 @@ public void clear(){
cachedImages = null;
}
}

@Override
public void close(){
this.clear();
}
}

public static void drawVanillaScreen(TextureManager renderEngine) throws LWJGLException
Expand Down Expand Up @@ -981,4 +992,4 @@ private static int bytesToMb(long bytes)
{
return (int) (bytes / 1024L / 1024L);
}
}
}

0 comments on commit 89dbd6b

Please sign in to comment.