Fix crash on resource reload

- Backend wasn't properly cleaning up its state
 - Sneaky error in WorldAttached
This commit is contained in:
Jozufozu 2021-07-14 15:35:52 -07:00
parent defc4dace5
commit d256397cb8
3 changed files with 5 additions and 3 deletions

View File

@ -60,7 +60,9 @@ public class Backend {
void clearContexts() {
SpecMetaRegistry.clear();
programSpecRegistry.clear();
contexts.forEach(IShaderContext::delete);
contexts.clear();
materialRegistry.clear();
}

View File

@ -102,8 +102,7 @@ public class InstancedRenderDispatcher {
}
public static void loadAllInWorld(ClientWorld world) {
materialManagers.get(world)
.delete();
materialManagers.replace(world, MaterialManager::delete);
InstanceManager<TileEntity> tiles = tileInstanceManager.replace(world);
world.loadedTileEntityList.forEach(tiles::add);

View File

@ -50,7 +50,8 @@ public class WorldAttached<T> {
public T replace(IWorld world, Consumer<T> finalizer) {
T remove = attached.remove(world);
finalizer.accept(remove);
if (remove != null)
finalizer.accept(remove);
return get(world);
}