diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index 8c5da8088..325b5653d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -60,7 +60,9 @@ public class Backend { void clearContexts() { SpecMetaRegistry.clear(); + programSpecRegistry.clear(); contexts.forEach(IShaderContext::delete); + contexts.clear(); materialRegistry.clear(); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedRenderDispatcher.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedRenderDispatcher.java index 5800b0f5a..6f85062d4 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedRenderDispatcher.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedRenderDispatcher.java @@ -102,8 +102,7 @@ public class InstancedRenderDispatcher { } public static void loadAllInWorld(ClientWorld world) { - materialManagers.get(world) - .delete(); + materialManagers.replace(world, MaterialManager::delete); InstanceManager tiles = tileInstanceManager.replace(world); world.loadedTileEntityList.forEach(tiles::add); diff --git a/src/main/java/com/jozufozu/flywheel/util/WorldAttached.java b/src/main/java/com/jozufozu/flywheel/util/WorldAttached.java index 4d4d944e9..a91acb0e8 100644 --- a/src/main/java/com/jozufozu/flywheel/util/WorldAttached.java +++ b/src/main/java/com/jozufozu/flywheel/util/WorldAttached.java @@ -50,7 +50,8 @@ public class WorldAttached { public T replace(IWorld world, Consumer finalizer) { T remove = attached.remove(world); - finalizer.accept(remove); + if (remove != null) + finalizer.accept(remove); return get(world); }