Skip to content

Commit

Permalink
Prevent clearing cache until the world is ready to load, this will pr…
Browse files Browse the repository at this point in the history
…event this code from running during init texture stitches.
  • Loading branch information
AlgorithmX2 committed Oct 3, 2016
1 parent 0472ca0 commit b5a3224
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/main/java/mod/chiselsandbits/core/ChiselsAndBits.java
Expand Up @@ -227,22 +227,28 @@ public void postinit(
NetworkRegistry.INSTANCE.registerGuiHandler( this, new ModGuiRouter() );
}

boolean idsHaveBeenMapped = false;

@EventHandler
public void idsMapped(
final FMLModIdMappingEvent event )
{
idsHaveBeenMapped = true;
clearCache();
}

public void clearCache()
{
for ( final ICacheClearable clearable : cacheClearables )
if ( idsHaveBeenMapped )
{
clearable.clearCache();
}
for ( final ICacheClearable clearable : cacheClearables )
{
clearable.clearCache();
}

addClearable( UndoTracker.getInstance() );
VoxelBlob.clearCache();
addClearable( UndoTracker.getInstance() );
VoxelBlob.clearCache();
}
}

public static void registerWithBus(
Expand All @@ -254,7 +260,10 @@ public static void registerWithBus(
public void addClearable(
final ICacheClearable cache )
{
cacheClearables.add( cache );
if ( !cacheClearables.contains( cache ) )
{
cacheClearables.add( cache );
}
}

}

0 comments on commit b5a3224

Please sign in to comment.