Don't hard fail when doing an unload and we don't know the world
dimension id.
@@ -147,6 +147,10 @@ public static WorldProvider getProvider(int dim) {
return forgeDimIds;
}
+ /**
+ * @author Zidane - Chris Sanders
+ * @reason Redirect all logic to the WorldManager.
+ */
@Overwrite
public static void setWorld(int id, WorldServer world, MinecraftServer server) {
if (world != null) {
@@ -154,10 +158,12 @@ public static void setWorld(int id, WorldServer world, MinecraftServer server) {
server.worldTickTimes.put(id, new long[100]);
FMLLog.info("Loading dimension %d (%s) (%s)", id, world.getWorldInfo().getWorldName(), world.getMinecraftServer());
} else {
- WorldManager.unloadWorld(WorldManager.getWorldByDimensionId(id).orElseThrow(() -> new RuntimeException("Attempt made to unload a "
- + "world with dimension id [" + id + "].")), false);
+ final WorldServer worldServer = WorldManager.getWorldByDimensionId(id).orElse(null);
+ if (worldServer != null) {
+ WorldManager.unloadWorld(worldServer, false);
server.worldTickTimes.remove(id);
}
+ }
WorldManager.reorderWorldsVanillaFirst();
}
