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 6ed59fb877
commit 1da67aaf1a
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,6 +50,7 @@ public class WorldAttached<T> {
public T replace(IWorld world, Consumer<T> finalizer) {
T remove = attached.remove(world);
if (remove != null)
finalizer.accept(remove);
return get(world);